Jump to content

[Solved] help needed - how do I access the price attribute of a combination


AppleEater
 Share

Recommended Posts

using PS 1.5.5

I have a product with 6 attribute groups, which only 3 affect the price. I'd like to display to the user a small table which summarizes the affecting attributes, and the product price for these values.

 

e.g.:

ATTRIBUTE GROUP_A:

value A1 -> priceA1

value A2 ->proce A2

 

ATTRIBUTE GROUP_B:

value B1 -> priceB1

....

 

 

I want to display a table like this:

<table>
<th>
<tr>
<td>Attribute</td>
<td>Price</td>
</tr>
</th>
<tbody>
<tr>
<td>valueA1</td>
<td>priceA1</td>
</tr>
<tr>
<td>ValueA2</td>
<td><priceA2>
</tr>
</tbody>
</table>

I reviewed the devug window and saw there's a parameter called "combinations" that holds the price, but I don't know how to accesss it from the .tpl .

 

Please advise.

 

Edited by AppleEater (see edit history)

Share this post


Link to post
Share on other sites

You can use {$combinations|@var_dump} in product.tpl to see the array of this smarty variable

For exampe If 8 combinations it dumps

array (size=8)
  105 => 
    array (size=13)
      'attributes_values' => 
        array (size=2)
          6 => string 'Izquierdo' (length=9)
          7 => string '-3' (length=2)
      'attributes' => 
        array (size=2)
          0 => int 33
          1 => int 36
      'price' => float 0
      'specific_price' => boolean false
      'ecotax' => float 0
      'weight' => float 0
      'quantity' => int 10000
      'reference' => string 'demo_1' (length=6)
      'unit_impact' => string '0.00' (length=4)
      'minimal_quantity' => string '1' (length=1)
      'available_date' => string '' (length=0)
      'id_image' => int -1
      'list' => string ''33','36'' (length=9)
  107 => 
    array (size=13)
      'attributes_values' => 
        array (size=2)
          6 => string 'Izquierdo' (length=9)
          7 => string '+1' (length=2)
      'attributes' => 
        array (size=2)
          0 => int 33
          1 => int 37
      'price' => float 0
      'specific_price' => boolean false
      'ecotax' => float 0
      'weight' => float 0
      'quantity' => int 10000
      'reference' => string 'demo_1' (length=6)
      'unit_impact' => string '0.00' (length=4)
      'minimal_quantity' => string '1' (length=1)
      'available_date' => string '' (length=0)
      'id_image' => int -1
      'list' => string ''33','37'' (length=9)
  103 => ETC ETC ETC

So you can access the variable values iterating the array like

{foreach from=$combinations key=idCombination item=combination}
         {$combination.available_date}
{foreach}

You have available other smarty useful variables regarding attributes.

 

{$attributesCombinations|@var_dump}
{$groups|@var_dump}

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More