PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.7.0
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.7.0
1.7.0 1.6.6 1.6.5 1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 All 50 releases
← All changes | app/Hooks/Handlers/ShortCodes/Checkout/CheckoutPageHandler.php +17 -0 1.3.21 → 1.7.0 View file →
@@ -40,8 +40,17 @@
40 40 // this is a new cart. So we should fill the address id if any
41 41 $primaryBillingAddress = $currentCustomer->primary_billing_address;
42 42 if ($primaryBillingAddress) {
43 43 $formData['billing_address_id'] = $primaryBillingAddress->id;
44 + } else {
45 + // Case 3: no primary address — use the first available billing address
46 + $firstBillingAddress = $currentCustomer->billing_address()
47 + ->where('status', 'active')
48 + ->orderBy('id', 'ASC')
49 + ->first();
50 + if ($firstBillingAddress) {
51 + $formData['billing_address_id'] = $firstBillingAddress->id;
52 + }
44 53 }
45 54
46 55 if ($cart->isShipToDifferent()) {
47 56 $primaryShippingAddress = $currentCustomer->primary_shipping_address;
@@ -46,8 +55,16 @@
46 55 if ($cart->isShipToDifferent()) {
47 56 $primaryShippingAddress = $currentCustomer->primary_shipping_address;
48 57 if ($primaryShippingAddress) {
49 58 $formData['shipping_address_id'] = $primaryShippingAddress->id;
59 + } else {
60 + $firstShippingAddress = $currentCustomer->shipping_address()
61 + ->where('status', 'active')
62 + ->orderBy('id', 'ASC')
63 + ->first();
64 + if ($firstShippingAddress) {
65 + $formData['shipping_address_id'] = $firstShippingAddress->id;
66 + }
50 67 }
51 68 }
52 69 }
53 70