Craft Commerce - For a discount, can we include all products in the product count but not include the sale items that receive the discount? What I would like is for a 10% discount to be applied to non sale items after the total cart quantity reaches 10 total items. I would ONLY like this discount on non sale items. Is that possible?

So, say I have 2 Products in my cart:


Item A - $20 on sale for $10, qty 9
Item B - $20, qty 1


This makes my total in cart quantity 10 line items even though 9 of them are sale items.

What I would like is for Item B to be discounted 10% making my cart total $108

( (10*9) + (20 * .9) ) = 108


As it currently stands, if I toggle Exclude this discount for products that are already on sale it doesn't count the sales items towards the total.
Based on some research, I believe a custom Adjuster is the way to solve this problem.

I created an adjuster with the following:

craft/plugins/myplugin/MypluginPlugin.php

public function commerce_registerOrderAdjusters()
{
  return [
    401 =&gt; new \Commerce\Adjusters\Myplugin_TenpercentDiscount
  ];
}


craft/plugins/myplugin/Adjusters/Myplugin_TenPercentDiscount.php

&lt;?php

namespace Commerce\Adjusters;
use Craft\Commerce_LineItemModel;
use Craft\Commerce_OrderAdjustmentModel;
use Craft\Commerce_OrderModel;

class Myplugin_TenPercentDiscount implements Commerce_AdjusterInterface {

public function adjust(Commerce_OrderModel &amp;$order, array $lineItems = []){

    if (empty($lineItems))
    {
        return [];
    }

    if ($order-&gt;totalQty &gt;= 10)
    {
        $adjuster = new Commerce_OrderAdjustmentModel();

        $adjuster-&gt;type        = 'Item Discount';
        $adjuster-&gt;name        = '10% Off Items';
        $adjuster-&gt;description = 'Your order qualifies for a 10% discount on all non sale items because you are purchasing at least 10 products.';
        $adjuster-&gt;orderId     = $order-&gt;id;

        $amountOff = 0;
        foreach ($lineItems as $item)
        {
            if (empty($item-&gt;onSale))
            {
                $amountOff += ($item-&gt;subtotal + $item-&gt;discount) * .1;
            }
        }
        $amountOff = $amountOff * -1;

        $adjuster-&gt;amount      = $amountOff;
        $adjuster-&gt;optionsJson = ['lineItemsAffected' =&gt; null];
        $order-&gt;baseDiscount  += $amountOff;

        $adjuster-&gt;included = false;

        return [$adjuster];
    }
    return[];
}

}


Does anyone see any flaws with this approach?