diff --git a/packages/Sarga/API/Http/Controllers/Checkout.php b/packages/Sarga/API/Http/Controllers/Checkout.php index abc986984..ce5126137 100644 --- a/packages/Sarga/API/Http/Controllers/Checkout.php +++ b/packages/Sarga/API/Http/Controllers/Checkout.php @@ -27,11 +27,9 @@ class Checkout extends CheckoutController ],400); } - Shipping::collectRates(); - $addresses = core()->getCurrentChannel()->inventory_sources()->get(); return response([ - 'rates' => CartShippingRateResource::collection(Shipping::getRates()), + 'shipping' => Shipping::getShippingMethods(), 'pickup_addresses' => PickupAddress::collection($addresses), ]); } diff --git a/packages/Sarga/Admin/src/Config/carriers.php b/packages/Sarga/Admin/src/Config/carriers.php index deba0d6a5..285a9d98f 100644 --- a/packages/Sarga/Admin/src/Config/carriers.php +++ b/packages/Sarga/Admin/src/Config/carriers.php @@ -7,7 +7,10 @@ return [ 'description' => 'Pickup from address', 'active' => true, 'is_calculate_tax' => false, - 'weight_price' => '40', + 'weight_price' => '20', + 'delivery_day_min' => '20', + 'delivery_day_max' => '25', + 'outlet_delivery' => '2', 'type' => 'per_unit', 'class' => 'Sarga\Admin\Shipment\Pickup', ], @@ -18,7 +21,10 @@ return [ 'description' => 'Courier Shipping', 'active' => true, 'is_calculate_tax' => false, - 'weight_price' => '40', + 'weight_price' => '20', + 'delivery_day_min' => '20', + 'delivery_day_max' => '25', + 'outlet_delivery' => '2', 'class' => 'Sarga\Admin\Shipment\Courier', ] ]; diff --git a/packages/Sarga/Admin/src/Config/system.php b/packages/Sarga/Admin/src/Config/system.php index 4d116e5f4..0434b83b5 100644 --- a/packages/Sarga/Admin/src/Config/system.php +++ b/packages/Sarga/Admin/src/Config/system.php @@ -34,6 +34,30 @@ return[ 'validation' => 'required_if:active,1', 'channel_based' => false, 'locale_based' => false, + ],[ + 'name' => 'delivery_day_min', + 'title' => 'Estimated delivery day min', + 'type' => 'depends', + 'depend' => 'active:1', + 'validation' => 'required_if:active,1', + 'channel_based' => false, + 'locale_based' => false, + ],[ + 'name' => 'delivery_day_max', + 'title' => 'Estimated delivery day max', + 'type' => 'depends', + 'depend' => 'active:1', + 'validation' => 'required_if:active,1', + 'channel_based' => false, + 'locale_based' => false, + ],[ + 'name' => 'outlet_delivery', + 'title' => 'Outlet delivery day', + 'type' => 'depends', + 'depend' => 'active:1', + 'validation' => 'required_if:active,1', + 'channel_based' => false, + 'locale_based' => false, ], [ 'name' => 'active', 'title' => 'admin::app.admin.system.status', @@ -78,6 +102,30 @@ return[ 'channel_based' => false, 'locale_based' => false, ], [ + 'name' => 'delivery_day_min', + 'title' => 'Estimated delivery day min', + 'type' => 'depends', + 'depend' => 'active:1', + 'validation' => 'required_if:active,1', + 'channel_based' => false, + 'locale_based' => false, + ],[ + 'name' => 'delivery_day_max', + 'title' => 'Estimated delivery day max', + 'type' => 'depends', + 'depend' => 'active:1', + 'validation' => 'required_if:active,1', + 'channel_based' => false, + 'locale_based' => false, + ],[ + 'name' => 'outlet_delivery', + 'title' => 'Outlet delivery day', + 'type' => 'depends', + 'depend' => 'active:1', + 'validation' => 'required_if:active,1', + 'channel_based' => false, + 'locale_based' => false, + ],[ 'name' => 'active', 'title' => 'admin::app.admin.system.status', 'type' => 'boolean', diff --git a/packages/Sarga/Admin/src/Shipment/Courier.php b/packages/Sarga/Admin/src/Shipment/Courier.php index af0ac2f0f..66bae855a 100644 --- a/packages/Sarga/Admin/src/Shipment/Courier.php +++ b/packages/Sarga/Admin/src/Shipment/Courier.php @@ -54,10 +54,11 @@ class Courier extends AbstractShipping if ($price = $this->getConfigData('weight_price')) { $total_weight = $cart->items->sum('total_weight'); - $cartShippingRate->price = core()->convertPrice($price * $total_weight,$cart->cart_currency_code); + $cartShippingRate->price = core()->convertPrice($price * $total_weight); $cartShippingRate->base_price = $price * $total_weight; } return $cartShippingRate; } + } \ No newline at end of file diff --git a/packages/Webkul/Shipping/src/Shipping.php b/packages/Webkul/Shipping/src/Shipping.php index c7baf59fb..93c52a348 100755 --- a/packages/Webkul/Shipping/src/Shipping.php +++ b/packages/Webkul/Shipping/src/Shipping.php @@ -14,9 +14,6 @@ class Shipping */ protected $rates = []; - public function getRates(){ - return $this->rates; - } /** * Collects rate from available shipping methods. * @@ -135,7 +132,12 @@ class Shipping 'code' => $object->getCode(), 'method' => $object->getMethod(), 'method_title' => $object->getTitle(), - 'description' => $object->getDescription() + 'description' => $object->getDescription(), + 'formatted_price' => core()->currency($object->getConfigData('weight_price')), + 'price' => core()->convertPrice($object->getConfigData('weight_price')), + 'outlet_delivery' => (double)$object->getConfigData('outlet_delivery'), + 'delivery_day_min' => (double)$object->getConfigData('delivery_day_min'), + 'delivery_day_max' => (double)$object->getConfigData('delivery_day_max'), ]; }