Adding Product Weight to Checkout Cart/Order

  • Posts: 40
  • Thank you received: 0
11 years 9 months ago #88389

Is there a way to add the Product Weight to the Order Cart during checkout? I have many products with the same name that are differentiated by size. Aside from the price there is currently no way to easily see specifically which size product the customer has ordered on the order email i receive.

Does anyone know of how to modify the code so the product weight is displayed in the cart?

Jason

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

  • Posts: 13201
  • Thank you received: 2322
11 years 9 months ago #88547

To add the weight in the cart of the checkout, you have to edit the view "checkout / cart" and then add a column for the weight.
The variable to use for the price is "$row->product_weight".

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

  • Posts: 40
  • Thank you received: 0
11 years 9 months ago #88716

Thank you for this. I was able to get the weight to appear, however my PHP is pretty weak and i can't seem to figure out how to get a new column to appear with the title "Weight" and the product weight under the column.

I was only able to get the weight directly beside the product name. Is there an example i can view somewhere that i can copy/paste the code i need to do this?

Jason

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

  • Posts: 13201
  • Thank you received: 2322
11 years 9 months ago #88811

It's not really PHP knowledge that are neede here, but HTML.
In the <thead> tag, you can add:

					<th id="hikashop_cart_product_weight_title" class="hikashop_cart_product_weight_title hikashop_cart_title">
						<?php echo JText::_('CART_PRODUCT_WEIGHT'); ?>
					</th>
after:
					<th id="hikashop_cart_product_name_title" class="hikashop_cart_product_name_title hikashop_cart_title">
						<?php echo JText::_('CART_PRODUCT_NAME'); ?>
					</th>
And in the <tbody>, add:
<td class="hikashop_cart_product_weight_value">
<?php echo $row->product_weight; ?>
</td>
Before:
<td class="hikashop_cart_product_price_value">

The following user(s) said Thank You: cluckngood

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

  • Posts: 40
  • Thank you received: 0
11 years 9 months ago #88908

This worked perfectly. Next step is to get the weight to also display in the User & Admin Order Confirmation Emails. I was able to get the title to publish in the email, however the weight value won't work. Something must be different for the email than the cart. I've tried adding the code

<td> <p class="hikashop_cart_product_weight_value">
<?php echo $row->product_weight; ?>
</p></td>

…but it doesn't pull the weight value into the email. I only get a blank cell. Is there a mod that needs to be applied to this to get it to work?

Jason

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

  • Posts: 13201
  • Thank you received: 2322
11 years 9 months ago #88977

You should try with "$item->order_product_weight" instead of "$row->product_weight"

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

  • Posts: 82868
  • Thank you received: 13377
  • MODERATOR
11 years 9 months ago #89101

It's not possible to use either "$item->order_product_weight" or "$row->product_weight" in emails as the product_weight data is simply not there.
You will need to first load the data from the database. So the code should be:

<?php $productClass = hikashop_get('class.product');
$product = $productClass->get($item->product_id);
echo $product->product_weight;
?>

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

  • Posts: 40
  • Thank you received: 0
11 years 9 months ago #91525

Thanks for the code. I've inserted it into the file located at "/media/com_hikashop/email/order_admin_notification.html.php" and am still having the product id show up.

The code for the User Order Confirmation has different code. I also tried inserting the supplied code in place for the file "/media/com_hikashop/email/order_admin_notification.html.php" and the shopping cart stopped working. It began loading a blank page at the end and wouldn't complete the order checkout. the code i have in place now is:

<?php } ?>
<!-- Product Weight Value Begins -->
<td><p class="hikashop_cart_product_weight_value" style="text-align: center;">
<?php echo $item->order_product_weight; ?> </p></td>
<!-- Product Weight Value Ends -->

I have attached these two pages for a complete reference. I'm not very familiar with PHP but am sure it is a very simple item that i am missing to correct this. Any idea what I am doing wrong?

Jason

Attachments:

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

  • Posts: 13201
  • Thank you received: 2322
11 years 9 months ago #91671

Hi,

Thanks to try with the following files:

File Attachment:

File Name: order_admi...tion.txt
File Size:13 KB


File Attachment:

File Name: order_stat...tion.txt
File Size:20 KB

Attachments:

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

Time to create page: 0.088 seconds
Powered by Kunena Forum