0

When adding to cart, I only sometimes get the stylish Ajax "Your item was added to cart"-popup. Other times I get the ugly standard magento added to cart orange and grey buttons. When I get the default behaviour, I can't see the items in cart before refreshing the page, so I suspect it's some kind of ajax error. I have captured both Ajax requests and they are quite different. Can someone figure out the error?

Works:

$.get('http://www.propagandashop.dk/proaddto/index/add/uenc/aHR0cDovL3d3dy5wcm9wYWdhbmRhc2hvcC5kay8,/product/754/form_key/vRnRi3VEvUkNw6xa/isAjax/1')
  .done (showResult)
  .fail(showError);


  {
  "frameId": 0,
  "method": "GET",
  "parentFrameId": -1,
  "requestId": "13544",
  "tabId": 57,
  "timeStamp": 1440573329737.51,
  "type": "xmlhttprequest",
  "url": "http://www.propagandashop.dk/proaddto/index/add/uenc/aHR0cDovL3d3dy5wcm9wYWdhbmRhc2hvcC5kay8,/product/754/form_key/vRnRi3VEvUkNw6xa/isAjax/1"
}

Doesnt work:

First get:

var queryData = {
  "block[]": "options",
  "awacp": "1",
  "no_cache": "1"
};
$.get('http://www.propagandashop.dk/checkout/cart/add/uenc/aHR0cDovL3d3dy5wcm9wYWdhbmRhc2hvcC5kay9rb2trZW4,/product/235/form_key/vRnRi3VEvUkNw6xa/', queryData)
  .done (showResult)
  .fail(showError);


  {
  "frameId": 0,
  "method": "GET",
  "parentFrameId": -1,
  "requestId": "13875",
  "tabId": 57,
  "timeStamp": 1440573421999.0598,
  "type": "xmlhttprequest",
  "url": "http://www.propagandashop.dk/checkout/cart/add/uenc/aHR0cDovL3d3dy5wcm9wYWdhbmRhc2hvcC5kay9rb2trZW4,/product/235/form_key/vRnRi3VEvUkNw6xa/?block%5B%5D=options&awacp=1&no_cache=1"
}

Second get (same time):

var queryData = {
  "actionData": "{\"added_product\":\"235\"}",
  "block[]": [
    "cart",
    "sidebar",
    "topLinks",
    "skipLinks",
    "wishlist",
    "miniWishlist",
    "addProductConfirmation",
    "removeProductConfirmation"
  ],
  "awacp": "1",
  "no_cache": "1"
};
$.get('http://www.propagandashop.dk/kokken', queryData)
  .done (showResult)
  .fail(showError);

  {
  "frameId": 0,
  "method": "GET",
  "parentFrameId": -1,
  "requestId": "13876",
  "tabId": 57,
  "timeStamp": 1440573422599.8179,
  "type": "xmlhttprequest",
  "url": "http://www.propagandashop.dk/kokken?actionData=%7B%22added_product%22%3A%22235%22%7D&block%5B%5D=cart&block%5B%5D=sidebar&block%5B%5D=topLinks&block%5B%5D=skipLinks&block%5B%5D=wishlist&block%5B%5D=miniWishlist&block%5B%5D=addProductConfirmation&block%5B%5D=removeProductConfirmation&awacp=1&no_cache=1"
}
1

Are you using caching of some sort, e.g. Varnish? If so please check your whitelist options. Sometimes ajax requests are cached thus returning different responses. Also, since you seem to be using an extension for the ajax cart make sure to check the developer docs.

  • I'm pretty sure I am only using the built-in magento caching. The extension for the cart is called 'SNS Proaddto' and is a part of the theme I am using, which is made by SNS. I have tried contacting the developers, but their response was that I probably have some conflicting extension. I cant see which extension I should have that makes a conflict on category pages (where it seldom works) and not on frontpage (where it always works) – user2806026 Aug 26 '15 at 8:07
  • Ok, in case you run into conflicts when using extensions you might want to check which files are actually loaded in the frontend, i.e. which blocks are rendered. This way you can debug your problem further. There are two options to go from here, use the built-in profiler or use a well-known extension called CommerceBug by Alan Storm. This will give you an overview of the files loaded on these page. – mkerstner Aug 26 '15 at 8:10
  • Ok. So you think I should point out the differences between a page that actually has the ajax add-to-cart working and one that doesnt? The error should lie in one of those? – user2806026 Aug 26 '15 at 8:14
  • Could'nt the error lie in this part?: var queryData = { "block[]": "options", "awacp": "1", "no_cache": "1" }; That one is only appearing in the call that fail.. – user2806026 Aug 26 '15 at 8:19
  • Does your session get initialized correctly for the first call? After the second call do you get the same result for all consecutive calls? – mkerstner Aug 28 '15 at 17:02

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.