Abo Einmalprodukte und Bestätigung abschließen
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
2bdc9ada3c
commit
2269ce031f
57 changed files with 3647 additions and 371 deletions
|
|
@ -177,6 +177,34 @@ class Yard extends Cart
|
|||
$this->calculateShippingPrice();
|
||||
}
|
||||
|
||||
/**
|
||||
* Höchstes Versandgewicht (in Gramm) des aktuell gesetzten Versandlandes.
|
||||
* Ergibt sich aus der obersten Gewichtsstufe (max. weight_to). 0 = keine Begrenzung ermittelbar.
|
||||
*/
|
||||
public function getMaxWeight(): int
|
||||
{
|
||||
$shippingCountry = ShippingCountry::find($this->shipping_country_id);
|
||||
if (! $shippingCountry || ! $shippingCountry->shipping) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (int) $shippingCountry->shipping->shipping_prices->max('weight_to');
|
||||
}
|
||||
|
||||
/**
|
||||
* Prüft, ob das Warenkorbgewicht zzgl. des optionalen Zusatzgewichts das
|
||||
* Maximalgewicht des Versandlandes überschreiten würde.
|
||||
*/
|
||||
public function exceedsMaxWeight(int $additionalWeight = 0): bool
|
||||
{
|
||||
$maxWeight = $this->getMaxWeight();
|
||||
if ($maxWeight <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return ($this->weight() + $additionalWeight) > $maxWeight;
|
||||
}
|
||||
|
||||
public function setShippingCountryWithPrice($shipping_country_id, $shipping_is_for = 'ot-member')
|
||||
{
|
||||
$this->shipping_country_id = $shipping_country_id;
|
||||
|
|
@ -276,9 +304,10 @@ class Yard extends Cart
|
|||
// if(!$shipping_price){
|
||||
// }
|
||||
}
|
||||
// default
|
||||
// default: Über der höchsten Gewichtsstufe die teuerste (höchste) Stufe nehmen,
|
||||
// nicht die günstigste. Im Normalfall wird das Hinzufügen vorher gestoppt (siehe exceedsMaxWeight()).
|
||||
if (! $shipping_price) {
|
||||
$shipping_price = $shipping->shipping_prices->first();
|
||||
$shipping_price = $shipping->shipping_prices->sortByDesc('weight_to')->first();
|
||||
}
|
||||
}
|
||||
if ($shipping_price) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue