當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Address::setData方法代碼示例

本文整理匯總了PHP中Magento\Quote\Model\Quote\Address::setData方法的典型用法代碼示例。如果您正苦於以下問題:PHP Address::setData方法的具體用法?PHP Address::setData怎麽用?PHP Address::setData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Quote\Model\Quote\Address的用法示例。


在下文中一共展示了Address::setData方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testGetShippingDataObject

 /**
  * @param array $addressData
  * @param bool $useBaseCurrency
  * @param string $shippingTaxClass
  * @param bool shippingPriceInclTax
  * @param array $expectedValue
  * @dataProvider getShippingDataObjectDataProvider
  */
 public function testGetShippingDataObject(array $addressData, $useBaseCurrency, $shippingTaxClass, $shippingPriceInclTax)
 {
     $baseShippingAmount = $addressData['base_shipping_amount'];
     $shippingAmount = $addressData['shipping_amount'];
     $itemMock = $this->getMock('Magento\\Tax\\Api\\Data\\QuoteDetailsItemInterface');
     $this->taxConfig->expects($this->any())->method('getShippingTaxClass')->with($this->store)->will($this->returnValue($shippingTaxClass));
     $this->taxConfig->expects($this->any())->method('shippingPriceIncludesTax')->with($this->store)->will($this->returnValue($shippingPriceInclTax));
     $this->address->expects($this->atLeastOnce())->method('getShippingDiscountAmount')->willReturn($shippingAmount);
     if ($shippingAmount) {
         if ($useBaseCurrency && $shippingAmount != 0) {
             $this->address->expects($this->once())->method('getBaseShippingDiscountAmount')->willReturn($baseShippingAmount);
             $this->quoteDetailsItemBuilderMock->expects($this->once())->method('setDiscountAmount')->with($baseShippingAmount);
         } else {
             $this->address->expects($this->never())->method('getBaseShippingDiscountAmount');
             $this->quoteDetailsItemBuilderMock->expects($this->once())->method('setDiscountAmount')->with($shippingAmount);
         }
     }
     foreach ($addressData as $key => $value) {
         $this->address->setData($key, $value);
     }
     $this->taxClassKeyBuilderMock->expects($this->any())->method('setType')->willReturnSelf();
     $this->taxClassKeyBuilderMock->expects($this->any())->method('setValue')->with($shippingTaxClass)->willReturnSelf();
     $this->quoteDetailsItemBuilderMock->expects($this->once())->method('create')->willReturn($itemMock);
     $this->assertEquals($itemMock, $this->commonTaxCollector->getShippingDataObject($this->address, $useBaseCurrency));
 }
開發者ID:ViniciusAugusto,項目名稱:magento2,代碼行數:33,代碼來源:CommonTaxCollectorTest.php

示例2: testGetShippingDataObject

 /**
  * @param array $addressData
  * @param bool $useBaseCurrency
  * @param string $shippingTaxClass
  * @param bool $shippingPriceInclTax
  * @dataProvider getShippingDataObjectDataProvider
  */
 public function testGetShippingDataObject(array $addressData, $useBaseCurrency, $shippingTaxClass, $shippingPriceInclTax)
 {
     $baseShippingAmount = $addressData['base_shipping_amount'];
     $shippingAmount = $addressData['shipping_amount'];
     $this->taxConfig->expects($this->any())->method('getShippingTaxClass')->with($this->store)->will($this->returnValue($shippingTaxClass));
     $this->taxConfig->expects($this->any())->method('shippingPriceIncludesTax')->with($this->store)->will($this->returnValue($shippingPriceInclTax));
     $this->address->expects($this->atLeastOnce())->method('getShippingDiscountAmount')->willReturn($shippingAmount);
     if ($shippingAmount) {
         if ($useBaseCurrency && $shippingAmount != 0) {
             $this->address->expects($this->once())->method('getBaseShippingDiscountAmount')->willReturn($baseShippingAmount);
             $expectedDiscountAmount = $baseShippingAmount;
         } else {
             $this->address->expects($this->never())->method('getBaseShippingDiscountAmount');
             $expectedDiscountAmount = $shippingAmount;
         }
     }
     foreach ($addressData as $key => $value) {
         $this->address->setData($key, $value);
     }
     $this->assertEquals($this->quoteDetailsItemDataObject, $this->commonTaxCollector->getShippingDataObject($this->address, $useBaseCurrency));
     if ($shippingAmount) {
         $this->assertEquals($expectedDiscountAmount, $this->quoteDetailsItemDataObject->getDiscountAmount());
     }
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:31,代碼來源:CommonTaxCollectorTest.php

示例3: _setQuoteAddress

 /**
  * Set and validate Quote address
  * All errors added to _errors
  *
  * @param \Magento\Quote\Model\Quote\Address $address
  * @param array $data
  * @return $this
  */
 protected function _setQuoteAddress(\Magento\Quote\Model\Quote\Address $address, array $data)
 {
     $isAjax = !$this->getIsValidate();
     // Region is a Data Object, so it is represented by an array. validateData() doesn't understand arrays, so we
     // need to merge region data with address data. This is going to be removed when we switch to use address Data
     // Object instead of the address model.
     // Note: if we use getRegion() here it will pull region from db using the region_id
     $data = isset($data['region']) && is_array($data['region']) ? array_merge($data, $data['region']) : $data;
     $addressForm = $this->_metadataFormFactory->create(AddressMetadataInterface::ENTITY_TYPE_ADDRESS, 'adminhtml_customer_address', $data, $isAjax, CustomerForm::DONT_IGNORE_INVISIBLE, []);
     // prepare request
     // save original request structure for files
     if ($address->getAddressType() == \Magento\Quote\Model\Quote\Address::TYPE_SHIPPING) {
         $requestData = ['order' => ['shipping_address' => $data]];
         $requestScope = 'order/shipping_address';
     } else {
         $requestData = ['order' => ['billing_address' => $data]];
         $requestScope = 'order/billing_address';
     }
     $request = $addressForm->prepareRequest($requestData);
     $addressData = $addressForm->extractData($request, $requestScope);
     if ($this->getIsValidate()) {
         $errors = $addressForm->validateData($addressData);
         if ($errors !== true) {
             if ($address->getAddressType() == \Magento\Quote\Model\Quote\Address::TYPE_SHIPPING) {
                 $typeName = __('Shipping Address: ');
             } else {
                 $typeName = __('Billing Address: ');
             }
             foreach ($errors as $error) {
                 $this->_errors[] = $typeName . $error;
             }
             $address->setData($addressForm->restoreData($addressData));
         } else {
             $address->setData($addressForm->compactData($addressData));
         }
     } else {
         $address->addData($addressForm->restoreData($addressData));
     }
     return $this;
 }
開發者ID:whoople,項目名稱:magento2-testing,代碼行數:48,代碼來源:Create.php

示例4: getAddressId

 /**
  * @param Address $address
  * @return string
  */
 protected function getAddressId(Address $address)
 {
     if ($address == null) {
         return '';
     }
     if (!$address->hasData('address_sales_rule_id')) {
         if ($address->hasData('address_id')) {
             $address->setData('address_sales_rule_id', $address->getData('address_id'));
         } else {
             $type = $address->getAddressType();
             $tempId = $type . $this->counter++;
             $address->setData('address_sales_rule_id', $tempId);
         }
     }
     return $address->getData('address_sales_rule_id');
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:20,代碼來源:Validator.php


注:本文中的Magento\Quote\Model\Quote\Address::setData方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。