How to get LineItems of an Order using Shopware 6 Store API - api

I want to integrate shopware in my application and I have a problem with the api.
I used dockware.io solution to get started with shopware and create a demo store. I was able to create customers and products and place orders.
But while I request the order through the API, I am not able to get lineItems of the order, it is always null. I have the same problem with the deliveries attribute. Here is a screenshot of the response to my request.
Why am I not receiving the items in the reply? Is there any other request I can make to receive them?

You need to add the lineItems association in the request body of your API request. Same for the deliveries association and so on.
{
"associations": {
"lineItems": [],
"deliveries": []
}
}

Related

Get ratings for an item via API - Podio

I'd like to get information about a rating (fivestars) of one of an app item.
I've tried to do it using two requests:
/rating/item/1********9
and
/item/1********9?mark_as_viewed=false
Both via https://developers.podio.com/.
I'm receiving only the response (related to ratings):
"ratings":{
"like":{
"average":null,
"counts":{
"1":{
"total":0,
"users":[
]
}
}
}
},
In the GUI I can see my vote (3 stars).
Could you please help me with how I could get the rating?
Thanks for your help!
Adding a star rating to a Podio app is actually creating a Voting object (I know it's not very intuitive). I believe the endpoint you're looking for is Get result of voting on an item.

Shopify API post one product in multiple collections

we're managing a marketplace in Shopify, and we're doing a lot of calls. We'd like to improve the number of calls and one of the keypoints is when we introduce the product in collections. One product can be inserted in multiple collections, and we do this for each post/collection:
public function pushCollection($shopifyProductId, $collectionId)
{
$collectData = [
"product_id" => $shopifyProductId,
"collection_id" => $collectionId
];
$this->client->Collect()->post($collectData);
return;
}
The question is, is there any way to post 1 product in multiple collections with a single call?
Thank you so much
You cannot do that. But if you can accumulate products to add to collections you can add multiple products to a collection in a single call.
see https://help.shopify.com/api/reference/customcollection#update
I am a little late to answer but you can add one product to multiple collections in a single API call using Shopify's GraphQL API. Here's the documentation on it: https://help.shopify.com/en/api/graphql-admin-api/reference/mutation/productcreate
The GraphQL API call to add an already existing product to already existing multiple collections would look something like this:
mutation {
productUpdate( input:
{
$id:"gid://shopify/Product/{shopifyProductId}"
collectionsToJoin:["gid://shopify/Collection/{collectionId1}","gid://shopify/Collection/{collectionId2}" ]
})
{
product{
id
}
}
}

Shopify - Client side order Tagging

As per the requirements I got, In the Shopify shop, admin should be able to search for the orders from a customer chosen delivery date. The only feasible thing I could find was to tag the orders with their delivery and to filter the orders from the tag. My question is whether there a proper way to tag the orders with a customer given delivery date when a order is created? (I'm not allowed use any paid app/plug-in)
There are two approaches I could figure out with the admin orders API, but both has issues,
Write a webhook (for order confirmation event) to an external server that could get the user selected delivery date and call the admin order API from there to tag the order - The issues are it's an overhead to maintain a server only for tagging the order and even if I do since admin API doesn't allow CORS is this feasible? (and since the shop owner doesn't even want to pay for a paid plugin, maintaining server is also not practical)
Call the admin API from the client-side after the order is confirmed. I tried this and it works as it's expected but the issue is I have to keep the admin API credentials for orders and transactions stored in the client-side JavaScript which is not a good practice at all, as per my knowledge.
It's allowed to create additional details about the order at the client side using cart-attributes, and they are shown at the admin order's page as well, but Shoify doesn't allow to search orders using cart-attributes added to the order.
I would be grateful if someone can suggest a solution for this.
You can actually do this with a Chrome plugin (or really complex bookmarklet) with no server side requirements. see https://developer.chrome.com/extensions/overview
your api calls would look something like the following POC scripts. API calls won't search the order by tags so you could skip that and filter by a note_attribute set via your theme's .liquid code. Your chrome plugin would then list open orders and display them by requested delivery date.
get an existing order and update its note attribute:
jQuery.get('/admin/orders/5803440262.json').then(function(d) {
console.log(d.order);
var so = {
id: d.order.id,
note_attributes: [{
name: 'Test Value',
value: 'Test'
}]
};
jQuery.ajax({
url: '/admin/orders/' + so.id + '.json',
type: 'PUT',
data: JSON.stringify({
order: so
}),
contentType: 'application/json'
}).then(function(d) {
console.log(JSON.stringify(d, null, ' '));
});
});
and reading orders:
jQuery.get('/admin/orders.json?limit=250').then(function(d) {
var count = 0;
d.orders.forEach(function(so) {
if (so.tags.indexOf('__amazon_pending') != -1) count++;
});
console.log(count + ' matching orders');
});

Bigcommerce API - Create Shipment - Include all Items

according to the documentation, the Create Shipment method requires the property "items" - an array of the items being shipped, for example:
{
"tracking_number": "EJ958083578US",
"comments": "Ready to go...",
"order_address_id": 1,
"items": [
{
"order_product_id": 15,
"quantity": 2
}
]
}
In our business, a shipment almost invariably contains ALL items from the relevant order.
That being the case, is there a way to create a shipment without listing all items (which would require iterating over the product line-items)? Or, alternatively, a way to include all items by default (without iterating)?
We are simply wishing to automate the process of adding tracking numbers to orders - which (as a manual process) involves uploading a csv with [order_number: tracking_number] - i.e. it self-evidently assumes that all items are being shipped. The API seems not to include that (very sensible) option, but I may be wrong.
From Bigcommerce Support:
There is not a way to add a tracking number without adding a shipment nor a way to default the shipment to include all products. This is a helpful suggestion though that I will be passing on to our Product Team for possible implementation into future versions of the API.
Unfortunately for now it is necessary that you GET to the products subresource of an order and iterate over all of the products to pull their 'id' values and 'order_address_id' values so you can generate your POST request to the shipment subresource. It is not necessary to make a GET request to the shipping address subresource directly unless you want the details of that shipping address. It is also not necessary to make a GET request to the base order object unless you want details found there or you are looking to automate the process of checking for orders ready to ship.
So assuming you know an order ID that you want to ship it should only take 2 requests total to both GET the products subresource and then POST to the shipment resource.

Office365 REST v1.0 API How to query global category list

I am using the new Office365 REST API: https://msdn.microsoft.com/en-us/office/office365/api/api-catalog and am successfully querying calendar events, which include their categories as a list of strings: https://outlook.office365.com/api/v1.0/me/events
How do I query the global list of all categories associated with a calendar, as well as the colour associated with each category? The colours I setup via the Outlook client appear to persist across client instances, and yet I can't find a way to access these data via the API.
Great question! You can't access that information currently with the REST APIs, but it's a great idea.
If you're curious, all the gory details on how the category list is stored are documented in [MS-OXOCFG].
You can actually do this now with the current version of the Graph API. If you want to list the categories that have been defined for a user, you can use either of these endpoints:
GET /me/outlook/masterCategories
GET /users/{id|userPrincipalName}/outlook/masterCategories
and get something like this:
HTTP/1.1 200 OK
Content-type: application/json
Content-length: 727
{
"#odata.context":"https://graph.microsoft.com/beta/$metadata#users('8ae6f565-0d7f-4ead-853e-7db94c912a1f')/outlook/masterCategories",
"value":[
{
"id":"5a9a6aa8-b65f-4357-b1f9-60c6bf6330d8",
"displayName":"Red category",
"color":"preset0"
},
{
"id":"4b1c2495-54c9-4a5e-90a2-0ab0b31987d8",
"displayName":"Orange category",
"color":"preset1"
},
{
"id":"de912e4d-c790-4da9-949c-ccd933aaa0f7",
"displayName":"Yellow category",
"color":"preset3"
}
]
}