add shipping rules

This commit is contained in:
Ludovic CANDELLIER
2023-07-16 14:45:42 +02:00
parent 72a7b270f9
commit 0879b0abf0
459 changed files with 6219 additions and 5416 deletions

View File

@@ -9,10 +9,11 @@ class Baskets
{
public static function addBasket($offer_id, $quantity = 1, $update = false)
{
if (ShopCart::has($offer_id) && !$quantity) {
if (ShopCart::has($offer_id) && ! $quantity) {
$ret = ShopCart::remove($offer_id);
}
$data = $quantity ? self::getBasketData($offer_id, $quantity) : false;
return $data ? ShopCart::add($data, $update) : false;
}
@@ -28,7 +29,7 @@ class Baskets
$prices = Offers::getPrice($item->id, $item->quantity, $sale_channel_id);
$detail[] = [
'offer_id' => (int) $item->id,
'name' => $offer->article->name . ' (' . $offer->variation->name . ')',
'name' => $offer->article->name.' ('.$offer->variation->name.')',
'quantity' => (int) $item->quantity,
'price' => (float) $prices->price,
'tax' => $prices->price_taxed - $prices->price,
@@ -48,6 +49,7 @@ class Baskets
'shipping' => $shipping,
'total_shipped' => $total_taxed + $shipping,
];
return $data ?? false;
}
@@ -68,7 +70,7 @@ class Baskets
'article.image',
'price_lists.price_list_values',
])->withPriceListsBySaleChannel($sale_channel_id)
->whereIn('id', ShopCart::keys())->get();
->whereIn('id', ShopCart::keys())->get();
foreach ($basket as $item) {
$offer = $offers->where('id', $item->id)->first();
$article_nature = strtolower($offer->article->article_nature->name);
@@ -82,12 +84,14 @@ class Baskets
'latin' => $offer->article->product->specie->latin ?? false,
];
}
return $data ?? false;
}
public static function getBasketData($id, $quantity = 1)
{
$offer = Offers::get($id, ['article', 'variation']);
return [
'id' => $id,
'name' => self::getArticleName($offer),