better management of shipping and basket summary display
This commit is contained in:
@@ -6,19 +6,19 @@ use App\Repositories\Core\User\ShopCart;
|
||||
|
||||
class Baskets
|
||||
{
|
||||
public static function addBasket($offer_id, $quantity = 1, $update = false)
|
||||
public static function addBasket($offerId, $quantity = 1, $update = false)
|
||||
{
|
||||
if (ShopCart::has($offer_id) && ! $quantity) {
|
||||
$ret = ShopCart::remove($offer_id);
|
||||
if (ShopCart::has($offerId) && ! $quantity) {
|
||||
$ret = ShopCart::remove($offerId);
|
||||
}
|
||||
$data = $quantity ? self::getBasketData($offer_id, $quantity) : false;
|
||||
$data = $quantity ? self::getBasketData($offerId, $quantity) : false;
|
||||
|
||||
return $data ? ShopCart::add($data, $update) : false;
|
||||
}
|
||||
|
||||
public static function getBasketTotal($deliveryId = false, $deliveryTypeId = false)
|
||||
{
|
||||
$saleChannelId = $deliveryId ? Deliveries::getField($deliveryId, 'sale_channel_id') : SaleChannels::getDefaultID();
|
||||
$saleChannelId = Deliveries::getSaleChannelId($deliveryId);
|
||||
|
||||
return self::getBasketSummary($saleChannelId, $deliveryTypeId);
|
||||
}
|
||||
@@ -36,8 +36,8 @@ class Baskets
|
||||
$prices = Offers::getPrice($item->id, $item->quantity, $saleChannelId);
|
||||
$weight = $offer->weight * $item->quantity;
|
||||
$detail[] = self::getRowDetail($item, $offer, $prices, $weight);
|
||||
$total += self::getTotal($item->quantity, $prices->price);
|
||||
$totalTaxed += self::getTotal($item->quantity, $prices->price_taxed);
|
||||
$total += $prices ? self::getTotal($item->quantity, $prices->price) : false;
|
||||
$totalTaxed += $prices ? self::getTotal($item->quantity, $prices->price_taxed) : false;
|
||||
$totalWeight += $weight;
|
||||
}
|
||||
$shipping = DeliveryTypeCalculations::getPriceByDeliveryType($deliveryTypeId, $totalWeight);
|
||||
@@ -52,6 +52,7 @@ class Baskets
|
||||
'count' => ShopCart::count(),
|
||||
'quantity' => ShopCart::getTotalQuantity(),
|
||||
'weight' => $totalWeight,
|
||||
'sale_channel' => SaleChannels::getArray($saleChannelId),
|
||||
];
|
||||
|
||||
return $data ?? false;
|
||||
@@ -63,12 +64,12 @@ class Baskets
|
||||
'offer_id' => (int) $item->id,
|
||||
'name' => $offer->article->name.' ('.$offer->variation->name.')',
|
||||
'quantity' => (int) $item->quantity,
|
||||
'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),
|
||||
'price' => $prices ? (float) $prices->price : false,
|
||||
'tax' => $prices ? $prices->price_taxed - $prices->price : false,
|
||||
'price_taxed' => $prices ? (float) $prices->price_taxed : false,
|
||||
'total' => $prices ? self::getTotal($item->quantity, $prices->price) : false,
|
||||
'total_tax' => $prices ? self::getTotal($item->quantity, $prices->price_taxed - $prices->price) : false,
|
||||
'total_taxed' => $prices ? self::getTotal($item->quantity, $prices->price_taxed) : false,
|
||||
'weight' => $weight,
|
||||
];
|
||||
}
|
||||
@@ -110,6 +111,7 @@ class Baskets
|
||||
'latin' => $offer->article->product->specie->latin ?? false,
|
||||
];
|
||||
}
|
||||
$data['sale_channel'] = Customers::getSaleChannel();
|
||||
|
||||
return $data ?? false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user