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


PHP Mage_Sales_Model_Quote_Address::getAllVisibleItems方法代码示例

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


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

示例1: _injectItemData

 /**
  * Add order items to the ship group for each item shipping to the address.
  *
  * @return self
  */
 protected function _injectItemData()
 {
     $orderItemIterable = $this->_shipGroup->getItems();
     // The first item needs to include shipping totals, use this flag to
     // track when item is the first item.
     $first = true;
     foreach ($this->_address->getAllVisibleItems() as $item) {
         // Add shipping amounts to the first item - necessary way of sending
         // address level shipping totals which is the only way Magento can
         // report shipping totals.
         if ($first) {
             $item->setIncludeShippingTotals(true);
         }
         $itemBuilder = $this->_taxFactory->createRequestBuilderItem($orderItemIterable, $this->_address, $item);
         $itemPayload = $itemBuilder->getOrderItemPayload();
         if ($itemPayload) {
             $orderItemIterable[$itemPayload] = null;
         }
         // After the first iteration, this should always be false.
         $first = false;
     }
     return $this;
 }
开发者ID:WinstonN,项目名称:magento-retail-order-management,代码行数:28,代码来源:Address.php

示例2: fetch

 public function fetch(Mage_Sales_Model_Quote_Address $address)
 {
     $checkoutSubtotal = Mage::getSingleton('checkout/session')->getQuote();
     $items = $address->getAllVisibleItems();
     if (!count($items)) {
         return $this;
     }
     if (!$check_tax) {
         $tax = $address->getBaseTaxAmount();
     }
     if (!$check_shipping) {
         $shipping = $address->getBaseShippingInclTax();
     }
     $baseGrandTotal = $address->getBaseGrandTotal();
     $store_id = Mage::app()->getStore()->getId();
     $quote = $address->getQuote();
     /*added by pavan 28/01/14*/
     $quote->setMwStorecreditCheckoutMax($baseGrandTotal);
     $quote->save();
     //Mage::log('currenturl'.$currentUrl, null, 'mytotal.log');
     //	   Mage::log('pavan is here', null, 'mylogfile.log');
     //	   Mage::log($checkoutSubtotal->getData(), null, 'mylogfile.log');
     //Mage::log('getMwStorecredit'.$address->getMwStorecredit(), null, 'mylogfile.log');
     if ($checkoutSubtotal->getData('subtotal') == $checkoutSubtotal->getData('subtotal_with_discount')) {
         $subTotalWithTax = $checkoutSubtotal->getData('subtotal') + $tax;
     } else {
         $couponAmount = $checkoutSubtotal->getData('subtotal_with_discount') - $checkoutSubtotal->getData('subtotal');
         $subTotalWithTax = $checkoutSubtotal->getData('subtotal_with_discount') + $tax;
     }
     // if($subTotalWithTax >= '500') {
     // $shipp = '0';
     // } else {
     // $shipp = '60';
     // }
     // if($address->getMwStorecredit() > ($subTotalWithTax + $shipp) || $address->getMwRewardpointDiscount() > ($subTotalWithTax + $shipp)) {
     // Mage::log('herere'.$address->getMwStorecredit().$subTotalWithTax, null, 'here123.log');
     // $address->setMwStorecredit(0)
     // ->setMwRewardpoint(0)
     // ->save();
     // $quote->setMwStorecredit(0)
     // ->setMwRewardpoint(0)
     // ->save();
     // }
     /*START -- values set to zero if cart quantity changes*/
     if (Mage::app()->getFrontController()->getRequest()->getActionName() == 'couponapply') {
         $quote = $address->getQuote();
         $quote->setMwStorecredit(0)->setMwStorecreditDiscount(0)->setMwStorecreditDiscountShow(0)->save();
         $quote->setMwRewardpoint(0)->setMwRewardpointDiscountShow(0)->setMwRewardpointDiscount(0)->save();
         $address->setMwStorecredit(0)->setMwStorecreditDiscount(0)->setMwStorecreditDiscountShow(0)->save();
         $address->setMwRewardpoint(0)->setMwRewardpointDiscountShow(0)->setMwRewardpointDiscount(0)->save();
     }
     if (Mage::app()->getFrontController()->getRequest()->getActionName() == 'cartqty' || Mage::app()->getFrontController()->getRequest()->getActionName() == 'delete') {
         $quote = $address->getQuote();
         $quote->setCouponCode('')->setMwStorecredit(0)->setMwStorecreditDiscount(0)->setMwStorecreditDiscountShow(0)->save();
         $quote->setCouponCode('')->setMwRewardpoint(0)->setMwRewardpointDiscountShow(0)->setMwRewardpointDiscount(0)->save();
         $address->setCouponCode('')->setMwStorecredit(0)->setMwStorecreditDiscount(0)->setMwStorecreditDiscountShow(0)->save();
     }
     /*END -- values set to zero if cart quantity changes*/
     $amount = $address->getMwStorecreditDiscountShow();
     $credit = $address->getMwStorecredit();
     if ($credit != 0) {
         $title = Mage::helper('storecreditpro')->__('Zoff Bank');
         $address->addTotal(array('code' => $this->getCode(), 'title' => $title, 'value' => -$credit, 'strong' => false));
     }
     return $this;
 }
