I want a feature in which user will be blocked by their Address.

Like I will add the address in block list of Magento Admin and then user will not be able to purchase anything if I add their address in back-end(block-list) instead of that it shows an error message on checkout page on clicking on next.

Thanks, Any help is appreciated.

  • How do you plan on blocking the address? If you use the first line of the address they could simply add another letter or a slight typo to bypass it and it would most likely still be delivered.
    – Ben Crook
    Jul 19, 2021 at 9:08
  • Address have different entities separate like city, region, zipcode etc, so specially based on which one you want restrict that user? Jul 19, 2021 at 10:01
  • @BenCrook thanks for your response i am planning to block the user by using city , region and zipcode if these 3 are matches then it will show the message.
    – Prits
    Jul 19, 2021 at 10:29
  • @DhirenVasoya thanks for your response i am planning to block the user by using city , region and zipcode like i am creating a back-end drop-down field to choose like block by city , region or zipcode and added the value of it and it will not pass that. Anything more required please ask.
    – Prits
    Jul 19, 2021 at 10:32
  • And you want compare this with billing address or shipping address? Jul 19, 2021 at 12:21

1 Answer 1


Try using observer for sales_order_place_before event

namespace Vendor\Extension\Observer;

use Magento\Framework\Event\ObserverInterface;

class RestrictOrderObserver implements ObserverInterface

  public function execute(\Magento\Framework\Event\Observer $observer)
    $order = $observer->getEvent()->getOrder();

    // If you want to put logic for Billing address then use this one.
    $address = $order->getBillingAddress();

    // If you want to put logic for Shipping address then use this one.
    $address = $order->getShippingAddress();


  • Thanks for your Answer Is this event sales_order_place_before occoured when a order is placed ? Actually i want when some click on next Shipping Page and the address which is enter by user is block address then show a error on that page user is not going to forward on payment page. Do you have any idea regarding that how to achieve that ?
    – Prits
    Jul 19, 2021 at 13:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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