weight calculator/show weight of products in cart

  • Posts: 115
  • Thank you received: 0
12 years 1 month ago #69145

On my site it is important that customers can check the weight of their shopping cart for shipping costs are dependent on weight. Is there a way you can display the current weight of the products in their cart?

price of delivery will vary depending on weight so its crucial that the weight is displayed.

Can anyone advise?

Many Thanks

Please Log in or Create an account to join the conversation.

  • Posts: 2334
  • Thank you received: 403
12 years 1 month ago #69152

Hi there,

You can display each product weight by adding this:

echo $row->product_weight;

in the file cart.php (components\views\checkout\tmpl) to display the weight where you want in the product table (for example near to <?php echo $row->product_name; ?> )
If you need the total weight just ask me, I'll give you few more lines of code to do so.

Please Log in or Create an account to join the conversation.

  • Posts: 115
  • Thank you received: 0
12 years 1 month ago #69203

many thanks for your reply, would it be possible for you to give me the code to display the total weight in the cart.

many thanks

Please Log in or Create an account to join the conversation.

  • Posts: 115
  • Thank you received: 0
12 years 1 month ago #69204

many thanks for your reply, would it be possible for you to give me the code to display the total weight in the cart.

would it also be possible that when a product is added to the cart the current weight is shown similar to showing the current total price. the idea is that a customer will know how much their shopping weighs as each weight is charged at different rates

many thanks

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13375
  • MODERATOR
12 years 1 month ago #69401

You can display the weight of the cart like that:

$cartClass = hikashop_get('class.cart');
$cart = $cartClass->loadFullCart(true);
echo $cart->weight;

Please Log in or Create an account to join the conversation.

  • Posts: 115
  • Thank you received: 0
12 years 1 month ago #69531

which file do i need to amend for above code?

Please Log in or Create an account to join the conversation.

  • Posts: 115
  • Thank you received: 0
12 years 1 month ago #69623

can someone let me know which file i need to edit to insert above code and where the code goes in the file? ive been waiting nearly 2 days now for the answer

thanks

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13375
  • MODERATOR
12 years 1 month ago #69715

You didn't wait 2 days but 1 day.

You can add it in the same file as Eliot told you already:

in the file cart.php (components\views\checkout\tmpl) to display the weight where you want in the product table


If you're unsure, add it at the end of the file.

The following user(s) said Thank You: itye2012

Please Log in or Create an account to join the conversation.

  • Posts: 115
  • Thank you received: 0
12 years 1 month ago #69825

i tried adding those lines but nothing happened..can you help?

Please Log in or Create an account to join the conversation.

  • Posts: 115
  • Thank you received: 0
12 years 1 month ago #69827

got it working now to show total weight but can you advise how i can add a label to it as it currently only shows a number, I also need to add a label and enter the weight measurement eg KG or G?

Thanks for your efforts

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13375
  • MODERATOR
12 years 1 month ago #69928

After the code I gave, you can just write your main weight unit:
echo "kg";

Please Log in or Create an account to join the conversation.

  • Posts: 115
  • Thank you received: 0
12 years 1 month ago #69974

many thanks for the help, the weight works great on checkout. Any possibility the current total weight can also be displayed in the cart? I mean not just on checkout but on the cart as the user is shopping

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13375
  • MODERATOR
12 years 1 month ago #70120

For the cart module, it's the file 'cart' of the view "product" that you need to modify. The code to add is the same.

Please Log in or Create an account to join the conversation.

  • Posts: 115
  • Thank you received: 0
12 years 1 month ago #70123

many thanks, Ill try that

Please Log in or Create an account to join the conversation.

  • Posts: 115
  • Thank you received: 0
12 years 1 month ago #70644

sorry not sure of which exact file you mean can you advise the path and file name?

Many Thanks

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13375
  • MODERATOR
12 years 1 month ago #70781

It's the file 'cart' of the view "product" that you need to modify. You can edit it via the menu Display->Views.

Please Log in or Create an account to join the conversation.

  • Posts: 115
  • Thank you received: 0
12 years 1 month ago #72046

im still not clear on which file to edit sorry, can you advise ? I need to know how to edit? ie is it through ftp or via back end?

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13375
  • MODERATOR
12 years 4 weeks ago #72337

It's in the backend.
When you are in HikaShop, go in the menu Display->Views and search for the file 'cart' of the view "product"

Please Log in or Create an account to join the conversation.

  • Posts: 115
  • Thank you received: 0
11 years 10 months ago #83547

since i upgraded this is not working for me anymore can you help

i need to display the current total weight in the cart and on checkout

thanks

Please Log in or Create an account to join the conversation.

  • Posts: 12953
  • Thank you received: 1778
11 years 10 months ago #83550

Hi,

Is the code that Nicolas and Eliot gave you still in the file 'cart' of the view "product" ?

Please Log in or Create an account to join the conversation.

Time to create page: 0.110 seconds
Powered by Kunena Forum