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


PHP Item::getAddress方法代码示例

本文整理汇总了PHP中Magento\Quote\Model\Quote\Item::getAddress方法的典型用法代码示例。如果您正苦于以下问题:PHP Item::getAddress方法的具体用法?PHP Item::getAddress怎么用?PHP Item::getAddress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Quote\Model\Quote\Item的用法示例。


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

示例1: testGetAddress

 public function testGetAddress()
 {
     $quote = $this->getMockBuilder('Magento\\Quote\\Model\\Quote')->setMethods(['getShippingAddress', 'getBillingAddress', 'getStoreId', '__wakeup'])->disableOriginalConstructor()->getMock();
     $quote->expects($this->once())->method('getShippingAddress')->will($this->returnValue('shipping'));
     $quote->expects($this->once())->method('getBillingAddress')->will($this->returnValue('billing'));
     $quote->expects($this->any())->method('getStoreId')->will($this->returnValue(1));
     $this->model->setQuote($quote);
     $quote->setItemsQty(2);
     $quote->setVirtualItemsQty(1);
     $this->assertEquals('shipping', $this->model->getAddress(), 'Wrong shipping address');
     $quote->setItemsQty(2);
     $quote->setVirtualItemsQty(2);
     $this->assertEquals('billing', $this->model->getAddress(), 'Wrong billing address');
 }
开发者ID:,项目名称:,代码行数:14,代码来源:

示例2: _initItem

 /**
  * Address item initialization
  *
  * @param Address $address
  * @param AddressItem|Item $item
  * @return bool
  */
 protected function _initItem($address, $item)
 {
     if ($item instanceof AddressItem) {
         $quoteItem = $item->getAddress()->getQuote()->getItemById($item->getQuoteItemId());
     } else {
         $quoteItem = $item;
     }
     $product = $quoteItem->getProduct();
     $product->setCustomerGroupId($quoteItem->getQuote()->getCustomerGroupId());
     /**
      * Quote super mode flag mean what we work with quote without restriction
      */
     if ($item->getQuote()->getIsSuperMode()) {
         if (!$product) {
             return false;
         }
     } else {
         if (!$product || !$product->isVisibleInCatalog()) {
             return false;
         }
     }
     $originalPrice = $product->getPrice();
     if ($quoteItem->getParentItem() && $quoteItem->isChildrenCalculated()) {
         $finalPrice = $quoteItem->getParentItem()->getProduct()->getPriceModel()->getChildFinalPrice($quoteItem->getParentItem()->getProduct(), $quoteItem->getParentItem()->getQty(), $product, $quoteItem->getQty());
         $this->_calculateRowTotal($item, $finalPrice, $originalPrice);
     } elseif (!$quoteItem->getParentItem()) {
         $finalPrice = $product->getFinalPrice($quoteItem->getQty());
         $this->_calculateRowTotal($item, $finalPrice, $originalPrice);
         $this->_addAmount($item->getRowTotal());
         $this->_addBaseAmount($item->getBaseRowTotal());
         $address->setTotalQty($address->getTotalQty() + $item->getQty());
     }
     return true;
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:41,代码来源:Subtotal.php


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