diff --git a/packages/Webkul/Checkout/src/Cart.php b/packages/Webkul/Checkout/src/Cart.php index e1c38b55b..f75e35d75 100755 --- a/packages/Webkul/Checkout/src/Cart.php +++ b/packages/Webkul/Checkout/src/Cart.php @@ -2,6 +2,7 @@ namespace Webkul\Checkout; +use Webkul\Checkout\Models\CartAddress; use Webkul\Checkout\Repositories\CartRepository; use Webkul\Checkout\Repositories\CartItemRepository; use Webkul\Checkout\Repositories\CartAddressRepository; @@ -1094,12 +1095,13 @@ class Cart { $attributes = []; - $attributes['address1'] = $addressAttributes['address1'] ?? ''; - $attributes['country'] = $addressAttributes['country'] ?? ''; - $attributes['state'] = $addressAttributes['state'] ?? ''; - $attributes['city'] = $addressAttributes['city'] ?? ''; - $attributes['postcode'] = $addressAttributes['postcode'] ?? ''; - $attributes['phone'] = $addressAttributes['phone'] ?? ''; + $cartAddress = new CartAddress(); + + foreach ($cartAddress->getFillable() as $attribute) { + if (isset($addressAttributes[$attribute])) { + $attributes[$attribute] = $addressAttributes[$attribute]; + } + } return $attributes; } @@ -1149,6 +1151,7 @@ class Cart $this->fillAddressAttributes($data['billing']) ); + return $billingAddress; } diff --git a/tests/functional/Checkout/Order/OrderCest.php b/tests/functional/Checkout/Order/OrderCest.php index 9402bee18..2cf903895 100644 --- a/tests/functional/Checkout/Order/OrderCest.php +++ b/tests/functional/Checkout/Order/OrderCest.php @@ -66,11 +66,6 @@ class OrderCest $I->seeResponseCodeIsSuccessful(); - // assert with the data from the customer model: - $addressData['first_name'] = $mocks['customer']->first_name; - $addressData['last_name'] = $mocks['customer']->last_name; - $addressData['email'] = $mocks['customer']->email; - $I->seeRecord(CartAddress::class, array_merge($addressData, [ 'address_type' => 'shipping', 'cart_id' => $mocks['cart']->id,