2

In our web-shop, we use an AJAX add to cart, so the page doesn't have to reload. But when the order is bigger than the stock, the ajax keeps loading and doesn't show a message the order isn't available.

The console error is 503 (Service Unavailable)

Is there a way to fix this or to disable ajax add to cart only on the product page but keep it working on other pages!

Error Log:

a:5:{i:0;s:81:"De gevraagde hoeveelheid voor "Restorative Hair Mask 250 ml" is niet beschikbaar.";i:1;s:1539:"#0 /home/users/beaxmftp/beautyballoon.nl/app/code/core/Mage/Checkout/Model/Cart.php(284): Mage::throwException('De gevraagde ho...') #1 /home/users/beaxmftp/beautyballoon.nl/app/code/local/Cmsmart/AjaxCart/controllers/IndexController.php(154): Mage_Checkout_Model_Cart->addProduct('53', Array) #2 /home/users/beaxmftp/beautyballoon.nl/app/code/local/Cmsmart/AjaxCart/controllers/IndexController.php(67): Cmsmart_AjaxCart_IndexController->tryaddAction(Object(Mage_Catalog_Model_Product), Array) #3 /home/users/beaxmftp/beautyballoon.nl/app/code/core/Mage/Core/Controller/Varien/Action.php(418): Cmsmart_AjaxCart_IndexController->indexAction() #4 /home/users/beaxmftp/beautyballoon.nl/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(254): Mage_Core_Controller_Varien_Action->dispatch('index') #5 /home/users/beaxmftp/beautyballoon.nl/app/code/community/ArtsOnIT/OfflineMaintenance/Controller/Router/Standard.php(46): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http)) #6 /home/users/beaxmftp/beautyballoon.nl/app/code/core/Mage/Core/Controller/Varien/Front.php(172): ArtsOnIT_OfflineMaintenance_Controller_Router_Standard->match(Object(Mage_Core_Controller_Request_Http)) #7 /home/users/beaxmftp/beautyballoon.nl/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch() #8 /home/users/beaxmftp/beautyballoon.nl/app/Mage.php(684): Mage_Core_Model_App->run(Array) #9 /home/users/beaxmftp/beautyballoon.nl/index.php(89): Mage::run('', 'store') #10 {main}";s:3:"url";s:98:"/ajaxcart/index/index/?form_key=hGxTgs9rzs7WqBfZ&product=53&related_product=&qty=5&_=1446135436562";s:11:"script_name";s:10:"/index.php";s:4:"skin";s:2:"nl";}

  • 1
    which extension you are using for ajax add to cart? do you have any live URL? – Akhilesh Patel Oct 29 '15 at 16:09
  • @Sjoerd Have you checked your server logs for potential PHP errors? 503 errors typically mean you have a fatal PHP error and/or an exception happening on the request. This log would give you a pointer on where the bug is causing the problem. (and if you find it, go ahead and add the log entry to the question here if it doesn't make sense to you) – davidalger Oct 29 '15 at 16:22
  • i've added the error log to the question – Sjoerd Oct 29 '15 at 16:27
0

To disable ajax add to cart only on the product page find out product details page from your module and comment out code for ajax Add To Cart

0

This code is trying to see if ordering a specific amount is possible, but then does not handle the exception.

Got full code?

[Edit]

I guess this came with the template, the quality is horrible. Aside from the fact that the private non-static method tryAddAction is called statically, it's also not guarded against exceptions and is well known exception for Magento developers that Magento throws there. This code will not run in developer mode, therefore you should not run it in production. The choice of Ajax carts is legion, no need to use the one that came with the template, although I understand the convenience.

0

in your addtocart.phtml

app\design\frontend\[Theme]\template\catalog\product\view\addtocart.phtml

button type='button'

change to

buttton type='submit'

  • Anyone help me to solve add to cart error in CMS Page, code -> justpaste.it/6tp4f error message Notice: Uninitialized string offset: 0 in C:\wamp\www\magento\app\code\local\Cmsmart\AjaxCart\controllers\IndexController.php on line 209 – Gem Aug 11 '18 at 6:19
  • error in controller file not in the phtml file – Jigs Parmar Aug 11 '18 at 6:42
  • can you pls explain in brief? – Gem Aug 14 '18 at 4:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.