Quantcast
Channel: Opinion: Shopify Community - Shopify APIs & SDKs
Viewing all articles
Browse latest Browse all 25503

Shopify API + add.js + 404 by David Nejedly

$
0
0

Hi, I've been bashing my head against the screen all morning trying to figure out why I'm getting a 404 error by using a post as described here (http://docs.shopify.com/support/your-website/themes/can-i-use-ajax-api) to add items to the cart...

What the final goal is, is to add multiple items to the car with 1 button click.

I've scoured the forum and found similar requests, none with a definite solution? I've asked live shopify chat who couldn't help so I'm hoping that someone can point me in the right direction.

We have a customised shopify theme based on the standard 'Minimal theme'.

When running this code:

Shopify.itemsToAdd = [];
 Shopify.addItemstoTheCart = function() {
  if (Shopify.itemsToAdd.length) {
    var item = Shopify.itemsToAdd.pop();
    $.ajax({
      url: '/cart/add.js',
      dataType: 'json',
      type: 'post',
      data: item,
      success: Shopify.addItemstoTheCart,
      error: Shopify.addItemstoTheCart
    });
  } else {
    //window.location.href = '/cart';
    alert('redirecting to cart');
  }

I get a 404 as shown in the firebug inspector

Remote Address:204.93.213.54:80
Request URL:http://the-nutritionists-3.myshopify.com/cart/add.js
Request Method:POST
Status Code:404 Not Found
Request Headersview source
Accept:application/json, text/javascript, */*; q=0.01
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Content-Length:23
Content-Type:application/x-www-form-urlencoded; charset=UTF-8
Cookie:cacheable_token=753a1ad0-bf11-4d48-ba52-9409852fe550; ki_u=dd2bf8c7-b211-74ce-95b4-c5c5bc62c646; ki_r=https%3A//delivery.shopifyapps.com/login/authenticate%3Fshop%3Dthe-nutritionists-3.myshopify.com; ki_s=120557%3A0.0.0.0.1; __atuvc=2%7C20%2C0%7C21%2C2%7C22%2C0%7C23%2C1%7C24; cart=9e7f42b87543a0e84b9165f491a3b483; ki_t=1403230130419%3B1404256168436%3B1404256681477%3B3%3B28; _session_id=56327072167c1d0ba915fb8782146129; admin_next_beta_domains=true; _ab=1; _ga=GA1.2.81915067.1397696914; __utma=1.81915067.1397696914.1404707052.1404771793.28; __utmc=1; __utmz=1.1402617312.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); storefront_digest=f6a73da942049ff8e0f85b80b17b5d5852f94972; ki_t=1403230130419%3B1404771851587%3B1404771851587%3B4%3B29; ki_r=; request_method=GET; _shopify_y=c69f41ad-0ab4-4e89-828f-fba0f6a2420c; _shopify_visit=t; _shopify_uniq=x; _shopify_s=72236e5e-dbc9-4e09-82ba-7d95fa546898
Host:the-nutritionists-3.myshopify.com
Origin:http://the-nutritionists-3.myshopify.com
Referer:http://the-nutritionists-3.myshopify.com/collections/bundle-1/products/bonvit-psyllium-husks
User-Agent:Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36
X-Requested-With:XMLHttpRequest

What is strange is that accessing change.js (http://the-nutritionists-3.myshopify.com/cart/change.js) is OK but http://the-nutritionists-3.myshopify.com/cart/add.js gives a 404....

 

Any information on what is going on here would be great... At this stage I'm thinking that the minimal theme is the cause and somehow missing the /cart/add.js file...?

UPDATE: the response found is this

{"status":404,"message":"Cart Error","description":" Cannot find variant (request_id: d03a5117-b88f-4453-86a8-30e5985b3ada)"} 

so it seems like a variant issue as described here http://ecommerce.shopify.com/c/ecommerce-design/t/shopify-additem-404-error-54782

I will keep investigating but if anyone has experienced this please let me know how you overcame the problem.

ANY help is greatly appreciated.

Regards,

David

 

 

 

 


Viewing all articles
Browse latest Browse all 25503

Trending Articles