cart responsive, Checkout from cart

This commit is contained in:
Kevin Adametz 2020-08-14 18:32:41 +02:00
parent bde1095014
commit fb27009339
17 changed files with 501 additions and 319 deletions

View file

@ -21,25 +21,26 @@ class Yard extends Cart
private $shipping_is_for;
private $ysession;
private $yinstance;
private $shopping_data = [];
public function __construct(SessionManager $session, Dispatcher $events)
{
$this->ysession = $session;
$this->yinstance = sprintf('%s.%s', 'cart', 'shipping_extras');
if($this->getShippingExtra('shipping_price')){
$this->shipping_price = (float) ($this->getShippingExtra('shipping_price'));
if($this->getYardExtra('shipping_price')){
$this->shipping_price = (float) ($this->getYardExtra('shipping_price'));
}
if($this->getShippingExtra('shipping_tax')){
$this->shipping_tax = (float) ($this->getShippingExtra('shipping_tax'));
if($this->getYardExtra('shipping_tax')){
$this->shipping_tax = (float) ($this->getYardExtra('shipping_tax'));
}
if($this->getShippingExtra('shipping_country_id')){
$this->shipping_country_id = $this->getShippingExtra('shipping_country_id');
if($this->getYardExtra('shipping_country_id')){
$this->shipping_country_id = $this->getYardExtra('shipping_country_id');
}
if($this->getShippingExtra('shipping_is_for')){
$this->shipping_is_for = $this->getShippingExtra('shipping_is_for');
if($this->getYardExtra('shipping_is_for')){
$this->shipping_is_for = $this->getYardExtra('shipping_is_for');
}
@ -62,14 +63,14 @@ class Yard extends Cart
return config('cart.tax');
}
public function putShippingExtra($key, $value){
public function putYardExtra($key, $value){
$content = $this->getYContent();
$content->put($key, $value);
$this->ysession->put($this->yinstance, $content);
}
public function getShippingExtra($key){
public function getYardExtra($key){
$content = $this->getYContent();
if ($content->has($key)){
return $content->get($key);
@ -116,10 +117,10 @@ class Yard extends Cart
public function setShippingCountryWithPrice($shipping_country_id, $shipping_is_for = 'ot')
{
$this->shipping_country_id = $shipping_country_id;
$this->putShippingExtra('shipping_country_id', $shipping_country_id);
$this->putYardExtra('shipping_country_id', $shipping_country_id);
$this->shipping_is_for = $shipping_is_for;
$this->putShippingExtra('shipping_is_for', $shipping_is_for);
$this->putYardExtra('shipping_is_for', $shipping_is_for);
$this->calculateShippingPrice();
@ -160,10 +161,10 @@ class Yard extends Cart
$this->shipping_price_net = round($price / ((100+$shipping_price->tax_rate) / 100), 2);
$this->shipping_tax = round($price / (100+$shipping_price->tax_rate) * 100, 2);
$this->putShippingExtra('shipping_price', $this->shipping_price);
$this->putShippingExtra('shipping_tax_rate', $this->shipping_tax_rate);
$this->putShippingExtra('shipping_tax', $this->shipping_tax);
$this->putShippingExtra('shipping_price_net', $this->shipping_price_net);
$this->putYardExtra('shipping_price', $this->shipping_price);
$this->putYardExtra('shipping_tax_rate', $this->shipping_tax_rate);
$this->putYardExtra('shipping_tax', $this->shipping_tax);
$this->putYardExtra('shipping_price_net', $this->shipping_price_net);
}
}