address while checkout & reduces code
This commit is contained in:
parent
d673b2a7b5
commit
36cb09bc58
|
|
@ -629,7 +629,7 @@ class Cart {
|
|||
$shippingAddress = $data['shipping'];
|
||||
$billingAddress['cart_id'] = $shippingAddress['cart_id'] = $cart->id;
|
||||
|
||||
if (isset($data['billing']['address_id'])) {
|
||||
if (isset($data['billing']['address_id']) && $data['billing']['address_id']) {
|
||||
$address = $this->customerAddress->findOneWhere(['id'=> $data['billing']['address_id']])->toArray();
|
||||
$billingAddress['first_name'] = auth()->guard('customer')->user()->first_name;
|
||||
$billingAddress['last_name'] = auth()->guard('customer')->user()->last_name;
|
||||
|
|
@ -643,7 +643,7 @@ class Cart {
|
|||
$billingAddress['phone'] = $address['phone'];
|
||||
}
|
||||
|
||||
if (isset($data['shipping']['address_id'])) {
|
||||
if (isset($data['shipping']['address_id']) && $data['shipping']['address_id']) {
|
||||
$address = $this->customerAddress->findOneWhere(['id'=> $data['shipping']['address_id']])->toArray();
|
||||
$shippingAddress['first_name'] = auth()->guard('customer')->user()->first_name;
|
||||
$shippingAddress['last_name'] = auth()->guard('customer')->user()->last_name;
|
||||
|
|
@ -657,11 +657,15 @@ class Cart {
|
|||
$shippingAddress['phone'] = $address['phone'];
|
||||
}
|
||||
|
||||
// if (auth()->guard('customer')->check()) {
|
||||
// if ($data['billing']['use_for_shipping'] == true) {
|
||||
// $shippingAddress = $billingAddress;
|
||||
// }
|
||||
// }
|
||||
if (isset($data['billing']['save_as_address']) && $data['billing']['save_as_address']) {
|
||||
$billingAddress['customer_id'] = auth()->guard('customer')->user()->id;
|
||||
$this->customerAddress->create($billingAddress);
|
||||
}
|
||||
|
||||
if (isset($data['shipping']['save_as_address']) && $data['shipping']['save_as_address']) {
|
||||
$shippingAddress['customer_id'] = auth()->guard('customer')->user()->id;
|
||||
$this->customerAddress->create($shippingAddress);
|
||||
}
|
||||
|
||||
if ($billingAddressModel = $cart->billing_address) {
|
||||
$this->cartAddress->update($billingAddress, $billingAddressModel->id);
|
||||
|
|
|
|||
|
|
@ -2493,6 +2493,24 @@ section.cart {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
.address-holder {
|
||||
justify-content: space-between;
|
||||
|
||||
.address-card-1 {
|
||||
margin-right: 0px !important;
|
||||
width: 253px !important;
|
||||
|
||||
.details {
|
||||
margin-left: 30px;
|
||||
|
||||
.checkmark {
|
||||
left: -30px;
|
||||
top: 12px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// complete page end here
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -422,7 +422,8 @@ return [
|
|||
'shipping-address' => 'Shipping Address',
|
||||
'contact' => 'Contact',
|
||||
'place-order' => 'Place Order',
|
||||
'new-address' => 'Add New Address'
|
||||
'new-address' => 'Add New Address',
|
||||
'save_as_address' => 'Save as Address'
|
||||
],
|
||||
|
||||
'total' => [
|
||||
|
|
|
|||
|
|
@ -117,6 +117,16 @@
|
|||
var paymentHtml = '';
|
||||
var reviewHtml = '';
|
||||
var summaryHtml = Vue.compile(`<?php echo view('shop::checkout.total.summary', ['cart' => $cart])->render(); ?>`);
|
||||
var customerAddress = null;
|
||||
|
||||
@auth('customer')
|
||||
@if(auth('customer')->user()->addresses)
|
||||
customerAddress = @json(auth('customer')->user()->addresses);
|
||||
customerAddress.email = "{{ auth('customer')->user()->email }}";
|
||||
customerAddress.first_name = "{{ auth('customer')->user()->first_name }}";
|
||||
customerAddress.last_name = "{{ auth('customer')->user()->last_name }}";
|
||||
@endif
|
||||
@endauth
|
||||
|
||||
Vue.component('checkout', {
|
||||
|
||||
|
|
@ -147,9 +157,37 @@
|
|||
|
||||
new_billing_address: false,
|
||||
|
||||
countryStates: @json(core()->groupedStatesByCountries())
|
||||
allAddress: {},
|
||||
|
||||
countryStates: @json(core()->groupedStatesByCountries()),
|
||||
|
||||
country: @json(core()->countries())
|
||||
}),
|
||||
|
||||
created() {
|
||||
if(!customerAddress) {
|
||||
this.new_shipping_address = true;
|
||||
this.new_billing_address = true;
|
||||
} else {
|
||||
if (customerAddress.length < 1) {
|
||||
this.new_shipping_address = true;
|
||||
this.new_billing_address = true;
|
||||
} else {
|
||||
this.allAddress = customerAddress;
|
||||
|
||||
for (var country in this.country) {
|
||||
for (var code in this.allAddress) {
|
||||
if (this.allAddress[code].country) {
|
||||
if (this.allAddress[code].country == this.country[country].code) {
|
||||
this.allAddress[code]['country'] = this.country[country].name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
navigateToStep (step) {
|
||||
if (step <= this.completedStep) {
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue