当前位置: 首页>>代码示例>>PHP>>正文


PHP Helper\Address类代码示例

本文整理汇总了PHP中Magento\Customer\Helper\Address的典型用法代码示例。如果您正苦于以下问题:PHP Address类的具体用法?PHP Address怎么用?PHP Address使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Address类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 /**
  * Restore initial customer group ID in quote if needed on collect_totals_after event of quote address
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  */
 public function execute($observer)
 {
     $quoteAddress = $observer->getQuoteAddress();
     $configAddressType = $this->customerAddressHelper->getTaxCalculationAddressType();
     // Restore initial customer group ID in quote only if VAT is calculated based on shipping address
     if ($quoteAddress->hasPrevQuoteCustomerGroupId() && $configAddressType == \Magento\Customer\Model\Address\AbstractAddress::TYPE_SHIPPING) {
         $quoteAddress->getQuote()->setCustomerGroupId($quoteAddress->getPrevQuoteCustomerGroupId());
         $quoteAddress->unsPrevQuoteCustomerGroupId();
     }
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:16,代码来源:RestoreCustomerGroupId.php

示例2: isEnabled

 /**
  * Check whether VAT ID validation is enabled
  *
  * @param \Magento\Quote\Model\Quote\Address $quoteAddress
  * @param \Magento\Store\Model\Store|int $store
  * @return bool
  */
 public function isEnabled(\Magento\Quote\Model\Quote\Address $quoteAddress, $store)
 {
     $configAddressType = $this->customerAddress->getTaxCalculationAddressType($store);
     // When VAT is based on billing address then Magento have to handle only billing addresses
     $additionalBillingAddressCondition = $configAddressType == \Magento\Customer\Model\Address\AbstractAddress::TYPE_BILLING ? $configAddressType != $quoteAddress->getAddressType() : false;
     // Handle only addresses that corresponds to VAT configuration
     if (!$this->customerAddress->isVatValidationEnabled($store) || $additionalBillingAddressCondition) {
         return false;
     }
     return true;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:18,代码来源:VatValidator.php

示例3: testExecute

 /**
  * @param string|null $configAddressType
  * @dataProvider restoreCustomerGroupIdDataProvider
  */
 public function testExecute($configAddressType)
 {
     $quoteAddress = $this->getMock('Magento\\Quote\\Model\\Quote\\Address', ['getQuote', 'setCustomerGroupId', 'getPrevQuoteCustomerGroupId', 'unsPrevQuoteCustomerGroupId', 'hasPrevQuoteCustomerGroupId'], [], '', false);
     $observer = $this->getMock('Magento\\Framework\\Event\\Observer', ['getQuoteAddress'], [], '', false);
     $observer->expects($this->once())->method('getQuoteAddress')->will($this->returnValue($quoteAddress));
     $this->customerAddressHelperMock->expects($this->once())->method('getTaxCalculationAddressType')->will($this->returnValue($configAddressType));
     $quoteAddress->expects($this->once())->method('hasPrevQuoteCustomerGroupId');
     $id = $quoteAddress->expects($this->any())->method('getPrevQuoteCustomerGroupId');
     $quoteAddress->expects($this->any())->method('setCustomerGroupId')->with($id);
     $quoteAddress->expects($this->any())->method('getQuote');
     $quoteAddress->expects($this->any())->method('unsPrevQuoteCustomerGroupId');
     $this->assertNull($this->quote->execute($observer));
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:17,代码来源:RestoreCustomerGroupIdTest.php

示例4: _getVatRequiredSalesAddress

 /**
  * Retrieve sales address (order or quote) on which tax calculation must be based
  *
  * @param \Magento\Sales\Model\Order $order
  * @param \Magento\Store\Model\Store|string|int|null $store
  * @return \Magento\Sales\Model\Order\Address|null
  */
 protected function _getVatRequiredSalesAddress($order, $store = null)
 {
     $configAddressType = $this->customerAddressHelper->getTaxCalculationAddressType($store);
     $requiredAddress = null;
     switch ($configAddressType) {
         case \Magento\Customer\Model\Address\AbstractAddress::TYPE_SHIPPING:
             $requiredAddress = $order->getShippingAddress();
             break;
         default:
             $requiredAddress = $order->getBillingAddress();
             break;
     }
     return $requiredAddress;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:21,代码来源:AddVatRequestParamsOrderComment.php

示例5: execute

 /**
  * Restore initial customer group ID in quote if needed on collect_totals_after event of quote address
  *
  * @param Observer $observer
  * @return void
  */
 public function execute(Observer $observer)
 {
     /** @var ShippingAssignmentInterface $shippingAssignment */
     $shippingAssignment = $observer->getEvent()->getShippingAssignment();
     /** @var Quote $quote */
     $quote = $observer->getEvent()->getQuote();
     $address = $shippingAssignment->getShipping()->getAddress();
     $configAddressType = $this->customerAddressHelper->getTaxCalculationAddressType();
     // Restore initial customer group ID in quote only if VAT is calculated based on shipping address
     if ($address->hasPrevQuoteCustomerGroupId() && $configAddressType == AbstractAddress::TYPE_SHIPPING) {
         $quote->setCustomerGroupId($address->getPrevQuoteCustomerGroupId());
         $address->unsPrevQuoteCustomerGroupId();
     }
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:20,代码来源:RestoreCustomerGroupId.php

示例6: afterAddressSave

 /**
  * Address after save event handler
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 public function afterAddressSave($observer)
 {
     /** @var $customerAddress Address */
     $customerAddress = $observer->getCustomerAddress();
     $customer = $customerAddress->getCustomer();
     if (!$this->_customerAddress->isVatValidationEnabled($customer->getStore()) || $this->_coreRegistry->registry(self::VIV_PROCESSED_FLAG) || !$this->_canProcessAddress($customerAddress)) {
         return;
     }
     try {
         $this->_coreRegistry->register(self::VIV_PROCESSED_FLAG, true);
         if ($customerAddress->getVatId() == '' || !$this->_customerVat->isCountryInEU($customerAddress->getCountry())) {
             $defaultGroupId = $this->_groupManagement->getDefaultGroup($customer->getStore())->getId();
             if (!$customer->getDisableAutoGroupChange() && $customer->getGroupId() != $defaultGroupId) {
                 $customer->setGroupId($defaultGroupId);
                 $customer->save();
             }
         } else {
             $result = $this->_customerVat->checkVatNumber($customerAddress->getCountryId(), $customerAddress->getVatId());
             $newGroupId = $this->_customerVat->getCustomerGroupIdBasedOnVatNumber($customerAddress->getCountryId(), $result, $customer->getStore());
             if (!$customer->getDisableAutoGroupChange() && $customer->getGroupId() != $newGroupId) {
                 $customer->setGroupId($newGroupId);
                 $customer->save();
             }
             $customerAddress->setVatValidationResult($result);
         }
     } catch (\Exception $e) {
         $this->_coreRegistry->register(self::VIV_PROCESSED_FLAG, false, true);
     }
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:36,代码来源:Observer.php

示例7: testAddVatRequestParamsOrderComment

 /**
  * @param string $configAddressType
  * @param string|int $vatRequestId
  * @param string|int $vatRequestDate
  * @param string $orderHistoryComment
  * @dataProvider addVatRequestParamsOrderCommentDataProvider
  */
 public function testAddVatRequestParamsOrderComment($configAddressType, $vatRequestId, $vatRequestDate, $orderHistoryComment)
 {
     $this->customerAddressHelperMock->expects($this->once())->method('getTaxCalculationAddressType')->will($this->returnValue($configAddressType));
     $orderAddressMock = $this->getMock('Magento\\Sales\\Model\\Order\\Address', ['getVatRequestId', 'getVatRequestDate', '__wakeup'], [], '', false);
     $orderAddressMock->expects($this->any())->method('getVatRequestId')->will($this->returnValue($vatRequestId));
     $orderAddressMock->expects($this->any())->method('getVatRequestDate')->will($this->returnValue($vatRequestDate));
     $orderMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order')->disableOriginalConstructor()->setMethods(['getShippingAddress', '__wakeup', 'addStatusHistoryComment', 'getBillingAddress'])->getMock();
     $orderMock->expects($this->any())->method('getShippingAddress')->will($this->returnValue($orderAddressMock));
     if ($orderHistoryComment === null) {
         $orderMock->expects($this->never())->method('addStatusHistoryComment');
     } else {
         $orderMock->expects($this->once())->method('addStatusHistoryComment')->with($orderHistoryComment, false);
     }
     $observer = $this->getMock('Magento\\Framework\\Event\\Observer', ['getOrder'], [], '', false);
     $observer->expects($this->once())->method('getOrder')->will($this->returnValue($orderMock));
     $this->assertNull($this->observer->execute($observer));
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:24,代码来源:AddVatRequestParamsOrderCommentTest.php

示例8: getAddressAsString

 /**
  * Represent customer address in 'online' format.
  *
  * @param \Magento\Customer\Api\Data\AddressInterface $address
  * @return string
  */
 public function getAddressAsString(\Magento\Customer\Api\Data\AddressInterface $address)
 {
     $formatTypeRenderer = $this->_addressHelper->getFormatTypeRenderer('oneline');
     $result = '';
     if ($formatTypeRenderer) {
         $result = $formatTypeRenderer->renderArray($this->addressMapper->toFlatArray($address));
     }
     return $this->escapeHtml($result);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:15,代码来源:Address.php

示例9: testGetFormat

 /**
  * @param string $code
  * @param array $result
  * @dataProvider getFormatDataProvider
  */
 public function testGetFormat($code, $result)
 {
     if ($result) {
         $renderer = $this->getMockBuilder('Magento\\Customer\\Block\\Address\\Renderer\\RendererInterface')->disableOriginalConstructor()->getMock();
         $renderer->expects($this->once())->method('getFormatArray')->will($this->returnValue(array('key' => 'value')));
     }
     $this->addressConfig->expects($this->once())->method('getFormatByCode')->with($code)->will($this->returnValue(new \Magento\Framework\Object(!empty($result) ? array('renderer' => $renderer) : array())));
     $this->assertEquals($result, $this->helper->getFormat($code));
 }
开发者ID:,项目名称:,代码行数:14,代码来源:

示例10: getStreetFieldConfig

 /**
  * Retrieve field configuration for street address attribute
  *
  * @param string $attributeCode
  * @param array $attributeConfig
  * @param string $providerName name of the storage container used by UI component
  * @param string $dataScopePrefix
  * @return array
  */
 protected function getStreetFieldConfig($attributeCode, array $attributeConfig, $providerName, $dataScopePrefix)
 {
     $streetLines = [];
     for ($lineIndex = 0; $lineIndex < $this->addressHelper->getStreetLines(); $lineIndex++) {
         $isFirstLine = $lineIndex === 0;
         $streetLines[] = ['component' => 'Magento_Ui/js/form/element/abstract', 'config' => ['customScope' => $dataScopePrefix, 'template' => 'ui/form/field', 'elementTmpl' => 'ui/form/element/input'], 'dataScope' => $lineIndex, 'provider' => $providerName, 'validation' => $isFirstLine ? ['required-entry' => true] : [], 'additionalClasses' => $isFirstLine ?: 'additional'];
     }
     return ['component' => 'Magento_Ui/js/form/components/group', 'label' => __('Address'), 'required' => true, 'dataScope' => $dataScopePrefix . '.' . $attributeCode, 'provider' => $providerName, 'sortOrder' => $attributeConfig['sortOrder'], 'type' => 'group', 'config' => ['template' => 'ui/group/group', 'additionalClasses' => 'street'], 'children' => $streetLines];
 }
开发者ID:kid17,项目名称:magento2,代码行数:18,代码来源:AttributeMerger.php

示例11: getBillingAddressHtml

 /**
  * @return string|null
  */
 public function getBillingAddressHtml()
 {
     try {
         $address = $this->_addressService->getAddress($this->getCustomer()->getDefaultBilling());
     } catch (NoSuchEntityException $e) {
         return __('The customer does not have default billing address.');
     }
     return $this->_addressHelper->getFormatTypeRenderer('html')->renderArray(AddressConverter::toFlatArray($address));
 }
开发者ID:aiesh,项目名称:magento2,代码行数:12,代码来源:View.php

示例12: _getBillingAddress

 /**
  * Get billing address request data
  *
  * @param \Magento\Framework\Object $address
  * @return array
  */
 protected function _getBillingAddress(\Magento\Framework\Object $address)
 {
     $request = array('billing_first_name' => $address->getFirstname(), 'billing_last_name' => $address->getLastname(), 'billing_city' => $address->getCity(), 'billing_state' => $address->getRegionCode() ? $address->getRegionCode() : $address->getCity(), 'billing_zip' => $address->getPostcode(), 'billing_country' => $address->getCountry());
     // convert streets to tow lines format
     $street = $this->_customerAddress->convertStreetLines($address->getStreet(), 2);
     $request['billing_address1'] = isset($street[0]) ? $street[0] : '';
     $request['billing_address2'] = isset($street[1]) ? $street[1] : '';
     return $request;
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:15,代码来源:Request.php

示例13: getAddressAsHtml

 /**
  * Represent customer address in HTML format.
  *
  * @param \Magento\Customer\Api\Data\AddressInterface $address
  * @return string
  */
 public function getAddressAsHtml(\Magento\Customer\Api\Data\AddressInterface $address)
 {
     $formatTypeRenderer = $this->_customerAddressHelper->getFormatTypeRenderer('html');
     $result = '';
     if ($formatTypeRenderer) {
         $result = $formatTypeRenderer->renderArray($this->addressMapper->toFlatArray($address));
     }
     return $result;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:15,代码来源:Select.php

示例14: getAddressAsString

 /**
  * Represent customer address in 'online' format.
  *
  * @param \Magento\Customer\Service\V1\Data\Address $addressData
  * @return string
  */
 public function getAddressAsString($addressData)
 {
     $formatTypeRenderer = $this->_addressHelper->getFormatTypeRenderer('oneline');
     $result = '';
     if ($formatTypeRenderer) {
         $result = $formatTypeRenderer->renderArray(AddressConverter::toFlatArray($addressData));
     }
     return $this->escapeHtml($result);
 }
开发者ID:zhangjiachao,项目名称:magento2,代码行数:15,代码来源:Address.php

示例15: getAddressAsHtml

 /**
  * Represent customer address in HTML format.
  *
  * @param \Magento\Customer\Service\V1\Data\Address $addressData
  * @return string
  */
 public function getAddressAsHtml($addressData)
 {
     $formatTypeRenderer = $this->_customerAddressHelper->getFormatTypeRenderer('html');
     $result = '';
     if ($formatTypeRenderer) {
         $result = $formatTypeRenderer->renderArray(AddressConverter::toFlatArray($addressData));
     }
     return $result;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:15,代码来源:Select.php


注:本文中的Magento\Customer\Helper\Address类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。