I need to create a restriction for the Billing [Country_Id] options

Based on a new Config. Setting that Pairs a Customer-Segment with specific Billing Country options.

I found:


I tried Testing on this code directly before making a plugin to hook into it at line:

$elements = $this->convertElementsToSelect($elements, $attributesToConvert);

I then logged the results of $elements I can see the list in the log gets trimmed to only the options I need. (Yikes!)

However when it renders on the frontend (After cache/generated folder cleared) It does render the default options selected originally in admin panel country allowances and ignore all my changes.

Any help is appreciated.

2 Answers 2


You should modify Magento\Checkout\Block\Checkout\DirectoryDataProcessor::process($jsLayout). Create plugin for this and modify country list.

Here getCountryOptions method is responsible for creating list. Also, this is private scope so copy that into your plugin.

  • Totally appreciate your help while I learn my way up on the new m2 ways. This worked partially, I can ow filter the countries I want to, however the list gets reduced for both Shipping and Billing I thought I could add an extra param to the array indicating when to render for one and when for the other, however, I havent found the code or way to identify the renderer for each of the dropdowns on the different sections. Feb 13, 2019 at 22:22

As mentioned in Magento Dev Doc, you can update template for any field of checkout page by overriding that field template and layout files in your custom theme/module.

In your case, file to override is


  • Awesome I'll try it and post results thanks Feb 13, 2019 at 6:23

Your Answer

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

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