first upload all files
This commit is contained in:
59
Modules/Shipping/Providers/ShippingServiceProvider.php
Normal file
59
Modules/Shipping/Providers/ShippingServiceProvider.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Shipping\Providers;
|
||||
|
||||
use Modules\Shipping\Method;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Modules\Shipping\Facades\ShippingMethod;
|
||||
|
||||
class ShippingServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap the application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
if (! config('app.installed')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->registerFreeShipping();
|
||||
$this->registerLocalPickup();
|
||||
$this->registerFlatRate();
|
||||
}
|
||||
|
||||
private function registerFreeShipping()
|
||||
{
|
||||
if (! setting('free_shipping_enabled')) {
|
||||
return;
|
||||
}
|
||||
|
||||
ShippingMethod::register('free_shipping', function () {
|
||||
return new Method('free_shipping', setting('free_shipping_label'), 0);
|
||||
});
|
||||
}
|
||||
|
||||
private function registerLocalPickup()
|
||||
{
|
||||
if (! setting('local_pickup_enabled')) {
|
||||
return;
|
||||
}
|
||||
|
||||
ShippingMethod::register('local_pickup', function () {
|
||||
return new Method('local_pickup', setting('local_pickup_label'), setting('local_pickup_cost'));
|
||||
});
|
||||
}
|
||||
|
||||
private function registerFlatRate()
|
||||
{
|
||||
if (! setting('flat_rate_enabled')) {
|
||||
return;
|
||||
}
|
||||
|
||||
ShippingMethod::register('flat_rate', function () {
|
||||
return new Method('flat_rate', setting('flat_rate_label'), setting('flat_rate_cost'));
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user