merger = $merger; $this->countryCollection = $countryCollection; $this->regionCollection = $regionCollection; $this->topDestinationCountries = $topDestinationCountries ?: \Magento\Framework\App\ObjectManager::getInstance() ->get(\Magento\Directory\Model\TopDestinationCountries::class); } /** * Show City in Shipping Estimation * * @return bool * @codeCoverageIgnore */ protected function isCityActive() { return false; } /** * Show State in Shipping Estimation * * @return bool * @codeCoverageIgnore */ protected function isStateActive() { return false; } /** * Process js Layout of block * * @param array $jsLayout * @return array * @SuppressWarnings(PHPMD.NPathComplexity) */ public function process($jsLayout) { $elements = [ 'city' => [ 'visible' => $this->isCityActive(), 'formElement' => 'input', 'label' => __('City'), 'value' => null ], 'country_id' => [ 'visible' => true, 'formElement' => 'select', 'label' => __('Country'), 'options' => [], 'value' => null ], 'region_id' => [ 'visible' => true, 'formElement' => 'select', 'label' => __('State/Province'), 'options' => [], 'value' => null ], 'postcode' => [ 'visible' => true, 'formElement' => 'input', 'label' => __('Zip/Postal Code'), 'value' => null ] ]; if (!isset($jsLayout['components']['checkoutProvider']['dictionaries'])) { $jsLayout['components']['checkoutProvider']['dictionaries'] = [ 'country_id' => $this->countryCollection->loadByStore()->setForegroundCountries( $this->topDestinationCountries->getTopDestinations() )->toOptionArray(), 'region_id' => $this->regionCollection->addAllowedCountriesFilter()->toOptionArray(), ]; } if (isset($jsLayout['components']['block-summary']['children']['block-shipping']['children'] ['address-fieldsets']['children']) ) { $fieldSetPointer = &$jsLayout['components']['block-summary']['children']['block-shipping'] ['children']['address-fieldsets']['children']; $fieldSetPointer = $this->merger->merge($elements, 'checkoutProvider', 'shippingAddress', $fieldSetPointer); $fieldSetPointer['region_id']['config']['skipValidation'] = true; } return $jsLayout; } }