/**
  * Process js Layout of block
  *
  * @param array $jsLayout
  * @return array
  */
 public function process($jsLayout)
 {
     /** @var \Magento\Eav\Api\Data\AttributeInterface[] $attributes */
     $attributes = $this->attributeMetadataDataProvider->loadAttributesCollection('customer_address', 'customer_register_address');
     $elements = [];
     foreach ($attributes as $attribute) {
         if ($attribute->getIsUserDefined()) {
             continue;
         }
         $elements[$attribute->getAttributeCode()] = $this->attributeMapper->map($attribute);
         if (isset($elements[$attribute->getAttributeCode()]['label'])) {
             $label = $elements[$attribute->getAttributeCode()]['label'];
             $elements[$attribute->getAttributeCode()]['label'] = __($label);
         }
     }
     // The following code is a workaround for custom address attributes
     if (isset($jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children'])) {
         if (!isset($jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['payments-list']['children'])) {
             $jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['payments-list']['children'] = [];
         }
         $jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['payments-list']['children'] = array_merge_recursive($jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['payments-list']['children'], $this->processPaymentConfiguration($jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['renders']['children'], $elements));
     }
     if (isset($jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']['shippingAddress']['children']['shipping-address-fieldset']['children'])) {
         $fields = $jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']['shippingAddress']['children']['shipping-address-fieldset']['children'];
         $jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']['shippingAddress']['children']['shipping-address-fieldset']['children'] = $this->merger->merge($elements, 'checkoutProvider', 'shippingAddress', $fields);
     }
     return $jsLayout;
 }
示例#2
0
 /**
  * @return array
  */
 private function getAddressAttributes()
 {
     /** @var \Magento\Eav\Api\Data\AttributeInterface[] $attributes */
     $attributes = $this->attributeMetadataDataProvider->loadAttributesCollection('customer_address', 'customer_register_address');
     $elements = [];
     foreach ($attributes as $attribute) {
         $code = $attribute->getAttributeCode();
         if ($attribute->getIsUserDefined()) {
             continue;
         }
         $elements[$code] = $this->attributeMapper->map($attribute);
         if (isset($elements[$code]['label'])) {
             $label = $elements[$code]['label'];
             $elements[$code]['label'] = __($label);
         }
     }
     return $elements;
 }