How to get a product / variant "committed" inventory? - shopify

Problem:
On the Shopify Admin, section Products > Inventory, there's a "committed" inventory.
Based on my comprehension it means "reserved stock for pending orders", or "inventory reserved by orders created but not yet completed".
This "committed" stock value can be very useful for stock updates by app. But pratically this value seems hard to retreive.
Question:
How to get this "committed" inventory value in an efficient way ?
Current state of researchs :
Not possible via Shopify APIs (REST & GraphQL, version 2022-07)
Can be approximated (not sure it's the right method) by looping over all unfulfilled orders, and sum up (by variant) the unfulfilled product variant quantity. However, it takes time and consumes a lot of API resources.

According to a Shopify Community Manager (ref. post)
The Committed inventory state isn't added to the API currently.

It's possible now in the 2023-01 version of the API. The InventoryLevel got a new field quantities, which returns this for a product with a total stock of 10 and two sold:
[
{
"quantity": 8,
"name": "available"
},
{
"quantity": 2,
"name": "committed"
},
{
"quantity": 0,
"name": "incoming"
},
{
"quantity": 10,
"name": "on_hand"
},
{
"quantity": 0,
"name": "reserved"
}
]

Related

Retrieve coin base price (or quantity) from transaction data using BscScan APIs

I'm trying to write an app to track my gains/losses for tax purposes based on the swaps I've made using Bscscan APIs. I can easily retrieve all the swaps I've made using one of BscScan "accounts" module api endpoint (Get a list of 'BEP-20 Token Transfer Events' by Address to be exact). Here's an example of the body response:
{
"status": "1",
"message": "OK",
"result": [{
"blockNumber": "2304192",
"timeStamp": "1605585978",
"hash": "0x7a5abf86c82d3f97a40dd841a9f2089fbe3ac1332157c01bd1a1d89f575c45fc",
"nonce": "57",
"blockHash": "0x703438fd8ba435996895a6b9b711934cc590c3e9297a7066419aa88dd9d83acc",
"from": "0x641414e2a04c8f8ebbf49ed47cc87dccba42bf07",
"contractAddress": "0xc9849e6fdb743d08faee3e34dd2d1bc69ea11a51",
"to": "0x7bb89460599dbf32ee3aa50798bbceae2a5f7f6a",
"value": "27605634758857128698365",
"tokenName": "Bunny Token",
"tokenSymbol": "BUNNY",
"tokenDecimal": "18",
"transactionIndex": "2",
"gas": "5000000",
"gasPrice": "20000000000",
"gasUsed": "2312130",
"cumulativeGasUsed": "2475576",
"input": "deprecated",
"confirmations": "8172919"
}
]
}
So the value input ("value": "27605634758857128698365") gives the value in the underlying coin "currency" - in this case "Bunny Token" - but without knowing the quantity of that coin bought, I can't determine the cost basis of that transaction. I've looked at other bscscan APIs but I couldn't find any that would could help me retrieve the price of the coin for a given transaction.
Does anyone know if there's a way to retrieve the price of a coin (or the quantity bought) based on the transaction data using bsccan api?
TIA

Double Discounted Lines in Shopify Order API

I came across a situation that I hope someone else has seen.
The order looks like this in shopify:
The Discounted Line Item JSON looks like this:
{
"id": XXXXX,
"name": "NAME",
"price": "19.10",
"product_exists": true,
"quantity": 1,
"sku": "SKU",
"total_discount": "9.55",
"discount_allocations": [
{
"amount": "9.55",
"amount_set": {
"shop_money": {
"amount": "9.55",
"currency_code": "USD"
},
"presentment_money": {
"amount": "9.55",
"currency_code": "USD"
}
},
"discount_application_index": 0
}
]
},
An Automatic Discount as a "BOGO at 50% off" was applied to this order, but I cant quite get the discounting right for a net unit price, without also causing issues elsewhere in this particular Shopify Tenant.
Previously I would
line_unit_price = price - (TotalDiscount/Quantity) - SumOfDiscountApplications
But in this case, that would just double discount it to zero, which is not correct. In other cases with this Shopify Tenant, I do need to use the Discount Applications as TotalDiscount would be 0. I cant quite figure out when/where/why to do the math differently for an effective Line Net Unit Price.
Very odd. Any help would be great.

create order with different extra bag for outbound and inbound

I want to test order create API by adding extra bags. And I am experiencing a strange problem.
I make a search for Paris-NYC round trip, then I send the request to offer price API using include=detailed-fare-rules,bags parameter.
In the response, I get 2 kinds of extra bag information:
1 bag, 30 EUR
2 bags, 75 EUR
"bags": {
"1": {
"quantity": 1,
"name": "CHECKED_BAG",
"price": {
"amount": "30.00",
"currencyCode": "EUR"
},
"bookableByItinerary": true,
"segmentIds": [
"1",
"3"
],
"travelerIds": [
"1"
]
},
"2": {
"quantity": 2,
"name": "CHECKED_BAG",
"price": {
"amount": "75.00",
"currencyCode": "EUR"
},
"bookableByItinerary": true,
"segmentIds": [
"1",
"3"
],
"travelerIds": [
"1"
]
}
}
Everything goes well if I create order by:
adding 1 bag for outbound(paris to NYC), and adding 1 bag for inbound(NYC to Paris)
adding only 1 bag for outbound (0 extra bag for inbound)
adding 2 bag for outbound(paris to NYC), and adding 2 bags for inbound(NYC to Paris)
The problem is for the scenario:
I create order by adding 1 bag for outbound, and adding 2 bags for inbound.
In this case, the order is created with a warning message
"warnings": [
{
"status": 200,
"code": 0,
"title": "BookingWithPriceMarginWarning",
"detail": "The prices are lower than expected"
}
]
And the created order contains 1 extra bag for outbound, and 1 extra bag for inbound.
So I have 2 questions about this strange problem:
Is it normal that my order is modified when processing order create ?
Adding different number of extra bags for different itineraries is supported ?
Thanks
Is it normal that my order is modified when processing order create ?
It depends if you are Self-Service or Enterprise user:
For Enterprise users, Flight Create Orders offer the possibility to do a "best-effort" for additional-service booking. If this option is activated, Flight Create Orders gives priority to the reservation of your flight and remove the additional service that cannot be booked. That's why you receive the warning in your request when it happens.
Self Service users have the default behavior which rejects the creation of the order if at least one additional service can not be booked. In this case you will receive the following error:
{
"errors": [
{
"status": 400,
"code": 38034,
"title": "ONE OR MORE SERVICES ARE NOT AVAILABLE",
"detail": "Error booking additional services"
}
]
}
Adding different number of extra bags for different itineraries is supported ?
Yes, that is supported. Be aware that you cannot have an infinite amount of bag on a plane, so it could happen that you get an error when adding extra bags if there are too many bags already added by other passengers.

BigCommerce Stencil - Retrieve Product Custom Fields in Product Card

I'm trying to retrieve each product's custom_fields data on the category list pages in BigCommerce Stencil. This documentation here, and the JSON product representation below, would suggest this is not possible.
It is hard for me to believe this functionality would be left out of Stencil, considering it was available in Blueprint.
{
"id": 691,
"name": "Archipelago Botanicals - Pomegranate Lip Gloss",
"url": "http://******.mybigcommerce.com/archipelago-botanicals-pomegranate-lip-gloss/",
"brand": {
"name": "Archipelago Botanicals"
},
"rating": 0,
"availability": "",
"summary": "Pomegranate lip gloss leaves lips hydrated, shiny and smooth. Apply liberally.Net Weight: 0.42 oz. / 12 g Mineral Oil, Polybutene, Octyidodecanol, Butylene, Ethylene, Styrene Copolymer, Ethylene, Propylene, Styrene Copolymer, C18-36 Acid Triglycerides, Fr",
"image": {
"data": "https://cdn3.bigcommerce.com/*****/images/stencil/{:size}/products/691/41439/arbopolipgl__77026.1464267682.jpg?c=2",
"alt": "Archipelago Botanicals - Pomegranate Lip Gloss"
},
"date_added": "Apr 7th 2016",
"qty_in_cart": 0,
"pre_order": false,
"has_options": false,
"show_cart_action": false,
"price": {
"without_tax": {
"formatted": "$5.00",
"value": 5
},
"rrp_without_tax": {
"formatted": "$12.50",
"value": 12.5
},
"saved": {
"formatted": "$7.50",
"value": 7.5
},
"tax_label": "Tax"
}
},
Am I missing something, or is this functionality not available on Stencil at this time?
Has anyone come up with a creative solution to retrieve this data inside each product card?
Thanks
The product card now allows this to be exposed. It provides an array of all custom fields associated with a product. Information on the product card object is here.
It was a change that had to be made in the BC core app and the fix was released on Sept 20th

How do i make custom reordering for products in collection in shopify

How do i make custom reorder for products in collection in shopify. i mean for exapmle i have 'test' collection and i want to reorder products in 'test' collection by using product tag i mean i put some tags like 'firstshowup' in some product in 'test' collection so when customer click 'test' collection customer see products which have 'firstshowup' tag first and then see the rest so what iam trying here is reordering using custom reordering not using like order by bestseller or allpabetically or date created s.t
thank you so much guys in advance
Your collection will be made up of Collect objects, which have a position attribute. Assuming you're using a CustomCollection, you can modify the position of the Collects by updating the CustomCollection: http://api.shopify.com/customcollection.html#update
From the examples, to update a collection, you can use:
PUT /admin/custom_collections/#{id}.json
With the following payload:
{
"custom_collection": {
"body_html": "<p>The best selling ipod ever</p>",
"handle": "ipods",
"id": 841564295,
"published_at": "2008-02-01T19:00:00-05:00",
"sort_order": "manual",
"template_suffix": null,
"title": "IPods",
"updated_at": "2008-02-01T19:00:00-05:00",
"image": {
"created_at": "2012-12-11T12:01:29-05:00",
"src": "http://cdn.shopify.com/s/files/1/0006/9093/3842/collections/ipod_nano_8gb.jpg?0"
},
"collects": [
{
"product_id": 921728736,
"position": 1
},
{
"id": 841564295,
"position": 2
}
]
}
}