Shopify ScriptTag API and custom variables - shopify

I have a question regarding ScriptTag API - http://api.shopify.com/scripttag.html, is there a way to add couple variables if code is being added into the Thank You page? I would like to collect order_id and order_amount so client can track performance etc. but looking at the API it seems that I can only specify event and source or am I missing somthing?
cheers,
/Marcin

You can only specify event and source when creating a script tag.
However, since the structure of the Thank You page is known, you can grab the order number and total from the DOM using js.
Alternatively, You can couple your js tracking on the front end with data from the Orders API to get the data you need.

Related

how to get image via order API

I am creating Shopify application named "Request for Quote",Is use for create quote for multiple products. in application I have added functionality to convert quote to order using order API provided by Shopify. I have got all data of product into the converted order but i haven't get image detail of order. So I am stuck in It Can anyone have idea about it or having solution of this problem, If yes then send me solution as soon as possible.
Thank You in Advance...
I tried order API but didn't get any solution.....

How do I access Shopify data without advanced account?

All I'm wanting to do is track sales of certain products from a certain date. My company is wanting to add a banner to track sales goals for raising money for charities. So basically, we'd tag a few products as being part of that goal, set a goal, and then need to update the goal progress by a certain amount every time a sale is made on one of those products. As far as I can tell, without access to Shopify's analytics API, this is not possible. How can I do this?
What you want to build is perfectly possible. However, you need to generate Private App Credentials, so you can use Shopify API. It doesn't matter if you have an account by yourself, someone else can follow these steps and send you the credentials your way.
If you don't actually need to modify anything through the API, you could have them set a webhook (Settings -> Notifications -> Webhook) on Order Creation (or similar) that posts to your server and you can check what product got sold and see if it has got the tag.
The "easy" way to do this is to create an app that receives order webhooks and can check on tagged products and keep a sum of target items sold.
Then the app should have use a script tag to insert a simple script with the current value into the web page at a configured place by css selector
OR the app could update one or more snippet files that you could include until the promo is done.
I'd tend to go with the script tag option since that's a bit more flexible and you should be able to change your theme when the promo is over to report results without having to touch the app again.

BigCommerce JavaScript API

In BigCommerce, can I access the current customer's record using JavaScript?
I want to change something on the product page based on the customer group that the current customer is in.
there is no JS SDK yet for Bigcommerce. However, because the APIs are restful, you should be able to execute a simple GET request to get a customer's record. The only challenge is that you need to get the customer ID/info when they login to the store and then get their record.
There is an example on Bigcommerce forums on using Javascript to hide pricing for customers who are not logged in.
http://forum.bigcommerce.com/f4/global-variable-for-current-user-s-group-1815/index2.html
This combined with GET request on the customer endpoint (http://developer.bigcommerce.com/api/customers) should get you moving in that direction.
Does this help? Are you looking for a code sample?
Use Javascript or jQuery to do the IF statement.
Then use Ajax to request the data that you want to display to the user.
So to answer your question, directly with Javascript you can't, but combine it with some PHP and then you use the API to do what you would like.
Hope this helps :)

Shopify API: Create a Promotion?

Using the Shopify API, is there a way to creation promotions for your store? If not, is there a way to programmatically create promotions in Shopify? (short of using CURL posts to the admin)
That is, I can create a promotion by hand using the admin and navigating to the Promotions and clicking the Add a discount code link. I'd like to be able to do the same thing programmatically, or to know for certain this isn't possible. I don't see any obvious method on the api list, but it seems like something should be an API method.
Unfortunately they don't allow it... I resorted to creating an interface to do so, though:
https://github.com/MartinAmps/Shopify-Private-APIs
Hope it helps
Edit
I also created a blog post about it.
There is no way to create discounts via the API.
If you want we have made an application that can be used to create discount codes.
Otherwise you can use a tool like Mechanize to automate coupon creation for you, but keep in mind theres a good chance that any time in the future it will break since we don't make any promises to keep our admin the same in the future. Any changes have a good chance of breaking whatever script you'd end up writing.
The Price Rules API is now public and allow any app to create price rules and discount codes.
https://help.shopify.com/api/price-rules
If you're familiar with Rails or you're already using ActiveResource for your Shopify API calls, then you can drop in this modified version of Discount < ActiveResource::Base https://gist.github.com/choonkeat/09a56da222f506e627c5

Getting current Product ID with Shopify API for a Javascript API call

I'm toying with developing a Shopify App that uses the DaisyAPI dynamic image service for Shopify. In order to make the correct call to the Daisy API, I need to know what Product the customer is looking at. It seems like, to reliably do that, I will need to manipulate their product.liquid theme to insert a hidden value containing the Product ID so that Jquery can pick up that value and insert it into the API call.
What's the best way to ensure every product page contains the product ID in such a way jQuery can reliably find it? Am I overlooking something obvious?
Many thanks!
Another option would be to use the Ajax API to request the product. Of you know you're on a product page simple make a request to the same URL and append .json. You will then have a json representation of the product that you can do whatever yo want with.
To get you js into the theme you can use a script tag which will load js from you server onto the shop.
You are missing a very obvious and cool Liquid filter.
In Liquid, pump the Object for it's JSON.
var p = {{ product | json }};
And then go to town... you cannot go far on the client without this concept. Get the JSON man.. get the JSON...