Answer the question
In order to leave comments, you need to log in
Does the darryldecode library add a limited number of products?
I pass a unique product ID, but only 4 products are added to the cart. The last product added replaces the last element of the array, as if there is a maximum number of products.
I apologize in advance for the long footcloth
Code in the controller:
// Проверяем, есть ли ID Пользователя в куки. Если нет - записываем
if (!Cookie::get('user_id')) {
$generate_id = intval(uniqid());
$user_id = $req->cookie('user_id', $generate_id, 120);
} else {
$user_id = Cookie::get('user_id');
}
if ($req->isSku == 'true') {
$sku = true;
$dataSku = 'yes';
}
else {
$sku = false;
$dataSku = 'no';
}
// Добавляемый товар является торговым предложением
if ($sku) {
$skuProduct = Sku::where('id', $req->id)->first();
$data = array(
'id' => $skuProduct->id,
'name' => $skuProduct->name,
'price' => $skuProduct->price,
'quantity' => 1,
'attributes' => array(
'image' => $skuProduct->image,
'sku' => $dataSku,
'grind' => $req->grind
),
);
}
// Добавляемый товар НЕ является торговым предложением
elseif (!$sku) {
$product = Product::where('id', $req->id)->first();
$data = array(
'id' => $product->id,
'name' => $product->name,
'price' => $product->price,
'quantity' => 1,
'attributes' => array(
'image' => $product->image,
'sku' => $dataSku,
'grind' => $req->grind
),
);
}
\Cart::session($user_id)->add($data);
return response()->json(\Cart::getContent())->cookie('user_id', $user_id, 120);
Answer the question
In order to leave comments, you need to log in
Try to play around with session storage, did a multilanguage site and English validation worked, and Russian validation either validated 3 or less incorrectly entered fields, or didn’t validate at all, changed it to file, and everything worked
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question