Sekka Posted June 3, 2019 Share Posted June 3, 2019 (edited) Hello everyone, I'm working on prestashop 1.7.5.0 and I want to show the product weight on the product page. I found that {$product->weight} was available and its working fine. When it comes to combinations, its not the same though. {$combination->weight} isnt working nor does {$product_attribute.weight}. Is there any way or a smarty variable to show the combination weight on the product page ? Thank you Edited August 6, 2020 by Sekka (see edit history) Link to comment Share on other sites More sharing options...
tdsoft Posted June 4, 2019 Share Posted June 4, 2019 A product have a lot of combinations, What is combination you want display it? Link to comment Share on other sites More sharing options...
Sekka Posted June 4, 2019 Author Share Posted June 4, 2019 Well if a combination as a different weight, I want to show it on the product page (ie. if the XL size of a product weights 1kg and the L size weights 0.5kg I want to show it on the product page). If the weight isn't dynamic at first its ok, I'd just like to be able to show it. Link to comment Share on other sites More sharing options...
Merlin-Naturkosmetik Posted August 5, 2020 Share Posted August 5, 2020 Is their any solution? I need the same. Combination A has the weight 40 grams, combination B has 80 grams. Link to comment Share on other sites More sharing options...
Sekka Posted August 6, 2020 Author Share Posted August 6, 2020 (edited) As the combination weight is determined by "weight difference" from the original weight you'd have to go with something like that : {$product->weight+$combinations[$product.id_product_attribute]["weight"]} Edited August 6, 2020 by Sekka (see edit history) 2 Link to comment Share on other sites More sharing options...
Merlin-Naturkosmetik Posted August 6, 2020 Share Posted August 6, 2020 Sekka thank you! That helps really. Is their any javascript structure to get the same data and reload after change the combination? Link to comment Share on other sites More sharing options...
Merlin-Naturkosmetik Posted August 6, 2020 Share Posted August 6, 2020 Oh it works without any javascript! Thank you!!!! Really 1 Link to comment Share on other sites More sharing options...
Gregio Posted November 3, 2020 Share Posted November 3, 2020 On 8/6/2020 at 9:10 AM, Sekka said: As the combination weight is determined by "weight difference" from the original weight you'd have to go with something like that : {$product->weight+$combinations[$product.id_product_attribute]["weight"]} Thanks, this works fine also for me but it doesn't refresh when I change the combination... How can I refresh the value? Link to comment Share on other sites More sharing options...
CC Posted January 14, 2021 Share Posted January 14, 2021 On 8/6/2020 at 9:10 AM, Sekka said: As the combination weight is determined by "weight difference" from the original weight you'd have to go with something like that : {$product->weight+$combinations[$product.id_product_attribute]["weight"]} This works great, but as others have mentioned it's not refreshing when you change attribute. If refreshing is out in this case, maybe if there is a way to pool all attributes weights at once, that would also be very useful. Thanks for the first solution! Link to comment Share on other sites More sharing options...
Sellmark Posted May 12, 2021 Share Posted May 12, 2021 On 1/14/2021 at 2:24 PM, CC said: This works great, but as others have mentioned it's not refreshing when you change attribute. ... I can't agree to that, as this is working perfectly fine upon choosing another combination(attribute) on the product page. Mechanics behind that is covered by PrestaShop Core in Product Controller , method displayAjaxRefresh: (https://github.com/PrestaShop/PrestaShop/blob/4edececed3066f483a472d2ac9f611a7e800ad60/controllers/front/ProductController.php#L400) The method does re-rendering some product _partials templates(price, pictures, EAN, Index, and Weight too if you place it in proper _partials template in your theme), which is then processed by JS. This is all built-in, EDIT: Sir, maybe you have pasted this line of code {$product->weight+$combinations[$product.id_product_attribute]["weight"]} outside of re-rendered _partials templates? I think you can choose one of those files(from above github link method): 'product_prices' => $this->render('catalog/_partials/product-prices'), 'product_cover_thumbnails' => $this->render('catalog/_partials/product-cover-thumbnails'), 'product_customization' => $this->render( 'catalog/_partials/product-customization', //... ), 'product_details' => $this->render('catalog/_partials/product-details'), 'product_variants' => $this->render('catalog/_partials/product-variants'), 'product_discounts' => $this->render('catalog/_partials/product-discounts'), 'product_add_to_cart' => $this->render('catalog/_partials/product-add-to-cart'), 'product_additional_info' => $this->render('catalog/_partials/product-additional-info'), 'product_images_modal' => $this->render('catalog/_partials/product-images-modal'), 1 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