fix shipping

This commit is contained in:
Ludovic CANDELLIER
2023-07-16 17:54:44 +02:00
parent c619f540f8
commit ddb4520621
36 changed files with 640 additions and 897 deletions

View File

@@ -15,24 +15,24 @@ class BasketController extends Controller
{
public function getPrice(Request $request)
{
$offer_id = $request->input('offer_id');
$offerId = $request->input('offer_id');
$quantity = $request->input('quantity') ?? 1;
$price = Offers::getPrice($offer_id, $quantity)->price_taxed;
$price = Offers::getPrice($offerId, $quantity)->price_taxed;
return number_format($quantity * $price, 2);
}
public function addBasket(Request $request)
{
$offer_id = $request->input('offer_id');
$offerId = $request->input('offer_id');
$quantity = $request->input('quantity') ?? 1;
$update = $request->input('update') ?? false;
return Baskets::addBasket($offer_id, $quantity, $update);
return Baskets::addBasket($offerId, $quantity, $update);
}
public function modalBasket($offer_id, $quantity)
public function modalBasket($offerId, $quantity)
{
$data['offer'] = Offers::getFull($offer_id)->toArray();
$data['basket'] = Baskets::addBasket($offer_id, $quantity);
$data['offer'] = Offers::getFull($offerId)->toArray();
$data['basket'] = Baskets::addBasket($offerId, $quantity);
return view('Shop.Baskets.partials.modalBasket', $data);
}
@@ -65,7 +65,7 @@ class BasketController extends Controller
$data = $request->all();
unset($data['_token']);
$data['user_id'] = Users::getId();
Orders::newOrder($data);
Orders::saveOrder($data);
return response()->json(['code' => '200']);
}

View File

@@ -19,72 +19,72 @@ class CategoryController extends Controller
return $dataTable->render('Shop.Categories.list');
}
public function show(Request $request, $category_id, $article_nature_id = false)
public function show(Request $request, $categoryId, $articleNatureId = false)
{
if ($article_nature_id) {
$product_type = ArticleNatures::getProductType($article_nature_id);
dump($product_type);
if ($articleNatureId) {
$productType = ArticleNatures::getProductType($articleNatureId);
dump($productType);
exit;
} else {
$article_nature = $request->input('article_nature');
if (!$article_nature) {
$articleNature = $request->input('article_nature');
if (!$articleNature) {
$articleNatures = Articles::getArticleNaturesWithOffers([
'category_id' => $category_id,
'category_id' => $categoryId,
]);
if (count($articleNatures) === 1) {
$article_nature = $articleNatures[0];
$articleNature = $articleNatures[0];
}
$productTypes = Articles::getProductTypesWithOffers([
'category_id' => $category_id,
'category_id' => $categoryId,
]);
if (count($productTypes) === 1) {
$product_type = $productTypes[0];
$productType = $productTypes[0];
}
}
switch ($article_nature) {
switch ($articleNature) {
case 'semences':
$product_type = 'botanic';
$article_nature_id = 1;
$productType = 'botanic';
$articleNatureId = 1;
break;
case 'plants':
$product_type = 'botanic';
$article_nature_id = 2;
$productType = 'botanic';
$articleNatureId = 2;
break;
case 'legumes':
$product_type = 'botanic';
$article_nature_id = 3;
$productType = 'botanic';
$articleNatureId = 3;
break;
default:
if (!($product_type ?? false)) {
$product_type = 'botanic';
$article_nature_id = 1;
$article_nature = 'semences';
if (!($productType ?? false)) {
$productType = 'botanic';
$articleNatureId = 1;
$articleNature = 'semences';
}
break;
}
// $product_type = ArticleNatures::getProductType($article_nature_id);
// dump($product_type);
// dump($article_nature_id);
// $productType = ArticleNatures::getProductType($articleNatureId);
// dump($productType);
// dump($articleNatureId);
// exit;
}
// exit;
$data = [
'category' => Categories::getFull($category_id),
'breadcrumb' => Categories::getAncestorsByCategory($category_id),
'category' => Categories::getFull($categoryId),
'breadcrumb' => Categories::getAncestorsByCategory($categoryId),
'display_by_rows' => $request->input('display_by_rows') ?? false,
'product_type' => $product_type,
'article_nature' => $article_nature,
'product_type' => $productType,
'article_nature' => $articleNature,
'article_natures' => $articleNatures ?? [],
'product_types' => $productTypes ?? [],
'tags_selected' => $request->input('tags') ?? [],
'articles' => Articles::getArticlesToSell([
'category_id' => $category_id,
'category_id' => $categoryId,
'tags' => $request->input('tags') ?? [],
'product_type' => $product_type ?? false,
'article_nature_id' => $article_nature_id ?? false,
'product_type' => $productType ?? false,
'article_nature_id' => $articleNatureId ?? false,
]),
'tags' => TagGroups::getWithTagsAndCountOffers($category_id),
'tags' => TagGroups::getWithTagsAndCountOffers($categoryId),
];
// dump($data);
// exit;