Get The Catgories of Products In Cart

  • Posts: 54
  • Thank you received: 0
8 years 4 months ago #259212

-- 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.

  • Posts: 26249
  • Thank you received: 4039
  • MODERATOR
8 years 4 months ago #259214

Hi,

Where and when you do want to display that message ?

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: 54
  • Thank you received: 0
8 years 4 months ago #259253

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: 8 years 4 months ago by eileensemporium.

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

  • Posts: 83931
  • Thank you received: 13586
  • MODERATOR
8 years 4 months ago #259305

Hi,

You'll have to get the products of the current cart with such 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.

  • Posts: 54
  • Thank you received: 0
8 years 4 months ago #259357

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.

  • Posts: 83931
  • Thank you received: 13586
  • MODERATOR
8 years 4 months ago #259364

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.086 seconds
Powered by Kunena Forum