I need to set free shipping in observer, under certain very specific conditions. I can't have free shipping enabled in the back end because customers shouldn't be able to select it.
I already tried these things with no success:
1) set free shipping on address directly in observer. It changes to true but on next call it reverts back to false(0) when checked with
$address = $quote->getShippingAddress(); $address->setFreeShipping(true);
requestShippingRates method. Hard-code
3) Magento\Quote\Model\Quote\Address\FreeShipping:16 Replace
return false with
true. This method looks unfinished by the way.
4) Magento\Quote\Model\Quote\Address\Total\Shipping:159. Hard-code:
It's equivalent to attempt number 3.
None of these worked. I would appreciate any suggestions. What can I try next? Which class to override?
This is a 'duplicate' of Magento 1 questions: