Get Product and Cart information after Order

  • Posts: 15
  • Thank you received: 0
9 years 3 months ago #211079

-- HikaShop version -- : 2.5.0
-- Joomla version -- : 3.1
-- PHP version -- : 5.4.3
-- Browser(s) name and version -- : Chrome
-- Error-message(debug-mod must be tuned on) -- : Getting Products and Cart information after Order Confirmed

Hi,
How do I get product information like the dimensions, weight, length etc, after order has been confirmed?
This is also when using the ShippingCache plugins.
All the information I need is lost when calling the onAfterOrderConfirm(&$order, &$methods, $method_id) function.

Thank you!

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
9 years 3 months ago #211085

Hi,

All the order data is available in the $order object. Yes, there is no dimensions or weight in there and that's normal since that information is not part of the order but of the products. So the information is not lost. It's just not loaded as not necessary when you usually load the data of an order.
So simply loop through the array of the products in $order->cart->products and use the product_id of the elements to load the product information like this:

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

I don't understand what you mean by "This is also when using the ShippingCache plugins."
The onAfterOrderConfirm trigger is a trigger only available for payment plugins and which will be called only for the payment plugin that has been selected by the customer. So there is no link to ShippingCache since that only applies to shipping plugins.

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

  • Posts: 15
  • Thank you received: 0
9 years 3 months ago #211307

Thanks Nicolas,

That works, I was able to get the product info.
I also needed to get other information about the shipping carrier passed from the Shipping to the onAfterOrderConfirm function, so I ended up creating a database, saving information there, and cleaning the database after I retrieved it in the after Order confirmation. Not sure if there is a better way of doing this.

I tried caching, using constants, etc....those did not work.
Thanks!

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
9 years 3 months ago #211311

Hi,

As I said, all the information of the order is available in $order.
You have $order->order_shipping_id and $order->order_shipping_method which will tell you which shipping method and which shipping service were selected for the order.

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

Time to create page: 0.057 seconds
Powered by Kunena Forum