Hi,
There is no option for that, but it can definitely be done as a plugin.
First, we have documentation about creating plugins for Joomla / HikaShop in general here:
www.hikashop.com/support/documentation/6...mentation.html#intro
If you're not familiar with this, I would recommend looking at this first.
I think the best is to implement the event onAfterCartProductsLoad of the cart API:
www.hikashop.com/support/documentation/6...fterCartProductsLoad
This event is triggered each time a cart is being loaded. You'll have most of the information about the cart in the one and only parameter of the event $cart, including an array of the product objects in $cart->products
So you can loop on that array in order to check which products are in the cart and the quantity of the product in the cart ( in the attribute cart_product_quantity ).
That way, you can calculate how much you want to give as a discount with whatever rules you need to apply.
Once you know the amount, you can add it to the cart:
$discountAmount = 10; // suppose we want to add a discount of 10$
$additionalDiscount = new stdClass();
$additionalDiscount->name = 'The label of the discount';
$additionalDiscount->price_currency_id = 2; // 2 is the id of the currency for USD in System>Currencies
$additional->price_value = - $discountAmount; // since the amount is added to the cart, you want to make it negative so that it can reduce the total amount, and not increase it
$additional->price_value_with_tax = - $discountAmount; // here you can add the amount with taxes. I just give the same amount for both discount amounts as this is just a simple example, but you'll likely want to calculate the taxes to be added or removed from your discount amount so that it matches with the taxes to apply to the cart
$cart->additional['my_custom_discount'] = $additionalDiscount; // here the "fee" is added to the cart.
This mechanism of additional fees is used by several plugins, like the "multi coupon plugin", the "cart fee plugin" or the "global cart fee plugin" (this one is free, you can easily look at its code if you want) which are available in our marketplace.