fill in correct address attributes

This commit is contained in:
Herbert Maschke 2020-03-05 16:16:17 +01:00
parent 7c634046db
commit e40d3ec619
2 changed files with 9 additions and 11 deletions

View File

@ -2,6 +2,7 @@
namespace Webkul\Checkout; namespace Webkul\Checkout;
use Webkul\Checkout\Models\CartAddress;
use Webkul\Checkout\Repositories\CartRepository; use Webkul\Checkout\Repositories\CartRepository;
use Webkul\Checkout\Repositories\CartItemRepository; use Webkul\Checkout\Repositories\CartItemRepository;
use Webkul\Checkout\Repositories\CartAddressRepository; use Webkul\Checkout\Repositories\CartAddressRepository;
@ -1094,12 +1095,13 @@ class Cart
{ {
$attributes = []; $attributes = [];
$attributes['address1'] = $addressAttributes['address1'] ?? ''; $cartAddress = new CartAddress();
$attributes['country'] = $addressAttributes['country'] ?? '';
$attributes['state'] = $addressAttributes['state'] ?? ''; foreach ($cartAddress->getFillable() as $attribute) {
$attributes['city'] = $addressAttributes['city'] ?? ''; if (isset($addressAttributes[$attribute])) {
$attributes['postcode'] = $addressAttributes['postcode'] ?? ''; $attributes[$attribute] = $addressAttributes[$attribute];
$attributes['phone'] = $addressAttributes['phone'] ?? ''; }
}
return $attributes; return $attributes;
} }
@ -1149,6 +1151,7 @@ class Cart
$this->fillAddressAttributes($data['billing']) $this->fillAddressAttributes($data['billing'])
); );
return $billingAddress; return $billingAddress;
} }

View File

@ -66,11 +66,6 @@ class OrderCest
$I->seeResponseCodeIsSuccessful(); $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, [ $I->seeRecord(CartAddress::class, array_merge($addressData, [
'address_type' => 'shipping', 'address_type' => 'shipping',
'cart_id' => $mocks['cart']->id, 'cart_id' => $mocks['cart']->id,