本文整理汇总了PHP中Magento\Quote\Model\Quote::getAllAddresses方法的典型用法代码示例。如果您正苦于以下问题:PHP Quote::getAllAddresses方法的具体用法?PHP Quote::getAllAddresses怎么用?PHP Quote::getAllAddresses使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Quote\Model\Quote
的用法示例。
在下文中一共展示了Quote::getAllAddresses方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: clearQuoteItemsCache
/**
* Mage_Sales_Model_Quote_Address caches items after each collectTotals call. Some extensions calls collectTotals
* after adding new item to quote in observers. So we need clear this cache before adding new item to quote.
*/
private function clearQuoteItemsCache()
{
foreach ($this->quote->getAllAddresses() as $address) {
$address->unsetData('cached_items_all');
$address->unsetData('cached_items_nominal');
$address->unsetData('cached_items_nonominal');
}
}
示例2: testGetAllAddresses
public function testGetAllAddresses()
{
$id = 1;
$this->quoteAddressCollectionMock->expects($this->once())->method('setQuoteFilter')->with($id)->will($this->returnSelf());
$this->quoteAddressMock->expects($this->once())->method('isDeleted')->will($this->returnValue(false));
$iterator = new \ArrayIterator([$this->quoteAddressMock]);
$this->quoteAddressCollectionMock->expects($this->any())->method('getIterator')->will($this->returnValue($iterator));
$this->quote->setId($id);
$result = $this->quote->getAllAddresses();
$this->assertEquals([$this->quoteAddressMock], $result);
}
示例3: enhanceTotalData
/**
* Adds minimal tax information to the "total" data structure
*
* @param \Magento\Quote\Model\Quote $quote
* @param Address\Total $total
* @return null
*/
protected function enhanceTotalData(\Magento\Quote\Model\Quote $quote, \Magento\Quote\Model\Quote\Address\Total $total)
{
$taxAmount = 0;
$shippingTaxAmount = 0;
$discountTaxCompensation = 0;
$subtotalInclTax = $total->getSubtotalInclTax();
$computeSubtotalInclTax = true;
if ($total->getSubtotalInclTax() > 0) {
$computeSubtotalInclTax = false;
}
/** @var \Magento\Quote\Model\Quote\Address $address */
foreach ($quote->getAllAddresses() as $address) {
$taxAmount += $address->getTaxAmount();
$shippingTaxAmount += $address->getShippingTaxAmount();
$discountTaxCompensation += $address->getDiscountTaxCompensationAmount();
if ($computeSubtotalInclTax) {
$subtotalInclTax += $address->getSubtotalInclTax();
}
}
$total->setTaxAmount($taxAmount);
$total->setShippingTaxAmount($shippingTaxAmount);
$total->setDiscountTaxCompensationAmount($discountTaxCompensation);
// accessed via 'discount_tax_compensation'
$total->setSubtotalInclTax($subtotalInclTax);
return;
}
示例4: _validateCouponCode
/**
* @param \Magento\Quote\Model\Quote $quote
* @return $this
*/
protected function _validateCouponCode(\Magento\Quote\Model\Quote $quote)
{
$code = $quote->getData('coupon_code');
if (strlen($code)) {
$addressHasCoupon = false;
$addresses = $quote->getAllAddresses();
if (count($addresses) > 0) {
foreach ($addresses as $address) {
if ($address->hasCouponCode()) {
$addressHasCoupon = true;
}
}
if (!$addressHasCoupon) {
$quote->setCouponCode('');
}
}
}
return $this;
}