Skip to main content

Get The Catgories of Products In Cart

More
9 years 8 months ago #259212 by eileensemporium
-- HikaShop version -- : HikaShop Business 2.6.4 [1610121552]
-- Joomla version -- : 3.6.5
-- PHP version -- : 5.4

I would like to display a message to customers if products from a certain category added to the cart, is this possible in PHP (the products may be in more than one category)?

Thanks

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

More
9 years 8 months ago #259214 by Jerome
Hi,

Where and when you do want to display that message ?

Regards,

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

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

More
9 years 8 months ago - 9 years 8 months ago #259253 by eileensemporium
In a PHP module (Metamod) as I just want to display a message to customers
Could also do with the volume of the combined products too
Last edit: 9 years 8 months ago by eileensemporium.

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

More
9 years 8 months ago #259305 by nicolas
Hi,

You'll have to get the products of the current cart with such code:
Code:
<?php if(!defined('DS')) define('DS',DIRECTORY_SEPARATOR); include_once(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_hikashop'.DS.'helpers'.DS.'helper.php'): $class = hikashop_get('class.cart'); $cart = $class->loadFullCart(); // in $cart->products you'll find an array of all the products in the cart // then you'll have to do a MySQL query on the hiksahop_product_category table in order to check if there are entries with these products' ids and the id of the category you want to check them against

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

More
9 years 8 months ago #259357 by eileensemporium
Thanks
Is the customer's country available too so that I can hide the message depending on the delivery country?

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

More
9 years 8 months ago #259364 by nicolas
Hi,

You can use such code:
$id = hikashop_getZone();
That will give you the id of the zone of the user. If you have the address_state custom field enabled, it will give you the id of the state selected, otherwise, it will be the id of the country.
And you can look up the countries/states in the table hikashop_zone in the database and their links in the hikashop_zone_link table.
The following user(s) said Thank You: eileensemporium

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

Time to create page: 0.210 seconds
Powered by Kunena Forum