本文整理汇总了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");
}
}
示例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;
}
示例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();
}
示例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);
}