Magento 2: Hide other shipping methods when free shipping is available
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
I charge my customers flat rate for shipping and I also offer free shipping for orders that are above certain amount. At the moment, customers who qualify for free shipping will also have paid shipping option shown, which may confuse some customers. Does anyone know if there's a way to hide other shipping methods when free shipping method is available?
magento2 shipping shipping-methods free-shipping
add a comment |
I charge my customers flat rate for shipping and I also offer free shipping for orders that are above certain amount. At the moment, customers who qualify for free shipping will also have paid shipping option shown, which may confuse some customers. Does anyone know if there's a way to hide other shipping methods when free shipping method is available?
magento2 shipping shipping-methods free-shipping
add a comment |
I charge my customers flat rate for shipping and I also offer free shipping for orders that are above certain amount. At the moment, customers who qualify for free shipping will also have paid shipping option shown, which may confuse some customers. Does anyone know if there's a way to hide other shipping methods when free shipping method is available?
magento2 shipping shipping-methods free-shipping
I charge my customers flat rate for shipping and I also offer free shipping for orders that are above certain amount. At the moment, customers who qualify for free shipping will also have paid shipping option shown, which may confuse some customers. Does anyone know if there's a way to hide other shipping methods when free shipping method is available?
magento2 shipping shipping-methods free-shipping
magento2 shipping shipping-methods free-shipping
asked Feb 24 '16 at 7:26
ifekifek
4315
4315
add a comment |
add a comment |
4 Answers
4
active
oldest
votes
I had the same problem.
Remove "Free Shipping" configuration because you don't need it (you already have "Cart Price Rules").
When your customer qualifies for free shipping it happens based on "Flat Rate" not in "Free Shipping".
add a comment |
Use the extension ShippingTweaks.
add a comment |
Write a plugin to disable flat rate shipping method when free shipping is actually enabled based on cart sub total.
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="MagentoOfflineShippingModelCarrierFlatrate">
<plugin name="disable-flatrate" type="VendorModuleNameModelCarrierFlatrate" sortOrder="1" />
</type>
</config>
Write a Model class to process sub total validation.
<?php
namespace VendorModuleNameModelCarrier;
class Flatrate
{
const XML_PATH_FREE_SHIPPING_SUBTOTAL = "carriers/freeshipping/free_shipping_subtotal";
/**
* @var MagentoCheckoutModelSession
*/
protected $_checkoutSession;
/**
* @var MagentoFrameworkAppConfigScopeConfigInterface
*/
protected $_scopeConfig;
public function __construct(
MagentoCheckoutModelSession $checkoutSession,
MagentoFrameworkAppConfigScopeConfigInterface $scopeConfig,
MagentoStoreModelStoreManagerInterface $storeManager
) {
$this->_storeManager = $storeManager;
$this->_checkoutSession = $checkoutSession;
$this->_scopeConfig = $scopeConfig;
}
public function afterCollectRates(MagentoOfflineShippingModelCarrierFlatrate $flatRate, $result)
{
$scopeId = $this->_storeManager->getStore()->getId();
$storeScope = MagentoStoreModelScopeInterface::SCOPE_STORES;
// Get MOA value from system configuration.
$freeShippingSubTotal = $this->_scopeConfig->getValue(self::XML_PATH_FREE_SHIPPING_SUBTOTAL, $storeScope, $scopeId);
// Get cart subtotal from checkout session.
$baseSubTotal = $this->_checkoutSession->getQuote()->getBaseSubtotal();
// Validate subtoal should be empty or Zero.
if(!empty($baseSubTotal) && !empty($freeShippingSubTotal)) {
if($baseSubTotal >= $freeShippingSubTotal) {
return false;
}
}
return $result;
}
}
hi @maniprakash where i need to create di.xml ?
– Nagaraju Kasa
Oct 30 '18 at 11:36
1
Romba nandri its working fine.
– Nagaraju Kasa
Oct 30 '18 at 13:26
add a comment |
in response to @Nagaraju and hoping to help to anyone.
The di.xml can be created in any module you have, or if you dont know how and where:
app/code/My_Vendor/MyModule/etc/di.xml -> here is where you put the code of @maniprakash
then you should create the class in:
app/code/My_Vendor/MyModule/Model/Flatrate -> and paste the class code of @maniprakash
Just remember to change the path in type tag on the di.xml
<plugin name="disable-flatrate" type="VendorModuleNameModelCarrierFlatrate" sortOrder="1" />
the path must match where your Model class is it. in my example should be
<plugin name="disable-flatrate" type="My_VendorMyModuleModelFlatrate" sortOrder="1" />
AND that's it! hope it helps! and thanks to @manipakrash , it helps me! =)
New contributor
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f103175%2fmagento-2-hide-other-shipping-methods-when-free-shipping-is-available%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
I had the same problem.
Remove "Free Shipping" configuration because you don't need it (you already have "Cart Price Rules").
When your customer qualifies for free shipping it happens based on "Flat Rate" not in "Free Shipping".
add a comment |
I had the same problem.
Remove "Free Shipping" configuration because you don't need it (you already have "Cart Price Rules").
When your customer qualifies for free shipping it happens based on "Flat Rate" not in "Free Shipping".
add a comment |
I had the same problem.
Remove "Free Shipping" configuration because you don't need it (you already have "Cart Price Rules").
When your customer qualifies for free shipping it happens based on "Flat Rate" not in "Free Shipping".
I had the same problem.
Remove "Free Shipping" configuration because you don't need it (you already have "Cart Price Rules").
When your customer qualifies for free shipping it happens based on "Flat Rate" not in "Free Shipping".
answered Mar 21 '17 at 0:05
Gabriel SilvaGabriel Silva
1047
1047
add a comment |
add a comment |
Use the extension ShippingTweaks.
add a comment |
Use the extension ShippingTweaks.
add a comment |
Use the extension ShippingTweaks.
Use the extension ShippingTweaks.
answered Aug 28 '17 at 13:21
VitaliiVitalii
393139
393139
add a comment |
add a comment |
Write a plugin to disable flat rate shipping method when free shipping is actually enabled based on cart sub total.
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="MagentoOfflineShippingModelCarrierFlatrate">
<plugin name="disable-flatrate" type="VendorModuleNameModelCarrierFlatrate" sortOrder="1" />
</type>
</config>
Write a Model class to process sub total validation.
<?php
namespace VendorModuleNameModelCarrier;
class Flatrate
{
const XML_PATH_FREE_SHIPPING_SUBTOTAL = "carriers/freeshipping/free_shipping_subtotal";
/**
* @var MagentoCheckoutModelSession
*/
protected $_checkoutSession;
/**
* @var MagentoFrameworkAppConfigScopeConfigInterface
*/
protected $_scopeConfig;
public function __construct(
MagentoCheckoutModelSession $checkoutSession,
MagentoFrameworkAppConfigScopeConfigInterface $scopeConfig,
MagentoStoreModelStoreManagerInterface $storeManager
) {
$this->_storeManager = $storeManager;
$this->_checkoutSession = $checkoutSession;
$this->_scopeConfig = $scopeConfig;
}
public function afterCollectRates(MagentoOfflineShippingModelCarrierFlatrate $flatRate, $result)
{
$scopeId = $this->_storeManager->getStore()->getId();
$storeScope = MagentoStoreModelScopeInterface::SCOPE_STORES;
// Get MOA value from system configuration.
$freeShippingSubTotal = $this->_scopeConfig->getValue(self::XML_PATH_FREE_SHIPPING_SUBTOTAL, $storeScope, $scopeId);
// Get cart subtotal from checkout session.
$baseSubTotal = $this->_checkoutSession->getQuote()->getBaseSubtotal();
// Validate subtoal should be empty or Zero.
if(!empty($baseSubTotal) && !empty($freeShippingSubTotal)) {
if($baseSubTotal >= $freeShippingSubTotal) {
return false;
}
}
return $result;
}
}
hi @maniprakash where i need to create di.xml ?
– Nagaraju Kasa
Oct 30 '18 at 11:36
1
Romba nandri its working fine.
– Nagaraju Kasa
Oct 30 '18 at 13:26
add a comment |
Write a plugin to disable flat rate shipping method when free shipping is actually enabled based on cart sub total.
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="MagentoOfflineShippingModelCarrierFlatrate">
<plugin name="disable-flatrate" type="VendorModuleNameModelCarrierFlatrate" sortOrder="1" />
</type>
</config>
Write a Model class to process sub total validation.
<?php
namespace VendorModuleNameModelCarrier;
class Flatrate
{
const XML_PATH_FREE_SHIPPING_SUBTOTAL = "carriers/freeshipping/free_shipping_subtotal";
/**
* @var MagentoCheckoutModelSession
*/
protected $_checkoutSession;
/**
* @var MagentoFrameworkAppConfigScopeConfigInterface
*/
protected $_scopeConfig;
public function __construct(
MagentoCheckoutModelSession $checkoutSession,
MagentoFrameworkAppConfigScopeConfigInterface $scopeConfig,
MagentoStoreModelStoreManagerInterface $storeManager
) {
$this->_storeManager = $storeManager;
$this->_checkoutSession = $checkoutSession;
$this->_scopeConfig = $scopeConfig;
}
public function afterCollectRates(MagentoOfflineShippingModelCarrierFlatrate $flatRate, $result)
{
$scopeId = $this->_storeManager->getStore()->getId();
$storeScope = MagentoStoreModelScopeInterface::SCOPE_STORES;
// Get MOA value from system configuration.
$freeShippingSubTotal = $this->_scopeConfig->getValue(self::XML_PATH_FREE_SHIPPING_SUBTOTAL, $storeScope, $scopeId);
// Get cart subtotal from checkout session.
$baseSubTotal = $this->_checkoutSession->getQuote()->getBaseSubtotal();
// Validate subtoal should be empty or Zero.
if(!empty($baseSubTotal) && !empty($freeShippingSubTotal)) {
if($baseSubTotal >= $freeShippingSubTotal) {
return false;
}
}
return $result;
}
}
hi @maniprakash where i need to create di.xml ?
– Nagaraju Kasa
Oct 30 '18 at 11:36
1
Romba nandri its working fine.
– Nagaraju Kasa
Oct 30 '18 at 13:26
add a comment |
Write a plugin to disable flat rate shipping method when free shipping is actually enabled based on cart sub total.
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="MagentoOfflineShippingModelCarrierFlatrate">
<plugin name="disable-flatrate" type="VendorModuleNameModelCarrierFlatrate" sortOrder="1" />
</type>
</config>
Write a Model class to process sub total validation.
<?php
namespace VendorModuleNameModelCarrier;
class Flatrate
{
const XML_PATH_FREE_SHIPPING_SUBTOTAL = "carriers/freeshipping/free_shipping_subtotal";
/**
* @var MagentoCheckoutModelSession
*/
protected $_checkoutSession;
/**
* @var MagentoFrameworkAppConfigScopeConfigInterface
*/
protected $_scopeConfig;
public function __construct(
MagentoCheckoutModelSession $checkoutSession,
MagentoFrameworkAppConfigScopeConfigInterface $scopeConfig,
MagentoStoreModelStoreManagerInterface $storeManager
) {
$this->_storeManager = $storeManager;
$this->_checkoutSession = $checkoutSession;
$this->_scopeConfig = $scopeConfig;
}
public function afterCollectRates(MagentoOfflineShippingModelCarrierFlatrate $flatRate, $result)
{
$scopeId = $this->_storeManager->getStore()->getId();
$storeScope = MagentoStoreModelScopeInterface::SCOPE_STORES;
// Get MOA value from system configuration.
$freeShippingSubTotal = $this->_scopeConfig->getValue(self::XML_PATH_FREE_SHIPPING_SUBTOTAL, $storeScope, $scopeId);
// Get cart subtotal from checkout session.
$baseSubTotal = $this->_checkoutSession->getQuote()->getBaseSubtotal();
// Validate subtoal should be empty or Zero.
if(!empty($baseSubTotal) && !empty($freeShippingSubTotal)) {
if($baseSubTotal >= $freeShippingSubTotal) {
return false;
}
}
return $result;
}
}
Write a plugin to disable flat rate shipping method when free shipping is actually enabled based on cart sub total.
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="MagentoOfflineShippingModelCarrierFlatrate">
<plugin name="disable-flatrate" type="VendorModuleNameModelCarrierFlatrate" sortOrder="1" />
</type>
</config>
Write a Model class to process sub total validation.
<?php
namespace VendorModuleNameModelCarrier;
class Flatrate
{
const XML_PATH_FREE_SHIPPING_SUBTOTAL = "carriers/freeshipping/free_shipping_subtotal";
/**
* @var MagentoCheckoutModelSession
*/
protected $_checkoutSession;
/**
* @var MagentoFrameworkAppConfigScopeConfigInterface
*/
protected $_scopeConfig;
public function __construct(
MagentoCheckoutModelSession $checkoutSession,
MagentoFrameworkAppConfigScopeConfigInterface $scopeConfig,
MagentoStoreModelStoreManagerInterface $storeManager
) {
$this->_storeManager = $storeManager;
$this->_checkoutSession = $checkoutSession;
$this->_scopeConfig = $scopeConfig;
}
public function afterCollectRates(MagentoOfflineShippingModelCarrierFlatrate $flatRate, $result)
{
$scopeId = $this->_storeManager->getStore()->getId();
$storeScope = MagentoStoreModelScopeInterface::SCOPE_STORES;
// Get MOA value from system configuration.
$freeShippingSubTotal = $this->_scopeConfig->getValue(self::XML_PATH_FREE_SHIPPING_SUBTOTAL, $storeScope, $scopeId);
// Get cart subtotal from checkout session.
$baseSubTotal = $this->_checkoutSession->getQuote()->getBaseSubtotal();
// Validate subtoal should be empty or Zero.
if(!empty($baseSubTotal) && !empty($freeShippingSubTotal)) {
if($baseSubTotal >= $freeShippingSubTotal) {
return false;
}
}
return $result;
}
}
answered Aug 28 '17 at 12:22
Maniprakash ChinnasamyManiprakash Chinnasamy
1537
1537
hi @maniprakash where i need to create di.xml ?
– Nagaraju Kasa
Oct 30 '18 at 11:36
1
Romba nandri its working fine.
– Nagaraju Kasa
Oct 30 '18 at 13:26
add a comment |
hi @maniprakash where i need to create di.xml ?
– Nagaraju Kasa
Oct 30 '18 at 11:36
1
Romba nandri its working fine.
– Nagaraju Kasa
Oct 30 '18 at 13:26
hi @maniprakash where i need to create di.xml ?
– Nagaraju Kasa
Oct 30 '18 at 11:36
hi @maniprakash where i need to create di.xml ?
– Nagaraju Kasa
Oct 30 '18 at 11:36
1
1
Romba nandri its working fine.
– Nagaraju Kasa
Oct 30 '18 at 13:26
Romba nandri its working fine.
– Nagaraju Kasa
Oct 30 '18 at 13:26
add a comment |
in response to @Nagaraju and hoping to help to anyone.
The di.xml can be created in any module you have, or if you dont know how and where:
app/code/My_Vendor/MyModule/etc/di.xml -> here is where you put the code of @maniprakash
then you should create the class in:
app/code/My_Vendor/MyModule/Model/Flatrate -> and paste the class code of @maniprakash
Just remember to change the path in type tag on the di.xml
<plugin name="disable-flatrate" type="VendorModuleNameModelCarrierFlatrate" sortOrder="1" />
the path must match where your Model class is it. in my example should be
<plugin name="disable-flatrate" type="My_VendorMyModuleModelFlatrate" sortOrder="1" />
AND that's it! hope it helps! and thanks to @manipakrash , it helps me! =)
New contributor
add a comment |
in response to @Nagaraju and hoping to help to anyone.
The di.xml can be created in any module you have, or if you dont know how and where:
app/code/My_Vendor/MyModule/etc/di.xml -> here is where you put the code of @maniprakash
then you should create the class in:
app/code/My_Vendor/MyModule/Model/Flatrate -> and paste the class code of @maniprakash
Just remember to change the path in type tag on the di.xml
<plugin name="disable-flatrate" type="VendorModuleNameModelCarrierFlatrate" sortOrder="1" />
the path must match where your Model class is it. in my example should be
<plugin name="disable-flatrate" type="My_VendorMyModuleModelFlatrate" sortOrder="1" />
AND that's it! hope it helps! and thanks to @manipakrash , it helps me! =)
New contributor
add a comment |
in response to @Nagaraju and hoping to help to anyone.
The di.xml can be created in any module you have, or if you dont know how and where:
app/code/My_Vendor/MyModule/etc/di.xml -> here is where you put the code of @maniprakash
then you should create the class in:
app/code/My_Vendor/MyModule/Model/Flatrate -> and paste the class code of @maniprakash
Just remember to change the path in type tag on the di.xml
<plugin name="disable-flatrate" type="VendorModuleNameModelCarrierFlatrate" sortOrder="1" />
the path must match where your Model class is it. in my example should be
<plugin name="disable-flatrate" type="My_VendorMyModuleModelFlatrate" sortOrder="1" />
AND that's it! hope it helps! and thanks to @manipakrash , it helps me! =)
New contributor
in response to @Nagaraju and hoping to help to anyone.
The di.xml can be created in any module you have, or if you dont know how and where:
app/code/My_Vendor/MyModule/etc/di.xml -> here is where you put the code of @maniprakash
then you should create the class in:
app/code/My_Vendor/MyModule/Model/Flatrate -> and paste the class code of @maniprakash
Just remember to change the path in type tag on the di.xml
<plugin name="disable-flatrate" type="VendorModuleNameModelCarrierFlatrate" sortOrder="1" />
the path must match where your Model class is it. in my example should be
<plugin name="disable-flatrate" type="My_VendorMyModuleModelFlatrate" sortOrder="1" />
AND that's it! hope it helps! and thanks to @manipakrash , it helps me! =)
New contributor
New contributor
answered yesterday
Joshua CastroJoshua Castro
1
1
New contributor
New contributor
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f103175%2fmagento-2-hide-other-shipping-methods-when-free-shipping-is-available%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown