Convert Cart to Order: Override Stock Check? #41
-
Your API has a functionality to convert a cart to an order (i.e. https://developers.swell.is/backend-api/carts/create-a-cart#convert-carts-to-orders). However, the conversion will fail if the product stock is unavailable. Is there a way to override this? In other words, we want the cart to convert even if the stock is unavailable. Of course, I know we can eliminate inventory tracking for the cart item on the backend, but we don't want to do that. For various scenarios, we need to both have inventory tracking on the backend, but also allow orders to go thru upon a cart conversion, even if the product stock is unavailable. Is there some argument we can send to the Convert to Cart api endpoint to force the order thru even if there is not enough stock of a product where we are tracking inventory? Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
@osseonews That's a great question! Documentation Reference: |
Beta Was this translation helpful? Give feedback.
-
Just an aside, but the "Allow purchases when out of stock" is set on an individual product level! This means that to allow backorders we need to go into every single product we want to allow backorders for and toggle this to true. This is impractical. No chance, we are going to update many products like this and risk breaking something. you need to have a global setting: "Allow purchases when out of stock.", if you are going to keep this part of your API which blocks orders on an inventory issue. In any case, your existing inventory control really doesn't make any sense for any practical use case. There is no reason for an order to fail at the very last step when converting a cart to an order b/c of a lack of inventory. you would check inventory prior to converting to an order, not after! It is nuts that a customer can get to the final step in checkout and the order will fail b/c of this (unless of course we go into every single product and change the setting - not happening). So now as it is, we need to manually create an order from a cart, per Eric's comment above, which is a huge, huge pain and prone to error. Please just remove this feature from the cart API, convert cart to orders, or make it a Boolean type of API - so if it is true, the order will fail for inventory, and if false the order will succeed. At least then it can be overwritten at the API level. Honestly, I've done e-commerce for 15+ yrs and never once have I seen an order API endpoint like this. It is totally not based on any actual use case. The inventory is always checked prior to converting to an order (in cart) or there is a global setting for checking on the order for something like this. In your case, there is neither. You need to set this on every single product individually. |
Beta Was this translation helpful? Give feedback.
-
@ericingram Can you please paste the full "Cart to Order" mapping function here that is internal to the API, so we don't need to reinvent the wheel and code our own "cart to order" in an attempt to override the inventory issue? Your code above has alot of ..., and we don't have access the code as it's not in the actual API packages. Thanks. |
Beta Was this translation helpful? Give feedback.
@osseonews That's a great question!
Yes, you can definitely do it. You're just one step away from enabling the
Allow purchases when out of stock
toggle under Inventory tab in Product details page.Documentation Reference:
https://www.swell.is/help/products/product-management/product-inventory#purchasing-while-out-of-stock