order
This commit is contained in:
parent
9a01fa714c
commit
af3249c8e0
|
|
@ -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',
|
||||
]
|
||||
];
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ return[
|
|||
],
|
||||
],
|
||||
],[
|
||||
'key' => 'sales.carriers.fly',
|
||||
'key' => 'sales.carriers.flight',
|
||||
'name' => 'Flight',
|
||||
'sort' => 4,
|
||||
'fields' => [
|
||||
|
|
|
|||
|
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
|
||||
namespace Sarga\Admin\Shipment;
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Webkul\Checkout\Facades\Cart;
|
||||
use Webkul\Checkout\Models\CartShippingRate;
|
||||
use Webkul\Shipping\Carriers\AbstractShipping;
|
||||
|
||||
class Flight extends AbstractShipping
|
||||
{
|
||||
/**
|
||||
* Shipping method carrier code.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $code = 'flight';
|
||||
|
||||
/**
|
||||
* Shipping method code.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $method = 'flight_flight';
|
||||
|
||||
public function calculate()
|
||||
{
|
||||
if (! $this->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');
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue