Welcome Guest, Not a member yet? Register   Sign In
Adding an item to the Cart always returns 2 (qty items)
(This post was last modified: 04-17-2016, 04:14 AM by thanhthangnet.)

Hello everybody, as the title,

I use the library cart
And when I added 1 product on the code below:
PHP Code:
$data = array(
       'id'      => 'sku_123ABC',
       'qty'     => 1,
       'price'   => 39.95,
       'name'    => 'T-Shirt',
       'options' => array('Size' => 'L''Color' => 'Red')


The result is a multiple of 2 qty as follows:

PHP Code:
   [0256a32c98ce49afbe2a4eb8c96c5884] => Array
           [id] => sku_123ABC
[qty] => 2
[price] => 39.95
[name] => T-Shirt
[options] => Array
                   [Size] => L
[Color] => Red

           [rowid] => 0256a32c98ce49afbe2a4eb8c96c5884
[subtotal] => 79.9

Similarly QTY will add 2 as 4,6,8 ... when I add 1 ITEM into cart

(This post was last modified: 04-17-2016, 07:29 AM by PaulD. Edit Reason: remembered something )


I had something like this once, a long time ago, and it turned out to be that the page was being loaded twice, because (I think) it was a malformed href causing the page to reload.

Sorry if that is a bit vague, as I don't really recall the cause in any detail, but I do remember being suprised to find the page was loading twice, due to a browser interpretation of the html.

So it sounds to me like your page is double loading, causing two items to be added rather than one.

Hope that helps in some way,

Best wishes,


PS If I remember right, it was an empty image src in the html

@PaulD: Thanks for your comments as it helped me to have more confidence

Cause of the fault is not Codeigniter library.
The reason is that I insert 2 times the products in my ajax request.
Library cart works well

Well, if it helps at all, CI "works well" in virtually all cases (except the very, very rare bug that gets reported by other people, I have never found one myself).

In fact, I am pretty sure that 100% of the time problems and weird behavior has always turned out to be something I am doing, rather than something CI is doing.

Hope you enjoy CI as much as I have.

Best wishes,


Theme © iAndrew 2016 - Forum software by © MyBB