Keron83 Posted March 13, 2015 Share Posted March 13, 2015 Is it possible to show the weight impact of the selected attribute on the product page?I already got the normal weight displayed on the product page, but also want to display the weight impact. Using Prestashop 1.6.11 Thanks Link to comment Share on other sites More sharing options...
NemoPS Posted March 14, 2015 Share Posted March 14, 2015 I didn't test it, but it's worth trying with {$group_attribute.weight} in the product.tpl file, within one of these foreach statements: {foreach from=$group.attributes key=id_attribute item=group_attribute} Although as far as I know the impact depends on combination, so it might as well be worth checking product.js, findCombination() method, where you might be able to access the weight property of each combo Link to comment Share on other sites More sharing options...
Keron83 Posted March 15, 2015 Author Share Posted March 15, 2015 Although as far as I know the impact depends on combination, so it might as well be worth checking product.js, findCombination() method, where you might be able to access the weight property of each combo Thanks for pointing me in the right direction. For me (custom theme) this didn't work out: {$group_attribute.weight} I modified product.js with these lines: function addCombination(...... , weight) combination['weight'] = weight; function findCombination() selectedCombination['weight'] = combinations[combination]['weight']; Used this in the product.tpl {$combination.weight} {$selectedCombination.weight} -> does not work returns 0 or nothing Well the weight impact is displayed, but shows it random (with: $combination.weight). Link to comment Share on other sites More sharing options...
NemoPS Posted March 16, 2015 Share Posted March 16, 2015 What if you try adding this selectedCombination['weight'] like $('.whatever-box').after('<span>Weight: '+selectedCombination['weight'] +'</span>');Of course use a valid selector Link to comment Share on other sites More sharing options...
Keron83 Posted March 16, 2015 Author Share Posted March 16, 2015 (edited) Weight: undefined (as it also says in my debug console) So $combintaion.weight is defined, but selectedCombination['weight'] is not...Changed a couple of rules in product.js file. Now selectedCombination['weight'] is defined but is is always 0. Shouldn't i Change somethin in controllers/front/productcontroller.php or classes/product.php? Edited March 16, 2015 by Keron83 (see edit history) Link to comment Share on other sites More sharing options...
NemoPS Posted March 18, 2015 Share Posted March 18, 2015 You used this?selectedCombination['weight'] = combinations[combination]['weight']; Link to comment Share on other sites More sharing options...
Keron83 Posted March 18, 2015 Author Share Posted March 18, 2015 Yes. Placed it in product.js selectedCombination['weight'] = combinations[combination]['weight']; in function:findCombination() Link to comment Share on other sites More sharing options...
NemoPS Posted March 20, 2015 Share Posted March 20, 2015 Now yes, if that's 0, I guess you can try inspeting productcontroller.php look for this method:assignAttributesCombinations inside it, after this line $attributes_combinations = Product::getAttributesInformationsByProduct($this->product->id); Add var_dump($attributes_combinations); See if the weight is added there Link to comment Share on other sites More sharing options...
madfred Posted June 22, 2016 Share Posted June 22, 2016 You was on the right way. I made it this way. In product.tpl <div class="aeuc_weight_label"><span id="product_weight" data-weight="{$product->weight|escape:'htmlall':'UTF-8'|number_format:0}">{$product->weight|escape:'htmlall':'UTF-8'|number_format:0} </span><span>{Configuration::get('PS_WEIGHT_UNIT')}</span></div> and the js in product.js new function updateWeight function updateWeight(){ // Get combination weight var combID = $('#idCombination').val(); var productWeight = $('#product_weight').data("weight"); var combination = combinationsFromController[combID]; if (typeof combination == 'undefined') return; newProductweight = productWeight+combination['weight']; $('#product_weight').text(newProductweight);}and call it in the function updateDisplay() f.e. ..... // If we have combinations, update price section: amounts, currency, discount amounts,... if (productHasAttributes) updatePrice(); updateWeight();} ..... Link to comment Share on other sites More sharing options...
TurkeyFish Posted July 31, 2017 Share Posted July 31, 2017 I'd like to do this too. madfred's solution looks like what I need. I copied the js function js function call, and tpl snnippet exactly as above, but I'm getting a js "NaN" error. Link to comment Share on other sites More sharing options...
fuusen Posted June 7, 2018 Share Posted June 7, 2018 Well .... there is no "product.js" as of version 1.7.3.2 .... 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