chg: use rich address partial in checkout with add/delete support
Replaces the simple address radio list in the checkout page with the richer ``Shop.Customers.partials.addresses`` partial already used on the profile edit page. Customers can now choose among existing addresses, add a new one on-the-fly, or delete an address directly from the checkout flow.
This commit is contained in:
@@ -245,6 +245,7 @@ class CustomerController extends Controller
|
||||
$html = view('Shop.Customers.partials.address_item', [
|
||||
'address' => $address->toArray(),
|
||||
'prefix' => $prefix,
|
||||
'inputName' => $request->input('input_name'),
|
||||
'with_name' => true,
|
||||
'selected' => $address->id,
|
||||
])->render();
|
||||
|
||||
@@ -9,6 +9,7 @@ use App\Repositories\Core\User\ShopCart;
|
||||
use App\Repositories\Shop\Baskets;
|
||||
use App\Repositories\Shop\Contents;
|
||||
use App\Repositories\Shop\Customers;
|
||||
use App\Repositories\Shop\CustomerAddresses;
|
||||
use App\Repositories\Shop\Deliveries;
|
||||
use App\Repositories\Shop\DeliveryTypes;
|
||||
use App\Repositories\Shop\OrderMails;
|
||||
@@ -57,8 +58,21 @@ class OrderController extends Controller
|
||||
$deliveries = $deliveries ? $deliveries->values() : collect();
|
||||
|
||||
$customerData = $customer ? $customer->toArray() : false;
|
||||
if ($customerData && $defaultSaleChannelId) {
|
||||
$customerData['default_sale_channel_id'] = $defaultSaleChannelId;
|
||||
if ($customerData) {
|
||||
$customerData['delivery_address_id'] = optional(CustomerAddresses::getDeliveryAddress($customerId))->id;
|
||||
$customerData['invoice_address_id'] = optional(CustomerAddresses::getInvoiceAddress($customerId))->id;
|
||||
|
||||
if (! $customerData['delivery_address_id'] && ! empty($customerData['delivery_addresses'])) {
|
||||
$customerData['delivery_address_id'] = $customerData['delivery_addresses'][0]['id'] ?? null;
|
||||
}
|
||||
|
||||
if (! $customerData['invoice_address_id'] && ! empty($customerData['invoice_addresses'])) {
|
||||
$customerData['invoice_address_id'] = $customerData['invoice_addresses'][0]['id'] ?? null;
|
||||
}
|
||||
|
||||
if ($defaultSaleChannelId) {
|
||||
$customerData['default_sale_channel_id'] = $defaultSaleChannelId;
|
||||
}
|
||||
}
|
||||
|
||||
$data = [
|
||||
|
||||
Reference in New Issue
Block a user