Hi,
For that last part there is no built-in "exclude this category" option on discounts, so the clean way is a small system plugin (group "hikashop") that reacts to the onSelectDiscount event. That event runs right before HikaShop picks the discount for each product, so you can remove the whole-shop discount for the products of the category you want to leave out, and those products then get no discount at all (no fake 0% or 0.001% discount, nothing shown on the front end).
Here is the method to put in your plugin, just set your category id at the top:
public function onSelectDiscount(&$product, &$discountsSelected, &$discounts, $zone_id, &$parent)
{
// Category to keep out of the whole-shop discount
$excludedCategoryId = 42;
// The whole-shop discount is the least specific one, stored under key 20.
// If it was not selected for this product, there is nothing to remove.
if(empty($discountsSelected[20]))
return;
// Use the parent product id for variants
$productId = (int)$product->product_id;
if(!empty($product->product_parent_id))
$productId = (int)$product->product_parent_id;
$db = \Joomla\CMS\Factory::getDBO();
// Bounds of the excluded category so its sub-categories are covered too
$db->setQuery('SELECT category_left, category_right FROM '.hikashop_table('category').
' WHERE category_id = '.(int)$excludedCategoryId);
$cat = $db->loadObject();
if(empty($cat))
return;
// Is the product linked to the excluded category or one of its children?
$db->setQuery(
'SELECT COUNT(*) FROM '.hikashop_table('product_category').' AS pc'.
' JOIN '.hikashop_table('category').' AS c ON pc.category_id = c.category_id'.
' WHERE pc.product_id = '.$productId.
' AND c.category_left >= '.(int)$cat->category_left.
' AND c.category_right <= '.(int)$cat->category_right
);
if($db->loadResult() > 0) {
// Remove the whole-shop discount: this category gets no discount at all
unset($discountsSelected[20]);
}
}
Your existing per-product and per-category discounts are not touched, they are stored under more specific keys and keep winning as before. Only the whole-shop 20% is removed, and only for the products of that one category.