Jump to content

Item will not add to cart


Claudia M

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

Link to comment
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.

Link to comment
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.

Link to comment
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.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...