Select shop type using Shopify API - api

I'm a developer who uses Shopify Developer API. I searched API, trying to find method to retrieve information about shop business industry.
I didn't find anything. I've tried to get this information from Metafield API from store, but I've found just information about pos_attributes.
Could you help me to solve this issue? (In general, is it possible or not?)

Unfortunately that is not possible. The information you've shown is only for Shopify to tailor some stuff for your usage and it is no where linked to your account in the accessible fields.
Fortunately, you can always add custom meta-fields (information fields) to the Shopify store using the Metafield API and retrieve it at anytime anywhere.
Use the Metafield API to POST the following information directly on the store url - https://your_store_name.myshopify.com/admin/metafields.json
{
"metafield": {
"namespace": "meta", //any string will work
"key": "industry", //any string will work
"value": "Leather Manufacturing", // A string or a number
"value_type": "string" //accepted values are string & integer
}
}
Once stored, you can call it on the shop using Metafield object property. {{ shop.metafields.namespace.key.}} (in this case {{ shop.metafields.meta.industry }})
And if you want to call it using the API use GET with the url - https://your_store_name.myshopify.com/admin/metafields/metafield_id.json

Related

Shopware 6 Store-API set newsletter recipient tags

I'm trying to add a newsletter recipient through store-api, which works. But when I try to add a tag inside the request, it fails. The documentation states that it is possible to add a tag as a string to the request, see here
My request looks like the following:
POST /store-api/newsletter/subscribe
{"option":"subscribe","email":"email#email.com","storefrontUrl":"http://myhost.test","tags":"men"}
I also tried to make the tags value an array, but this doesn't work either...
So my question is: how do I add a tag to the newsletter recipient through the store api?
As of Version 6.4.3.0 this seems not possible.
I tried the same request as you, as well as
"tags":["men"]
and
"tags":["uuidOfExistingTagGoesHere"]
all does not work.
Also the doc block for tags is wrong (it says "zip code" instead of a useful description).
In addition I tried to assign existing tags - this is what works via the admin API:
"tags": [
{
"id": "80df380188364f3c9bbaaa4d6b993dbd"
},
{
"id": "108428f0a37c4d11a66976adc5337c23"
}
]
Which still returns
"code": "FRAMEWORK__WRITE_MALFORMED_INPUT",
"title": "Bad Request",
"detail": "Expected data to be array.",
Also looking at the code there currently seems no handling of the tags. As far as I understand it, the tags would needed to be created on the fly
A possible fix would be the following code:
if (isset($data['tags']) { // inserted that lines
$data['tags'] = $data['tags']->all();
} // end inserted lines
$data = $this->completeData($data, $context);
Using that line, the last mentioned request works (you could then use the IDs of existing newsletter recipient tags).
Of course in this case the API docs have to be adapted.
TL;DR
In my opinion, this seems a flaw in the current Store API implementation.
I would suggest to create an issue on the Shopware 6 issue tracker.

BigCommerce storefront apis for order

Where is the documentation for /api/storefront/orders/*?
I was expecting to find it on this page.
https://developer.bigcommerce.com/api-docs/cart-and-checkout/working-sf-apis
Specifically, the documentation that would cover /api/storefront/orders/:order-id
and cover the valid inputs to the querystring. I know you can pass include, with one or more of the values as a comma separated string
payments
lineItems.physicalItems.socialMedia
lineItems.physicalItems.options
lineItems.digitalItems.socialMedia
lineItems.digitalItems.options
Edit
The checkout stencil context object used on theme\templates\pages\order-confirmation.html has this schema
{
"order_confirmation_content": "goes in the body",
"checkout_head": "goes in the head",
"order": {
"id": 206
},
"header_image": "for an img src attribute"
}
The documentation for the storefront orders API can be found here:
https://developer.bigcommerce.com/api-reference/orders/storefront-orders-api/order/ordersbyorderidget
However, as you mentioned, there are a few query parameters that are undocumented. Those are not officially supported, and they might be subject to change in the future. This is a case where our position is to hold off on documenting the API parameters until we've determined long-term support. Hope that helps to provide some context!

Retrieving image files from referenced items in filtered items

Being new to REST APIs (and APIs in general), I ran into some problems while trying to retrieve some Podio data using the Klipfolio web service, where I want to setup a simple dashboard with a list containing a name field from collected Podio and a image field from a reference field from the collected items.
So far I was led in the direction of 'bundling' and 'nesting', but I am not quite sure if this is the way forward.
In order to retrieve the filtered items, I have used the following POST method:
POST /item/app/11821547/filter/
Body:
{
"from": -1mr,
"to": -0mr
}
And then, from the items I here retrieve, I want to GET the referenced items, for instance using:
GET /reference/{ref_type}/{ref_id}
And finally, I want to get the image URL from the respective field in these referenced items, for instance using:
GET /item/{item_id}/value/{field_id}
Any help is much appreciated!!
To accomplish this you only need to use one API call to the Podio filter items endpoint in which you wrote above; POST /item/app/11821547/filter/.
In your POST body, you can filter down your results with the created to and from dates. For example, if you only want the items for the past month, you can use Klipfolio's date parameters. Your POST body will look like this:
{
"filters": {
"created_on": {
"from": "{date.addMonths(-1).format()}",
"to": "{date.today}"
}
}
}
This will return an API reponse of all items that were created within the past month. From here you can build a klip and manipulate the JSON with xpath expressions to extract the image urls and names. All this information will be within the #item/fields array in your API response. You'll have to determine which field ID is used for the name and image url field. These are unique to each account.
An example of xpath to extract these values would be like so:
#/items/fields[field_id='id_number']/values/value
Where id_number is the exact id number for the field.
If you are unfamiliar with xpath expressions within Klipfolio, here is a document that walks through this.

is it possible to store product fields and tie them into liquid templeting?

Is it possible to store fields into variables for individual products to use elsewhere in the code or am I stuck with only API calls?
I'd like to store data for each product into a variables and pass them to the liquid product template to make a dynamic hyperlink for each product.
https://imgur.com/a/dmdZy - Example of Embedded App fields to be saved.
https://imgur.com/a/qgMhq - Example of product listing.
You can use metafields to store and display custom properties of a product.
To save a metafield in your app make a request to the Shopify API:
POST /admin/products/#{id}/metafields.json
{
"metafield": {
"namespace": "test_app",
"key": "seller_id",
"value": 123,
"value_type": "integer"
}
}
To get seller_id in the product template:
{{ product.metafields.test_app.seller_id }}
Metafields are available automatically in the templates.

How to get the most popular page under a section using Site Catalyst (Omniture)?

I want to use the site catalyst api to get the most popular page (page that has maximum pageviews) under a given site-section? Let me explain better with an example.
My website has multiple channels (News/Journals/Books/Events etc). Each of the channel has many pages under it. I want a api call that will get the most popular news page or Journals page or Books page etc.
I am passing data to sitecatalyst like this..
s.pageName = o_title;
s.channel = o_structure
s.prop1 = o_iden
where o_title has the page title of a newspage or a journalpage etc..
o_structure refers to either "News" or "Journals" or "Books" etc.
Currently I am able to only get the most popular page on the entire site. I would appreciate if someone can help me find the most popular page per section.
Thanks,
Rag
I assume that you already know the basics of using the Omniture API, how to queue up a report and look for status and get it etc... here is a basic REST data string to get site sections (s.channel) broken down by page names (s.pageName) with page views as metric. You will use the Report.QueueRanked API method, and you need to specify the rsid(s) to get the data from and the date ranges.
{
"reportDescription": {
"reportSuiteID":"RSID",
"dateFrom":"YYYY-MM-DD",
"dateTo":"YYYY-MM-DD",
"metrics":[
{
"id":"pageViews"
}
],
"sortBy":"pageViews",
"elements":[
{
"id":"siteSection"
},
{
"id":"page"
}
]
}
}