hdp2101 Posted July 14, 2015 Share Posted July 14, 2015 Hello all my lovely friends If anybody is interested about how to show product weight in his shopping cart then this is a useful code for him. Please note that before changing code to this files I advise to him to take backup of all files mentioned below. Also I am not responsible for any changes or any mashup happened in site but any way this works for me so I put in our community. To make our theme batter may be user will modified the code in mentioned files. So due to changes in all this files may be you will find the code in some other lines. So don't worry for that (This is a normal course to work). Also i am attaching the modified files. But if you done any previous changes in that files then don't copy straight away or else your previous changes will be disappear.Then also if you are copy willing to copy all this files then remove the last word from file-name. (Ex blockcart.php.modified is file name then remove modified word) For safer side i am attaching all the images of below file as result how it will look in file after pasting or replacing. Also the final result of site how the design was before and after. And last but very important i am attaching the original files also in-case if you forget to take backup of that files. Just change the last word from file-name (Ex blockcart.php.original is file name then remove original word) and copy back to his place again. Once again I am not responsible for any changes or any mashup happened in site but any way this works for me so I put in our community. Original file name shopping-cart.tpl in ../themes/your theme name/ blockcart-json.tpl in ../themes/your theme name/modules/blockcart/ blockcart.php in ../modules/blockcart/ ajax-cart.js in ../themes/your theme name/js/modules/blockcart/ shopping-cart-product-line.tpl in ../themes/your theme name/ order-payment-classic.tpl in ../themes/your theme name/ Please go through following steps carefully. All the best shopping-cart.tpl in ../themes/your theme name/ Paste this following code : <tr class="cart_total_price"> <td colspan="{$col_span_subtotal}" class="text-right"><span>{l s='Total weight'}</span></td> <td colspan="3" class="price"><span class="ajax_block_cart_weight">{$cart->getTotalWeight()|escape:'htmlall':'UTF-8'|number_format:3} {Configuration::get('PS_WEIGHT_UNIT')}</span></td> </tr> Above this line </tfoot> blockcart-json.tpl in ../themes/your theme name/modules/blockcart Paste this following code : "totalWeight": {$total_weight|json_encode}, Below this line : "shippingCost": {$shipping_cost|json_encode}, blockcart.php in ../modules/blockcart Paste this following code : $totalWeight = $params['cart']->getTotalWeight().' '.Configuration::get('PS_WEIGHT_UNIT'); Below this line : $totalToPay = $params['cart']->getOrderTotal($useTax); ****************************************************************************************** Again Paste this following code : 'total_weight' => $totalWeight Below this line : 'free_shipping' => $total_free_shipping please add , at the end of line 'free_shipping' => $total_free_shipping Result will be as follow. 'free_shipping' => $total_free_shipping, ajax-cart.js in ../themes/your theme name/js/modules/blockcart/ Paste this following code : $('.ajax_block_cart_weight').text(jsonData.totalWeight); Below this line : $('.ajax_total_price_wt').text(jsonData.total_price_wt); shopping-cart.tpl in ../themes/your theme name/ Paste this following code : <th class="cart_weight item">{l s='Weight'}</th> Below this line : <th class="cart_description item">{l s='Description'}</th> ********************************************************** Again Find this line : <td class="cart_discount_name" colspan="{if $PS_STOCK_MANAGEMENT}3{else}2{/if}">{$discount.name}</td> and replace with this line : (due to title change may be you can't find the complete code then try to find the title words which is at and of the code) <td class="cart_discount_name" colspan="{if $PS_STOCK_MANAGEMENT}4{else}3{/if}">{$discount.name}</td> Please note about above changes in line number is depand on your theme (this change is for default theme of PS 1.6.1.0 default-bootstrap theme) so please change all line one by one (update value in each line then save and the check in your browserand according to design change the value) shopping-cart-product-line.tpl in ../themes/your theme name/ Paste this following code : <td class="cart_weight">{if $product.weight}{$product.weight|number_format:3|escape:'htmlall':'UTF-8'} {Configuration::get('PS_WEIGHT_UNIT')}{/if}</td> Below this line : {if isset($product.attributes) && $product.attributes}<small><a href="{$link->getProductLink($product.id_product, $product.link_rewrite, $product.category, null, null, $product.id_shop, $product.id_product_attribute)|escape:'html':'UTF-8'}">{$product.attributes|@replace: $smarty.capture.sep:$smarty.capture.default|escape:'html':'UTF-8'}</a></small>{/if} order-payment-classic.tpl in ../themes/your theme name/ Paste this following code : <th class="cart_weight item">{l s='Weight'}</th> Below this line : <th class="cart_description item">{l s='Description'}</th> ********************************************************** Again Due to modification in design one need to change following line in order-payment-classic.tpl in ../themes/your theme name/ Please change in this all line number (49,54,60,75,90,97,102,108,124,141,146,151,158,191,198) following code You just need to change following number only (rest everything will intact) In above each line you can find following code : <td colspan="2" Just replace following code with the above one <td colspan="3" *************************************************************************************************************************** Again Please change in this all line number (48,53,59,64,89,96,101,107,113,140,145,150,197) following code You just need to change following number only (rest everything will intact) In above each line you can find following code : <td colspan="4" Just replace following code with the above one <td colspan="6" 48,53,59,64, 89,96,101,107,113, 140,145,150, 197 (Line Number 49,54,60, 75,90,97,102,108, 124,141,146,151,158,191,198 The code will be approx 2 to 3 line up or down, Depends of your theme) Please note about above changes in line number is depend on your theme (this change is for default theme of PS 1.6.1.0 default-bootstrap theme) so please change all line one by one (update value in each line then save and the check in your browser and according to design change the value) ************************************************************************************************************************************************* Again Find this line : <td class="cart_discount_name" colspan="{if $PS_STOCK_MANAGEMENT}3{else}2{/if}">{$discount.name}</td> and replace with this line : (due to title change may be you can't find the complete code then try to find the title words which is at and of the code) <td class="cart_discount_name" colspan="{if $PS_STOCK_MANAGEMENT}4{else}3{/if}">{$discount.name}</td> Please note about above changes in line number is depend on your theme (this change is for default theme of PS 1.6.1.0 default-bootstrap theme) so please change all line one by one (update value in each line then save and the check in your browserand according to design change the value) ******************************************************************************************************************************************************* Again Paste this following code : <tr class="cart_total_price"> <td colspan="6" class="text-right"><span>{l s='Total weight'}</span></td> <td colspan="5" class="price"><span class="ajax_block_cart_weight">{$cart->getTotalWeight()|escape:'htmlall':'UTF-8'|number_format:3} {Configuration::get('PS_WEIGHT_UNIT')}</span></td> </tr> Above this line </tfoot> shopping-cart.tpl in ../themes/your theme name/ Find this line : <td colspan="{$col_span_subtotal}" class="text-right">{if $display_tax_label}{l s='Total products (tax excl.)'}{else}{l s='Total products'}{/if}</td> and replace with this line : (due to title change may be you can't find the complete code then try to find the title words which is at and of the code) <td colspan="{$col_span_subtotal}" class="text-right">{if $display_tax_label}{l s='Total products (tax excl.)'}{else}{l s='Net amount of total products (Before discount)'}{/if}</td> ************************************************************************************************************************************************************************************* Again Find this line : <td colspan="{$col_span_subtotal}" class="text-right">{if $display_tax_label}{l s='Total products (tax incl.)'}{else}{l s='Total products'}{/if}</td> and replace with this line : (due to title change may be you can't find the complete code then try to find the title words which is at and of the code) <td colspan="{$col_span_subtotal}" class="text-right">{if $display_tax_label}{l s='Total products (tax incl.)'}{else}{l s='Net amount of total products (Before discount)'}{/if}</td> ************************************************************************************************************************************************************************************* Again Find this code : {if $use_taxes} {if $display_tax_label}{l s='Total gift wrapping (tax incl.)'}{else}{l s='Total gift-wrapping cost'}{/if} {else} {l s='Total gift-wrapping cost'} {/if} and replace with this code : (due to title change may be you can't find the complete code then try to find the title words which is at and of the code) {if $use_taxes} {if $display_tax_label}{l s='Total gift wrapping (tax incl.)'}{else}{l s='Gift-wrapping charges'}{/if} {else} {l s='Gift-wrapping charges'} {/if} ******************************************************************************************************************************************************* Again Find this code : <td colspan="{$col_span_subtotal}" class="text-right">{l s='Total shipping'}</td> Same line 1st and replace with this code : (due to title change may be you can't find the complete code then try to find the title words which is at and of the code) <td colspan="{$col_span_subtotal}" class="text-right">{l s='Shipping charges'}</td> Find this code : <td colspan="{$col_span_subtotal}" class="text-right">{l s='Total shipping'}</td> same line 2nd and replace with this code : (due to title change may be you can't find the complete code then try to find the title words which is at and of the code) <td colspan="{$col_span_subtotal}" class="text-right">{l s='Shipping charges'}</td> ******************************************************************************************************************************************************* Again Find this code : {l s='Total vouchers'} and replace with this code : (due to title change may be you can't find the complete code then try to find the title words which is at and of the code) {l s='Total amount of discount for applied vouchers'} ******************************************************************************************************************************************************* Again Find this code : <span>{l s='Total'}</span> and replace with this code : (due to title change may be you can't find the complete code then try to find the title words which is at and of the code) <span>{l s='Final Total'}</span> ******************************************************************************************************************************************************* Again Find this code : <td colspan="{$col_span_subtotal}" class="text-right"><span>{l s='Total weight'}</span></td> and replace with this code : (due to title change may be you can't find the complete code then try to find the title words which is at and of the code) <td colspan="{$col_span_subtotal}" class="text-right"><span>{l s='Total weight of all products'}</span></td> order-payment-classic.tpl in ../themes/your theme name/ Find this code : <td colspan="4" class="text-right">{if $display_tax_label}{l s='Total products (tax excl.)'}{else}{l s='Total products'}{/if}</td> and replace with this code : (due to title change may be you can't find the complete code then try to find the title words which is at and of the code) <td colspan="6" class="text-right">{if $display_tax_label}{l s='Total products (tax excl.)'}{else}{l s='Net amount of total products (Before discount)'}{/if}</td> ****************************************************************************************************************************************************************** Again Find this code : <td colspan="4" class="text-right">{if $display_tax_label}{l s='Total products (tax incl.)'}{else}{l s='Total products'}{/if}</td> and replace with this code : (due to title change may be you can't find the complete code then try to find the title words which is at and of the code) <td colspan="6" class="text-right">{if $display_tax_label}{l s='Total products (tax incl.)'}{else}{l s='Net amount of total products (Before discount)'}{/if}</td> ****************************************************************************************************************************************************************** Again Find this code : {if $use_taxes} {if $priceDisplay} {if $display_tax_label}{l s='Total gift wrapping (tax excl.):'}{else}{l s='Total gift wrapping cost:'}{/if} {else} {if $display_tax_label}{l s='Total gift wrapping (tax incl.)'}{else}{l s='Total gift wrapping cost:'}{/if} {/if} {else} {l s='Total gift wrapping cost:'} {/if} and replace with this code : (due to title change may be you can't find the complete code then try to find the title words which is at and of the code) {if $use_taxes} {if $priceDisplay} {if $display_tax_label}{l s='Total gift wrapping (tax excl.):'}{else}{l s='Gift-wrapping charges'}{/if} {else} {if $display_tax_label}{l s='Total gift wrapping (tax incl.)'}{else}{l s='Gift-wrapping charges'}{/if} {/if} {else} {l s='Gift-wrapping charges'} {/if} ******************************************************************************************************************************************************* Again Find this code : <td colspan="4" class="text-right">{l s='Total shipping'}</td> and replace with this code : (due to title change may be you can't find the complete code then try to find the title words which is at and of the code) <td colspan="6" class="text-right">{l s='Shipping charges'}</td> ******************************************************************************************************************************************************* Again Find this code : <td colspan="4" class="text-right">{l s='Total shipping'}</td> and replace with this code : (due to title change may be you can't find the complete code then try to find the title words which is at and of the code) <td colspan="6" class="text-right">{l s='Shipping charges'}</td> ******************************************************************************************************************************************************* Again Find this code : {if $use_taxes} {if $priceDisplay} {if $display_tax_label}{l s='Total vouchers (tax excl.)'}{else}{l s='Total vouchers'}{/if} {else} {if $display_tax_label}{l s='Total vouchers (tax incl.)'}{else}{l s='Total vouchers'}{/if} {/if} {else} {l s='Total vouchers'} {/if} and replace with this code : (due to title change may be you can't find the complete code then try to find the title words which is at and of the code) {if $use_taxes} {if $priceDisplay} {if $display_tax_label}{l s='Total amount of discount for applied vouchers (tax excl.)'}{else}{l s='Total amount of discount for applied vouchers'}{/if} {else} {if $display_tax_label}{l s='Total amount of discount for applied vouchers (tax incl.)'}{else}{l s='Total amount of discount for applied vouchers'}{/if} {/if} {else} {l s='Total amount of discount for applied vouchers'} {/if} **************************************************************************************************************************************************************** Again Find this code : <td colspan="4" class="total_price_container text-right"><span>{l s='Total'}</span></td> and replace with this code : (due to title change may be you can't find the complete code then try to find the title words which is at and of the code) <td colspan="6" class="total_price_container text-right"><span>{l s='Final Total'}</span></td> ******************************************************************************************************************************************************** Again Find this code : <td colspan="4" class="text-right"><span>{l s='Total weight'}</span></td> and replace with this code : (due to title change may be you can't find the complete code then try to find the title words which is at and of the code) <td colspan="6" class="text-right"><span>{l s='Total weight of all products'}</span></td> Now please see the images Finally the end comes. I hope you guys had done great job. Thank you Hemal Parikh 2 Link to comment Share on other sites More sharing options...
r_r4f Posted September 30, 2016 Share Posted September 30, 2016 Hello, i am trying to follow all instructions above carefully but nothing happen on my shoppingcart. No product weight found, even i clear my cache. My PS version 1.6.1.6 Anyone can help? thankyou Link to comment Share on other sites More sharing options...
selectshop.at Posted September 30, 2016 Share Posted September 30, 2016 Did you deleted the browser cache and smarty cache ? Are you using advancedeucompliance module ? For me seems the instruction is something complicated. On my own page I have not more than one file changed and is less code and it is working as well. Please let me know if caches are deleted and you are using the module I wrote before. I will instruct you how to add the weight on cart. Link to comment Share on other sites More sharing options...
selectshop.at Posted September 30, 2016 Share Posted September 30, 2016 Change of code PS 1.5. and PS 1.6. WITHOUT advancedeucompliance module: Change with editor (notepad++) your file /themes/YOUR THEME/shopping-cart.tpl, if you are using native theme it is - /themes/default-bootstrap/shopping-cart.tpl as follows: Search for the block </foot> Just a line BEFORE this block add the following code: <tr class="cart_total_price"> <td colspan="{$col_span_subtotal}" class="text-right"><span> {l s='Total cart weight'} </span></td> <td colspan="2" class="price"><span class="ajax_block_cart_weight">{$cart->getTotalWeight()|escape:'htmlall':'UTF-8'|number_format:3} {Configuration::get('PS_WEIGHT_UNIT')} </span></td> </tr> Change of code for Prestashop 1.5. and 1.6 using advancedeucompliance module: Change with editor (notepad++) your file /themes/YOUR THEME/shoppping-cart-advanced.tpl, if you are using native theme it is /themes/default-bootstrap/shoppping-cart-advanced.tpl - as follows: Search for the block </foot> Just a line BEFORE this block add the following code: <tr class="cart_total_price"> <td colspan="{$col_span_subtotal}" class="text-right"><span> {l s='Total cart weight'} </span></td> <td colspan="2" class="price"><span class="ajax_block_cart_weight">{$cart->getTotalWeight()|escape:'htmlall':'UTF-8'|number_format:3} {Configuration::get('PS_WEIGHT_UNIT')} </span></td> </tr> After changes made, delete your browser cache, cookie sessions and also the smarty cache. Link to comment Share on other sites More sharing options...
r_r4f Posted October 5, 2016 Share Posted October 5, 2016 thankyou. its work for me after deleted smarty cache Link to comment Share on other sites More sharing options...
TillyOak Posted February 12, 2017 Share Posted February 12, 2017 Great little tutorial, makes a big difference to let the customer know the weight of the item(s) Mark Link to comment Share on other sites More sharing options...
Claudiocool Posted March 26, 2017 Share Posted March 26, 2017 Before i make these changes, can someone tell me if the weigt is updated in the cart, when the amount of an item gets changed by * or - buttons? 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