I'm trying to configure my checkout so that if any coupon code is used, free shipping is disabled - basically the customer either receives free shipping or a discount, but not both. In the delivery methods settings it seems free shipping is either on or off based on a threshold with no other parameters. On the cart rule side, I have free shipping set to no, but it still allows the customer to receive both. How can I go about configuring this? If it matters, free shipping is only via USPS on orders over $39, with options to pay for faster delivery.
You can hide the free shipping programmatically by following the below code:
1. Create a plugin in di.xml file and use this below code.
<type name="Magento\Shipping\Model\Shipping"> <plugin disabled="false" name="Vendor_Extension_Model_Shipping" sortOrder="10" type="Vendor\Extension\Plugin\ApplyShipping"/> </type>
2. Create a plugin file in Vendor/Extension/Plugin.
<?php namespace Vendor\Extension\Plugin; class ApplyShipping { public function __construct() { } public function aroundCollectCarrierRates( \Magento\Shipping\Model\Shipping $subject, \Closure $proceed, $carrierCode, $request ) { // Enter Shipping Code here instead of 'freeshipping' if ($carrierCode == 'freeshipping') { // To disable the shipping method return false return false; } // To enable the shipping method return $proceed($carrierCode, $request); } }
You can get and check the coupon code with the below code:
"$this->chcekoutSession is object of \Magento\Checkout\Model\Session" $couponCode = $this->checkoutSession->getQuote()->getCouponCode();
Free Shipping is one of the promotion programs you can set up on Magento 2 when customers don’t need to pay any fee for your delivery. Unlike traditional shopping where customers can come to the store and pick up items directly, online shopping requires them to pay the extra shipping fee, which can become a burden for them to make purchase decisions. Click Here For More Info Therefore, offering free shipping promotion can make them feel comfortable to purchase more - a great way to increase conversion rates and boost sales, isn’t it?
From Magento 2 Shopping Cart Rule settings, depending on conditions you set, the Free Shipping can be applied for any order when all conditions are met. Simultaneously, you are able to generate an coupon code, that allows the customers to use coupon or not to apply the Free Shipping Promotion.
4 Steps To Set up Free Shipping Promotion in Magento 2
Step 1: Activate Free Shipping
Please activate the Free Shipping and finish its settings in your store’s configuration.
I completely agreed with @dolgeneral0ea6 Because the same process i have been followed to get rid off from my issue on instantly why don't you try and follow the same thing might be it will be work for you
Block certain methods of the shipping carrier
Create restrictions based on customer’s shipping data
Restrict shipping by various product attributes and order info
Use customer groups and store views as a restriction base
Disable or allow delivery with coupon