shipping costs
This commit is contained in:
parent
d4f6a774d0
commit
22a2b4710a
20 changed files with 797 additions and 457 deletions
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\ShippingCountry;
|
||||
use \Gloudemans\Shoppingcart\Cart;
|
||||
use Gloudemans\Shoppingcart\CartItem;
|
||||
use Illuminate\Session\SessionManager;
|
||||
|
|
@ -11,6 +12,7 @@ class Yard extends Cart
|
|||
{
|
||||
|
||||
private $shipping = 0;
|
||||
private $shipping_country_id = 0;
|
||||
|
||||
public function __construct(SessionManager $session, Dispatcher $events)
|
||||
{
|
||||
|
|
@ -33,6 +35,24 @@ class Yard extends Cart
|
|||
|
||||
}
|
||||
|
||||
public function setShippingCountry($shipping_country_id)
|
||||
{
|
||||
$this->shipping_country_id = $shipping_country_id ;
|
||||
if($this->shipping_country_id > 0){
|
||||
$shippingCountry = ShippingCountry::find($this->shipping_country_id);
|
||||
$shipping = $shippingCountry->shipping;
|
||||
$price = $shipping->prices->first();
|
||||
if($price){
|
||||
$this->setShipping($price->price);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getShippingCountry()
|
||||
{
|
||||
return $this->shipping_country_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $decimals
|
||||
* @param null $decimalPoint
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue