Per unit and per order feature added in Flatrate shipping
This commit is contained in:
parent
6b2b054f97
commit
de90ab1d6a
|
|
@ -5,6 +5,7 @@ namespace Webkul\Shipping\Carriers;
|
||||||
use Config;
|
use Config;
|
||||||
use Webkul\Checkout\Models\CartShippingRate;
|
use Webkul\Checkout\Models\CartShippingRate;
|
||||||
use Webkul\Shipping\Facades\Shipping;
|
use Webkul\Shipping\Facades\Shipping;
|
||||||
|
use Webkul\Checkout\Facades\Cart;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Rate.
|
* Class Rate.
|
||||||
|
|
@ -29,6 +30,8 @@ class FlatRate extends AbstractShipping
|
||||||
if(!$this->isAvailable())
|
if(!$this->isAvailable())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
$cart = Cart::getCart();
|
||||||
|
|
||||||
$object = new CartShippingRate;
|
$object = new CartShippingRate;
|
||||||
|
|
||||||
$object->carrier = 'flatrate';
|
$object->carrier = 'flatrate';
|
||||||
|
|
@ -36,8 +39,15 @@ class FlatRate extends AbstractShipping
|
||||||
$object->method = 'flatrate_flatrate';
|
$object->method = 'flatrate_flatrate';
|
||||||
$object->method_title = $this->getConfigData('title');
|
$object->method_title = $this->getConfigData('title');
|
||||||
$object->method_description = $this->getConfigData('description');
|
$object->method_description = $this->getConfigData('description');
|
||||||
$object->price = core()->convertPrice($this->getConfigData('default_rate'));
|
|
||||||
$object->base_price = $this->getConfigData('default_rate');
|
if ($this->getConfigData('type') == 'per_unit') {
|
||||||
|
$object->price = core()->convertPrice($this->getConfigData('default_rate')) * $cart->items_qty;
|
||||||
|
$object->base_price = $this->getConfigData('default_rate') * $cart->items_qty;
|
||||||
|
} else {
|
||||||
|
$object->price = core()->convertPrice($this->getConfigData('default_rate'));
|
||||||
|
$object->base_price = $this->getConfigData('default_rate');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return $object;
|
return $object;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -74,9 +74,9 @@ return [
|
||||||
'options' => [
|
'options' => [
|
||||||
[
|
[
|
||||||
'title' => 'Per Unit',
|
'title' => 'Per Unit',
|
||||||
'value' => 'Per Order'
|
'value' => 'per_unit'
|
||||||
], [
|
], [
|
||||||
'title' => 'Inactive',
|
'title' => 'Per Order',
|
||||||
'value' => 'per_order'
|
'value' => 'per_order'
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue