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

Bennett Lee commented on Shopify's AJAX API: Add Item To Cart Not Working

$
0
0

I'm testing this on localhost:8045. It seems like I got a 200 ok status.

This is the response I'm getting:


Bennett Lee commented on Shopify's AJAX API: Add Item To Cart Not Working

$
0
0

I changed the post request to the url of my shop instead of locahost. It doesn't make sense why I can submit a post request through a REST client like POSTMAN on chrome, but not be able to do this. So there is no way I can add an item to cart from localhost?

 

Chris Saunders commented on Shopify's AJAX API: Add Item To Cart Not Working

Bennett Lee commented on Shopify's AJAX API: Add Item To Cart Not Working

$
0
0

So there is no way to asynchronously add to shopify's cart from a remote website even if I have the variant ID/quantity?

Chris Saunders commented on Shopify's AJAX API: Add Item To Cart Not Working

$
0
0

Currently no. We don't have CORS (or JSONP) support for the storefront yet I believe.

Bennett Lee commented on Shopify's AJAX API: Add Item To Cart Not Working

Brandon commented on App development: how to install my app into my dev shop and test it

$
0
0

Thank you, Nate - that's exactly what I needed!

I'll chime in and agree with Carted, better documentation would be helpful in this aspect. An accompanying infographic could be a simple, but effective, addition as well.

Ben Cardwell commented on Sort by best selling products

$
0
0

Hey Chris, 

 

I'm hoping we can find a solution for this as well, it's a small requirement but I think it's potential for Shopify users and App creators alike is enormous. I myself was hoping to use the feature to really take the mobile app for my store to the next level.

 

Ben 


Search API return wrong price by Nguyen Tien

Jason commented on Search API return wrong price

$
0
0

Search API return wrong price

It's not wrong. You're also confusing the api with the storefront search. They are not the same.

The search results you are seeing will be based on the code within that json template. You can just use the money filters within that file to change the value to whatever you need. 

 

Capturing Add To Cart Event by Bennett Lee

$
0
0

I have a product page with an "Add To Cart" button. Example: http://shop.tapiture.com/collections/beach-days/products/old-glories-swim-trunks

Is it possible to either intercept the "Add To Cart" event and get the variant ID/ quantity number of the item OR pass a call back receiving the JSON data of the cart? Thanks!

I tried

Shopify.onItemAdded = function(line_item) {
    	console.log('line item added');
  	  };

Shopify.onCartUpdate = function(cart) {
  alert('There are now ' + cart.item_count + ' items in the cart.');
}; 

 

But neither of them seem to work. I'm not calling the Shopify.addItem(...) function so that might be the case, but I need to listen for that event in the product page.

Jason commented on Execute Javascript Before Rendering Template

$
0
0

So just editing the cart template won't do? You've got me curious in any case.

Bennett Lee commented on Execute Javascript Before Rendering Template

$
0
0

Ok let me break down what I'm experimenting with. I'm trying to modify Shopify's cart from a remote siteasynchronously. This can't be done. What can be done however, is saving the updated cart data from the remote site into a cookie. Basically the cookie will have information about items users have added from our remote site.

When users go back to their cart, I want to pull the updated cart data and push these items to the cart. I know this can be done inside Shopify with Shopify's AJAX API, but I want to make sure these new items get added to the cart before the cart page gets rendered.

This is a pretty hackish approach to go about things, but it's the only way. Hope that makes sense!

Jason commented on Capturing Add To Cart Event

$
0
0

Possible on both counts.

You could also add the id and quantity into the page itself to save you looking it up, though if the customer has sat on the page for while the quantity values may be different.

 

Bennett Lee commented on Capturing Add To Cart Event

$
0
0

How would I achieve this? I tried the two Shopify callback handlers (mentioned above), don't seem to work. Not sure exactly where the code is that calls "Shopify.addItem..." when the user clicks "Add To Cart".

I know I can get the quantity from the product page easily, but I guess my problem is figuring out what variant ID is being selected by the user after he has selected option 1-2-3.


Jason commented on Capturing Add To Cart Event

$
0
0

Your using the option selector script so you could tap in that to pull the variant id whenever the options change. The variant object should have all sorts of things like stock, id, etc.

You want to look for the function that starts with this:

var selectCallback = function(variant, selector) {

There's other ways, but this might be the easiest since you've got those scripts in place already.

As a sidenote - your theme is using this to add to cart (from your radiance.js)

function addToCart(e){

  if (typeof e !== 'undefined') e.preventDefault();

    var cartAmountContainer = $('.cart-amount');
    if (cartAmountContainer.length == 0) {
        $('.cart').append('<span class="cart-amount"/>');
        cartAmountContainer = $('.cart-amount');
    }
    var currentCount = (cartAmountContainer.text() * 1) || 0;
    cartAmountContainer.text(currentCount + 1);

  var form      = $(this).parents('form');

  $.ajax({
    type: 'POST',
    url: '/cart/add.js',
    async: false,
    data: form.serialize(),
    dataType: 'json',
    error: addToCartFail,
    success: addToCartSuccess,
    cache: false
  });

}

 

Uploading snippet file through API by Fredrik Skeppstedt

$
0
0

I'm trying to figure out how to add a file in the snippet directory over the API. Is that possible? Can't find anything about it in the docs for Theme (http://docs.shopify.com/api/theme).&nbsp;

What I'm trying to accomplish is a way to give the shop owner an easy way to display a small box where he/she sees appropriate with content that my app delivers. My thought was to have a div tag and some javascript in a snippet, which would be easy to place and then build up the content of the box (div tag) with jquery. Much like Linkcious does on my product page.

Chris Saunders commented on Uploading snippet file through API

406 Error When Posting Order by nc-tester

$
0
0

Attempting to post to orders to our dev Shopify store always yields 406 errors for an inexplicable reason. I am able get orders and post/put/get/delete items, but every time I post an order (working from the C# library) it returns a 406. In the response, the content type is application/xml, which matches the accept header, so there doesn't seem to be any straightforward reason for this to occur, especially given that so many other api calls work smoothly in the exact same environment.

Chris Saunders commented on 406 Error When Posting Order

$
0
0

You aren't creating a valid order. Line Items is an array of entries not a single item. Also you need to send the variant_id not the product_id

From what I see this is the XML you are submitting:

<order><line_item><product_id>1234</product_id><quantity>1</product_id></line_item></order>

Instead you should be sending something close to the following: 

<order><line_items><line_item><variant_id>1234</variant_id><quantity>1</product_id></line_item></line_items></order>

Can you can configure your library to use JSON instead of XML? The XML API is basically unsupported at this point.

Viewing all 25503 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>