У меня есть хорошо функционирующая корзина, все, что я хочу, - это отображать элементы корзины на странице оформления заказа. Я попытался вставить код корзины на странице оформления заказа и попытался отобразить ее переменную, но она отображается пустой. Ниже приведен мой код
$product_ids = array();
if(isset($_POST['login'])){
if(isset($_SESSION['shopping_cart'])){
$count = count($_SESSION['shopping_cart']);
$product_ids = array_column($_SESSION['shopping_cart'], 'id');
if (!in_array(filter_input(INPUT_GET, 'id'), $product_ids)){
$_SESSION['shopping_cart'][$count] = array
(
'id' => filter_input(INPUT_GET, 'id'),
'name' => filter_input(INPUT_POST, 'name'),
'price' => filter_input(INPUT_POST, 'price'),
'qty' => filter_input(INPUT_POST, 'qty'),
'img' => filter_input(INPUT_POST, 'img'),
);
echo "Product Added to cart";
}else{
echo "Product Already added to cart";
}
}else{
$_SESSION['shopping_cart'][0] = array
(
'id' => filter_input(INPUT_GET, 'id'),
'name' => filter_input(INPUT_POST, 'name'),
'price' => filter_input(INPUT_POST, 'price'),
'qty' => filter_input(INPUT_POST, 'qty'),
'img' => filter_input(INPUT_POST, 'img'),
);
}
}
if (filter_input(INPUT_GET, 'action') == 'delete'){
foreach($_SESSION['shopping_cart'] as $key => $r){
if ($r['id'] == filter_input(INPUT_GET, 'id')){
unset($_SESSION['shopping_cart'][$key]);
echo "Product Removed from cart";
}
}
$_SESSION['shopping_cart'] = array_values($_SESSION['shopping_cart']);
}
?>
<?php
foreach($_SESSION['shopping_cart'] as $key => $r):
?>
<li class="d-flex flex-row align-items-center justify-content-start">
<div class="order_list_title"><?php echo $r['name']; ?></div>
<div class="order_list_value ml-auto"><?php echo $r['price']; ?></div>
</li>
<?php
endforeach;
?
Пожалуйста, как мне отобразить элементы корзины покупок на странице оформления заказа?