I want to display all the session data, but have some control over it. the problem is that I canβt know exactly what is stored in the session as data from the shopping cart.
for example, here is one variable in my session:
item_name_1: Product Name
item_quantity_1: 5
Each product has some variables with a number. If there were 2 different products in the basket, then the second would be
item_number_2 etc.
There is also a variable called itemcount that tells you how many different products are in the basket.
how can I tell php that all variables starting with item_name_ should appear, for example, in separate divs after all other variables, such as the total price?
this is what i am currently using to print session data:
<?php foreach ($_SESSION as $key=>$val) echo $key. ": ".$val. "<br>"; ?>
here is what i see:
Currency: EUR
delivery: 10
grandTotal: 70.5
itemCount: 4
item_name_1: Tomato Suppe
item_quantity_1: 1
item_price_1: 3.5
item_options_1:
item_name_2: Lentils Suppe
item_quantity_2: 14
item_price_2: 3.5
item_options_2:
item_name_3: Chicken Suppe
item_quantity_3: 1
item_price_3: 4.5
item_options_3:
item_name_4: "Green Leaves" | item_quantity_4: 1
item_price_4: 3.5
item_options_4:
Obviously, I want to make reading easier.
I can use echo $ _SESSION ['shipping'] for the shipping cost to put it where I want, but how can I access the products?
Say I want each product to appear in a div and / div, for example?
Sorry for the noob question.
Thank you