Jump to content
Claudia M

Item will not add to cart

Recommended Posts

I was doing a test order and the item would not go into the cart.  Click add to cart on any page. The mini basket said your cart is empty.  I got this error in my log.  xxxxed out my name

Countable in /home/xxxxx/public_html/classes/cart.class.php on line 1196

EDIT:  Add item to basket the above happens.  Go to another page and the mini basket is spread over the top of the page showing the item in the cart.

Works ok on small display

http://www.claudiasbargains.com

I put an old main template file that works in its place.  Must be something I did.  I'll do a through check

Edited by Claudia M

Share this post


Link to post
Share on other sites

PHP will complain, as of PHP 7, if the PHP function count() doesn't have anything to count.

So, something is not sending the correct data to be added to the shopping basket.

Have your browser show you the network diagnostics tab and check to see what is getting sent when you click Add to Basket.

Just checked and all seems to be working fine with the 'cbargainsfive' skin.

Share this post


Link to post
Share on other sites

"Have your browser show you the network diagnostics tab and check to see what is getting sent when you click Add to Basket. "  How do I do this in FireFox?

What I don't understand is using my old main template file, it works.  Just when I try to use my restyled main template ... it messes up. 

This is from topic/54973. I made this change but still it acts up.

PHP documentation says:

Warning: count(): Parameter must be an array or an object that implements Countable in … // as of PHP 7.2

I think there is another instance of this. But, an edit:

/classes/cart.class.php, line 1196:

From:

if (count($this->basket['contents']) == 0) {

To:

if (empty($this->basket['contents'])) {

To me, using empty is easier than checking for a count of zero - which is an empty array.

Edited by Claudia M

Share this post


Link to post
Share on other sites

True, but $this->basket['contents'] is not supposed to be empty. Once the Add to Basket button is clicked, the browser is supposed to send certain data to CubeCart. It is after the item has - supposedly - been added to the cart that this function, update(), gets called.

Note: update() also gets called when the customer deletes or changes the quantity of products already in the basket from the View Basket page. If the quantities all get set to zero, the offending code (the count() function, line 1196) sees no contents and will clear out the entire shopping basket -- shipping choices, coupons(?), whatever.

So, not being able to add to the shopping basket points to a problem early in the process.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...