Welcome Guest, Not a member yet? Register   Sign In
Cart help please:
#1

[eluser]nealumney[/eluser]
I have developed a simple add to cart routine which is called via AJAX, that is a user clicks an 'add to cart' button and my Shop controller is called. The relevant code is:

Code:
if (!$incart)
{
    var_dump($cartarray);
    $this->cart->insert($cartarray);
    var_dump($this->cart->contents());
}

I have included the var_dumps so that you can see the input and the output of two consecutive 'button clicks'.

The first click works:

Code:
array(4) {
  ["id"]=> string(5) "00429"
  ["qty"]=> int(1)
  ["price"]=> float(4.4885)
  ["name"]=> string(24) "HANDCUFFS METAL WITH KEY"
}
array(1) {
  ["4d0831bc5ae00dc8343f8ebad4b60fef"]=>
  array(6) {
    ["rowid"]=> string(32) "4d0831bc5ae00dc8343f8ebad4b60fef"
    ["id"]=> string(5) "00429"
    ["qty"]=> string(1) "1"
    ["price"]=> string(6) "4.4885"
    ["name"]=> string(24) "HANDCUFFS METAL WITH KEY"
    ["subtotal"]=> float(4.4885)
  }
}

The second click does not:

Code:
array(4) {
  ["id"]=> string(5) "00380"
  ["qty"]=> int(2)
  ["price"]=> float(2.726)
  ["name"]=> string(30) "SPECS DROOPY EYES,Metal Spring"
}
array(1) {
  ["4d0831bc5ae00dc8343f8ebad4b60fef"]=>
  array(6) {
    ["rowid"]=> string(32) "4d0831bc5ae00dc8343f8ebad4b60fef"
    ["id"]=> string(5) "00429"
    ["qty"]=> string(1) "1"
    ["price"]=> string(6) "4.4885"
    ["name"]=> string(24) "HANDCUFFS METAL WITH KEY"
    ["subtotal"]=> float(4.4885)
  }
}

Apart from the contents I can not see any difference in the arrays passed to the this->cart->insert. The cart does not change. I have tried 'clicking' in reverse oder, I have tried casting price as a float, and qty as an integer. I am at a complete loss.

Many thanks for your help in advance.

Neal




Theme © iAndrew 2016 - Forum software by © MyBB