开发者ID:shebin512,项目名称:Magento_Zoff,代码行数:66,代码来源:Storecredit.php

示例3: getItemsToDiscount

 /**
  * Get the items the need to be discounted based on the category ids or root category and escape bundle products from calculation
  *
  * @author Mohamed Meabed <mo.meabed@gmail.com>
  *
  * @param Mage_SalesRule_Model_Rule           $rule
  * @param Mage_Sales_Model_Quote_Address      $address
  * @param Mage_Sales_Model_Quote_Address_Item $_addressItem
  *
  * @return array
  */
 public function getItemsToDiscount($rule, $address, $_addressItem)
 {
     $conditions = $rule->getConditions()->getConditions();
     $allowedCatIds = null;
     $parsedCats = array();
     $condition = null;
     $_productCategories = array();
     $cartCategories = array();
     $catToProcess = array();
     $isRootCategory = false;
     $validCondition = false;
     $rootCategoryId = Mage::app()->getStore()->getRootCategoryId();
     $ignoreType = array('bundle');
     /** @var Mage_SalesRule_Model_Rule_Condition_Address $c */
     foreach ($conditions as $c) {
         if (!$allowedCatIds && !$condition && $c->getData('attribute')) {
             $condition = $c;
             $val = $c->getValueParsed();
             if (is_string($val)) {
                 $parsedCats = explode(',', $val);
             }
             if (is_array($val)) {
                 $parsedCats = $val;
             }
             if ($parsedCats && is_array($parsedCats)) {
                 if (in_array($rootCategoryId, $parsedCats)) {
                     $isRootCategory = true;
                     $_productCategories = array($rootCategoryId);
                 }
             }
         }
     }
     $items = $address->getAllVisibleItems();
     $discountStep = $rule->getDiscountStep();
     $i = 0;
     /** @var Mage_Sales_Model_Quote_Item $item */
     foreach ($items as $item) {
         // Escape bundles
         if (in_array($ignoreType, $item->getProductType())) {
             continue;
         }
         if (!$isRootCategory) {
             /** @var Mage_Catalog_Model_Product $_product */
             $_product = Mage::getModel('catalog/product')->load($item->getProductId());
             $_productCategories = $_product->getCategoryIds();
         }
         $validCondition = $condition->validateAttribute($_productCategories);
         $cat = array_shift($_productCategories);
         if ($isRootCategory || $validCondition) {
             for ($x = 0; $x < $item->getQty(); $x++) {
                 $cartCategories[$cat][$i]['itemId'] = $item->getId();
                 $cartCategories[$cat][$i]['qty'] = $item->getQty();
                 $cartCategories[$cat][$i]['price'] = $item->getPrice();
                 $cartCategories[$cat][$i]['item'] = $item;
                 $i++;
                 if (count($cartCategories[$cat]) >= $discountStep) {
                     $catToProcess[$cat] = $cat;
                 }
             }
         }
     }
     $x = $rule->getDiscountStep();
     $y = $rule->getDiscountAmount();
     $return = array();
     foreach ($catToProcess as $cat) {
         $catItems = $cartCategories[$cat];
         $this->aaSort($catItems, 'price');
         $qtyTobeDiscounted = (int) ($i / $discountStep);
         $qtyTobeDiscounted *= $y;
         for ($j = 0; $j < $qtyTobeDiscounted; $j++) {
             $itemDisc = array_pop($catItems);
             /** @var Mage_Sales_Model_Quote_Address_Item $salesItem */
             $salesItem = $itemDisc['item'];
             if ($salesItem && !isset($return[$salesItem->getId()])) {
                 $return[$salesItem->getId()] = 0;
             }
             $return[$salesItem->getId()]++;
         }
     }
     return $return;
 }
