How can I get store id in the bigcommerce theme? - bigcommerce

I need the store id for an external js script that will be put in the theme's header and try to find the store based on this id (on our side).

If just trying to grab it manually, you can find it by logging in to the store. The URL will be https://store-XXXXXX.mybigcommerce.com/admin. XXXXXX is the store ID.
If trying to get it via the API, you will want to use the Store resource (https://developer.bigcommerce.com/api/stores/v2/store_information).

I am not aware of any supported way how to get Store ID.
Unsupported way (which theoretically can break anytime, but I believe it should work for quite long time) is to get it in Javascript from Fornax.configuration.defaultEventProperties.storeId variable.

Related

How do we store variables for each user on a shopify app?

I'm building a simple app where that shows product recommendations.
I want to make it possible for the client to choose how many products he'd like to display, like from 5 or 20 with a liquid variable called {{NofProducts}}
I'm using the shopify app example, there are two important pages:
pages/index.js <- here the client can write inputs
theme-app-extension/block.liquid <- here we write a liquid code that will be appended to the page.
How do I pass the inputs from index.js to the block.liquid?
Do I have to store it elsewhere in a database for each user?
Do I have to create a file using graphQL inside each theme with the user choices using "createScriptTag"?
Ok, unfortunately every Shopify tutorial is extremely confusing for beginners.
They way you pass the store owner inputs to the app is using a database, I did it using Redis, but you can use MongoDB or maybe even a local file, but that's not ideal.
You should not store the user inputs inside their theme, because each time you access or modify a file in the customer's store, you need to use their getSessionToken function and make a new request using the token, while using your database you just need to get the session ID using SESSION_STORAGE.

Is there a way to change the id parameter automatically when creating a GET request on Postman, rather than manually creating separate requests

I am quite new to Postman and I am trying to solve the following problem:
I am using the CKAN api and have found a way to get list of active users and their id
http://demo.ckan.org/api/3/action/user_list.
I now want to find the last time each user was active using this call http://demo.ckan.org/api/3/action/user_activity_list?id=
These calls were found on ckan's api guide. https://docs.ckan.org/en/2.9/api/
Is there a way to update the id parameter with a loop of some sort, so that i dont have to call separate get requests for each id
Cheers.
http://demo.ckan.org/api/3/action/user_activity_list?id={{id}}
Use a variable as I'd , and then update the value from pre request script

How to use metafield value in Shopify APP

I have created metafield using API. Currently accessing those Metafield in shopify cart.liquid like given below -
{{shop.metafields.AnnexCloud.access_token}}
Getting correct value using above syntax.
But when I try to access Metafield through above syntax in APP files facing issue.
I am creating new shopify public APP using python. In that want access metafield using
{{shop.metafields.AnnexCloud.access_token}}
So, please help me out.
Thanks
I'm not 100% sure what you mean about accessing that metafield through your app - there are lots of places where you might be trying to use that value, so I'll try to cover a few of the bases here.
If you're trying to access the metafield in your Python code
Your app is not running on Shopify's servers and doesn't have any native concept of Liquid code. However, since your app is running on your servers with access to whatever database you've used to store the data you need, you shouldn't need to access this metafield - you should have all the information you need already saved.
That said, if your app's requirements have put you in a position where you need to read that live from the store, you can use your app's credentials to access [the-store-domain.myshopify.com]/admin/metafields.json to get metafield information into your app. You can refine your request as well - for example, [the-store-domain.myshopify.com]/admin/metafields.json?namespace=atuls-app would only return metafields where the namespace was atuls-app.
If you're trying to access the metafield in your app's front-end code
You unfortunately won't be able to put the liquid drop into any file inside of the store's /assets folder (if you're writing any files there), nor will you be able to put any Liquid inside of any assets your app loads through the content_for_header.
For the latter case, though, the scripts loaded through content_for_header would be coming from your server, so you could use any of the methods listed above to get that value injected into the script file through your server's code/logic.
For the former case, where you are adding a file to the /assets folder of a Shopify theme, you would only have access to a very limited number of Liquid variables (and unfortunately shop isn't one of them). To get around this, you would need your app's install to add a script tag to the layouts/theme.liquid file to save a global variable with the contents of your metafield. Any other scripts would then be able to access that global variable. (Note: this method comes with all the normal caveats/considerations about using global variables for things)
Hope this helps!

Adding licence field to WSO2 API in API manager

I have the need to add a licence field to the APIs published by the API manager.
It does not seems to be any extension point beyond the api.rxt file in the resource folder.
If I modify the file and run the application the carbon app correctly show the added field, but nor the publishe nor the store are able to get the field and there is no way to get it also with REST APIs since it calls a method of a class that (in later versions) outputted fields positionally.
Is it possible to add the field, without running the risk of crashing the API Manager?
Which is the correct way?
Thanks
This change cannot be done without modifying the code. When an API is created from the Publisher app, it gets stored in the registry. The api.txt you modified, only defines the structure of this stored artifact. It may add a new field to the artifact, but to correctly populate that field, you need to modify several methods in APIProviderHostObject and APIProviderImpl + several Jaggery scripts.

Passing a variable from the store to my API

Each category page on the Bigcommerce store has a unique id: %%GLOBAL_CatId%%
I need to pass this variable, which I cannot possibly know before hand, to my API script. I'm using an include for my script so I've tried several variations of the following but I can't get anything to work:
%%Include.http://example.com/api.php?catid=%%GLOBAL_CatId%%%%
Is this possible and how can I accomplish this?
I was informed by API support that this is NOT possible.