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 Webkul\Checkout\Models\CartShippingRate;
|
||||
use Webkul\Shipping\Facades\Shipping;
|
||||
use Webkul\Checkout\Facades\Cart;
|
||||
|
||||
/**
|
||||
* Class Rate.
|
||||
|
|
@ -29,6 +30,8 @@ class FlatRate extends AbstractShipping
|
|||
if(!$this->isAvailable())
|
||||
return false;
|
||||
|
||||
$cart = Cart::getCart();
|
||||
|
||||
$object = new CartShippingRate;
|
||||
|
||||
$object->carrier = 'flatrate';
|
||||
|
|
@ -36,8 +39,15 @@ class FlatRate extends AbstractShipping
|
|||
$object->method = 'flatrate_flatrate';
|
||||
$object->method_title = $this->getConfigData('title');
|
||||
$object->method_description = $this->getConfigData('description');
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,9 +74,9 @@ return [
|
|||
'options' => [
|
||||
[
|
||||
'title' => 'Per Unit',
|
||||
'value' => 'Per Order'
|
||||
'value' => 'per_unit'
|
||||
], [
|
||||
'title' => 'Inactive',
|
||||
'title' => 'Per Order',
|
||||
'value' => 'per_order'
|
||||
]
|
||||
],
|
||||
|
|
|
|||
Loading…
Reference in New Issue