restart
This commit is contained in:
@@ -16,39 +16,44 @@ class Baskets
|
||||
return $data ? ShopCart::add($data, $update) : false;
|
||||
}
|
||||
|
||||
public static function getBasketSummary()
|
||||
public static function getBasketSummary($sale_channel_id = false)
|
||||
{
|
||||
$basket = ShopCart::getContent();
|
||||
$offers = Offer::with('variation')->whereIn('id', ShopCart::keys())->get();
|
||||
$total = 0;
|
||||
$total_taxed = 0;
|
||||
$shipping = 5;
|
||||
foreach ($basket as $item) {
|
||||
$offer = $offers->where('id', $item->id)->first();
|
||||
$prices = Offers::getPrice($item->id, $item->quantity, $sale_channel_id);
|
||||
$detail[] = [
|
||||
'id' => (int) $item->id,
|
||||
'offer_id' => (int) $item->id,
|
||||
'name' => $offer->article->name . ' (' . $offer->variation->name . ')',
|
||||
'quantity' => (int) $item->quantity,
|
||||
'price' => $item->price,
|
||||
'tax' => '',
|
||||
'price_taxed' => $item->price,
|
||||
'total' => self::getTotal($item->quantity, $item->price),
|
||||
'total_taxed' => self::getTotal($item->quantity, $item->price),
|
||||
'price' => (float) $prices->price,
|
||||
'tax' => $prices->price_taxed - $prices->price,
|
||||
'price_taxed' => (float) $prices->price_taxed,
|
||||
'total' => self::getTotal($item->quantity, $prices->price),
|
||||
'total_tax' => self::getTotal($item->quantity, $prices->price_taxed - $prices->price),
|
||||
'total_taxed' => self::getTotal($item->quantity, $prices->price_taxed),
|
||||
];
|
||||
$total += self::getTotal($item->quantity, $item->price);
|
||||
$total_taxed += self::getTotal($item->quantity, $item->price);
|
||||
$total += self::getTotal($item->quantity, $prices->price);
|
||||
$total_taxed += self::getTotal($item->quantity, $prices->price_taxed);
|
||||
}
|
||||
$data = [
|
||||
'detail' => $detail,
|
||||
'total' => $total,
|
||||
'taxes' => $total_taxed - $total,
|
||||
'total_taxed' => $total_taxed,
|
||||
'shipping' => $shipping,
|
||||
'total_shipped' => $total_taxed + $shipping,
|
||||
];
|
||||
return $data ?? false;
|
||||
}
|
||||
|
||||
public static function getTotal($quantity, $price)
|
||||
{
|
||||
return (int) $quantity * $price;
|
||||
return $quantity * $price;
|
||||
}
|
||||
|
||||
public static function getBasket($sale_channel_id = false)
|
||||
|
||||
Reference in New Issue
Block a user