Tomas LT Posted January 17, 2015 Share Posted January 17, 2015 I'd like to show the price impact right beside the combination selector (a radio button or dropdown list) so the user can quickly make decisions. Can anyone help me? Thanks Link to comment Share on other sites More sharing options...
BarryH Posted January 18, 2015 Share Posted January 18, 2015 One way to do this is to change the name of the attribute accordingly. This works well as long as you don't have thousands of products that require this approach. Say, for example, you want to offer 4 variations of the movie "The Matrix". You could create an attribute group called: The Matrix Options. Within that group, create 4 attributes named: - Blueray - $19.99 - DVD - $14.99 - VHS - $4.99 - Betamax - $0.99 Then, in the product for "The Matrix", create your combination products using this attribute group. That will give you 4 combination products and the select list will contain the text (AND price) spelled out in the name of each attribute. You then change the price impact aspect of each combination product to yield the price shown in the select list. The downside is that if you change prices, you also have to change the attributes' names to match the new prices. Worst case scenario, you could create an attribute for every product SKU you have. More likely, some products may require this approach and can be grouped to use a shared attribute group while others will require dedicated attributes. I use explicit attributes like this when I have a family of products with a range of prices that I want to lump into one product page. Then, insert a table within the product description outlining the specific characteristics of each product within the family. Link to comment Share on other sites More sharing options...
Tomas LT Posted January 18, 2015 Author Share Posted January 18, 2015 (edited) Thanks for reply, but i have thousands of products... This method is not for me Need show price impact programmatically. Edited January 20, 2015 by Tomas LT (see edit history) Link to comment Share on other sites More sharing options...
Tomas LT Posted January 20, 2015 Author Share Posted January 20, 2015 (edited) I found solution. 1)/controllers/front/ProductController.phpat line 439 add: $groups[$row['id_attribute_group']]['name_price'][$row['id_attribute']] = array('name' => $row['attribute_name'],'price' => $row['price']); 2)/themes/YOUR_THEME/product.tpl at ~345 line find : {if ($group.group_type == 'select')} and replace code with this: <select name="{$groupName}" id="group_{$id_attribute_group|intval}" class="form-control attribute_select no-print"> {foreach from=$group.name_price key=id_attribute item=group_attribute}<option value="{$id_attribute|intval}"{if (isset($smarty.get.$groupName) && $smarty.get.$groupName|intval == $id_attribute) || $group.default == $id_attribute} selected="selected"{/if} title="{$group_attribute.name|escape:'html':'UTF-8'}">{$group_attribute.name|escape:'html':'UTF-8'} {if $group_attribute.price>0}+{/if}{if $group_attribute.price!=0} {$price_with_tax = $group_attribute.price + ($group_attribute.price*($tax_rate/100))} {if $product->specificPrice && $product->specificPrice.reduction_type == 'percentage'}{$price_with_tax = $price_with_tax - ($price_with_tax*$product->specificPrice.reduction)}{/if}{convertPrice price=$price_with_tax} {/if} </option>{/foreach}</select> Price showing with tax and discount. Edited January 21, 2015 by Tomas LT (see edit history) 1 Link to comment Share on other sites More sharing options...
Tomas LT Posted January 22, 2015 Author Share Posted January 22, 2015 Is not work, when product have more combinations Link to comment Share on other sites More sharing options...
mstange Posted February 10, 2015 Share Posted February 10, 2015 Use the code below topic: https://www.prestashop.com/forums/topic/29219-variable-to-display-attribute-price/?p=1731377 Link to comment Share on other sites More sharing options...
softhightech Posted March 14, 2017 Share Posted March 14, 2017 I found solution. 1)/controllers/front/ProductController.phpat line 439 add: $groups[$row['id_attribute_group']]['name_price'][$row['id_attribute']] = array('name' => $row['attribute_name'],'price' => $row['price']); 2)/themes/YOUR_THEME/product.tpl at ~345 line find : {if ($group.group_type == 'select')} and replace code with this: <select name="{$groupName}" id="group_{$id_attribute_group|intval}" class="form-control attribute_select no-print"> {foreach from=$group.name_price key=id_attribute item=group_attribute} <option value="{$id_attribute|intval}"{if (isset($smarty.get.$groupName) && $smarty.get.$groupName|intval == $id_attribute) || $group.default == $id_attribute} selected="selected"{/if} title="{$group_attribute.name|escape:'html':'UTF-8'}">{$group_attribute.name|escape:'html':'UTF-8'} {if $group_attribute.price>0}+{/if}{if $group_attribute.price!=0} {$price_with_tax = $group_attribute.price + ($group_attribute.price*($tax_rate/100))} {if $product->specificPrice && $product->specificPrice.reduction_type == 'percentage'} {$price_with_tax = $price_with_tax - ($price_with_tax*$product->specificPrice.reduction)} {/if} {convertPrice price=$price_with_tax} {/if} </option> {/foreach} </select> Price showing with tax and discount. your code is logique Link to comment Share on other sites More sharing options...
hakeryk2 Posted July 17, 2018 Share Posted July 17, 2018 It will won't work if there is more then 1 group of attributes. Does anyone know how to achieve this using product.js? It is for the moment probably the best option to do this. Link to comment Share on other sites More sharing options...
Daresh Posted December 14, 2021 Share Posted December 14, 2021 I know it's an old topic, but if someone is looking for a solution like this for PrestaShop 1.7, I might have one. Example on a dev store. Link to comment Share on other sites More sharing options...
JBW Posted December 15, 2021 Share Posted December 15, 2021 You can check out my module Attribute Price and Availability Display Link to comment Share on other sites More sharing options...
Pragati P Posted December 30, 2022 Share Posted December 30, 2022 Hello I need an help related to product title. however the price impact are displaying i want change the product title on change of attributes can any one help me for this? Link to comment Share on other sites More sharing options...
JBW Posted December 30, 2022 Share Posted December 30, 2022 You can program this in javascript e.g. by listening to updatedProduct Prestashop event 1 Link to comment Share on other sites More sharing options...
Pragati P Posted January 2, 2023 Share Posted January 2, 2023 Hello @JBW can you help me more about this i am new to prestashop so can you send me the file path where need to change the program Link to comment Share on other sites More sharing options...
ps8modules Posted January 2, 2023 Share Posted January 2, 2023 ./themes/your_theme/assets/custom.js If not exists, create it. After starting JavaScript, all the parameters that you can use will be displayed in the console. /* after change attributes */ prestashop.on('updatedProduct',function() { console.log($.parseJSON($(".js-product-details").attr("data-product"))); }); /* after read page */ $(document).ready(function() { var isProductPage = prestashop.page.page_name; if (isProductPage == 'product') { console.log($.parseJSON($(".js-product-details").attr("data-product"))); } }); Link to comment Share on other sites More sharing options...
Pragati P Posted January 2, 2023 Share Posted January 2, 2023 Thank you @prestashopfree.com i have already created custom.js i will try with above code and let you know 1 Link to comment Share on other sites More sharing options...
ps8modules Posted January 2, 2023 Share Posted January 2, 2023 (edited) How to get attributes? ... var attributesGroup = $.parseJSON($(".js-product-details").attr("data-product")).attributes; var attributeGroupAndName = []; var valSep = ' : '; for (var key in attributesGroup) { attributeGroupAndName.push(' ' + attributesGroup[key].group + valSep + attributesGroup[key].name); } console.log(attributeGroupAndName.join(', '); /* Color : Red, Size : XXL */ Edited January 2, 2023 by prestashopfree.com (see edit history) 1 Link to comment Share on other sites More sharing options...
Pragati P Posted January 2, 2023 Share Posted January 2, 2023 (edited) @prestashopfree.comIt throws the below error in console Edited January 2, 2023 by Pragati P (see edit history) Link to comment Share on other sites More sharing options...
ps8modules Posted January 2, 2023 Share Posted January 2, 2023 And can you please upload the entire custom.js content here? Link to comment Share on other sites More sharing options...
Pragati P Posted January 2, 2023 Share Posted January 2, 2023 Here the js file is custom.js 1 Link to comment Share on other sites More sharing options...
ps8modules Posted January 2, 2023 Share Posted January 2, 2023 Already loading jQuery(document).ready(function($) ... It needs to be inserted in this section ... jQuery(document).ready(function($) { var isProductPage = prestashop.page.page_name; if (isProductPage == 'product') { console.log($.parseJSON($(".js-product-details").attr("data-product"))); } prestashop.on('updatedProduct',function() { console.log($.parseJSON($(".js-product-details").attr("data-product"))); }); ..... 1 Link to comment Share on other sites More sharing options...
ps8modules Posted January 2, 2023 Share Posted January 2, 2023 Hold on a moment and I will release a free module for displaying attributes for the product name. Then you can look at the code. 1 Link to comment Share on other sites More sharing options...
Pragati P Posted January 2, 2023 Share Posted January 2, 2023 6 minutes ago, prestashopfree.com said: Hold on a moment and I will release a free module for displaying attributes for the product name. Then you can look at the code. okay 1 Link to comment Share on other sites More sharing options...
ps8modules Posted January 2, 2023 Share Posted January 2, 2023 (edited) I am sending the module for testing in a private message 😉 Edited January 2, 2023 by prestashopfree.com (see edit history) 2 Link to comment Share on other sites More sharing options...
Pragati P Posted January 3, 2023 Share Posted January 3, 2023 Hello @prestashopfree.com Your all modules works great and your guidance is very nice I really like the solutions which you gave and they are accurate thank you for helping and I will always look forward for learning from you new things. Your dynamic product name changing modules works great as I am accepting. 1 Link to comment Share on other sites More sharing options...
ps8modules Posted January 3, 2023 Share Posted January 3, 2023 Hi @Pragati P, thank you. I'm happy to help novice programmers without unnecessary links to extensive articles. I'd rather give the whole code and the programmer can figure out the rest themselves 😉 2 Link to comment Share on other sites More sharing options...
Oliver CG Posted February 20, 2023 Share Posted February 20, 2023 On 1/3/2023 at 5:18 AM, ps8moduly.cz said: Hi @Pragati P, thank you. I'm happy to help novice programmers without unnecessary links to extensive articles. I'd rather give the whole code and the programmer can figure out the rest themselves 😉 Good morning. Could be possible to have access to that module so I can see if it helps in my case please? Thank you! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now