Price information from another component

  • Posts: 180
  • Thank you received: 13
11 years 1 week ago #132071

Hi

I am accessing the product information from another component to display in a scroller with certain effects not available on the standard one.

I have successfully got the product name and image loading, but wanted to know where to get the best code to use for fetching the price, which takes into account the currency and discounts.

Thanks in advance

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

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
11 years 1 week ago #132144

Hi,

If you want to load an HikaShop product, the best is to use the HikaShop product class.

$productClass = hikashop_get('class.product');
$product = $productClass->get($product_id);
It will load the values from the different tables (product, product_price, etc).

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: 180
  • Thank you received: 13
11 years 1 week ago #132164

Thank you for the quick response Jerome. I'll give that a go :)

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

  • Posts: 180
  • Thank you received: 13
11 years 6 days ago #132871

The line $productClass = hikashop_get('class.product'); crashes the page.

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
11 years 6 days ago #132961

Of course you need to initialize HikaShop before calling HikaShop functions.
You can initialize HikaShop with that line of code:

if(!include_once(rtrim(JPATH_ADMINISTRATOR,DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'components'.DIRECTORY_SEPARATOR.'com_hikashop'.DIRECTORY_SEPARATOR.'helpers'.DIRECTORY_SEPARATOR.'helper.php')) return true;

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

Time to create page: 0.065 seconds
Powered by Kunena Forum