leeloo Posted October 21, 2010 Share Posted October 21, 2010 HiI would like to display the total weight in the module blockcart.In module/blockcart.php, after 'id_carrier' => $params['cart']->id_carrier, I added the code 'weightUnit' => Configuration::get('PS_WEIGHT_UNIT'), and in module/blockcart.tplafter {l s='Total' mod='blockcart'}{$total} I added the code {l s='Weight :' mod='blockcart'} {$cart->getTotalWeight()|escape:'htmlall':'UTF-8'|number_format:3} {$weightUnit} The total weight is displayed if you refresh the page, but there is no interaction effect with ajax when you add or remove products.Can anyone help me?--------------Ver 1.2.5 Link to comment Share on other sites More sharing options...
rocky Posted October 22, 2010 Share Posted October 22, 2010 Unfortunately, it's not an easy change to make. I'll try to explain what you need to do. Try changing lines 137-142 of modules/blockcart/blockcart.php from: public function hookAjaxCall($params) { global $smarty; $this->smartyAssigns($smarty, $params); return $this->display(__FILE__, 'blockcart-json.tpl'); } to: public function hookAjaxCall($params) { global $smarty; $this->smartyAssigns($smarty, $params); $smarty->assign('total_weight', $params['cart']->getTotalWeight() . ' ' . Configuration::get('PS_WEIGHT_UNIT')); return $this->display(__FILE__, 'blockcart-json.tpl'); } then change line 68 of modules/blockcart/blockcart-json.tpl from: 'shippingCost': '{$shipping_cost|html_entity_decode:2:'UTF-8'}', to: 'totalWeight': '{$total_weight|html_entity_decode:2:'UTF-8'}', then change line 507 of modules/blockcart/ajax-cart.js from: $('.ajax_cart_shipping_cost').text(jsonData.shippingCost); to: $('.ajax_cart_shipping_cost').text(jsonData.shippingCost); $('.ajax_block_cart_weight').text(jsonData.totalWeight); Link to comment Share on other sites More sharing options...
leeloo Posted October 26, 2010 Author Share Posted October 26, 2010 I have not received notification of the response to this message.Thank you very much for your help!your explanations are clear and I managed to make the changes.In the line 68 of modules/blockcart/blockcart-json.tpl from I kept the code : 'shippingCost': '{$shipping_cost|html_entity_decode:2:'UTF-8'}', and i add after : 'totalWeight': '{$total_weight|html_entity_decode:2:'UTF-8'}', because when the blockcart is emptied, the shipping cost is not updated.Last question about this solution :How to display the weight to 3 decimal (after comma) ? Link to comment Share on other sites More sharing options...
rocky Posted October 27, 2010 Share Posted October 27, 2010 The number_format function can be used to display the weight with 3 decimal places: public function hookAjaxCall($params) { global $smarty; $this->smartyAssigns($smarty, $params); $smarty->assign('total_weight', number_format($params['cart']->getTotalWeight(), 3) . ' ' . Configuration::get('PS_WEIGHT_UNIT')); return $this->display(__FILE__, 'blockcart-json.tpl'); } Link to comment Share on other sites More sharing options...
leeloo Posted October 27, 2010 Author Share Posted October 27, 2010 Clear and precise explanations! It works perfectly.This is 2 times that you help me solve my small problems. Thank you very much rocky. Link to comment Share on other sites More sharing options...
maofree Posted November 2, 2010 Share Posted November 2, 2010 Hi rockyThanks for your solution Link to comment Share on other sites More sharing options...
salsuissa Posted November 8, 2010 Share Posted November 8, 2010 Hi Rocky!how are you?I hope you can help me out quickly I installed your contributions to do the WEIGHT as a SHIPPING PRICEBut here is my problem...i add my product , add attributes to the product ( i make SURE not to increase weight)Then i set the general weight of item to 25Kg for instance...THen i save it all , but when i click on item in my shop and decide to check out , no shipping cost is added....How come?My shop address : www.officefive.comthanks! Link to comment Share on other sites More sharing options...
rocky Posted November 9, 2010 Share Posted November 9, 2010 I have no idea. It's a really bad hack that is only a temporary fix until PrestaShop v1.4 is released. It won't work for everyone. Link to comment Share on other sites More sharing options...
Stefand Posted December 31, 2010 Share Posted December 31, 2010 Rocky,I use this modification but the weight will not update in my ajax cart.When I use F5 the weight will update... Link to comment Share on other sites More sharing options...
rocky Posted January 2, 2011 Share Posted January 2, 2011 The modules/blockcart/blockcart-json.tpl code and modules/blockcart/ajax-cart.js code above should make the total weight update without refreshing the page. I don't know why it isn't working for you. Link to comment Share on other sites More sharing options...
korku Posted March 28, 2011 Share Posted March 28, 2011 Hello!I've been following this post. I made the changes but does not update the total weight when I delete a product. Not resolved with version Prestashop 1.4 :-( Link to comment Share on other sites More sharing options...
atop Posted April 3, 2011 Share Posted April 3, 2011 Hi,I made these changes too in version 1.4.0.17, but the weight will not update my ajax block cart.Has someone already a solution for this? Link to comment Share on other sites More sharing options...
korku Posted April 3, 2011 Share Posted April 3, 2011 It seems that nobody knows. We continue expect the solution Link to comment Share on other sites More sharing options...
Artizzz Posted June 3, 2011 Share Posted June 3, 2011 Hello!I've been following this post. I made the changes but does not update the total weight when I delete a product. Not resolved with version Prestashop 1.4 :-( For me it's works perfect on 1.4. Link to comment Share on other sites More sharing options...
wakaka Posted July 22, 2011 Share Posted July 22, 2011 Hi everybody, how to display total weight in onepagecheckout above Total in "SHOPPING CART SUMMARY"? and also invoice in guestracking.php? I`m using prestashop1.4. Thanks all. Link to comment Share on other sites More sharing options...
pablowilson Posted October 28, 2011 Share Posted October 28, 2011 Hi guys I follow this post because i want to do the same thing show the total weight in the block cart so i follow one by one the instructions for the version 1.4.4.1 First you must do all the steps sayed before I repeat ALL and the final step is this: in the file blockcart.tpl leeloo say add this {l s='Weight :' mod='blockcart'} {$cart->getTotalWeight()|escape:'htmlall':'UTF-8'|number_format:3} {$weightUnit} you must change it for: <span>{l s='Weight :' mod='blockcart'}</span> <span id="cart_block_weight" class="price ajax_block_cart_weight">{$totalWeight}{$weightUnit}</span I hope it helps you and thanks to Leeloo and rocky Link to comment Share on other sites More sharing options...
deprims2 Posted February 17, 2012 Share Posted February 17, 2012 thanks Leeloo, Rocky, Pablowilson work perfectly on 1.4.6.2 Link to comment Share on other sites More sharing options...
jager Posted March 30, 2012 Share Posted March 30, 2012 but if i'd like to display weight in the summary of order (order-opc.php) ? how can i do? Could you try to explain to me? Link to comment Share on other sites More sharing options...
jager Posted April 2, 2012 Share Posted April 2, 2012 I answer myself alone ..... Simply just add in order-carrier.tpl (because I want it here): {$cart->getTotalWeight()|escape:'htmlall':'UTF-8'|number_format:0} {Configuration::get('PS_WEIGHT_UNIT')} but if in "order summary" page I add (or remove) some products total weight doesn't refresh.... someone can help me to complete my work? Thank! Link to comment Share on other sites More sharing options...
helldog2004 Posted May 5, 2012 Share Posted May 5, 2012 Works perfectly on 1.4.7.3 No problems at all, and it doesn't matter how many products the customer want to buy, it will calculate it all together. Great option, might be a lovely option for the 1.5, to have an option for the weight calculator on the cart. Thanks for the help!! Link to comment Share on other sites More sharing options...
Pichayutm Posted December 26, 2012 Share Posted December 26, 2012 Any idea if this also work on 1.5.2? Link to comment Share on other sites More sharing options...
[email protected] Posted December 30, 2012 Share Posted December 30, 2012 I am also in need of this for PrestaShop™ 1.5.2.0 can anyone please help us? Thanks in advance!! Link to comment Share on other sites More sharing options...
jimmyc Posted April 24, 2013 Share Posted April 24, 2013 I am also in need of this for PrestaShop™ 1.5.2.0 can anyone please help us? Thanks in advance!! Me also for 1.5 latest version if anyone has the solution. Link to comment Share on other sites More sharing options...
l.zuccarini Posted June 6, 2013 Share Posted June 6, 2013 Me also for 1.5 latest version if anyone has the solution. I am also interested for 1.5.3. I didn't done any test. Did you done some test jimmyc? Isn't it compatible with 1.5.x version? Thank you in advance. Link to comment Share on other sites More sharing options...
ALMAJ Posted July 9, 2013 Share Posted July 9, 2013 we need this for Prestashop 1.5.4.1! Link to comment Share on other sites More sharing options...
ALMAJ Posted July 10, 2013 Share Posted July 10, 2013 (edited) Unfortunately, it's not an easy change to make. I'll try to explain what you need to do. Try changing lines 137-142 of modules/blockcart/blockcart.php from: public function hookAjaxCall($params) { global $smarty; $this->smartyAssigns($smarty, $params); return $this->display(__FILE__, 'blockcart-json.tpl'); } to: public function hookAjaxCall($params) { global $smarty; $this->smartyAssigns($smarty, $params); $smarty->assign('total_weight', $params['cart']->getTotalWeight() . ' ' . Configuration::get('PS_WEIGHT_UNIT')); return $this->display(__FILE__, 'blockcart-json.tpl'); } then change line 68 of modules/blockcart/blockcart-json.tpl from: 'shippingCost': '{$shipping_cost|html_entity_decode:2:'UTF-8'}', to: 'totalWeight': '{$total_weight|html_entity_decode:2:'UTF-8'}', then change line 507 of modules/blockcart/ajax-cart.js from: $('.ajax_cart_shipping_cost').text(jsonData.shippingCost); to: $('.ajax_cart_shipping_cost').text(jsonData.shippingCost); $('.ajax_block_cart_weight').text(jsonData.totalWeight); Hi rocky tanks for your help how to make the same "update the weight when changing the quantity of the product" on the prestashop 1.5.4.1? best regards Edited July 10, 2013 by majority (see edit history) Link to comment Share on other sites More sharing options...
deprims Posted August 21, 2013 Share Posted August 21, 2013 (edited) somehow i got the dynamic weight on blockcart not functioning anymore, it's happen after i doing re-install the PS with the same version with maintaining old data site, the sad news is Rocky not wandering anymore for Prestashop, he sure have other things to do, back again i think perhaps the culprit is the smarty 3, since before i do the install i used smarty 2, i search Google and Forum but there's still no one offering the same dynamic idea for blockcart, temporary solution for me is putting static weight info shopping page detail, when customer do checkout they gonna see the total weight info, but if they're doing any change with the cart they still need to refresh the page to get updated weight put this code whenever you want the weight to show: {$cart->getTotalWeight()|escape:'htmlall':'UTF-8'|number_format:2} {Configuration::get('PS_WEIGHT_UNIT')} change number decimal format into your desire add {l s='text'} before or after the code to give extra information for your customer ps: i put the code on order-opc.tpl after {include file="$tpl_dir./shopping-cart.tpl"} Edited August 21, 2013 by deprims (see edit history) Link to comment Share on other sites More sharing options...
jimmyc Posted April 25, 2014 Share Posted April 25, 2014 anyone have a solution for this in 1.6? 1 Link to comment Share on other sites More sharing options...
oskar86 Posted October 5, 2014 Share Posted October 5, 2014 Hi, pls check this post, it worked for me (1.6.0.9): http://www.prestashop.com/forums/topic/45353-solved-how-to-show-weight-of-the-order-in-shopping-cart/page-3 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