Rule condition discount calculation now working properly
This commit is contained in:
parent
fc43b158dd
commit
8d68be8e07
|
|
@ -1297,7 +1297,8 @@ class Cart {
|
|||
'id' => $item->id,
|
||||
'total' => $item->total,
|
||||
'base_total' => $leastValue,
|
||||
'quantity' => $item->quantity
|
||||
'quantity' => $item->quantity,
|
||||
'price' => $item->price
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,8 +39,8 @@ class CreateCartRuleTable extends Migration
|
|||
$table->integer('sort_order')->unsigned()->default(0);
|
||||
$table->string('action_type')->nullable();
|
||||
$table->decimal('disc_amount', 12, 4)->default(0);
|
||||
$table->decimal('disc_quantity', 12, 4)->default(0);
|
||||
$table->string('disc_threshold')->default(0);
|
||||
$table->decimal('disc_quantity', 12, 4)->default(1);
|
||||
$table->string('disc_threshold')->default(1);
|
||||
$table->integer('coupon_type')->default(1);
|
||||
$table->boolean('auto_generation')->default(0);
|
||||
$table->boolean('apply_to_shipping')->default(0);
|
||||
|
|
|
|||
|
|
@ -376,24 +376,36 @@ class Discount
|
|||
$leastWorthItem = \Cart::leastWorthItem();
|
||||
$realQty = $leastWorthItem['quantity'];
|
||||
|
||||
if ($cart->items_qty >= $disc_threshold && $realQty >= $disc_quantity) {
|
||||
if ($cart->items_qty >= $disc_threshold) {
|
||||
if ($action_type == config('pricerules.cart.validation.0')) {
|
||||
$amountDiscounted = $leastWorthItem['total'] * ($disc_amount / 100);
|
||||
$amountDiscounted = $leastWorthItem['price'] * ($disc_amount / 100);
|
||||
|
||||
if ($amountDiscounted > $leastWorthItem['total']) {
|
||||
$amountDiscounted = $leastWorthItem['total'];
|
||||
if ($realQty > $disc_quantity) {
|
||||
$amountDiscounted = $amountDiscounted * $disc_quantity;
|
||||
}
|
||||
|
||||
if ($amountDiscounted > $leastWorthItem['price']) {
|
||||
$amountDiscounted = $leastWorthItem['price'];
|
||||
}
|
||||
} else if ($action_type == config('pricerules.cart.validation.1')) {
|
||||
$amountDiscounted = $disc_amount;
|
||||
|
||||
if ($amountDiscounted > $leastWorthItem['total']) {
|
||||
$amountDiscounted = $leastWorthItem['total'];
|
||||
if ($realQty > $disc_quantity) {
|
||||
$amountDiscounted = $amountDiscounted * $disc_quantity;
|
||||
}
|
||||
|
||||
if ($amountDiscounted > $leastWorthItem['price']) {
|
||||
$amountDiscounted = $leastWorthItem['price'];
|
||||
}
|
||||
} else if ($action_type == config('pricerules.cart.validation.2')) {
|
||||
$amountDiscounted = $disc_amount;
|
||||
|
||||
if ($amountDiscounted > $leastWorthItem['total']) {
|
||||
$amountDiscounted = $leastWorthItem['total'];
|
||||
if ($realQty > $disc_quantity) {
|
||||
$amountDiscounted = $amountDiscounted * $disc_quantity;
|
||||
}
|
||||
|
||||
if ($amountDiscounted > $leastWorthItem['price']) {
|
||||
$amountDiscounted = $leastWorthItem['price'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue