enhance add to basket

This commit is contained in:
Ludovic CANDELLIER
2022-04-01 00:11:15 +02:00
parent eff2cb21c7
commit 6e133246cf
17 changed files with 359 additions and 53 deletions

View File

@@ -98,12 +98,12 @@ class Articles
case 'App\Models\Botanic\Variety':
$variety = $article->product;
$specie = $variety->specie;
$description = empty($specie->description) ? '' : $specie->description . '<br>';
$description .= empty($variety->description) ? '' : $variety->description . '<br>';
$description = empty($specie->description) ? '' : $specie->description . '<br><br>';
$description .= empty($variety->description) ? '' : $variety->description . '<br><br>';
break;
case 'App\Models\Botanic\Specie':
$specie = $article->product;
$description = empty($specie->description) ? '' : $specie->description . '<br>';
$description = empty($specie->description) ? '' : $specie->description . '<br><br>';
break;
default:
$description = '';

View File

@@ -7,6 +7,32 @@ use App\Repositories\Core\User\ShopCart;
class Offers
{
public static function addBasket($offer_id, $quantity = 1)
{
if (ShopCart::has($offer_id)) {
$ret = ShopCart::remove($offer_id);
}
$data = $quantity ? Offers::getBasketData($offer_id, $quantity) : false;
return $data ? ShopCart::add($data) : false;
}
public static function getFull($id, $sale_channel_id = false)
{
$sale_channel_id = $sale_channel_id ? $sale_channel_id : SaleChannels::getDefaultID();
return Offer::with([
'article.article_nature',
'article.product',
'article.image',
'tariff' => function ($query) use ($sale_channel_id) {
$query->bySaleChannel($sale_channel_id);
},
'tariff.price_lists' => function ($query) use ($sale_channel_id) {
$query->BySaleChannel($sale_channel_id);
},
'tariff.price_lists.price_list_values',
'variation',
])->find($id);
}
public static function getPrice($id, $quantity = 1, $sale_channel_id = false)
{
@@ -153,5 +179,4 @@ class Offers
{
return self::update(['status_id' => $status_id], $id);
}
}