From af3249c8e05c62aaf899a73b76eb17521708a586 Mon Sep 17 00:00:00 2001 From: merdan Date: Tue, 10 Jan 2023 21:57:05 +0500 Subject: [PATCH] order --- packages/Sarga/Admin/src/Config/carriers.php | 6 +- packages/Sarga/Admin/src/Config/system.php | 2 +- packages/Sarga/Admin/src/Shipment/Flight.php | 68 ++++++++++++++++++++ 3 files changed, 72 insertions(+), 4 deletions(-) create mode 100644 packages/Sarga/Admin/src/Shipment/Flight.php diff --git a/packages/Sarga/Admin/src/Config/carriers.php b/packages/Sarga/Admin/src/Config/carriers.php index 63011a93b..d0fd14989 100644 --- a/packages/Sarga/Admin/src/Config/carriers.php +++ b/packages/Sarga/Admin/src/Config/carriers.php @@ -28,8 +28,8 @@ return [ 'class' => 'Sarga\Admin\Shipment\Courier', ], - 'fly' => [ - 'code' => 'fly', + 'flight' => [ + 'code' => 'flight', 'title' => 'Flight', 'description' => 'Flight Shipping', 'active' => false, @@ -38,6 +38,6 @@ return [ 'delivery_day_min' => '20', 'delivery_day_max' => '25', 'outlet_delivery' => '2', - 'class' => 'Sarga\Admin\Shipment\Courier', + 'class' => 'Sarga\Admin\Shipment\Flight', ] ]; diff --git a/packages/Sarga/Admin/src/Config/system.php b/packages/Sarga/Admin/src/Config/system.php index 1c96d4078..70e25f8ec 100644 --- a/packages/Sarga/Admin/src/Config/system.php +++ b/packages/Sarga/Admin/src/Config/system.php @@ -75,7 +75,7 @@ return[ ], ], ],[ - 'key' => 'sales.carriers.fly', + 'key' => 'sales.carriers.flight', 'name' => 'Flight', 'sort' => 4, 'fields' => [ diff --git a/packages/Sarga/Admin/src/Shipment/Flight.php b/packages/Sarga/Admin/src/Shipment/Flight.php new file mode 100644 index 000000000..4fb3ea1e4 --- /dev/null +++ b/packages/Sarga/Admin/src/Shipment/Flight.php @@ -0,0 +1,68 @@ +isAvailable()) { + return false; + } + + return $this->getRate(); + } + + /** + * Get rate. + * + * @return \Webkul\Checkout\Models\CartShippingRate + */ + public function getRate(): \Webkul\Checkout\Models\CartShippingRate + { + $cartShippingRate = new CartShippingRate; + + $cartShippingRate->carrier = $this->getCode(); + $cartShippingRate->carrier_title = $this->getConfigData('title'); + $cartShippingRate->method = $this->getMethod(); + $cartShippingRate->method_title = $this->getConfigData('title'); + $cartShippingRate->method_description = $this->getConfigData('description'); + $cartShippingRate->is_calculate_tax = $this->getConfigData('is_calculate_tax'); + $cartShippingRate->price = 0; + $cartShippingRate->base_price = 0; + + $cart = Cart::getCart(); + + if ($price = $this->getConfigData('weight_price')) { + $total_weight = $cart->items->sum('total_weight'); + $cartShippingRate->price = core()->convertPrice($price * $total_weight); + $cartShippingRate->base_price = $price * $total_weight; + } + + return $cartShippingRate; + } + + public function estimatedDelivery($date){ + return $date->addDays($this->getConfigData('delivery_day_max'))->format('d.m.Y'); + } +} \ No newline at end of file