Changed frontend attributes and syntax fixes in checkout
This commit is contained in:
parent
9ae4f8a801
commit
15abe379e0
|
|
@ -476,7 +476,6 @@
|
|||
this.conditions_list.push(this.cart_object);
|
||||
|
||||
this.cart_object = {
|
||||
criteria: null,
|
||||
attribute: null,
|
||||
condition: null,
|
||||
value: []
|
||||
|
|
@ -526,7 +525,7 @@
|
|||
|
||||
onSubmit: function (e) {
|
||||
if (this.conditions_list.length != 0) {
|
||||
this.conditions_list.test_mode = this.match_criteria;
|
||||
this.conditions_list.push({'criteria': this.match_criteria});
|
||||
}
|
||||
|
||||
this.all_conditions = JSON.stringify(this.conditions_list);
|
||||
|
|
|
|||
|
|
@ -567,12 +567,32 @@
|
|||
},
|
||||
|
||||
onSubmit: function (e) {
|
||||
if (this.conditions_list.length != 0) {
|
||||
|
||||
// if (this.conditions_list.length != 0) {
|
||||
// this.conditions_list.push(this.match_criteria);
|
||||
// }
|
||||
indexes = [];
|
||||
|
||||
console.log(JSON.stringify(this.conditions_list));
|
||||
for (i in this.conditions_list) {
|
||||
if (this.conditions_list[i].hasOwnProperty('criteria') && ! this.conditions_list[i].hasOwnProperty('attribute')) {
|
||||
indexes.push(i);
|
||||
}
|
||||
}
|
||||
|
||||
if (indexes.length > 1) {
|
||||
for (i in indexes) {
|
||||
console.log(indexes[i]);
|
||||
if (this.conditions_list.length )
|
||||
this.conditions_list.splice(indexes[i], 1);
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
this.conditions_list.push({'criteria': this.match_criteria});
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
this.all_conditions = JSON.stringify(this.conditions_list);
|
||||
|
||||
|
|
|
|||
|
|
@ -502,6 +502,8 @@ class Discount
|
|||
}
|
||||
|
||||
protected function testIfAllConditionAreTrue($conditions, $cart) {
|
||||
array_pop($conditions);
|
||||
|
||||
$shipping_address = $cart->getShippingAddressAttribute() ?? '';
|
||||
|
||||
$shipping_method = $cart->shipping_method ?? '';
|
||||
|
|
@ -524,6 +526,7 @@ class Discount
|
|||
$test_conditions = config('pricerules.cart.conditions');
|
||||
|
||||
$result = 1;
|
||||
|
||||
foreach ($conditions as $condition) {
|
||||
$actual_value = ${$condition->attribute};
|
||||
$test_value = $condition->value;
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ class CartRuleController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* @return Redirect
|
||||
* @return redirect
|
||||
*/
|
||||
public function store()
|
||||
{
|
||||
|
|
@ -451,7 +451,9 @@ class CartRuleController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* Delete
|
||||
* Deletes the cart rule
|
||||
*
|
||||
* @return JSON
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -99,13 +99,13 @@ class OnepageController extends Controller
|
|||
$data['billing']['address1'] = implode(PHP_EOL, array_filter($data['billing']['address1']));
|
||||
$data['shipping']['address1'] = implode(PHP_EOL, array_filter($data['shipping']['address1']));
|
||||
|
||||
if (Cart::hasError() || !Cart::saveCustomerAddress($data) || ! $rates = Shipping::collectRates())
|
||||
return response()->json(['redirect_url' => route('shop.checkout.cart.index')], 403);
|
||||
|
||||
Cart::applyNonCoupon();
|
||||
|
||||
Cart::collectTotals();
|
||||
|
||||
if (Cart::hasError() || !Cart::saveCustomerAddress($data) || ! $rates = Shipping::collectRates())
|
||||
return response()->json(['redirect_url' => route('shop.checkout.cart.index')], 403);
|
||||
|
||||
return response()->json($rates);
|
||||
}
|
||||
|
||||
|
|
@ -118,13 +118,13 @@ class OnepageController extends Controller
|
|||
{
|
||||
$shippingMethod = request()->get('shipping_method');
|
||||
|
||||
if (Cart::hasError() || !$shippingMethod || !Cart::saveShippingMethod($shippingMethod))
|
||||
return response()->json(['redirect_url' => route('shop.checkout.cart.index')], 403);
|
||||
|
||||
Cart::applyNonCoupon();
|
||||
|
||||
Cart::collectTotals();
|
||||
|
||||
if (Cart::hasError() || !$shippingMethod || !Cart::saveShippingMethod($shippingMethod))
|
||||
return response()->json(['redirect_url' => route('shop.checkout.cart.index')], 403);
|
||||
|
||||
return response()->json(Payment::getSupportedPaymentMethods());
|
||||
}
|
||||
|
||||
|
|
@ -137,15 +137,15 @@ class OnepageController extends Controller
|
|||
{
|
||||
$payment = request()->get('payment');
|
||||
|
||||
Cart::applyNonCoupon();
|
||||
|
||||
Cart::collectTotals();
|
||||
|
||||
if (Cart::hasError() || !$payment || !Cart::savePaymentMethod($payment))
|
||||
return response()->json(['redirect_url' => route('shop.checkout.cart.index')], 403);
|
||||
|
||||
$cart = Cart::getCart();
|
||||
|
||||
Cart::applyNonCoupon();
|
||||
|
||||
Cart::collectTotals();
|
||||
|
||||
return response()->json([
|
||||
'jump_to_section' => 'review',
|
||||
'html' => view('shop::checkout.onepage.review', compact('cart', 'rule'))->render()
|
||||
|
|
|
|||
|
|
@ -71,8 +71,12 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="step-content review" v-show="currentStep == 4" id="summary-section">
|
||||
<review-section v-if="currentStep == 4" hide-discount="1"></review-section>
|
||||
<div class="step-content review" v-show="currentStep == 4" id="summary-section" @applyDiscount="getOrderSummary" @removeDiscount="getOrderSummary">
|
||||
<review-section v-if="currentStep == 4">
|
||||
<div slot="body">
|
||||
<summary-section :active="true" @onCouponApply="getOrderSummary"></summary-section>
|
||||
</div>
|
||||
</review-section>
|
||||
|
||||
<div class="button-group">
|
||||
<button type="button" class="btn btn-lg btn-primary" @click="placeOrder()" :disabled="disable_button" id="checkout-place-order-button">
|
||||
|
|
@ -83,7 +87,7 @@
|
|||
</div>
|
||||
|
||||
<div class="col-right" v-if="resetSummary" v-show="currentStep != 4">
|
||||
<summary-section hide-discount="1"></summary-section>
|
||||
<summary-section :active="false"></summary-section>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
|
|
@ -341,42 +345,6 @@
|
|||
}
|
||||
})
|
||||
|
||||
var summaryTemplateRenderFns = [];
|
||||
|
||||
Vue.component('summary-section', {
|
||||
inject: ['$validator'],
|
||||
|
||||
data: function() {
|
||||
return {
|
||||
templateRender: null,
|
||||
|
||||
code: null,
|
||||
|
||||
coupon_used: false,
|
||||
|
||||
hide_discount: 0
|
||||
}
|
||||
},
|
||||
|
||||
staticRenderFns: summaryTemplateRenderFns,
|
||||
|
||||
mounted: function() {
|
||||
this.templateRender = summaryHtml.render;
|
||||
|
||||
for (var i in summaryHtml.staticRenderFns) {
|
||||
summaryTemplateRenderFns.push(summaryHtml.staticRenderFns[i]);
|
||||
}
|
||||
},
|
||||
|
||||
render: function(h) {
|
||||
return h('div', [
|
||||
(this.templateRender ?
|
||||
this.templateRender() :
|
||||
'')
|
||||
]);
|
||||
}
|
||||
})
|
||||
|
||||
var shippingTemplateRenderFns = [];
|
||||
|
||||
Vue.component('shipping-section', {
|
||||
|
|
@ -460,40 +428,78 @@
|
|||
eventBus.$emit('after-payment-method-selected');
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
var reviewTemplateRenderFns = [];
|
||||
|
||||
Vue.component('review-section', {
|
||||
data: function() {
|
||||
props: ['active'],
|
||||
|
||||
data: function () {
|
||||
return {
|
||||
templateRender: null,
|
||||
|
||||
code: '',
|
||||
|
||||
hide_discount: 1,
|
||||
|
||||
coupon_used: false,
|
||||
|
||||
error_message: ''
|
||||
hide_discount: null,
|
||||
}
|
||||
},
|
||||
|
||||
staticRenderFns: reviewTemplateRenderFns,
|
||||
|
||||
mounted: function() {
|
||||
mounted: function () {
|
||||
this.hide_discount = this.active;
|
||||
|
||||
this.templateRender = reviewHtml.render;
|
||||
|
||||
for (var i in reviewHtml.staticRenderFns) {
|
||||
reviewTemplateRenderFns.push(reviewHtml.staticRenderFns[i]);
|
||||
}
|
||||
|
||||
@if ($cart->coupon_code != null)
|
||||
this.code = '{{ $cart->coupon_code }}';
|
||||
this.coupon_used = true;
|
||||
@endif
|
||||
},
|
||||
|
||||
render: function(h) {
|
||||
return h('div', [
|
||||
(this.templateRender ?
|
||||
this.templateRender() :
|
||||
'')
|
||||
]
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
var summaryTemplateRenderFns = [];
|
||||
|
||||
Vue.component('summary-section', {
|
||||
inject: ['$validator'],
|
||||
props: ['active'],
|
||||
|
||||
data: function () {
|
||||
return {
|
||||
templateRender: null,
|
||||
|
||||
code: null,
|
||||
|
||||
coupon_used: false,
|
||||
|
||||
hide_discount: null,
|
||||
|
||||
error_message: '',
|
||||
|
||||
call_count: 0,
|
||||
}
|
||||
},
|
||||
|
||||
staticRenderFns: summaryTemplateRenderFns,
|
||||
|
||||
mounted: function () {
|
||||
this.hide_discount = this.active;
|
||||
|
||||
this.templateRender = summaryHtml.render;
|
||||
|
||||
for (var i in summaryHtml.staticRenderFns) {
|
||||
summaryTemplateRenderFns.push(summaryHtml.staticRenderFns[i]);
|
||||
}
|
||||
},
|
||||
|
||||
render: function (h) {
|
||||
return h('div', [
|
||||
(this.templateRender ?
|
||||
this.templateRender() :
|
||||
|
|
@ -510,12 +516,8 @@
|
|||
}).then(function(response) {
|
||||
this_this.coupon_used = true;
|
||||
|
||||
document.getElementById("discount-detail").style.display = "block";
|
||||
document.getElementById("discount-detail-discount-amount").innerHTML = response.data.result.formatted_discount;
|
||||
|
||||
document.getElementById("grand-total-amount-detail").innerHTML = response.data.result.grand_total;
|
||||
this_this.getOrderSummary();
|
||||
}).catch(function(error) {
|
||||
console.log(error.data);
|
||||
});
|
||||
},
|
||||
|
||||
|
|
@ -527,20 +529,24 @@
|
|||
this_this.coupon_used = false;
|
||||
|
||||
this_this.code = '';
|
||||
}).catch(function(error) {});
|
||||
},
|
||||
|
||||
console.log(response.data.data.grand_total);
|
||||
getOrderSummary () {
|
||||
var this_this = this;
|
||||
|
||||
document.getElementById("discount-detail").style.display = "none";
|
||||
this.$http.get("{{ route('shop.checkout.summary') }}")
|
||||
.then(function(response) {
|
||||
this_this.resetSummary = false;
|
||||
|
||||
document.getElementById("grand-total-amount-detail").innerHTML = response.data.data.grand_total;
|
||||
}).catch(function(error) {
|
||||
console.log(error.data);
|
||||
|
||||
this_this.error_message = '{{ __('shop::app.checkout.onepage.total.cannot-apply-coupon') }}'
|
||||
});
|
||||
}
|
||||
summaryHtml = Vue.compile(response.data.html)
|
||||
setTimeout(function() {
|
||||
this_this.resetSummary = true;
|
||||
}, 0);
|
||||
}).catch(function (error) {})
|
||||
},
|
||||
}
|
||||
});
|
||||
})
|
||||
</script>
|
||||
|
||||
@endpush
|
||||
|
|
@ -155,7 +155,8 @@
|
|||
</div>
|
||||
|
||||
<div class="pull-right" style="width: 40%; float: left;">
|
||||
@include('shop::checkout.total.summary', ['cart' => $cart])
|
||||
{{-- @include('shop::checkout.total.summary', ['cart' => $cart]) --}}
|
||||
<slot name="body"></slot>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
<div class="order-summary">
|
||||
<div class="order-summary" id="summary-template">
|
||||
<h3>{{ __('shop::app.checkout.total.order-summary') }}</h3>
|
||||
|
||||
<div class="item-detail">
|
||||
|
|
@ -35,7 +35,6 @@
|
|||
</label>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="payable-amount" id="grand-total-detail">
|
||||
<label>{{ __('shop::app.checkout.total.grand-total') }}</label>
|
||||
<label class="right" id="grand-total-amount-detail">
|
||||
|
|
@ -46,14 +45,13 @@
|
|||
<div @if (! request()->is('checkout/cart')) v-if="hide_discount" @endif>
|
||||
@if (! request()->is('checkout/cart'))
|
||||
<div class="discount">
|
||||
@{{ coupon_used }}
|
||||
<div class="discount-group" v-if="! coupon_used">
|
||||
<form class="coupon-form" method="post" @submit.prevent="onSubmit">
|
||||
<div class="control-group mt-20" :class="[errors.has('code') ? 'has-error' : '']">
|
||||
<input type="text" class="control" value="" v-model="code" name="code" placeholder="Enter Coupon Code" v-validate="'required'" style="width: 100%">
|
||||
</div>
|
||||
|
||||
<span class="control-error" v-if="error_message.length > 0">@{{ error_message }}</span>
|
||||
|
||||
<button class="btn btn-lg btn-black">{{ __('shop::app.checkout.onepage.apply-coupon') }}</button>
|
||||
</form>
|
||||
</div>
|
||||
|
|
@ -62,7 +60,12 @@
|
|||
<div class="discount-details-group" v-if="coupon_used">
|
||||
<div class="item-detail">
|
||||
<label>{{ __('shop::app.checkout.total.coupon-applied') }}</label>
|
||||
<label class="right" style="display: inline-flex; align-items: center;"><b>@{{ code }}</b><span class="icon cross-icon" title="{{ __('shop::app.checkout.total.remove-coupon') }}" v-on:click="removeCoupon"></span></label>
|
||||
|
||||
<label class="right" style="display: inline-flex; align-items: center;">
|
||||
<b>@{{ code }}</b>
|
||||
|
||||
<span class="icon cross-icon" title="{{ __('shop::app.checkout.total.remove-coupon') }}" v-on:click="removeCoupon"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@
|
|||
computed: {
|
||||
iconClass() {
|
||||
return {
|
||||
'accordian-down-icon': !this.isActive,
|
||||
'accordian-down-icon': ! this.isActive,
|
||||
'accordian-up-icon': this.isActive,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue