some bug fixes
This commit is contained in:
parent
9068528c41
commit
82293d5f71
|
|
@ -39,6 +39,7 @@
|
|||
"laravel/dusk": "^4.0",
|
||||
"mockery/mockery": "^1.0",
|
||||
"nunomaduro/collision": "^2.0",
|
||||
"phploc/phploc": "^5.0@dev",
|
||||
"phpunit/phpunit": "^7.0"
|
||||
},
|
||||
"replace": {
|
||||
|
|
|
|||
|
|
@ -1240,6 +1240,13 @@ class Cart {
|
|||
return $result;
|
||||
}
|
||||
|
||||
public function applyNonCoupon()
|
||||
{
|
||||
$result = $this->discount->applyNonCouponAble();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function leastWorthItem()
|
||||
{
|
||||
$cart = $this->getCart();
|
||||
|
|
@ -1247,8 +1254,8 @@ class Cart {
|
|||
$leastSubTotal = [];
|
||||
|
||||
foreach ($cart->items as $item) {
|
||||
if ($item->base_total < $leastValue) {
|
||||
$leastValue = $item->total;
|
||||
if ($item->price < $leastValue) {
|
||||
$leastValue = $item->price;
|
||||
$leastSubTotal = [
|
||||
'id' => $item->id,
|
||||
'base_total' => $leastValue
|
||||
|
|
|
|||
|
|
@ -78,8 +78,9 @@ class Discount
|
|||
if ($channel->channel_id == $currentChannel->id) {
|
||||
if (auth()->guard('customer')->check()) {
|
||||
foreach ($rule->customer_groups as $customerGroup) {
|
||||
if (auth()->guard('customer')->user()->customer_group_id == $customerGroup->customer_group_id)
|
||||
if (auth()->guard('customer')->user()->customer_group_id == $customerGroup->customer_group_id) {
|
||||
array_push($suitableRules, $rule);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -100,8 +101,9 @@ class Discount
|
|||
if ($channel->channel_id == $currentChannel->id) {
|
||||
if (auth()->guard('customer')->check()) {
|
||||
foreach ($rule->customer_groups as $customerGroup) {
|
||||
if (auth()->guard('customer')->user()->customer_group_id == $customerGroup->customer_group_id)
|
||||
if (auth()->guard('customer')->user()->customer_group_id == $customerGroup->customer_group_id) {
|
||||
array_push($suitableRules, $rule);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -272,14 +274,6 @@ class Discount
|
|||
}
|
||||
}
|
||||
|
||||
// works automatically on the basis of no conditions
|
||||
public function checkNonCouponConditions()
|
||||
{
|
||||
$rules = $this->applyNonCouponAble();
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
public function ruleCheck($code)
|
||||
{
|
||||
$rules = $this->applyCouponAble();
|
||||
|
|
@ -306,33 +300,14 @@ class Discount
|
|||
$cart = \Cart::getCart();
|
||||
|
||||
//all of conditions is/are true
|
||||
$result = null;
|
||||
if ($appliedRule->conditions) {
|
||||
$result = 1;
|
||||
if ($appliedRule->conditions && $appliedRule->conditions != "null") {
|
||||
$conditions = json_decode(json_decode($appliedRule->conditions));
|
||||
|
||||
$shipping_address = $cart->getShippingAddressAttribute();
|
||||
|
||||
$shipping_method = $cart->shipping_method;
|
||||
$shipping_country = $shipping_address->country;
|
||||
$shipping_state = $shipping_address->state;
|
||||
$shipping_postcode = $shipping_address->postcode;
|
||||
$shipping_city = $shipping_address->city;
|
||||
|
||||
$payment_method = $cart->payment->method;
|
||||
$sub_total = $cart->base_sub_total;
|
||||
|
||||
$total_items = $cart->items_qty;
|
||||
$total_weight = 0;
|
||||
|
||||
foreach($cart->items as $item) {
|
||||
$total_weight = $total_weight + $item->base_total_weight;
|
||||
}
|
||||
|
||||
$test_mode = config('pricerules.test_mode.0');
|
||||
$test_conditions = config('pricerules.cart.conditions');
|
||||
|
||||
// dd($conditions);
|
||||
if ($test_mode == config('pricerules.test_mode.0')) {
|
||||
$result = $this->testAllConditionAreTrue($conditions, $cart);
|
||||
// dd($result);
|
||||
} else if ($test_mode == config('pricerules.test_mode.1')) {
|
||||
$result = $this->testAllConditionAreFalse($conditions, $cart);
|
||||
} else if ($test_mode == config('pricerules.test_mode.2')) {
|
||||
|
|
@ -358,7 +333,7 @@ class Discount
|
|||
$leastWorthItem = \Cart::leastWorthItem();
|
||||
|
||||
if ($action_type == config('pricerules.cart.validation.0')) {
|
||||
$newBaseSubTotal = ($leastWorthItem['base_total'] * $disc_amount) / 100;
|
||||
$newBaseSubTotal = $cart->grand_total - ($leastWorthItem['base_total'] * $disc_amount) / 100;
|
||||
} else if ($action_type == config('pricerules.cart.validation.1')) {
|
||||
$newBaseSubTotal = $leastWorthItem['base_total'] - $disc_amount;
|
||||
} else if ($action_type == config('pricerules.cart.validation.2')) {
|
||||
|
|
@ -372,14 +347,16 @@ class Discount
|
|||
'message' => trans('admin::app.promotion.status.coupon-applied'),
|
||||
'action' => $action_type,
|
||||
'amount_given' => false,
|
||||
'amount' => $newQuantity
|
||||
'amount_payable' => $newQuantity,
|
||||
'amount' => null
|
||||
]);
|
||||
} else {
|
||||
return response()->json([
|
||||
'message' => trans('admin::app.promotion.status.coupon-applied'),
|
||||
'action' => $action_type,
|
||||
'amount_given' => true,
|
||||
'amount' => core()->currency($newBaseSubTotal)
|
||||
'amount_payable' => core()->currency($newBaseSubTotal),
|
||||
'amount' => core()->currency($cart->grand_total - $newBaseSubTotal)
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
|
|
@ -489,11 +466,10 @@ class Discount
|
|||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function testAllConditionAreFalse($condition, $cart) {
|
||||
protected function testAllConditionAreFalse($conditions, $cart) {
|
||||
$shipping_address = $cart->getShippingAddressAttribute();
|
||||
|
||||
$shipping_method = $cart->shipping_method;
|
||||
|
|
@ -514,8 +490,8 @@ class Discount
|
|||
|
||||
$test_mode = config('pricerules.test_mode.0');
|
||||
$test_conditions = config('pricerules.cart.conditions');
|
||||
$result = 1;
|
||||
|
||||
$result = 1;
|
||||
foreach ($conditions as $condition) {
|
||||
$actual_value = ${$condition->attribute};
|
||||
$test_value = $condition->value;
|
||||
|
|
@ -584,7 +560,7 @@ class Discount
|
|||
return $result;
|
||||
}
|
||||
|
||||
protected function testAnyConditionIsTrue($condition, $cart) {
|
||||
protected function testAnyConditionIsTrue($conditions, $cart) {
|
||||
$shipping_address = $cart->getShippingAddressAttribute();
|
||||
|
||||
$shipping_method = $cart->shipping_method;
|
||||
|
|
@ -654,7 +630,7 @@ class Discount
|
|||
return $result;
|
||||
}
|
||||
|
||||
protected function testAnyConditionIsFalse($condition, $cart) {
|
||||
protected function testAnyConditionIsFalse($conditions, $cart) {
|
||||
$shipping_address = $cart->getShippingAddressAttribute();
|
||||
|
||||
$shipping_method = $cart->shipping_method;
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ use Webkul\Sales\Repositories\OrderRepository;
|
|||
/**
|
||||
* Chekout controller for the customer and guest for placing order
|
||||
*
|
||||
* @author Jitendra Singh <jitendra@webkul.com>
|
||||
* @author Jitendra Singh <jitendra@webkul.com>
|
||||
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
|
||||
*/
|
||||
class OnepageController extends Controller
|
||||
|
|
@ -114,6 +114,10 @@ class OnepageController extends Controller
|
|||
|
||||
$cart = Cart::getCart();
|
||||
|
||||
$rules = Cart::applyNonCoupon($cart);
|
||||
|
||||
dd($rules);
|
||||
|
||||
return response()->json([
|
||||
'jump_to_section' => 'review',
|
||||
'html' => view('shop::checkout.onepage.review', compact('cart'))->render()
|
||||
|
|
|
|||
|
|
@ -512,8 +512,8 @@
|
|||
this_this.message = response.data.message;
|
||||
|
||||
this_this.discounted = true;
|
||||
this_this.discount.amount = response.data.amount;
|
||||
this_this.discount.amount_given = response.data.amount_given;
|
||||
this_this.discount.amount = response.data.amount_payable;
|
||||
this_this.discount.amount_given = response.data.amount;
|
||||
}).catch(function(error) {
|
||||
this_this.discounted = false;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -47,17 +47,18 @@
|
|||
</form>
|
||||
|
||||
<div class="discounted" v-if="discounted">
|
||||
<div class="mt-10 mb-10">
|
||||
<div class="mt-15 mb-10">
|
||||
<b>Coupon used</b>
|
||||
</div>
|
||||
|
||||
<span class="mt-10 mb-10" style="display: block; margin-bottom: 5px; width: 100%">
|
||||
<span class="row mb-10">
|
||||
<label style="float: left;">@{{ code }}</label>
|
||||
<label style="float: right;">@{{ discount.amount }}</label>
|
||||
<label style="float: right;">@{{ discount.amount_given }}</label>
|
||||
</span>
|
||||
|
||||
<span class="horizontal-rule"></span>
|
||||
<span class="mt-10 mb-10" style="display: block; margin-bottom: 5px; width: 100%">
|
||||
|
||||
<span class="row mt-10">
|
||||
<label style="float: left;">Amount Payable</label>
|
||||
<label style="float: right;">@{{ discount.amount }}</label>
|
||||
</span>
|
||||
|
|
@ -65,4 +66,4 @@
|
|||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -188,6 +188,13 @@ h5 {
|
|||
display: none !important;
|
||||
}
|
||||
|
||||
.row {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.btn {
|
||||
@include box-shadow(
|
||||
0 1px 4px 0 rgba(0, 0, 0, 0.2),
|
||||
|
|
|
|||
Loading…
Reference in New Issue