This is for Magento 2 Enterprise Edition.

Some products can only be shipped within the United States. How can we identify those products and prevent checkout when the shipping address is international?

Note that this only applies to certain products.


Yes,You can do this some code.

First create a YES/NO product attribute is_usa_shipping assign its value to YES on which products only ship at USA.

Then you need to remove your shipping methods when a customer select Shipping address international and Cart has items.

In this case, create a plugin around method on CollectRates of your shipping method and change the behavior.

Suppose ,you want remove Table rate when you cart have USA item

namespace Devamitbera\CoreRewrite\Plugin;
class TablerateForFrontPlugin
    protected $_logger;
    protected $quoteFactory;

     public function __construct(
        \Psr\Log\LoggerInterface $logger,
        \Magento\Quote\Model\QuoteFactory $quoteFactory

    ) {
        $this->_logger = $logger;
        $this->quoteFactory = $quoteFactory;
    public function aroundCollectRates(
        \Magento\OfflineShipping\Model\Carrier\Tablerate $subject ,
        \Closure $proceed ,
        \Magento\Quote\Model\Quote\Address\RateRequest $request
         foreach ($request->getAllItems() as $item) {

            $is_usa_shipping = $item->getProduct()->getResource()->getAttribute('is_usa_shipping');
            $is_usa_shipping_value = $description_attribute->getFrontend()->getValue($item->getProduct());
            // If  not EQual USA  Then disabled
            if($is_usa_shipping_value && $request->getDestCountryId() !='US'):
                return false;

        return  $proceed($request);




Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.