Jump to content

[PS 1.7] product variants price


koubin

Recommended Posts

Hello,

for Prestashop 1.7 I would like to know, if there is an easy way to display the variant additional price (price impact for the standalone product).

Lets say I sell cups. It would look like this:

Cup  $20

Variants:

- cup with color +$5

- cup with image +$10

 

I have found the place where to add it. It is product-variants.tpl and the code there:   

       {foreach from=$group.attributes key=id_attribute item=group_attribute}
            <option value="{$id_attribute}" title="{$group_attribute.name}"{if $group_attribute.selectedselected="selected"{/if}>{$group_attribute.name} ...HERE ADD VARIANT PRICE...</option>
       {/foreach}

but I can't figure out how to find and use the correct variable for that (I also have no idea how to find available variables in the TPL. The {debug} is not sufficient for that)

I guess it should be something like this:

{$combinations.price}

and the $combinations should be somehow referenced in TPL and PHP, but don't know how and where.

Could someone give me a little insight on how this works?

Thanks

Edited by koubin
gramatic (see edit history)
Link to comment
Share on other sites

  • koubin changed the title to [PS 1.7] product variants price

I might found the solution.

{$combinations[$id_attribute].price}

so the final code is:

          {foreach from=$group.attributes key=id_attribute item=group_attribute}
            <option value="{$id_attribute}" title="{$group_attribute.name}"{if $group_attribute.selected} selected="selected"{/if}>{$group_attribute.name} +{$combinations[$id_attribute].price}{$currency.sign}</option>
          {/foreach}

 

Link to comment
Share on other sites

  • 3 months later...
  • 3 months later...
On 7/7/2021 at 6:40 PM, koubin said:

I might found the solution.

{$combinations[$id_attribute].price}

so the final code is:

          {foreach from=$group.attributes key=id_attribute item=group_attribute}
            <option value="{$id_attribute}" title="{$group_attribute.name}"{if $group_attribute.selected} selected="selected"{/if}>{$group_attribute.name} +{$combinations[$id_attribute].price}{$currency.sign}</option>
          {/foreach}

 

I tried this but I only get +€ and not the price? Is there a solution?

  • Sad 1
Link to comment
Share on other sites

  • 2 weeks later...
On 3/7/2022 at 4:42 PM, Mohammad Oveissi said:

Hello, does anyone know how to solve this problem? 
It shows exactly the same for me
tnx

ps 1.7.8.4

seems like the combinations (attributes) ids can be whatever number, so when I try to go through them with a key (where $id_attribute is key and its value goes from 0, 1, 2...), it can give me empty results, as the ids of the attributes might be like 70, 72, 73... for example. I did not find the way to find out those attributes ids, but it was not necessary feature in the end for me.

If anybody find the solution, please share.

Link to comment
Share on other sites

  • 7 months later...
12 minutes ago, cycloholic said:

Trying also to resolve this issue with attributes for myself. But where should i put this code? 

it was in this file, but if I remember well it did not work as intended:

\<your shop>\themes\<your theme>\templates\catalog\_partials\product-variants.tpl

Link to comment
Share on other sites

it's very complex to solve this problem,

we have modified the code for ps1.6x and 1.7 early versions

 

we also developed this feature in our website too , you can click some color ,the price/weight will change,

https://www.irder.com/item/17/solid-color-formal-business-work-man-shirt-tshirt-work-uniform.html

QQ截图20230111234835.png

Edited by irder shopping (see edit history)
Link to comment
Share on other sites

  • 4 months later...
  • 8 months later...

I have similar problem. Do anybode know what function causes product price update when variant is selected? Price in product-prices.tpl works fine (its original code), but I would like "copy/paste" to product-additional-info.tpl, but here code for display price not works (its not change when variant is change). Thank you

Link to comment
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
×
×
  • Create New...