fix on basket
This commit is contained in:
@@ -7,22 +7,21 @@ use App\Repositories\Core\User\ShopCart;
|
||||
|
||||
class Offers
|
||||
{
|
||||
public static function addBasket($offer_id, $quantity = 1)
|
||||
public static function addBasket($offer_id, $quantity = 1, $update = false)
|
||||
{
|
||||
if (ShopCart::has($offer_id)) {
|
||||
if (ShopCart::has($offer_id) && !$quantity) {
|
||||
$ret = ShopCart::remove($offer_id);
|
||||
}
|
||||
$data = $quantity ? Offers::getBasketData($offer_id, $quantity) : false;
|
||||
return $data ? ShopCart::add($data) : false;
|
||||
return $data ? ShopCart::add($data, $update) : false;
|
||||
}
|
||||
|
||||
public static function getFull($id, $sale_channel_id = false)
|
||||
{
|
||||
$sale_channel_id = $sale_channel_id ? $sale_channel_id : SaleChannels::getDefaultID();
|
||||
return Offer::with([
|
||||
$offer = Offer::with([
|
||||
'article.article_nature',
|
||||
'article.product',
|
||||
'article.image',
|
||||
'tariff' => function ($query) use ($sale_channel_id) {
|
||||
$query->bySaleChannel($sale_channel_id);
|
||||
},
|
||||
@@ -32,6 +31,8 @@ class Offers
|
||||
'tariff.price_lists.price_list_values',
|
||||
'variation',
|
||||
])->find($id);
|
||||
$offer->article->image = Articles::getFullImageByArticle($offer->article);
|
||||
return $offer;
|
||||
}
|
||||
|
||||
public static function getPrice($id, $quantity = 1, $sale_channel_id = false)
|
||||
@@ -56,7 +57,7 @@ class Offers
|
||||
'quantity' => (int) $item->quantity,
|
||||
'price' => $item->price,
|
||||
'variation' => $offer->variation->name,
|
||||
'image' => Articles::getPreviewSrc($offer->article->image),
|
||||
'image' => Articles::getPreviewSrc(Articles::getFullImageByArticle($offer->article)),
|
||||
];
|
||||
}
|
||||
return $data ?? false;
|
||||
|
||||
Reference in New Issue
Block a user