开发者ID:anshumanravi,项目名称:magento-buy-x-get-the-cheapest-y-for-free,代码行数:92,代码来源:Data.php

示例4: collect

 public function collect(Mage_Sales_Model_Quote_Address $address)
 {
     $session = Mage::getSingleton('admin/session');
     $store_id = Mage::app()->getStore()->getId();
     if (Mage::helper('affiliate/data')->getEnabledStore($store_id)) {
         $quote = $address->getQuote();
         $items = $address->getAllVisibleItems();
         //$items = $address->getAllNonNominalItems();
         if (!count($items)) {
             return $this;
         }
         // xu ly code
         // zend_debug::dump($items);die();
         $discountAmount = 0;
         $referral_code = Mage::helper('affiliate')->getReferralCodeByCheckout();
         $customer_id = (int) Mage::getSingleton("customer/session")->getCustomer()->getId();
         $program_priority = Mage::helper('affiliate/data')->getAffiliatePositionStore($store_id);
         $position_discount = Mage::helper('affiliate/data')->getAffiliateDiscountStore($store_id);
         $programs = array();
         $programs = $this->getAllProgram();
         if (!Mage::app()->isSingleStoreMode()) {
             $programs = $this->getProgramByStoreView($programs);
         }
         $programs = $this->getProgramByEnable($programs);
         $_programs = $this->getProgramByTime($programs);
         foreach ($items as $item) {
             $product_id = $item->getProductId();
             $qty = $item->getQty();
             //$price = $item->getPrice();
             //$item->setBaseDiscountAmount($item->getBaseDiscountAmount() - $item->getAffiliateDiscount());
             if ($position_discount == 1) {
                 $price = $item->getBasePrice();
             } else {
                 $price = $item->getBasePrice() - $item->getBaseDiscountAmount() / $qty;
             }
             //$price = $item->getPrice();
             $programs = $this->processRule($item, $_programs);
             //var_dump($programs);exit;
             // neu mang program > 0
             $programs = $this->getProgramByCustomer($programs, $referral_code);
             //var_dump($programs);exit;
             if (sizeof($programs) >= 2) {
                 $array_customer_inviteds = array_splice($programs, sizeof($programs) - 1, 1);
                 foreach ($array_customer_inviteds as $array_customer_invited) {
                     $customer_invited = $array_customer_invited;
                     break;
                 }
                 // lay program theo 3 tieu chi
                 if ($program_priority == 1) {
                     $program_id = $this->getProgramByCommission($programs, $qty, $price, $customer_invited);
                 } else {
                     if ($program_priority == 2) {
                         $program_id = $this->getProgramByDiscount($programs, $qty, $price, $customer_invited);
                     } else {
                         if ($program_priority == 3) {
                             $program_id = $this->getProgramByPosition($programs);
                         }
                     }
                 }
                 $discount = $this->getDiscountByProgram($program_id, $qty, $price, $customer_invited);
             } else {
                 $discount = 0;
             }
             $discount = round($discount, 2);
             $discountAmount = $discountAmount + $discount;
             $item->setDiscountAmount($item->getDiscountAmount() + Mage::helper('core')->currency($discount, false, false));
             $item->setBaseDiscountAmount($item->getBaseDiscountAmount() + $discount);
             $item->setMwAffiliateDiscount($discount);
             // tim ra mang chuong trinh cho moi san pham $programs
             // kiem tra xem san pham do dung chuong trinh khuyen mai nao
             //var_dump($program_id);die();
         }
         //$discountAmount = 100;
         //phan xu ly cuoi cung
         $discountAmount_show = Mage::helper('core')->currency($discountAmount, false, false);
         //$address->setDiscountAmount($address->getDiscountAmount() - $discountAmount_show);// gia de hien thi
         $address->setBaseDiscountAmount($address->getBaseDiscountAmount() - $discountAmount);
         // gia de tinh toan
         $address->setAffiliateDiscount($discountAmount_show);
         // gia de hien thi
         $address->setBaseAffiliateDiscount($discountAmount);
         $address->setGrandTotal($address->getGrandTotal() - $address->getAffiliateDiscount());
         $address->setBaseGrandTotal($address->getBaseGrandTotal() - $address->getBaseAffiliateDiscount());
         return $this;
     }
 }
开发者ID:Gilbertoavitia1,项目名称:AHBS,代码行数:86,代码来源:Discount.php


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