Prevent Hikashop module from showing items which are already in the cart

  • Posts: 32
  • Thank you received: 5
  • Hikashop Essential
1 week 8 hours ago #368107

-- HikaShop version -- : 6.0.0
-- Joomla version -- : 4.4.13
-- PHP version -- : 8.1.32

Hello,
I have set the Hikashop module to show Related products from cart.
Then I have published this module on the Cart Display menu item (index.php?option=com_hikashop&view=cart&layout=show)
But the module displays products which are already in the cart.
I'd like to prevent this from happening, because I only allow one copy per product to be purchased (I sell digital products only).
I have multiple related products set, so if I refresh the cart page, a product which is not already in the cart will show up.
But I'd like this to happen by default.
I'd like the module to not show any product if there are no more related items which haven't already been added to the cart.
How can I achieve this?
Thanks in advance.

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

  • Posts: 84216
  • Thank you received: 13665
  • MODERATOR
6 days 22 hours ago #368109

Hi,

I agree that the system could be improved to avoid referencing such products in the module as it doesn't make sense in most cases.

Try adding the line:

$filters[] = 'b.product_id NOT IN ('.implode(',',$mainIds).')';
after the line:
$filters[] = 'b.product_id IN ('.$ids.')';
in the file components/com_hikashop/views/product/view.html.php
That should do it. Let us know how it goes so that we can include the change for the next version of HikaShop.

The following user(s) said Thank You: brettv

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

  • Posts: 32
  • Thank you received: 5
  • Hikashop Essential
1 day 9 hours ago #368178

Yes it worked. Thanks.

The following user(s) said Thank You: nicolas

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

Time to create page: 0.055 seconds
Powered by Kunena Forum