[SOLVED] Products, Formatting Price Attribute

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
swanriver
Forum Members
Forum Members
Posts: 44
Joined: Sun Apr 29, 2007 5:24 pm
Location: Cape Cod, Massachusetts

[SOLVED] Products, Formatting Price Attribute

Post 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!
Attachments
Screen grab of formatting in question.
Screen grab of formatting in question.
Last edited by swanriver on Sat Feb 18, 2012 9:24 pm, edited 1 time in total.
swanriver
Forum Members
Forum Members
Posts: 44
Joined: Sun Apr 29, 2007 5:24 pm
Location: Cape Cod, Massachusetts

Re: Products, Formatting Price Attribute

Post 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
swanriver
Forum Members
Forum Members
Posts: 44
Joined: Sun Apr 29, 2007 5:24 pm
Location: Cape Cod, Massachusetts

Re: Products, Formatting Price Attribute

Post 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.
jmcgin51
Power Poster
Power Poster
Posts: 1899
Joined: Mon Jun 12, 2006 9:02 pm

Re: Products, Formatting Price Attribute

Post 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
swanriver
Forum Members
Forum Members
Posts: 44
Joined: Sun Apr 29, 2007 5:24 pm
Location: Cape Cod, Massachusetts

Re: Products, Formatting Price Attribute

Post 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.
applejack
Power Poster
Power Poster
Posts: 1014
Joined: Fri Mar 30, 2007 2:28 am
Location: London

Re: [SOLVED] Products, Formatting Price Attribute

Post 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.
Post Reply

Return to “Modules/Add-Ons”