add shipping rules
This commit is contained in:
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user