From 95dfe3f8d0132e429b48a8ac0cb31a2941467d11 Mon Sep 17 00:00:00 2001 From: Herbert Maschke Date: Wed, 26 Feb 2020 07:37:17 +0100 Subject: [PATCH] propagate the company_name and vat_id from address through cart to order addresses --- packages/Webkul/Checkout/src/Cart.php | 2 +- .../Checkout/src/Models/CartAddress.php | 16 ++++++- ...20_02_25_181902_propagate_company_name.php | 45 +++++++++++++++++++ .../Webkul/Sales/src/Models/OrderAddress.php | 18 ++++++++ 4 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 packages/Webkul/Customer/src/Database/Migrations/2020_02_25_181902_propagate_company_name.php diff --git a/packages/Webkul/Checkout/src/Cart.php b/packages/Webkul/Checkout/src/Cart.php index 7b125b01a..96582b4e9 100755 --- a/packages/Webkul/Checkout/src/Cart.php +++ b/packages/Webkul/Checkout/src/Cart.php @@ -212,7 +212,7 @@ class Cart 'items_count' => 1, ]; - //Authentication details + // Fill in the customer data, as far as possible: if ($this->getCurrentCustomer()->check()) { $cartData['customer_id'] = $this->getCurrentCustomer()->user()->id; $cartData['is_guest'] = 0; diff --git a/packages/Webkul/Checkout/src/Models/CartAddress.php b/packages/Webkul/Checkout/src/Models/CartAddress.php index 1434b838c..737632589 100755 --- a/packages/Webkul/Checkout/src/Models/CartAddress.php +++ b/packages/Webkul/Checkout/src/Models/CartAddress.php @@ -9,7 +9,21 @@ class CartAddress extends Model implements CartAddressContract { protected $table = 'cart_address'; - protected $fillable = ['first_name', 'last_name', 'email', 'address1', 'city', 'state', 'postcode', 'country', 'phone', 'address_type', 'cart_id']; + protected $fillable = [ + 'first_name', + 'last_name', + 'email', + 'company_name', + 'vat_id', + 'address1', + 'city', + 'state', + 'postcode', + 'country', + 'phone', + 'address_type', + 'cart_id', + ]; /** * Get the shipping rates for the cart address. diff --git a/packages/Webkul/Customer/src/Database/Migrations/2020_02_25_181902_propagate_company_name.php b/packages/Webkul/Customer/src/Database/Migrations/2020_02_25_181902_propagate_company_name.php new file mode 100644 index 000000000..a7064a0d3 --- /dev/null +++ b/packages/Webkul/Customer/src/Database/Migrations/2020_02_25_181902_propagate_company_name.php @@ -0,0 +1,45 @@ +string('company_name')->nullable()->after('email'); + $table->string('vat_id')->nullable()->after('company_name'); + + }); + + Schema::table('order_address', function (Blueprint $table) { + $table->string('company_name')->nullable()->after('email'); + $table->string('vat_id')->nullable()->after('company_name'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('cart_address', function (Blueprint $table) { + $table->dropColumn('company_name'); + $table->dropColumn('vat_id'); + }); + + Schema::table('order_address', function (Blueprint $table) { + $table->dropColumn('company_name'); + $table->dropColumn('vat_id'); + }); + } +} diff --git a/packages/Webkul/Sales/src/Models/OrderAddress.php b/packages/Webkul/Sales/src/Models/OrderAddress.php index 827e499a9..0b5f5b89c 100755 --- a/packages/Webkul/Sales/src/Models/OrderAddress.php +++ b/packages/Webkul/Sales/src/Models/OrderAddress.php @@ -11,6 +11,24 @@ class OrderAddress extends Model implements OrderAddressContract protected $guarded = ['id', 'created_at', 'updated_at']; + protected $fillable = [ + 'first_name', + 'last_name', + 'email', + 'company_name', + 'vat_id', + 'address1', + 'address2', + 'city', + 'state', + 'postcode', + 'country', + 'phone', + 'address_type', + 'cart_id', + 'customer_id', + ]; + /** * Get of the customer fullname. */