I'd like to create a discount that is applied based on the weight of a cart.
I'm working with bottles & boxes of wine, so a bottle of wine has a weight of 1kg & a box of wine can have a weight of 6kg (6 bottles) or 12kg (12 bottles).
I need the discount to only apply when a customer from a certain customer group purchases 12 or more bottles of wine, but can't work with quantity because a quantity of 1 could be 1 bottle of wine or 1 box of wine (which could contain 6 or 12 bottles), hence my desire to apply the discount by weight of the entire cart instead.
I think the best way to do this would be to set up a rule for the customer group, apply it to all products & set a minimum of 1 to ensure that the rule always runs & then add logic in a plugin that fires on some or other discount event that then checks the weight and applies or doesn't apply the discount.
Something like:
craft()->on('commerce_discounts.onBeforeMatchLineItem',
function($event){
if( cartWeight >= 12){
return;
}else{
$event->performAction = false;
}
});
But I'm having trouble figuring out which event to use & how to put all the pieces together to achieve my desired result.
Any pointers in the right direction would be greatly appreciated.