• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Shopping Cart Question

#1
[eluser]RMinor[/eluser]
Hi Everyone,
I need to try and sort through my shopping cart to make some custom adjustments but am having very little luck doing so. Basically I want to get the total price and quantity of items in the cart that DO NOT have the words "Tank Top", "Tabs", or "Gift Card" in the product name. The code I have below is not working properly. It is returning the total amount and price of everything in the cart even though I am trying to not include the said items above. Can anyone help me out at all?

Code:
<?php $gift_allowed = FALSE;
$price = array();
$quantity = array();
foreach ($cart as $product) {
    if (strpos($product['name'], 'Tank Top') !== TRUE || strpos($product['name'], 'Gift Card') !== TRUE || strpos($product['name'], 'Tabs') !== TRUE) {
        $price[] = $product['price'] * $product['qty'];
        $quantity[] = $product['qty'];
    }
}
$nail_total = array_sum($price);
$nail_quantity = array_sum($quantity);
if ($nail_total >= 25) {
    $gift_allowed = TRUE;
    $free_tank = TRUE;
}
if ($nail_quantity >= 3) {
    $gift_allowed = TRUE;
    $free_nail = TRUE;
}
var_dump($gift_allowed);
//print_r($price);
//print_r($quantity);
echo '<br />' . $nail_total . '<br />';
echo $nail_quantity; ?&gt;
&lt;?php if ($this->session->userdata('free_nail') != TRUE && $this->session->userdata('free_tanktop') != TRUE && ($gift_allowed == TRUE)) { ?&gt;
    <table width="100%" border="0" cellspacing="5">
    <tr>
        <td align="center" valign="bottom" width="50%">
        &lt;?php if ($this->cart->total_items() >= 3 && $free_nail == TRUE) { ?&gt;
            <a href="&lt;?php echo base_url(); ?&gt;free_nail"><img src="&lt;?php echo base_url(); ?&gt;images/cart-free-nail.png" width="100%" /></a>
        &lt;?php } ?&gt;
        </td>
        <td align="center" valign="bottom" width="50%">
        &lt;?php if ($this->cart->total() > 25.00 && $free_tank == TRUE) { ?&gt;
            <a href="&lt;?php echo base_url(); ?&gt;free_tanktop"><img src="&lt;?php echo base_url(); ?&gt;images/cart-free-nail-or-tank.png" width="100%" /></a>
        &lt;?php } ?&gt;
        </td>
    </tr>
    </table>
&lt;?php } ?&gt;


Messages In This Thread
Shopping Cart Question - by El Forum - 06-23-2012, 11:24 AM
Shopping Cart Question - by El Forum - 06-23-2012, 12:14 PM
Shopping Cart Question - by El Forum - 06-24-2012, 05:05 PM
Shopping Cart Question - by El Forum - 06-24-2012, 05:38 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.