Magento 2: How to hide shipping method on front end for custom logicShipping method only avialable for manual order creation 1.9Custom Shipping Method only for logged usersMagento2 : custom rate for shipping methodExtension attribute for shipping method in Magento 2Magento 2 : Custom online shipping method with shipping APIremove free shipping method from custom shipping module magento2magento 2: Hide shipping method in frontendupdate shipping address for shipping method changeMagento2 - Add Custom fields block after shipping method
If you attack a Tarrasque while swallowed, what AC do you need to beat to hit it?
tikz: 5 squares on a row, roman numbered 1 -> 5
Good examples of "two is easy, three is hard" in computational sciences
Germany rejected my entry to Schengen countries
RAID 5/6 rebuild time calculation
Does the fact that we can only measure the two-way speed of light undermine the axiom of invariance?
What Species of Trees are These?
Keeping the dodos out of the field
Why is there no current between two capacitors connected in series?
Why was Harry at the Weasleys' at the beginning of Goblet of Fire but at the Dursleys' after?
Was murdering a slave illegal in American slavery, and if so, what punishments were given for it?
Managing heat dissipation in a magic wand
Does George B Sperry logo on fold case for photos indicate photographer or case manufacturer?
Vehemently against code formatting
What to call a small, open stone or cement reservoir that supplies fresh water from a spring or other natural source?
Best practice for printing and evaluating formulas with the minimal coding
How to safely discharge oneself
Existence of a model of ZFC in which the natural numbers are really the natural numbers
Rotate and duplicate row values in Google Sheets
Expand a hexagon
How should I mix small caps with digits or symbols?
pwaS eht tirsf dna tasl setterl fo hace dorw
Does the Aboleth have expertise in History and Perception?
Connecting circles clockwise in TikZ
Magento 2: How to hide shipping method on front end for custom logic
Shipping method only avialable for manual order creation 1.9Custom Shipping Method only for logged usersMagento2 : custom rate for shipping methodExtension attribute for shipping method in Magento 2Magento 2 : Custom online shipping method with shipping APIremove free shipping method from custom shipping module magento2magento 2: Hide shipping method in frontendupdate shipping address for shipping method changeMagento2 - Add Custom fields block after shipping method
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
Hi I have create custom shipping method. I have enabled it from back end. Now I want show this only if product custom attribute match some conditions.
magento2 shipping-methods custom-shipping-method
add a comment |
Hi I have create custom shipping method. I have enabled it from back end. Now I want show this only if product custom attribute match some conditions.
magento2 shipping-methods custom-shipping-method
add a comment |
Hi I have create custom shipping method. I have enabled it from back end. Now I want show this only if product custom attribute match some conditions.
magento2 shipping-methods custom-shipping-method
Hi I have create custom shipping method. I have enabled it from back end. Now I want show this only if product custom attribute match some conditions.
magento2 shipping-methods custom-shipping-method
magento2 shipping-methods custom-shipping-method
asked Apr 5 '17 at 16:10
AbhishekAbhishek
443823
443823
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
It's your custom shipping method which have collectRates method in somewhere in model folder ex. for Flatrate shipping method collectRates method is located at MagentoOfflineShippingModelCarrierFlatrate
public function collectRates(RateRequest $request)
if (!$this->getConfigFlag('active'))
return false;
if($customeProductConditionFalse)
return false;
........
In this method you can check your condition for product custom attribute match or not and
return false;
to disable shipping method
i can add product attribute condition but what is the code for disable shipping method.
– Dhaval Patel
Mar 27 '18 at 12:30
you need to send return false to disable it
– Vaibhav Ahalpara
Mar 27 '18 at 13:30
Is this working for you? I do not want to disable shipping method. But I want to hide the shipping method on some product custom option condition.
– Dhaduk Mitesh
Jul 7 '18 at 9:17
@DhadukMitesh Did you find the solution for this?
– Pratik Kamani
May 14 at 11:17
@PratikKamani Please check my answer.
– Dhaduk Mitesh
May 14 at 12:48
add a comment |
Create etc/di.xml
.
<?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="MagentoQuoteApiShipmentEstimationInterface">
<plugin name="hide_show_shipping_methods" type="VendorModulePluginQuoteApiShipmentEstimationPlugin"/>
</type>
</config>
Create VendorModulePluginQuoteApiShipmentEstimationPlugin.php
.
<?php
namespace VendorModulePluginQuoteApi;
use MagentoQuoteApiShipmentEstimationInterface;
class ShipmentEstimationPlugin
public function __construct(
MagentoCustomerModelSession $customerSession
)
$this->customerSession = $customerSession;
public function aroundEstimateByExtendedAddress(
ShipmentEstimationInterface $subject,
Closure $proceed,
$cartId,
MagentoQuoteApiDataAddressInterface $address
)
$shippingMethods = $proceed($cartId, $address);
if ($this->customerSession->isLoggedIn())
foreach ($shippingMethods as $key => $shippingMethod)
//Replace 'freeshipping' with your shipping method which you want to hide
if ($shippingMethod->getMethodCode() == 'freeshipping')
unset($shippingMethods[$key]);
return $shippingMethods;
It will work for you.
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%2f167828%2fmagento-2-how-to-hide-shipping-method-on-front-end-for-custom-logic%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
It's your custom shipping method which have collectRates method in somewhere in model folder ex. for Flatrate shipping method collectRates method is located at MagentoOfflineShippingModelCarrierFlatrate
public function collectRates(RateRequest $request)
if (!$this->getConfigFlag('active'))
return false;
if($customeProductConditionFalse)
return false;
........
In this method you can check your condition for product custom attribute match or not and
return false;
to disable shipping method
i can add product attribute condition but what is the code for disable shipping method.
– Dhaval Patel
Mar 27 '18 at 12:30
you need to send return false to disable it
– Vaibhav Ahalpara
Mar 27 '18 at 13:30
Is this working for you? I do not want to disable shipping method. But I want to hide the shipping method on some product custom option condition.
– Dhaduk Mitesh
Jul 7 '18 at 9:17
@DhadukMitesh Did you find the solution for this?
– Pratik Kamani
May 14 at 11:17
@PratikKamani Please check my answer.
– Dhaduk Mitesh
May 14 at 12:48
add a comment |
It's your custom shipping method which have collectRates method in somewhere in model folder ex. for Flatrate shipping method collectRates method is located at MagentoOfflineShippingModelCarrierFlatrate
public function collectRates(RateRequest $request)
if (!$this->getConfigFlag('active'))
return false;
if($customeProductConditionFalse)
return false;
........
In this method you can check your condition for product custom attribute match or not and
return false;
to disable shipping method
i can add product attribute condition but what is the code for disable shipping method.
– Dhaval Patel
Mar 27 '18 at 12:30
you need to send return false to disable it
– Vaibhav Ahalpara
Mar 27 '18 at 13:30
Is this working for you? I do not want to disable shipping method. But I want to hide the shipping method on some product custom option condition.
– Dhaduk Mitesh
Jul 7 '18 at 9:17
@DhadukMitesh Did you find the solution for this?
– Pratik Kamani
May 14 at 11:17
@PratikKamani Please check my answer.
– Dhaduk Mitesh
May 14 at 12:48
add a comment |
It's your custom shipping method which have collectRates method in somewhere in model folder ex. for Flatrate shipping method collectRates method is located at MagentoOfflineShippingModelCarrierFlatrate
public function collectRates(RateRequest $request)
if (!$this->getConfigFlag('active'))
return false;
if($customeProductConditionFalse)
return false;
........
In this method you can check your condition for product custom attribute match or not and
return false;
to disable shipping method
It's your custom shipping method which have collectRates method in somewhere in model folder ex. for Flatrate shipping method collectRates method is located at MagentoOfflineShippingModelCarrierFlatrate
public function collectRates(RateRequest $request)
if (!$this->getConfigFlag('active'))
return false;
if($customeProductConditionFalse)
return false;
........
In this method you can check your condition for product custom attribute match or not and
return false;
to disable shipping method
answered May 6 '17 at 7:27
Vaibhav AhalparaVaibhav Ahalpara
3,70042762
3,70042762
i can add product attribute condition but what is the code for disable shipping method.
– Dhaval Patel
Mar 27 '18 at 12:30
you need to send return false to disable it
– Vaibhav Ahalpara
Mar 27 '18 at 13:30
Is this working for you? I do not want to disable shipping method. But I want to hide the shipping method on some product custom option condition.
– Dhaduk Mitesh
Jul 7 '18 at 9:17
@DhadukMitesh Did you find the solution for this?
– Pratik Kamani
May 14 at 11:17
@PratikKamani Please check my answer.
– Dhaduk Mitesh
May 14 at 12:48
add a comment |
i can add product attribute condition but what is the code for disable shipping method.
– Dhaval Patel
Mar 27 '18 at 12:30
you need to send return false to disable it
– Vaibhav Ahalpara
Mar 27 '18 at 13:30
Is this working for you? I do not want to disable shipping method. But I want to hide the shipping method on some product custom option condition.
– Dhaduk Mitesh
Jul 7 '18 at 9:17
@DhadukMitesh Did you find the solution for this?
– Pratik Kamani
May 14 at 11:17
@PratikKamani Please check my answer.
– Dhaduk Mitesh
May 14 at 12:48
i can add product attribute condition but what is the code for disable shipping method.
– Dhaval Patel
Mar 27 '18 at 12:30
i can add product attribute condition but what is the code for disable shipping method.
– Dhaval Patel
Mar 27 '18 at 12:30
you need to send return false to disable it
– Vaibhav Ahalpara
Mar 27 '18 at 13:30
you need to send return false to disable it
– Vaibhav Ahalpara
Mar 27 '18 at 13:30
Is this working for you? I do not want to disable shipping method. But I want to hide the shipping method on some product custom option condition.
– Dhaduk Mitesh
Jul 7 '18 at 9:17
Is this working for you? I do not want to disable shipping method. But I want to hide the shipping method on some product custom option condition.
– Dhaduk Mitesh
Jul 7 '18 at 9:17
@DhadukMitesh Did you find the solution for this?
– Pratik Kamani
May 14 at 11:17
@DhadukMitesh Did you find the solution for this?
– Pratik Kamani
May 14 at 11:17
@PratikKamani Please check my answer.
– Dhaduk Mitesh
May 14 at 12:48
@PratikKamani Please check my answer.
– Dhaduk Mitesh
May 14 at 12:48
add a comment |
Create etc/di.xml
.
<?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="MagentoQuoteApiShipmentEstimationInterface">
<plugin name="hide_show_shipping_methods" type="VendorModulePluginQuoteApiShipmentEstimationPlugin"/>
</type>
</config>
Create VendorModulePluginQuoteApiShipmentEstimationPlugin.php
.
<?php
namespace VendorModulePluginQuoteApi;
use MagentoQuoteApiShipmentEstimationInterface;
class ShipmentEstimationPlugin
public function __construct(
MagentoCustomerModelSession $customerSession
)
$this->customerSession = $customerSession;
public function aroundEstimateByExtendedAddress(
ShipmentEstimationInterface $subject,
Closure $proceed,
$cartId,
MagentoQuoteApiDataAddressInterface $address
)
$shippingMethods = $proceed($cartId, $address);
if ($this->customerSession->isLoggedIn())
foreach ($shippingMethods as $key => $shippingMethod)
//Replace 'freeshipping' with your shipping method which you want to hide
if ($shippingMethod->getMethodCode() == 'freeshipping')
unset($shippingMethods[$key]);
return $shippingMethods;
It will work for you.
add a comment |
Create etc/di.xml
.
<?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="MagentoQuoteApiShipmentEstimationInterface">
<plugin name="hide_show_shipping_methods" type="VendorModulePluginQuoteApiShipmentEstimationPlugin"/>
</type>
</config>
Create VendorModulePluginQuoteApiShipmentEstimationPlugin.php
.
<?php
namespace VendorModulePluginQuoteApi;
use MagentoQuoteApiShipmentEstimationInterface;
class ShipmentEstimationPlugin
public function __construct(
MagentoCustomerModelSession $customerSession
)
$this->customerSession = $customerSession;
public function aroundEstimateByExtendedAddress(
ShipmentEstimationInterface $subject,
Closure $proceed,
$cartId,
MagentoQuoteApiDataAddressInterface $address
)
$shippingMethods = $proceed($cartId, $address);
if ($this->customerSession->isLoggedIn())
foreach ($shippingMethods as $key => $shippingMethod)
//Replace 'freeshipping' with your shipping method which you want to hide
if ($shippingMethod->getMethodCode() == 'freeshipping')
unset($shippingMethods[$key]);
return $shippingMethods;
It will work for you.
add a comment |
Create etc/di.xml
.
<?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="MagentoQuoteApiShipmentEstimationInterface">
<plugin name="hide_show_shipping_methods" type="VendorModulePluginQuoteApiShipmentEstimationPlugin"/>
</type>
</config>
Create VendorModulePluginQuoteApiShipmentEstimationPlugin.php
.
<?php
namespace VendorModulePluginQuoteApi;
use MagentoQuoteApiShipmentEstimationInterface;
class ShipmentEstimationPlugin
public function __construct(
MagentoCustomerModelSession $customerSession
)
$this->customerSession = $customerSession;
public function aroundEstimateByExtendedAddress(
ShipmentEstimationInterface $subject,
Closure $proceed,
$cartId,
MagentoQuoteApiDataAddressInterface $address
)
$shippingMethods = $proceed($cartId, $address);
if ($this->customerSession->isLoggedIn())
foreach ($shippingMethods as $key => $shippingMethod)
//Replace 'freeshipping' with your shipping method which you want to hide
if ($shippingMethod->getMethodCode() == 'freeshipping')
unset($shippingMethods[$key]);
return $shippingMethods;
It will work for you.
Create etc/di.xml
.
<?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="MagentoQuoteApiShipmentEstimationInterface">
<plugin name="hide_show_shipping_methods" type="VendorModulePluginQuoteApiShipmentEstimationPlugin"/>
</type>
</config>
Create VendorModulePluginQuoteApiShipmentEstimationPlugin.php
.
<?php
namespace VendorModulePluginQuoteApi;
use MagentoQuoteApiShipmentEstimationInterface;
class ShipmentEstimationPlugin
public function __construct(
MagentoCustomerModelSession $customerSession
)
$this->customerSession = $customerSession;
public function aroundEstimateByExtendedAddress(
ShipmentEstimationInterface $subject,
Closure $proceed,
$cartId,
MagentoQuoteApiDataAddressInterface $address
)
$shippingMethods = $proceed($cartId, $address);
if ($this->customerSession->isLoggedIn())
foreach ($shippingMethods as $key => $shippingMethod)
//Replace 'freeshipping' with your shipping method which you want to hide
if ($shippingMethod->getMethodCode() == 'freeshipping')
unset($shippingMethods[$key]);
return $shippingMethods;
It will work for you.
edited May 14 at 13:02
answered May 14 at 12:47
Dhaduk MiteshDhaduk Mitesh
667218
667218
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%2f167828%2fmagento-2-how-to-hide-shipping-method-on-front-end-for-custom-logic%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