Add variations, slider, fix cart ...
This commit is contained in:
@@ -3,9 +3,40 @@
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use App\Models\Shop\Offer;
|
||||
use App\Repositories\Core\User\ShopCart;
|
||||
|
||||
class Offers
|
||||
{
|
||||
|
||||
public static function getPrice($id, $quantity = 1, $sale_channel_id = false)
|
||||
{
|
||||
$sale_channel_id = $sale_channel_id ? $sale_channel_id : SaleChannels::getDefaultID();
|
||||
$offer = Offer::withPriceBySaleChannelByQuantity($sale_channel_id, $quantity)->find($id);
|
||||
return $offer->price_lists->first()->price_list_values->first();
|
||||
}
|
||||
|
||||
public static function getBasket()
|
||||
{
|
||||
$basket = ShopCart::getContent();
|
||||
$offers = Offer::with(['variation', 'article.article_nature'])->whereIn('id', ShopCart::keys())->get();
|
||||
dump($basket->toArray());
|
||||
dump($offers->toArray());
|
||||
exit;
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function getBasketData($id, $quantity = 1)
|
||||
{
|
||||
$offer = Offer::with(['article'])->findOrFail($id);
|
||||
return [
|
||||
'id' => $id,
|
||||
'name' => $offer->article->name,
|
||||
'price' => self::getPrice($id, $quantity)->price_taxed,
|
||||
'quantity' => $quantity,
|
||||
'attributes' => [],
|
||||
];
|
||||
}
|
||||
|
||||
public static function getOffersByArticles($articles_ids, $sale_channel_id = false)
|
||||
{
|
||||
$sale_channel_id = $sale_channel_id ? $sale_channel_id : SaleChannels::getDefaultID();
|
||||
@@ -13,7 +44,7 @@ class Offers
|
||||
->with([
|
||||
'article_nature',
|
||||
'variation',
|
||||
'tariff.price_lists' => function($query) use ($sale_channel_id) {
|
||||
'tariff.price_lists' => function ($query) use ($sale_channel_id) {
|
||||
$query->bySaleChannel($sale_channel_id);
|
||||
},
|
||||
'tariff.price_lists.price_list_values',
|
||||
@@ -30,7 +61,7 @@ class Offers
|
||||
->with([
|
||||
'article_nature',
|
||||
'variation',
|
||||
'tariff.price_lists' => function($query) use ($sale_channel_id) {
|
||||
'tariff.price_lists' => function ($query) use ($sale_channel_id) {
|
||||
$query->bySaleChannel($sale_channel_id);
|
||||
},
|
||||
'tariff.price_lists.price_list_values',
|
||||
|
||||
Reference in New Issue
Block a user