From 7534ef4b8146c3d260b311e882024b806ea003f4 Mon Sep 17 00:00:00 2001 From: merdan Date: Wed, 9 Mar 2022 13:51:07 +0500 Subject: [PATCH] fixing pickup --- packages/Sarga/Shop/src/ShoppingCart.php | 77 ------------------------ packages/Webkul/Checkout/src/Cart.php | 8 +-- 2 files changed, 4 insertions(+), 81 deletions(-) diff --git a/packages/Sarga/Shop/src/ShoppingCart.php b/packages/Sarga/Shop/src/ShoppingCart.php index 017f2bb96..44e5ec1a4 100644 --- a/packages/Sarga/Shop/src/ShoppingCart.php +++ b/packages/Sarga/Shop/src/ShoppingCart.php @@ -8,81 +8,4 @@ use Webkul\Checkout\Models\CartAddress; class ShoppingCart extends \Webkul\Checkout\Cart { - public function saveAddress($address, $shipment) : bool - { - if (! $cart = $this->getCart()) { - return false; - } - - if($shipment !== 'pickup_pickup'){ - $this->saveMusteriAddress($address,$cart); - } - else - $this->saveRecipientAddress($address,$cart); - - $this->assignCustomerFields($cart); - - return $cart->save(); - } - - /** - * Save customer address. - * - * @param array $data - * @return bool - * @throws \Prettus\Validator\Exceptions\ValidatorException - */ - private function saveMusteriAddress($data,$cart) - { - $billingAddressData = $this->gatherBillingAddress($data, $cart); - - $shippingAddressData = $this->gatherShippingAddress($data, $cart); - - $this->linkAddresses($cart, $billingAddressData, $shippingAddressData); - - } - - public function saveRecipientAddress($data,$cart) - { - - $recipientAddressRepository = app(RecipientRepository::class); - - $customerAddress = []; - - if (isset($data['billing']['address_id']) && $data['billing']['address_id']) - { - $customerAddress = $recipientAddressRepository->findOneWhere(['id' => $data['billing']['address_id']]) - ->toArray(); - } - - $billingAddress = array_merge( - $customerAddress, - $data['billing'], - ['cart_id' => $cart->id, 'customer_id' => $cart->customer_id], - $this->fillAddressAttributes($data['billing']) - ); - - $this->linkAddresses($cart,$billingAddress,$billingAddress); - - } - - /** - * Fill address attributes. - * - * @return array - */ - private function fillAddressAttributes(array $addressAttributes): array - { - $attributes = []; - - $cartAddress = new CartAddress(); - - foreach ($cartAddress->getFillable() as $attribute) { - if (isset($addressAttributes[$attribute])) { - $attributes[$attribute] = $addressAttributes[$attribute]; - } - } - - return $attributes; - } } \ No newline at end of file diff --git a/packages/Webkul/Checkout/src/Cart.php b/packages/Webkul/Checkout/src/Cart.php index 4d0de503c..8c41957cd 100755 --- a/packages/Webkul/Checkout/src/Cart.php +++ b/packages/Webkul/Checkout/src/Cart.php @@ -786,7 +786,7 @@ class Cart * * @param \Webkul\Checkout\Contracts\Cart $cart */ - public function assignCustomerFields(\Webkul\Checkout\Contracts\Cart $cart): void + private function assignCustomerFields(\Webkul\Checkout\Contracts\Cart $cart): void { if ( auth()->guard()->check() @@ -923,7 +923,7 @@ class Cart * @param $cart * @return array */ - public function gatherBillingAddress($data, \Webkul\Checkout\Models\Cart $cart): array + private function gatherBillingAddress($data, \Webkul\Checkout\Models\Cart $cart): array { $customerAddress = []; @@ -952,7 +952,7 @@ class Cart * @param \Webkul\Checkout\Cart|null $cart * @return array */ - public function gatherShippingAddress($data, \Webkul\Checkout\Models\Cart $cart): array + private function gatherShippingAddress($data, \Webkul\Checkout\Models\Cart $cart): array { $customerAddress = []; @@ -982,7 +982,7 @@ class Cart * @param array $shippingAddressData * @throws \Prettus\Validator\Exceptions\ValidatorException */ - public function linkAddresses( + private function linkAddresses( \Webkul\Checkout\Models\Cart $cart, array $billingAddressData, array $shippingAddressData