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


PHP Cart66Common::trimmedExplode方法代码示例

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


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

示例1: getMembershipPrice

 public function getMembershipPrice()
 {
     // Return pricing (if applicable) for different membership levels
     // Otherwise, just return the default pricing (without options or fancy subscription stuff)
     $price = $this->price;
     if (Cart66Common::isLoggedIn()) {
         $levels = Cart66Common::trimmedExplode(',', $this->priceMembership);
         foreach ($levels as $level) {
             list($subscription, $p) = Cart66Common::trimmedExplode(':', $level);
             $membershipPriceList[$subscription] = $p;
         }
         $account = new Cart66Account();
         if ($account->load(Cart66Session::get('Cart66AccountId'))) {
             $userFeatureLevel = $account->getFeatureLevel();
             if ($account->isActive() && array_key_exists($userFeatureLevel, $membershipPriceList)) {
                 $price = $membershipPriceList[$userFeatureLevel];
             }
         }
     }
     return $price;
 }
开发者ID:rbredow,项目名称:allyzabbacart,代码行数:21,代码来源:Cart66Product.php

示例2: hideFrom

 /**
  * This is the inverse of the showTo shortcode function above.
  */
 public function hideFrom($attrs, $content = 'null')
 {
     $isAllowed = true;
     if (Cart66Common::isLoggedIn()) {
         $levels = Cart66Common::trimmedExplode(',', $attrs['level']);
         $account = new Cart66Account();
         if (in_array('all_members', $levels)) {
             $isAllowed = false;
         } elseif ($account->load(Cart66Session::get('Cart66AccountId'))) {
             if ($account->isActive() && in_array($account->getFeatureLevel(), $levels)) {
                 $isAllowed = false;
             }
         }
     }
     $content = $isAllowed ? $content : '';
     return do_shortcode($content);
 }
开发者ID:rbredow,项目名称:allyzabbacart,代码行数:20,代码来源:Cart66ShortcodeManager.php

示例3: getDiscountAmount

 public function getDiscountAmount($cartObject = null, $taxed_products = false)
 {
     $p = new Cart66Product();
     //Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Running getDiscountAmount()");
     $discount = 0;
     if (!$cartObject) {
         $cartObject = Cart66Session::get('Cart66Cart');
     }
     // First, check to see if a membership group is excluded from using this coupon
     if ($this->membership_eligibility) {
         Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] This coupon requires a membership to use:" . $this->membership_eligibility);
         if (Cart66Common::isLoggedIn()) {
             if ($this->membership_eligibility == "guest") {
                 // The user is logged in as a non-guest and this is a guest-only coupon. Return 0.00
                 Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] The user is logged in as a non-guest and this is a guest-only coupon.");
                 return number_format($discount, 2, '.', '');
             }
             $account = new Cart66Account();
             if ($account->load(Cart66Session::get('Cart66AccountId'))) {
                 $userFeatureLevel = $account->getFeatureLevel();
                 $allowedLevels = Cart66Common::trimmedExplode(',', $this->membership_eligibility);
                 Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] The user is logged in as " . $userFeatureLevel);
                 if (!in_array($userFeatureLevel, $allowedLevels)) {
                     // The user is logged in, but cannot use this coupon. Return 0.00
                     Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] The user is logged in as " . $userFeatureLevel . " and is not eligible to use this coupon.");
                     return number_format($discount, 2, '.', '');
                 }
             }
         } else {
             // The user is not logged in...and this coupon requires a login to work, no discount
             if ($this->membership_eligibility && $this->membership_eligibility != "guest") {
                 Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] The user is not logged in, cant use this coupon as guest.");
                 return number_format($discount, 2, '.', '');
             }
         }
     }
     if ($this->apply_to == "products" && !empty($cartObject)) {
         // coupon applies to products
         $products = explode(',', $this->products);
         $cartItems = $cartObject->getItems();
         Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] The number of items in the cart: " . count($cartItems));
         $usedThisOrder = 0;
         if (empty($this->products)) {
             // all products
             // apply coupon to every item in the cart
             $counter = 0;
             foreach ($cartItems as $item) {
                 $p->load($item->getProductId());
                 if (!$taxed_products || $taxed_products && $p->taxable == 1) {
                     $basePrice = $item->getBaseProductPrice();
                     $stayPositivePrice = $this->stayPositive($basePrice, $this->getAmount($basePrice));
                     $quantity = $item->getQuantity();
                     for ($i = 1; $i <= $quantity; $i++) {
                         if (empty($this->max_uses_per_order)) {
                             $discount += $stayPositivePrice;
                             Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Max uses per order is empty. Discount: {$discount}");
                         } elseif ($counter < $this->max_uses_per_order) {
                             $discount += $stayPositivePrice;
                             Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Max uses per order is NOT empty. Discount: {$discount} :: Stay Positive: {$stayPositivePrice}");
                         }
                         $counter++;
                     }
                 }
             }
         } else {
             // coupon applies to specific products
             foreach ($cartItems as $item) {
                 $p->load($item->getProductId());
                 if (!$taxed_products || $taxed_products && $p->taxable == 1) {
                     if ($this->exclude_from_products == 0) {
                         if (in_array($item->getProductId(), $products)) {
                             // add up discount
                             $itemQuantity = $item->getQuantity();
                             if ($this->max_uses_per_order > 0) {
                                 $usesRemaining = $this->max_uses_per_order - $usedThisOrder;
                                 $allowedQuantity = $usesRemaining <= $itemQuantity ? $usesRemaining : $itemQuantity;
                             } else {
                                 $allowedQuantity = $itemQuantity;
                             }
                             $productDiscount = $this->getAmount($item->getBaseProductPrice());
                             $discount += $allowedQuantity * $this->stayPositive($item->getBaseProductPrice(), $productDiscount);
                         }
                     } elseif ($this->exclude_from_products == 1) {
                         if (!in_array($item->getProductId(), $products)) {
                             // add up discount
                             $itemQuantity = $item->getQuantity();
                             if ($this->max_uses_per_order > 0) {
                                 $usesRemaining = $this->max_uses_per_order - $usedThisOrder;
                                 $allowedQuantity = $usesRemaining <= $itemQuantity ? $usesRemaining : $itemQuantity;
                             } else {
                                 $allowedQuantity = $itemQuantity;
                             }
                             $productDiscount = $this->getAmount($item->getBaseProductPrice());
                             $discount += $allowedQuantity * $this->stayPositive($item->getBaseProductPrice(), $productDiscount);
                         }
                     }
                 }
             }
         }
     }
//.........这里部分代码省略.........
开发者ID:rbredow,项目名称:allyzabbacart,代码行数:101,代码来源:Cart66Promotion.php


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