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


PHP Discount::get方法代码示例

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


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

示例1: run

 public function run($request)
 {
     //check if OrderCouponModifier exists
     if (DB::getConn()->hasTable("OrderCouponModifier")) {
         $this->log("OrderCouponModifier table exists");
         $query = DB::query("SELECT *\n\t\t\t\tFROM OrderModifier\n\t\t\t\tINNER JOIN `OrderAttribute` ON `OrderModifier`.`ID` = `OrderAttribute`.`ID`\n\t\t\t\tINNER JOIN `OrderCouponModifier` ON `OrderModifier`.`ID` = `OrderCouponModifier`.`ID`\n\t\t\t\tINNER JOIN `Order` ON `OrderAttribute`.`OrderID` = `Order`.`ID`;");
         foreach ($query as $row) {
             $newdata = $row;
             $newdata["ClassName"] = "OrderDiscountModifier";
             $newdata["ID"] = 0;
             if (!OrderDiscountModifier::get()->filter("OrderID", $newdata["OrderID"])->exists()) {
                 $newmodifier = new OrderDiscountModifier($newdata);
                 $newmodifier->write();
                 $discount = Discount::get()->byID($newdata["CouponID"]);
                 //set up discount values
                 if ($discount && $discount->exists()) {
                     $newmodifier->Discounts()->add($discount, array("DiscountAmount" => $newmodifier->Amount));
                 }
                 $this->log("Migrated modifier for Order " . $newdata["OrderID"] . " " . $newmodifier->ID);
             }
         }
     } else {
         $this->log("OrderCouponModifier table does not exist");
     }
 }
开发者ID:burnbright,项目名称:silverstripe-shop-discount,代码行数:25,代码来源:ShopDiscountMigrationTask.php

示例2: Discounts

 /**
  * Get all discounts that have been applied to an order.
  *
  * @return ArrayList
  */
 public function Discounts()
 {
     $discounts = Discount::get()->leftJoin("OrderDiscountModifier_Discounts", "\"Discount\".\"ID\" = \"OrderDiscountModifier_Discounts\".\"DiscountID\"")->innerJoin("OrderAttribute", "(\"OrderDiscountModifier_Discounts\".\"OrderDiscountModifierID\" = \"OrderAttribute\".\"ID\")")->filter("OrderAttribute.OrderID", $this->owner->ID);
     $finalDiscounts = new ArrayList();
     foreach ($discounts as $discount) {
         $finalDiscounts->push($discount);
     }
     foreach ($this->owner->Items() as $item) {
         foreach ($item->Discounts() as $discount) {
             $finalDiscounts->push($discount);
         }
     }
     $finalDiscounts->removeDuplicates();
     return $finalDiscounts;
 }
开发者ID:burnbright,项目名称:silverstripe-shop-discount,代码行数:20,代码来源:DiscountedOrderExtension.php

示例3: doAddDiscount

 /**
  * Action that will find a discount based on the code
  *
  * @param type $data
  * @param type $form
  */
 public function doAddDiscount($data, $form)
 {
     $code_to_search = $data['DiscountCode'];
     // First check if the discount is already added (so we don't
     // query the DB if we don't have to).
     if (!$this->discount || $this->discount && $this->discount->Code != $code_to_search) {
         $code = Discount::get()->filter("Code", $code_to_search)->exclude("Expires:LessThan", date("Y-m-d"))->first();
         if ($code) {
             $this->discount = $code;
         }
     }
     $this->save();
     return $this->redirectBack();
 }
开发者ID:helpfulrobot,项目名称:i-lateral-silverstripe-commerce,代码行数:20,代码来源:ShoppingCart.php

示例4: Discounts

 /**
  * Get all discounts that have been applied to an order.
  */
 function Discounts()
 {
     return Discount::get()->leftJoin("OrderDiscountModifier_Discounts", "\"Discount\".\"ID\" = \"OrderDiscountModifier_Discounts\".\"DiscountID\"")->leftJoin("Product_OrderItem_Discounts", "\"Discount\".\"ID\" = \"Product_OrderItem_Discounts\".\"DiscountID\"")->innerJoin("OrderAttribute", "(\"OrderDiscountModifier_Discounts\".\"OrderDiscountModifierID\" = \"OrderAttribute\".\"ID\") OR \n\t\t\t\t(\"Product_OrderItem_Discounts\".\"Product_OrderItemID\" = \"OrderAttribute\".\"ID\")")->filter("OrderAttribute.OrderID", $this->owner->ID);
 }
开发者ID:helpfulrobot,项目名称:silvershop-discounts,代码行数:7,代码来源:DiscountedOrderExtension.php


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