Note that there are some explanatory texts on larger screens.

plurals
  1. POAdd items to a cart from an array
    primarykey
    data
    text
    <p>I'm creating a php driven shopping cart as part of a task. All products are currently stored in an array (I'm aware they would realistically be stored in a database, however for this task it isn't required)</p> <p>I would like to know if its possible to add items to a cart from clicking a link, upon clicking proceed, it would take the user to a summary screen, displaying the cost of each item (value displayed from the array) and total cost of all items.</p> <p>I am also looking to include a promotion code input box, is it possible to calculate and display a discount on button click, E.G "Update"</p> <p>So far, I only have the products displayed in a table which is ok, the cart section is confusing me at the moment as well as the discount section.</p> <pre><code>&lt;?php $Item1 = array('SKU'=&gt;test1, 'name'=&gt;ProductTest1, 'Price'=&gt;10.00); $Item2 = array('SKU'=&gt;test2, 'name'=&gt;ProductTest2, 'Price'=&gt;11.00); $Item3 = array('SKU'=&gt;test3, 'name'=&gt;ProductTest3, 'Price'=&gt;12.00); ?&gt; &lt;html&gt; &lt;head&gt; &lt;link rel="stylesheet" type="text/css" href="Style.css"&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="container"&gt; &lt;div id="main"&gt; &lt;table&gt; &lt;tr&gt; &lt;th&gt;SKU&lt;/th&gt; &lt;th&gt;Name&lt;/th&gt; &lt;th&gt;Price&lt;/th&gt; &lt;th&gt;Action&lt;/th&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;?php echo $Item1[SKU]; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $Item1[name]; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo '£'. number_format($Item1[Price],2); ?&gt;&lt;/td&gt; &lt;td&gt;&lt;a href=#&gt;Add To Cart&lt;/a&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;?php echo $Item2[SKU]; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $Item2[name]; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo '£'. number_format($Item2[Price],2); ?&gt;&lt;/td&gt; &lt;td&gt;&lt;a href=#&gt;Add To Cart&lt;/a&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;?php echo $Item3[SKU]; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $Item3[name]; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo '£'. number_format($Item3[Price],2); ?&gt;&lt;/td&gt; &lt;td&gt;&lt;a href=#&gt;Add To Cart&lt;/a&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;input id="Proceed" type="Submit" value="Proceed"&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload