-- HikaShop version -- : current
-- Joomla version -- : current 3.3
-- PHP version -- : current
hi!
I would like to create a plugin that does something when a product is added to the cart:
- It should check whether the product is part of a certain category. If this is the case, the plugin should empty the cart and then add the product to the cart, making it the only product in the cart
- If a certain product is added to the cart, it should change the shop's currency
Right now, I am working on the first part, but I do not even manage to make the cart get cleared for every product added. What I tried is this:
function onBeforeCartUpdate(&$cartClass,&$cart,$product_id,$quantity,$add,$type,$resetCartWhenUpdate,$force,&$do)
{
if (($type=='product') && ($add=1)) $cartClass->resetCart();
$do=true;
return true;
}
It clears the cart, but the product is not added afterwards. Can somebody please guide me on what I am doing wrong here? Additionally, I would greatly appreciate if you could tell me how to check if a certain product is part of a certain category.
Thank you very much & all the best,
Lukas