Show weight and price per unit in checkout cart

  • Posts: 136
  • Thank you received: 7
7 years 2 months ago #277023

-- HikaShop version -- : 3.1.1
-- Joomla version -- : 3.7.5
-- PHP version -- : 7.0.10
-- Browser(s) name and version -- : all
-- Error-message(debug-mod must be tuned on) -- : none

Hi Hikashop

I'm trying to add a little more information to the customers experience when viewing the checkout cart. I have done some override to show_block_cart.php.

Under product name I would suggest and like that the product_weight is shown. I have added the code below, but I have two problems:

//if(!empty($this->options['show_product_weight'])) {
	?><span id="hikashop_cart_product_weight" class="hikashop_cart_product_weight">
		<?php echo rtrim(rtrim($product->product_weight,'0'),',.').' '.JText::_($product->product_weight_unit);
	?></span><?php
//}

1) the $this->options[show_product_weight] is not in the array and this is why I have comment it out for now.
2) the $product->product_weight_unit is all in 'kilo' even though the product has 'gram' as unit.

Under price I would suggest and like that the price_per_unit is shown.

Both information's can be found on the product detail page, from where I have looked for code inspiration.

Thanks in advanced.

Best regards,
Henrik


.ninja { color: black; visibility: hidden; }
In case of fire:
1. git commit
2. git push
3. exit building
Attachments:
Last edit: 7 years 2 months ago by flexsus.

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

  • Posts: 12953
  • Thank you received: 1778
7 years 2 months ago #277029

Hello Henrik,

The best solution will probably be to directly check what you have on your PHP variables like "$product" in your case, using functions like var_dump and then you'll fully see which information you have and what you can display.

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

  • Posts: 136
  • Thank you received: 7
7 years 2 months ago #277111

Hi Mohamed

Yes, in $product there is a lot of strings I can show.
But I was looking for the details of the product found in the product-details page, e.g. if unit is 450 gram. In the cart, this will be two strings product_weight: 0.450 and product_weight_unit: kg
So right now, the cart can not show the details I'm looking for. I will have to do some more customization.

Regards,
Henrik


.ninja { color: black; visibility: hidden; }
In case of fire:
1. git commit
2. git push
3. exit building

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

  • Posts: 4747
  • Thank you received: 644
  • MODERATOR
7 years 2 months ago #277116

Hello,

What is show in your show_cart is a weight and unit that have already set in order be a useful data for some shipping method that use
these data to process price.
And so you have to use the function "hikashop_get()" function in order to have no processed data, and so have data has you entered it in your product configuration page.

Something must able you to get what you need :

$productClass = hikashop_get('class.product');
$product = $productClass->get($product_id);
echo $product->product_weight . ' ' . $product->product_weight_unit;

Hope this will help you.

Regards.

Last edit: 7 years 2 months ago by Philip.

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

Time to create page: 0.081 seconds
Powered by Kunena Forum