John Davidson

php - Laravel post data

0 comments
Message:


I am adding a order on my database with diferent taxes and I was suprise with this function that work prefectly on local envoirement is not working wen I deploy the website $tva6, $tva10 and $tva20 still 0.


    $tva6 = 0;
$tva10 = 0;
$tva20 = 0;

$cart = session('orderList.orderList');
foreach ($cart as $item){
if ($item['tva'] === 6){
$tva6 += ($item['price'] * $item['qty']);
}
if ($item['tva'] === 10){
$tva10 += ($item['price'] * $item['qty']);
}
if ($item['tva'] === 20){
$tva20 += ($item['price'] * $item['qty']);
}
}
$tva6 = $tva6 - ($tva6 / 1.055);
$tva10 = $tva10 - ($tva10 / 1.1);
$tva20 = $tva20 - ($tva20 / 1.2);

$total = session('orderList.deliSup') + session('DBcart.totalPrice');

$order = Order::create([
"user_id"=>Auth::id(),
"orderId"=>session('orderList.orderIdNaga'),
"orderList"=>session('orderList.orderList'),
"payMethod"=>session('orderList.payMethod'),
"utensils"=>session('orderList.utensils'),
"infoOrder"=>session('orderList.infoOrder'),
"totalPrice"=>$total,
"tva6"=>$tva6,
"tva10"=>$tva10,
"tva20"=>$tva20,
"deliSup"=>session('orderList.deliSup'),
"deliTime"=>session('orderList.deliTime'),
"deliDate"=>session('orderList.deliDate')
]);

Any idea ? thx


edit: $cart is a array with product infos



My Answer:
'tva6' => $tva6,
'tva10' => $tva10,
'tva20' => $tva20,
'total' => $total
]);

Make sure that the session variables 'orderList.orderList', 'orderList.deliSup', and 'DBcart.totalPrice' are properly set and accessible in your deployed environment. Also, check if the values of 'tva' in your $cart items are correctly set to 6, 10, or 20. If the issue persists, you may need to debug further or check for any differences in the server environment that could be causing the problem.

Rate this post

3 of 5 based on 9001 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us