本文整理匯總了PHP中Magento\Quote\Model\Quote\Address::getAddressType方法的典型用法代碼示例。如果您正苦於以下問題:PHP Address::getAddressType方法的具體用法?PHP Address::getAddressType怎麽用?PHP Address::getAddressType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Quote\Model\Quote\Address
的用法示例。
在下文中一共展示了Address::getAddressType方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: 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;
}
示例2: getShippingAddressTotals
/**
* @param Address $address
* @return mixed
*/
public function getShippingAddressTotals($address)
{
$totals = $address->getTotals();
foreach ($totals as $total) {
if ($total->getCode() == 'grand_total') {
if ($address->getAddressType() == Address::TYPE_BILLING) {
$total->setTitle(__('Total'));
} else {
$total->setTitle(__('Total for this address'));
}
}
}
return $totals;
}
示例3: _prepareCustomerAddress
/**
* Create customer address and save it in the quote so that it can be used to persist later.
*
* @param \Magento\Customer\Api\Data\CustomerInterface $customer
* @param \Magento\Quote\Model\Quote\Address $quoteCustomerAddress
* @return void
* @throws \InvalidArgumentException
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
protected function _prepareCustomerAddress($customer, $quoteCustomerAddress)
{
// Possible that customerId is null for new customers
$quoteCustomerAddress->setCustomerId($customer->getId());
$customerAddress = $quoteCustomerAddress->exportCustomerAddress();
$quoteAddressId = $quoteCustomerAddress->getCustomerAddressId();
$addressType = $quoteCustomerAddress->getAddressType();
if ($quoteAddressId) {
/** Update existing address */
$existingAddressDataObject = $this->addressRepository->getById($quoteAddressId);
/** Update customer address data */
$this->dataObjectHelper->mergeDataObjects(get_class($existingAddressDataObject), $existingAddressDataObject, $customerAddress);
$customerAddress = $existingAddressDataObject;
} elseif ($addressType == \Magento\Quote\Model\Quote\Address::ADDRESS_TYPE_SHIPPING) {
try {
$billingAddressDataObject = $this->accountManagement->getDefaultBillingAddress($customer->getId());
} catch (\Exception $e) {
/** Billing address does not exist. */
}
$isShippingAsBilling = $quoteCustomerAddress->getSameAsBilling();
if (isset($billingAddressDataObject) && $isShippingAsBilling) {
/** Set existing billing address as default shipping */
$customerAddress = $billingAddressDataObject;
$customerAddress->setIsDefaultShipping(true);
}
}
switch ($addressType) {
case \Magento\Quote\Model\Quote\Address::ADDRESS_TYPE_BILLING:
if (is_null($customer->getDefaultBilling())) {
$customerAddress->setIsDefaultBilling(true);
}
break;
case \Magento\Quote\Model\Quote\Address::ADDRESS_TYPE_SHIPPING:
if (is_null($customer->getDefaultShipping())) {
$customerAddress->setIsDefaultShipping(true);
}
break;
default:
throw new \InvalidArgumentException('Customer address type is invalid.');
}
$this->getQuote()->setCustomer($customer);
$this->getQuote()->addCustomerAddress($customerAddress);
}
示例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');
}
示例5: df_address_is_billing
/**
* 2016-07-27
* Адрес приобретает тип, только когда используется при оформлении заказа.
* Пока же адрес просто принадлежит покупателю
* @see \Magento\Customer\Model\Data\Address
* @see \Magento\Customer\Api\Data\AddressInterface
* а не используется в контексте оформления заказа, то такой адрес ещё типа не имеет,
* и в будущем, в зависимости от контекста,
* может использоваться и как адрес доставки, и как платёжный адрес.
*
* @uses \Magento\Quote\Model\Quote\Address::getAddressType()
* @uses \Magento\Customer\Model\Address::getAddressType()
* @param AA|CA|QA|OA $a
* @return bool
*/
function df_address_is_billing($a)
{
return $a instanceof AA ? AA::TYPE_BILLING === $a['address_type'] : ($a instanceof OA ? OA::TYPE_BILLING === $a->getAddressType() : df_error("Invalid address class: «%s».", get_class($a)));
}