• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Helper\Address类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: execute

 /**
  * Address before save event handler
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     if ($this->_coreRegistry->registry(self::VIV_CURRENTLY_SAVED_ADDRESS)) {
         $this->_coreRegistry->unregister(self::VIV_CURRENTLY_SAVED_ADDRESS);
     }
     /** @var $customerAddress Address */
     $customerAddress = $observer->getCustomerAddress();
     if ($customerAddress->getId()) {
         $this->_coreRegistry->register(self::VIV_CURRENTLY_SAVED_ADDRESS, $customerAddress->getId());
     } else {
         $configAddressType = $this->_customerAddress->getTaxCalculationAddressType();
         $forceProcess = $configAddressType == AbstractAddress::TYPE_SHIPPING ? $customerAddress->getIsDefaultShipping() : $customerAddress->getIsDefaultBilling();
         if ($forceProcess) {
             $customerAddress->setForceProcess(true);
         } else {
             $this->_coreRegistry->register(self::VIV_CURRENTLY_SAVED_ADDRESS, 'new_address');
         }
     }
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:25,代码来源:BeforeAddressSaveObserver.php


示例17: getBillingAddressHtml

 /**
  * Retrieve billing address html
  *
  * @return \Magento\Framework\Phrase|string
  */
 public function getBillingAddressHtml()
 {
     try {
         $address = $this->accountManagement->getDefaultBillingAddress($this->getCustomer()->getId());
     } catch (NoSuchEntityException $e) {
         return __('The customer does not have default billing address.');
     }
     if ($address === null) {
         return __('The customer does not have default billing address.');
     }
     return $this->addressHelper->getFormatTypeRenderer('html')->renderArray($this->addressMapper->toFlatArray($address));
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:17,代码来源:PersonalInfo.php


示例18: testExecute

 /**
  * @param string|null $configAddressType
  * @dataProvider restoreCustomerGroupIdDataProvider
  */
 public function testExecute($configAddressType)
 {
     $eventMock = $this->getMock('\\Magento\\Framework\\Event', ['getShippingAssignment', 'getQuote'], [], '', false);
     $observer = $this->getMock('Magento\\Framework\\Event\\Observer', ['getEvent'], [], '', false);
     $observer->expects($this->exactly(2))->method('getEvent')->willReturn($eventMock);
     $shippingAssignmentMock = $this->getMock('\\Magento\\Quote\\Api\\Data\\ShippingAssignmentInterface');
     $quoteMock = $this->getMock('\\Magento\\Quote\\Model\\Quote', [], [], '', false);
     $eventMock->expects($this->once())->method('getShippingAssignment')->willReturn($shippingAssignmentMock);
     $eventMock->expects($this->once())->method('getQuote')->willReturn($quoteMock);
     $shippingMock = $this->getMock('\\Magento\\Quote\\Api\\Data\\ShippingInterface');
     $shippingAssignmentMock->expects($this->once())->method('getShipping')->willReturn($shippingMock);
     $quoteAddress = $this->getMock('\\Magento\\Quote\\Model\\Quote\\Address', ['getPrevQuoteCustomerGroupId', 'unsPrevQuoteCustomerGroupId', 'hasPrevQuoteCustomerGroupId'], [], '', false);
     $shippingMock->expects($this->once())->method('getAddress')->willReturn($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->quote->execute($observer);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:25,代码来源:RestoreCustomerGroupIdTest.php


示例19: getAddressStreets

 /**
  * Export streets from address data
  *
  * @param DataObject $address
  * @return array
  */
 protected function getAddressStreets(DataObject $address)
 {
     $street1 = '';
     $street2 = '';
     $data = $this->customerAddress->convertStreetLines($address->getStreet(), 2);
     if (!empty($data[0])) {
         $street1 = $data[0];
     }
     if (!empty($data[1])) {
         $street2 = $data[1];
     }
     return [$street1, $street2];
 }
开发者ID:koliaGI,项目名称:magento2,代码行数:19,代码来源:Request.php


示例20: _canProcessAddress

 /**
  * Check whether specified address should be processed in after_save event handler
  *
  * @param Address $address
  * @return bool
  */
 protected function _canProcessAddress($address)
 {
     if ($address->getForceProcess()) {
         return true;
     }
     if ($this->_coreRegistry->registry(BeforeAddressSaveObserver::VIV_CURRENTLY_SAVED_ADDRESS) != $address->getId()) {
         return false;
     }
     $configAddressType = $this->_customerAddress->getTaxCalculationAddressType();
     if ($configAddressType == AbstractAddress::TYPE_SHIPPING) {
         return $this->_isDefaultShipping($address);
     }
     return $this->_isDefaultBilling($address);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:20,代码来源:AfterAddressSaveObserver.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Helper\View类代码示例发布时间:2022-05-23
下一篇:
PHP Data\CustomerInterfaceFactory类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap