cancel
Showing results for 
Search instead for 
Did you mean: 

Shopping cart error

Shopping cart error

Hi, 

 

I can't seem to find anyone else with this problem on the forum. I am not very good with programming but have managed to build and run the website from a theme and have had very few issues over the last 2 years. I have learnt a fair bit by self teaching and through this forum.

 

However, I recently encountered a problem that i am unable to solve. I have not changed any programming or anything on my site recently, however I can't seem to add anything to the cart. I tried to contact the theme creator but he has told me it's an issue with my Magento and not his theme. I have not updated my magento or applied any patches ever, 

 

Could anyone tell me what the issue could be and/or how to solve this problem. 

 

The URL for my site is www.orno.com.au

 

Thanks in advance Smiley Happy

7 REPLIES

Re: Shopping cart error

Hi @srinalik

 

Please check the browser console for following message. (In Chrome)

Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience.  For more help, check http://xhr.spec.whatwg.org/.

I think you are using Ajax add to cart extension for adding the products to cart. Try to disable it for time being and check if the add to cart functionality works?

 

Are you using Varnish cache?If yes try to disable it for testing purpose to check if add to cart works for you.

Without much details it is difficult to suggest any solution.

---
Problem Solved Click Accept as Solution!:Magento Community India Forum

Re: Shopping cart error

Hi muk_t Thank you so much for your reply . 

 

 

I seem to have gone from bad to worse. I attempted to find the extension, during which i thought it would be a good idea to udate a few things in "Magento Connect" After it was done updating i tried to go back to my admin panel and was unable to. My website had completely stopped working. After a few "quick fixes" found from various posts I managed to get my website to kind of work. I have no idea what has happened and how to even start to fix this. Anything i click on, goes to an error page, and I cannot access my admin panel. When i try to open my admin panel URL, it takes me to an error page saying " Not Found

The requested URL /dinki was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request."

 

 

I was thinking of completely restarting the website from scratch but I'm not sure if i have everything backed up and how to go about uploading all my old products etc back. 

Re: Shopping cart error

Hi muk_t 

 

Thank you so much for your reply . 

 

 

I seem to have gone from bad to worse. I attempted to find the extension, during which i thought it would be a good idea to udate a few things in "Magento Connect" After it was done updating i tried to go back to my admin panel and was unable to. My website had completely stopped working. After a few "quick fixes" found from various posts I managed to get my website to kind of work. I have no idea what has happened and how to even start to fix this. Anything i click on, goes to an error page, and I cannot access my admin panel. When i try to open my admin panel URL, it takes me to an error page saying " Not Found

The requested URL /dinki was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request."

 

 

I was thinking of completely restarting the website from scratch but I'm not sure if i have everything backed up and how to go about uploading all my old products etc back. 

Re: Shopping cart error

For 404 not found error, it seems that something is not good with web rewrites. Please restore your .htaccess file if you have taken backup. And check your apache settings and check if rewrite module is enabled or not

Sr. Consultant
www.knowarth.com

Re: Shopping cart error

@shabbirforever

 Thank you for your reply Smiley Happy 


I have managed to fix the 404 not found error. And now I am back to trying to figure out why my shopping cart is not working. Is there any other information I can give for me to be able to solve my problem?? Before the problem first started I had definitely not touched any of the coding etc or added any new extensions. 

 

I am unsure why this happened on a running website. 

 

Since, my site was always working perfectly, I never updated anything - Do you think I need to update everything?? I am now a litlle scared of updating anything since I feel I might make the site crash again. 

 

To all of you who are trying to help me , all your help is much appreciated in advance. 

 

@muk_t

Re: Shopping cart error

@srinalik

When i click on add to cart button in your site for "3 in 1 Mobile Phone Lens Clip On Kit"

, it shows me below error 

 

<b>Fatal error</b>:  Call to a member function toHtml() on a non-object in <b>/home/ornocoma/public_html/app/code/local/Excellence/Ajax/controllers/IndexController.php</b> on line <b>53</b><br />

 

Can you please write what code is there in this file?

Sr. Consultant
www.knowarth.com

Re: Shopping cart error

@shabbirforever

 

I am copying the code in the file for you!! Thank you for your help Smiley Happy

 

<?php
require_once 'Mage/Checkout/controllers/CartController.php';
class Excellence_Ajax_IndexController extends Mage_Checkout_CartController
{
public function addAction()
{
$cart = $this->_getCart();
$params = $this->getRequest()->getParams();
if($params['isAjax'] == 1){
$response = array();
try {
if (isset($params['qty'])) {
$filter = new Zend_Filter_LocalizedToNormalized(
array('locale' => Mage::app()->getLocale()->getLocaleCode())
);
$params['qty'] = $filter->filter($params['qty']);
}

$product = $this->_initProduct();
$related = $this->getRequest()->getParam('related_product');

/**
* Check product availability
*/
if (!$product) {
$response['status'] = 'ERROR';
$response['message'] = $this->__('Unable to find Product ID');
}

$cart->addProduct($product, $params);
if (!empty($related)) {
$cart->addProductsByIds(explode(',', $related));
}

$cart->save();

$this->_getSession()->setCartWasUpdated(true);

/**
* @todo remove wishlist observer processAddToCart
*/
Mage::dispatchEvent('checkout_cart_add_product_complete',
array('product' => $product, 'request' => $this->getRequest(), 'response' => $this->getResponse())
);

if (!$cart->getQuote()->getHasError()){
$message = $this->__('%s was added to your shopping cart.', Mage::helper('core')->htmlEscape($product->getName()));
$response['status'] = 'SUCCESS';
$response['message'] = $message;
//New Code Here
$this->loadLayout();
Mage::register('referrer_url', $this->_getRefererUrl());
$toplink = $this->getLayout()->getBlock('top_cart')->toHtml();
$sidebar_block = $this->getLayout()->getBlock('cart_sidebar');
if($sidebar_block){
$sidebar = $sidebar_block->toHtml();
$response['sidebar'] = $sidebar;
}
if($toplink){
$response['topcart'] = $toplink;
}
}
} catch (Mage_Core_Exception $e) {
$msg = "";
if ($this->_getSession()->getUseNotice(true)) {
$msg = $e->getMessage();
} else {
$messages = array_unique(explode("\n", $e->getMessage()));
foreach ($messages as $message) {
$msg .= $message.'<br/>';
}
}

$response['status'] = 'ERROR';
$response['message'] = $msg;
} catch (Exception $e) {
$response['status'] = 'ERROR';
$response['message'] = $this->__('Cannot add the item to shopping cart.');
Mage::logException($e);
}
$this->getResponse()->setHeader('Content-Type', 'application/json; charset=UTF-8', true)->setBody(Mage::helper('core')->jsonEncode($response));
return;
}else{
return parent::addAction();
}
}
public function optionsAction(){
$productId = $this->getRequest()->getParam('product_id');
// Prepare helper and params
$viewHelper = Mage::helper('catalog/product_view');

$params = new Varien_Object();
$params->setCategoryId(false);
$params->setSpecifyOptions(false);

// Render page
try {
Mage::getSingleton('core/session')->setReferrerUrl($this->_getRefererUrl());
$viewHelper->prepareAndRender($productId, $this, $params);
} catch (Exception $e) {
if ($e->getCode() == $viewHelper->ERR_NO_PRODUCT_LOADED) {
if (isset($_GET['store']) && !$this->getResponse()->isRedirect()) {
$this->_redirect('');
} elseif (!$this->getResponse()->isRedirect()) {
$this->_forward('noRoute');
}
} else {
Mage::logException($e);
$this->_forward('noRoute');
}
}
}
/**
* Delete shoping cart item action
*/
public function deleteAction()
{
$id = (int) $this->getRequest()->getParam('id');
if ($id) {
try {
$this->_getCart()->removeItem($id)
->save();
} catch (Exception $e) {
$this->_getSession()->addError($this->__('Cannot remove the item.'));
Mage::logException($e);
}
}

$string = $this->_getRefererUrl();
$key = 'ajax';
$cnt = preg_match_all("#\\b(".$key.")\\b#usi", $string, $pocket);

if($cnt){
$url = Mage::getSingleton('core/session')->getReferrerUrl();
Mage::getSingleton('core/session')->unsReferrerUrl();
if(@$url){
$this->_redirectUrl($url);
}else{
$this->_redirectReferer(Mage::getUrl('*/*'));
}
}else{
$this->_redirectReferer(Mage::getUrl('*/*'));
}
}
}