Page 1 of 1

[SOLVED] Products, Formatting Price Attribute

Posted: Wed Feb 15, 2012 3:20 pm
by swanriver
Hello,

I have racked my brain on this one and searched forum for 2 days, but haven't been able to solve this.

I have a website for an artist, and she would like to sell four different types of prints, Lithographs, Framed Lithographs, Canvas Giclee, Framed Canvas Giclee. I have this set-up in Products, and would like to use Attributes to prices each of these types of prints.

The trouble is, the prices are coming out incorrect, showing the first number and then (decimal) zero zero. (example: 1.00)

Here is the code within the template:

Code: Select all

{* print out attributes *}
{if isset($entry->attribs_full)}
  {foreach from=$entry->attributes key='name' item='attribset'} <!--  -->
       <select id='lithoType' name='lithoType'>
       {foreach from=$attribset key='label' item='attribute'}
         <option value='{$attribute.attrib_sku}' name='{$attribute.attrib_text}' label='{$label}'>{$label} {$currency_symbol}{$attribute.attrib_adjustment|string_format:"%.2f"}</option>
       {/foreach}
     </select>
  {/foreach}
{/if}
Here is what spits out from {$entry->attributes|@print_r}

Code: Select all

Array ( [Price] => Array ( [Lithograph Framed] => 179.00 [Canvas Giclee] => 350.00 [Canvas Giclee Framed] => 450.00 [Lithograph] => 70.00 ) ) 1
And what comes out of {$entry->attribs_full|@print_r}

Code: Select all

Array ( [Price] => Array ( [Lithograph Framed] => Array ( [attrib_id] => 111 [attrib_set_id] => 5 [attrib_text] => Lithograph Framed [attrib_adjustment] => 179.00 [sku] => MM13LF ) [Canvas Giclee] => Array ( [attrib_id] => 112 [attrib_set_id] => 5 [attrib_text] => Canvas Giclee [attrib_adjustment] => 350.00 [sku] => MM13CG ) [Canvas Giclee Framed] => Array ( [attrib_id] => 110 [attrib_set_id] => 5 [attrib_text] => Canvas Giclee Framed [attrib_adjustment] => 450.00 [sku] => MM13CGF ) [Lithograph] => Array ( [attrib_id] => 109 [attrib_set_id] => 5 [attrib_text] => Lithograph [attrib_adjustment] => 70.00 [sku] => MM13L ) ) ) 1
I would like to show the three digits of the price, followed by .00, but the .00 is not necessary. Any ideas? I believe it is just the formatting, and I have tired everything I could get my hands on. So if someone could just point me in the right direction, I would be totally grateful.

Thanks!

Re: Products, Formatting Price Attribute

Posted: Wed Feb 15, 2012 3:25 pm
by swanriver
Oh, I forgot to mention version specifics:

CMSMS Version: 1.10.3
CGExtensions: 1.27.4
CGSimpleSmarty: 1.4.10
Products: 2.15.1
CGEcommerceBase: 1.3.9
CGPaymentGatewayBase: 1.0.11
PaypalGateway: 2.3.5

Apologies and thank you

Re: Products, Formatting Price Attribute

Posted: Thu Feb 16, 2012 1:02 pm
by swanriver
I have a deadline that I would like to keep, and since I'm clueless, I'm totally willing to pay someone to fix this problem, and will be posting in the "Help Wanted" section. Thank you.

Re: Products, Formatting Price Attribute

Posted: Thu Feb 16, 2012 4:08 pm
by jmcgin51
Can't say for sure, but here's a guess:
Change:
<option value='{$attribute.attrib_sku}' name='{$attribute.attrib_text}' label='{$label}'>{$label} {$currency_symbol}{$attribute.attrib_adjustment|string_format:"%.2f"}</option>

to

<option value='{$attribute.attrib_sku}' name='{$attribute.attrib_text}' label='{$label}'>{$label} {$currency_symbol}{$attribute.attrib_adjustment|string_format:"%d"}</option>

See http://us.php.net/sprintf

Re: Products, Formatting Price Attribute

Posted: Sat Feb 18, 2012 9:24 pm
by swanriver
I finally got it. Here is the answer:

Code: Select all

{if isset($entry->attribs_full)}
  {foreach from=$entry->attributes key=name item='attribset'}
       <select id='lithoType' name='lithoType'>
       {foreach from=$attribset key='label' item='adjustment'}
         <option value='Price' label='{$label}'>
          {$label} {$currency_symbol}{$adjustment}
         </option>
       {/foreach}
     </select>
  {/foreach}
{/if}
Thanks for the help! Just hope this helps someone else.

Re: [SOLVED] Products, Formatting Price Attribute

Posted: Thu Mar 01, 2012 10:20 am
by applejack
Hi swanriver

I am about to do a site selling the same sort of products. I am curious how you plan to set the hierarchy / categories up. I have used the Products module before but not for an e-commerce system. I would be grateful if you could confirm that for a single product i.e. 1 print you can have multiple prices for different sizes.

Thanks in advance.