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


PHP OrderItem::Product方法代码示例

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


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

示例1: updateSessionCart

 /**
  * If this order is still a cart, we save a copy of the items and
  * the subtotal in the session for the quick cart dropdown to be
  * usable even on static cached pages.
  *
  * @param OrderItem $item
  * @param Buyable   $buyable
  * @param int       $quantity
  */
 protected function updateSessionCart($item, $buyable, $quantity)
 {
     if (!session_id() || !$buyable) {
         return;
     }
     $cart = !empty($_SESSION['Cart']) ? $_SESSION['Cart'] : array('Items' => array(), 'SubTotal' => 0.0);
     if ($quantity > 0) {
         if (!isset($cart['Items'][$buyable->ID])) {
             $prod = $item->Product();
             $img = $prod ? $prod->Image() : null;
             $img = $img ? $img->getThumbnail() : null;
             // TODO: the key here should probably include the classname (or cover the diff bt Products and Variations)
             $cart['Items'][$buyable->ID] = array('ThumbURL' => $img ? $img->RelativeLink() : '', 'Link' => $prod ? $prod->RelativeLink() : '', 'Title' => $item->TableTitle(), 'SubTitle' => $item->hasMethod('SubTitle') ? $item->SubTitle() : '', 'UnitPrice' => $item->obj('UnitPrice')->Nice(), 'Quantity' => $quantity, 'RemoveLink' => $item->removeallLink());
         } else {
             // update the quantity if it's already present
             $cart['Items'][$buyable->ID]['Quantity'] = $quantity;
         }
     } else {
         // remove the item if quantity is 0
         unset($cart['Items'][$buyable->ID]);
     }
     // recalculate the subtotal
     $cart['SubTotal'] = $this->owner->obj('SubTotal')->Nice();
     // and the total number of items
     $cart['TotalItems'] = 0;
     foreach ($cart['Items'] as $item) {
         $cart['TotalItems'] += $item['Quantity'];
     }
     $_SESSION['Cart'] = $cart;
 }
开发者ID:helpfulrobot,项目名称:markguinn-silverstripe-shop-livepub,代码行数:39,代码来源:LivePubOrder.php

示例2: itemMatchesCriteria

 public function itemMatchesCriteria(OrderItem $item, Discount $discount)
 {
     $products = $discount->Products();
     $itemproduct = $item->Product(true);
     //true forces the current version of product to be retrieved.
     if ($products->exists() && !$products->find('ID', $item->ProductID)) {
         return false;
     }
     return true;
 }
开发者ID:helpfulrobot,项目名称:silvershop-discounts,代码行数:10,代码来源:ProductsDiscountConstraint.php

示例3: itemMatchesCriteria

 public function itemMatchesCriteria(OrderItem $item, Discount $discount)
 {
     $products = $discount->Products();
     $itemproduct = $item->Product(true);
     // true forces the current version of product to be retrieved.
     if ($products->exists()) {
         foreach ($products as $product) {
             // uses 'DiscountedProductID' since some subclasses of buyable could be used as the item product (such as
             // a bundle) rather than the product stored.
             if ($product->ID == $itemproduct->DiscountedProductID) {
                 return true;
             }
         }
         $this->error(_t('ProductsDiscountConstraint.MISSINGPRODUCT', "The required products are not in the cart."));
         return false;
     }
     return true;
 }
开发者ID:burnbright,项目名称:silverstripe-shop-discount,代码行数:18,代码来源:ProductsDiscountConstraint.php


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