Could you please specify, what is the correct way to track the quantity of the variants of items in stock?
I see that products/update webhook shows the quantity, but I'm not sure if it fires when an item is purchased (and its quantity reduces by one), and in case of inventory_items/update there's no quantity information (though it seems I can thract it using InventoryLevel API call), but I'm not sure if this notification launches after item purchase.
Short answer: Both products/update and inventory_levels/update are fired when an item is purchased.
The request body of products/update looks something like this:
{
"id": 123,
"variants": [
{
"id": 456,
"product_id": 123,
"inventory_quantity": 99
}
]
}
inventory_quantity is the updated stock of the item that has just been purchased.
On the other hand, the request body of inventory_levels/update looks something like this:
{
"inventory_item_id": 987,
"available": 99
}
So both webhook topics give you access to the data you need. In the end it depends on your specific use case which of those two topics to use.
Related
I have a high volume shop with a lot of products and categories.
The products are seasonal, so a lot of new products are added.
Because of this, dynamic product groups are perfect. We set conditions and add the group to the category.
Right now i'm trying to get all the products of the category in the api's (both backend and store), but i dont get any product back. I do get a streamId back in the store-api https://localhost//store-api/product-listing/9cf2c65bd7084144aa4d4a35bb3f568e But there is no endpoint i can call for the streamId.
Next to that, the breadcrumbs are also missing on the front-end.
What is the best way to get a the products from a category back in the API?
Thanks!
If you do have the id of the product_stream you can filter product entities by them having that id as part of their streamIds:
// POST /api/search-ids/product
{
"page": 1,
"limit": 500,
"filter": [
{
"type": "equalsAny",
"field": "streamIds",
"value": [
"65103ca79e1e4e3ba846f551fbb1cb36" // your product stream id
]
}
]
}
I tried to follow this guide https://developers.amadeus.com/blog/add-baggage-amadeus-flight-booking-api on retrieving flight offer price.
After first request to the pricing endpoint I get:
"included": {
"bags": {
"1": {
"quantity": 1,
"name": "CHECKED_BAG",
"price": {
"amount": "1637",
"currencyCode": "NOK"
},
"bookableByItinerary": true,
"segmentIds": [
"3",
"21"
],
"travelerIds": [
"0",
"1"
]
},
"2": {
"quantity": 1,
"name": "CHECKED_BAG",
"price": {
"amount": "655",
"currencyCode": "NOK"
},
"bookableByItinerary": true,
"segmentIds": [
"3",
"21"
],
"travelerIds": [
"0",
"1"
]
}
}
},
To be honest I'm not sure how to interpret that. What do the "1" and "2" keys represent here? Are those for the first and the second flight offer that I sent in the request?
Anyway, after getting this response I'm assigning 1 to travelerPricings.fareDetailsBySegment.additionalServices.chargeableCheckedBags.quantity to every segment (ids "3" and "21") in every flight offer (2 of them).
I was expecting to get different prices in a response for a second request, but I got the same thing and additional services are never mentioned in the second response to flight offers pricing.
Am I doing something wrong?
I also tried to add bags for just one segment and the same thing happened.
I'm looking for a JFK<->MAD flight (2020-10-20 -> 2020-10-30).
The “1” and “2” are the id’s of the bag offers. In this case the API returns the offer 1 with 1 bag for 1637 NOK and the offer 2 with 1 bag for 655 NOK. By the price difference it means that one bag is bigger than the other even though the airline hasn’t provided explicitly this information. The segmentId in each bag offer guarantees which bag offer can be applied to which segment. Now, in this case both bag offers have the same quantity = 1. In order to choose which bag offer you want to add in the flight (as both offers have the same quantity), you can manually update the price of the flight offer with the one of the bag you’ve selected, so the system will know which bag to add.
When the price returned after adding the bags to the flight offers is the same, it means the bag was not possible to be added. This can be linked to several things such as: this bag is not available to a specific segment, due to the test environment data and it's limitations the amount of bags is not available while confirming in the flight offers price, or specific airlines allow only one bag for each person, or even the specific flight reached the limit of bag capacity as there is not unlimited amount of space.
With the legacy API, I can obtain product variant prices for productId 100 with the following:
https://something.com/api/v2/products/100/skus.json
But in the Stencil documentation for Product, there is no price property for a product attribute SKU, and the available properties that are available are limited vs the legacy API.
With product:
"values": [
{
"label": "Hardcover",
"id": 98,
"data": "Hardcover",
"selected": false
},
{
"label": "Paperback",
"id": 100,
"data": "Paperback",
"selected": false
}
],
From what I can gather, the variant pricing is only available via cart.items, but I need to display the prices before the user places an item in the cart.
Is there a way to get product variant pricing/info without using the cart.items object? Thanks!
I'm not aware of a way to do this via a stencil object.
On the product detail page I check if a product has_options, then make ajax calls to the variant URLs to get their prices to create a price range before the user selects their variants. This is pretty necessary when the vendor has huge price differences in variants.
ex.) "From $49.99 - $499.99" instead of "$49.99" default functionality.
I don't have a resolution for category pages as it doesn't make sense to make AJAX requests for each variant of each item on the category page on load. Once Stencil adds support for custom fields on the category page, you could add the child's prices to a parent SKUs custom field and perform some logic for whatever your trying to accomplish.
I don't know when custom fields will be available on the category page but I know they are working on it.
I used the Shopify API to create an order using my product's variantID.
For some reason, line_items in orders created using the API always have "vendor":"null". Whereas orders for the same variant created via the store returns the correct vendor.
Am I doing anything wrong?
URL: https://xxyy.myshopify.com/admin/orders.json
{ "order": {
"email": "ken#xxyy.com",
"fulfillment_status": "unfulfilled" ,
"send_receipt": true,
"send_fulfillment_receipt": false,
"line_items": [{
"variant_id": 3866750123,
"quantity": 1
}]
}
}
I get that sometimes too and it is truly crappy. If you create a line item using the API it seems you need to provide not only the product and variant ID, but also the vendor, as even if it exists in the product, that does not get picked up in the order creation process. A lot of Apps screw this up. Which screws up other Apps expecting good orders. And a it seems to me a good order should have the product vendor field set.
I've written an automated system to automatically fulfill items in shopify via the API from data received from a fulfillment center but would like to build a tool to "undo" fulfillment should there be a problem but I can't seem to get the API to respond and the documentation is fuzzy as to which id's are required..
I assume the first #id is the order id and the second the item but I've tried all the id's from the order/fulfillment (line item ids, item_id, etc) and I'm still getting a {"errors":"Not Found"} from POST CURL call.
Am I using the wrong id? or is there some other reason work?
Here's the url Im hitting:
https://{API_KEY}:{API_PASS}#{my_store}.myshopify.com/admin/orders/{order_id}/fulfillments/{some_id?}/cancel.json
The first ID is the order ID, as defined in the order_id parameter on the fulfillment.
The second ID is the fulfillment ID, which is defined in the id parameter on the fulfillment.
Assuming you have a fulfillment that looks like this:
"fulfillment": {
"created_at": "2012-10-16T11:31:17-04:00",
"id": 255858046,
"order_id": 450789469,
"service": "manual",
"status": "pending",
"tracking_company": null,
"tracking_number": "1Z2345",
"tracking_url": "http://www.google.com/search?q=1Z2345",
"updated_at": "2012-10-16T11:31:17-04:00",
"receipt": {
"testcase": true,
"authorization": "123456"
}
}
Your POST URL should look like this:
/admin/orders/450789469/fulfillments/255858046/cancel.json