2018-09-13 11:10:45 +00:00
|
|
|
<?php
|
|
|
|
|
|
2018-09-19 06:58:15 +00:00
|
|
|
namespace Webkul\Shipping\Carriers;
|
2018-09-13 11:10:45 +00:00
|
|
|
|
|
|
|
|
use Config;
|
2018-09-26 04:21:14 +00:00
|
|
|
use Webkul\Cart\Models\CartShippingRate;
|
2018-09-21 10:17:01 +00:00
|
|
|
use Webkul\Shipping\Facades\Shipping;
|
2018-09-13 11:10:45 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class Rate.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
class FlatRate extends AbstractShipping
|
|
|
|
|
{
|
2018-09-20 10:01:51 +00:00
|
|
|
/**
|
|
|
|
|
* Payment method code
|
|
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
|
|
|
|
protected $code = 'flatrate';
|
|
|
|
|
|
2018-09-26 04:21:14 +00:00
|
|
|
/**
|
|
|
|
|
* Returns rate for flatrate
|
|
|
|
|
*
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
2018-09-13 11:10:45 +00:00
|
|
|
public function calculate()
|
|
|
|
|
{
|
2018-09-21 10:17:01 +00:00
|
|
|
if(!$this->isAvailable())
|
|
|
|
|
return false;
|
|
|
|
|
|
2018-09-26 04:21:14 +00:00
|
|
|
$object = new CartShippingRate;
|
2018-09-20 10:01:51 +00:00
|
|
|
|
2018-09-21 10:17:01 +00:00
|
|
|
$object->carrier = 'flatrate';
|
|
|
|
|
$object->carrier_title = $this->getConfigData('title');
|
|
|
|
|
$object->method = 'flatrate_flatrate';
|
2018-09-20 10:01:51 +00:00
|
|
|
$object->method_title = $this->getConfigData('title');
|
|
|
|
|
$object->method_description = $this->getConfigData('description');
|
2018-09-26 10:19:18 +00:00
|
|
|
$object->price = core()->convertPrice($this->getConfigData('default_rate'));
|
|
|
|
|
$object->base_price = $this->getConfigData('default_rate');
|
2018-09-20 10:01:51 +00:00
|
|
|
|
2018-09-21 10:17:01 +00:00
|
|
|
return $object;
|
2018-09-13 11:10:45 +00:00
|
|
|
}
|
|
|
|
|
}
|