<p>It would probably be best to make your own shipping adjuster. I have attached an example plugin here: <a href="http://jmp.sh/wC95ZPj" rel="nofollow noreferrer">http://jmp.sh/wC95ZPj</a></p>

<p>The adjuster plugin I have linked can look at the weight of the cart, it's line item contents, and then reduce (or add to) the shipping costs after the regular shipping calculations are run.</p>

CC BY-SA 3.0
2017-06-29T05:17:01.427Z
Ok - so not possible to do this with a custom discount adjuster ?
celeste.nexus
CC BY-SA 3.0
2017-06-30T04:09:36.890Z
Just another way that makes sense to me, and simplifies the whole thing. Let your discounts and shipping costs apply, but reduce the shipping cost with another shipping adjustment.
Luke Holder
CC BY-SA 3.0
2017-06-29T01:28:20.100Z
2017-06-29T01:55:00.777Z
2017-06-29T01:55:00.777Z
Luke Holder
<p>I'd like to create a discount that is applied based on the weight of a cart. </p>

<p>I'm working with bottles &amp; boxes of wine, so a bottle of wine has a weight of 1kg &amp; a box of wine can have a weight of 6kg (6 bottles) or 12kg (12 bottles).</p>

<p>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. </p>

<p>I think the best way to do this would be to set up a rule for the customer group, apply it to all products &amp; set a minimum of 1 to ensure that the rule always runs &amp; 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. </p>

<p>Something like: </p>

<pre><code>craft()-&gt;on('commerce_discounts.onBeforeMatchLineItem',
  function($event){
    if( cartWeight &gt;= 12){
       return;
    }else{
       $event-&gt;performAction = false;
    } 
 });
</code></pre>

<p>But I'm having trouble figuring out which event to use &amp; how to put all the pieces together to achieve my desired result. </p>

<p>Any pointers in the right direction would be greatly appreciated. </p>

<plugin-craftcommerce><discounts>
How to apply a discount on cart weight ?
# How to apply a discount on cart weight ?

(Asked by: username_0 on 2017-06-27)

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.

**Tags:** plugin-craftcommerce, discounts

---

## 1 answers

### Answer by username_1 on 2017-06-29. Score: 1

It would probably be best to make your own shipping adjuster. I have attached an example plugin here: <http://jmp.sh/wC95ZPj>

The adjuster plugin I have linked can look at the weight of the cart, it's line item contents, and then reduce (or add to) the shipping costs after the regular shipping calculations are run.

> **Comments:**
> **username_0**: Ok - so not possible to do this with a custom discount adjuster ?  
> **username_1**: Just another way that makes sense to me, and simplifies the whole thing. Let your discounts and shipping costs apply, but reduce the shipping cost with another shipping adjustment.  

---

