This commit is contained in:
Kevin Adametz 2024-08-05 12:05:24 +02:00
parent 04d677d37a
commit bfa3bb1df4
1191 changed files with 637397 additions and 10619 deletions

View file

@ -1,6 +1,7 @@
<?php
namespace App\Services;
use App\Services\Shop;
use App\Models\Country;
use App\Models\Product;
use App\Models\ShippingCountry;
@ -136,6 +137,12 @@ class Yard extends Cart
}
public function getShippingPrice()
{
return $this->shipping_price;
}
public function getYContent()
{
if (is_null($this->ysession->get($this->yinstance))) {
@ -149,7 +156,7 @@ class Yard extends Cart
$this->calculateShippingPrice();
}
public function setShippingCountryWithPrice($shipping_country_id, $shipping_is_for = 'ot')
public function setShippingCountryWithPrice($shipping_country_id, $shipping_is_for = 'ot-member')
{
$this->shipping_country_id = $shipping_country_id;
$this->putYardExtra('shipping_country_id', $shipping_country_id);
@ -208,6 +215,15 @@ class Yard extends Cart
return $this->shipping_free;
}
public function getShippingFreeMissingValue()
{
if($this->shipping_free && $this->total(2, '.', '') < $this->shipping_free){
return $this->shipping_free - $this->total(2, '.', '');
}
return 0;
}
private function calculateShippingPrice(){
$shippingCountry = ShippingCountry::find($this->shipping_country_id);
@ -246,8 +262,8 @@ class Yard extends Cart
}
if($shipping_price){
$price = $shipping_price->price;
$this->num_comp = 0;
if($this->shipping_is_for === 'me'){
$this->num_comp = 0; //compensation is checked in Settings
if(Shop::isCompProducts($this->shipping_is_for)){
$price = $shipping_price->price_comp;
$this->num_comp = $shipping_price->num_comp;