Note that there are some explanatory texts on larger screens.

plurals
  1. POCustomizing the cart of "OpenCart"
    primarykey
    data
    text
    <p>I am trying to make a few changes to the actual cart in OpenCart. As for now when adding a product to the cart information will be shown the following way:</p> <pre><code>Product1 Amount: Size: XL 2 </code></pre> <p>And a new row is created if the same product, but with a different size, is added to the cart. My wish is to get the following design of the cart</p> <pre><code>Product1 S M L XL 1 2 </code></pre> <p>So, that each product will only create one, single line and then show the correct amount under the corresponding size categories. This is my code so far:</p> <pre><code>&lt;?php $saveName = array(); $sizesArray = array("S","M","L","XL"); $x = 0; if($products || $vouchers) { foreach ($products as $product){ foreach ($product['option'] as $option) { $option['value']; } $saveName[$x] = $product['name'].'|'.$option['value'].'|'.$product['quantity']; $seperateValues = explode("|",$saveName[$x]); ?&gt; &lt;tr&gt; &lt;td class="image"&gt;&lt;?php if ($product['thumb']) { ?&gt; &lt;a href="&lt;?php echo $product['href']; ?&gt;"&gt;&lt;img src="&lt;?php echo $product['thumb']; ?&gt;" alt="&lt;?php echo $product['name']; ?&gt;" title="&lt;?php echo $product['name']; ?&gt;" /&gt;&lt;/a&gt; &lt;?php } ?&gt;&lt;/td&gt; &lt;td class="name"&gt;&lt;a href="&lt;?php echo $product['href']; ?&gt;"&gt;&lt;?php echo $product['name']; ?&gt;&lt;/a&gt;&lt;/td&gt; &lt;?php foreach($sizesArray as $sizes){ if($sizes == $seperateValues[1]){ echo '&lt;td&gt;'.$seperateValues[0].' '.$seperateValues[2].'&lt;/td&gt;'; } else{ echo '&lt;td&gt;0&lt;/td&gt;'; } } ?&gt; &lt;td class="total"&gt;&lt;?php echo $product['total']; ?&gt;&lt;/td&gt; &lt;td class="remove"&gt;Remove&lt;/td&gt; &lt;/tr&gt; &lt;?php $x++; } ?&gt; </code></pre> <p>The code formats the amount under the right category, but I can't get it to produce only one row for each product. Any help is much appriciated.</p> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    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.
    1. This table or related slice is empty.
    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