$Product does not hold categories, why not

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

-- 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) -- : $product variable does not print the categories.

Hi,
I am following the documentation here on the $Product variable, and I need to access the categories array. When I print the $Product variable I can see that the categories are not in the array. Nothing at all, not even an empty categories array.
My product all have categories, how or where do I get access to those product categories? I'm working on a shipping plugin.
Thanks!

doc link:
www.hikashop.com/support/documentation/157

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

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
9 years 3 months ago #210191

Hi,

Would it be possible to have the exact context where you are using that $product variable ?
Depending how you access it and which variable it is exactly, the category might not be available (depending if it's just the product which has been loaded or the "full product").

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

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

Hi Jerome,
That sounds like my issue. I am just doing a print_r($product) inside a function I passed the $order variable to. I didn't do a full load.
I'll try this below....from the docs website.....Thank you very much.

If you want to load the whole information of an order, you can use the code :
$orderClass = hikashop_get('class.order');
$order = $orderClass->loadFullOrder($order_id, true, false);
Similarly to the cart, the products will be available in the attribute as an array of product objects:
$order->products

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

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

I am trying to access those categories from a shipping plugin that extends the hikashopshipping plugin.
How can I access it from there?
It is needed in the onShippingDisplay function.

Thanks.

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

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

I think i got it. This has been an invaluable exercise in understanding Hikashop.

$productClass = hikashop_get('class.product');
$product=$productClass->getCategories(79);

This returns an array. Pretty cool, now I know how to access the other classes and their functions.

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

Time to create page: 0.060 seconds
Powered by Kunena Forum