If you are clicking the Add to Cart button and it appears that nothing is happening and no products are getting added to the cart, the most likely cause is a javascript error on your page. Here are some tips on how to fix this problem.
Javascript Errors Breaking Inventory Tracking
If you click on an Add To Cart button and nothing seems to happen the most likely cause is a javascript error in your theme or one of your active plugins. When an Add To Cart button is clicked, PHPurchase issues an ajax call behind the scenes to see if you have enough inventory on hand to fulfill the order. If you do, then the product is added to the cart. If not, then an inventory message is displayed to your customer. If, however, there is a javascript error on the page then the ajax call will not complete successfully and it will appear like nothing happens when you click the Add To Cart button.
The best way to fix this problem is, of course, to resolve the javascript errors in your theme. If you are using Firefox you can install the Web Developer toolbar and/or Firebug which will be helpful in tracking down the javascript errors. If you are using Safari you can use the Web Inspector feature, also extremely helpful in debugging javascript problems. Safari has some excellent .
Other Possible Causes
If you do not have any javascript errors on your page, there are a couple other things to look for.
- Mixed Domains: Make sure that your product page is on the same domain as your WordPress installation. Ajax will not pass data between domains.
- SSL Certificate Problems: If you are using an SSL certificate, make sure it is installed correctly and you are not getting any warnings about expired certificates or mismatched sub-domains.
- jQuery Missing: Make sure you have jQuery installed. PHPurchase tries to make sure jQuery is linked into your WordPress site but some poorly coded themes do not have a head() function call in the header.php file of the theme. Without that function call, WordPress will not include the scripts enqueued by PHPurchase. Without jQuery, PHPurchase will fail.
- jQuery Conflicts: jQuery conflicts can also cause javascript errors. Often times inexperienced theme developers or plugin developers do not realize that it is a bad idea to use the $ variable for jQuery unless the jQuery code uses one of the magic shortcuts.
Last Resort, Disable Inventory Tracking
If the javascript errors are too overwhelming or you can’t figure out what the problem is and you don’t care about inventory tracking, you can simply turn off the inventory tracking feature (as of PHPurchase version 2.5.7). To turn off inventory tracking, log into your WordPress admin and navigate to the PHPurchase Settings panel. In the Main Settings box select “No” for the Track Inventory setting and click Save. With inventory tracking turned off, PHPurchase will not need to use javascript to add products to the cart and will work even if there are javascript problems on the page.