Fix on addresses

This commit is contained in:
ludo
2023-11-13 00:02:21 +01:00
parent 4ce3d528dd
commit 9f90f983ab
29 changed files with 660 additions and 447 deletions

View File

@@ -17,16 +17,17 @@ class Baskets
return $data ? ShopCart::add($data, $update) : false;
}
public static function getBasketSummary($sale_channel_id = false)
public static function getBasketSummary($saleChannelId = false)
{
$basket = ShopCart::getContent();
$offers = Offer::with('variation')->whereIn('id', ShopCart::keys())->get();
$total = 0;
$total_taxed = 0;
$totalTaxed = 0;
$shipping = 5;
foreach ($basket as $item) {
$offer = $offers->where('id', $item->id)->first();
$prices = Offers::getPrice($item->id, $item->quantity, $sale_channel_id);
$prices = Offers::getPrice($item->id, $item->quantity, $saleChannelId);
$weight = $offer->weight * $item->quantity;
$detail[] = [
'offer_id' => (int) $item->id,
'name' => $offer->article->name.' ('.$offer->variation->name.')',
@@ -37,17 +38,18 @@ class Baskets
'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),
'weight' => $weight,
];
$total += self::getTotal($item->quantity, $prices->price);
$total_taxed += self::getTotal($item->quantity, $prices->price_taxed);
$totalTaxed += self::getTotal($item->quantity, $prices->price_taxed);
}
$data = [
'detail' => $detail,
'total' => $total,
'taxes' => $total_taxed - $total,
'total_taxed' => $total_taxed,
'taxes' => $totalTaxed - $total,
'total_taxed' => $totalTaxed,
'shipping' => $shipping,
'total_shipped' => $total_taxed + $shipping,
'total_shipped' => $totalTaxed + $shipping,
];
return $data ?? false;
@@ -58,9 +60,9 @@ class Baskets
return $quantity * $price;
}
public static function getBasket($sale_channel_id = false)
public static function getBasket($saleChannelId = false)
{
$sale_channel_id = $sale_channel_id ? $sale_channel_id : SaleChannels::getDefaultID();
$saleChannelId = $saleChannelId ? $saleChannelId : SaleChannels::getDefaultID();
$basket = ShopCart::getContent();
// dump($basket->toArray());
$offers = Offer::with([
@@ -69,7 +71,7 @@ class Baskets
'article.product.Specie',
'article.image',
'price_lists.price_list_values',
])->withPriceListsBySaleChannel($sale_channel_id)
])->withPriceListsBySaleChannel($saleChannelId)
->whereIn('id', ShopCart::keys())->get();
foreach ($basket as $item) {
$offer = $offers->where('id', $item->id)->first();