verbb / postie

A Craft Commerce shipping calculator plugin.
Other
12 stars 18 forks source link

Check discounts and free shipping when getting line items used in fetching rates #106

Closed zollf closed 1 year ago

zollf commented 1 year ago

https://github.com/verbb/postie/issues/104

Unfortunately the change i suggested wasn't the full picture, apologies. It works for the reproduction I'd given, but not for discounts with "free shipping for matching line items". image

In Commerce, their shipping adjustments look up discounts and filters any line items that match those discounts. https://github.com/craftcms/commerce/blob/fd56ea73faea66bb8d4f09bbd99fb7e33f0ff371/src/adjusters/Shipping.php#L113-L133

In our use case, our client wants to create a discount with free shipping matching line items in a certain category/purchasable. Commerce already supports this out of the box.

To test this, I created 2 products. Then I created a discount that will match on line item for only one of those products and give it free shipping. This means that one product will have free shipping and the other will not.

engram-design commented 1 year ago

Thanks for this!