can not update data_01 / 403 error

api_issuesapi_issues Member Posts: 4

Hello,

We have lightspeed for retail and ecommerce. Since there is no stock level variables exposed on snippets/products.rain (?) we are setting a simple "Yes" or "No" value to the product property Data_01 which is exposed to that template file. This helps determine whether or not a given product has stock available - ex show "In Stock" or "Custom Order" if no stock.

Currently this done via Excel imports, however we are trying to automate this as long term exporting/updating/uploading Excel documents multiple times a day is NOT a solution. We have an eCom API key with full permissions and can fetch a list of all products no problem, however we can not update a product using the following example:


curl -X PUT https://api.shoplightspeed.com/en/products/{PRODUCT_ID}.json \

 -u key:secret \

 -d product[data01]="Yes"


As it yields this error:

{"error":{"code":403,"method":"UPDATE","request":"\/en\/products\/{PRODUCT_ID}.json","message":"The server understood the request, but is refusing to fulfill it."}}


I'm reading elsewhere that products can't be updated via api if it's an OMNI account (retail+ecom?). Ok, that's fine, but I'm not seeing anywhere to update data_01 on the retail side.


Please help, this is urgent...

6 comments

  • LucienVersendaalLucienVersendaal Moderator, Lightspeed Staff Posts: 723 moderator

    Hi @api_issues,

    Thank you for contacting us.

    In products.rain page you can use {{ product.available }} which give you the products which are in or out of stock.

  • api_issuesapi_issues Member Posts: 4

    Hello @LucienVersendaal

    That won't work for our use case since we allow all products to be purchasable regardless of stock quantities. So if an item is out of stock, that variable will still return 'true'.

  • LucienVersendaalLucienVersendaal Moderator, Lightspeed Staff Posts: 723 moderator

    Hi @api_issues,

    Okay I understand, so what you are saying is that when a product is out of stock it still can be sold? If so, you can Allow Backorders in your variant so when your stock is 0 it still is purchasable.

    I hope this helps.

  • api_issuesapi_issues Member Posts: 4

    Hello @LucienVersendaal ,

    We already have that configured. I'll try to explain more clearly. In our "snippets/products.rain" we have the following:


        {% if product.data_01 == 'Yes' %} 

        <div class="product-instock">In Stock</div>

        {% else %}

        <div class="product-outstock">Custom Order</div>

        {% endif %}


    There is currently NO variable exposed with "product" so we can determine whether the product has stock or is out of stock. So, we are using one of the template variables "data_01" which means we have to do manual exports of all our products, update the excel sheet for every product then re-import it.


    No looking at my previous comments, we can't update "data_01" with the ecommerce api since we also use 'retail' for some silly reason, even though data_01 appears to be an ecommerce specific variable meaning we can't update this variable with the Retail api as far as I know.


    That's the problem here...

  • LucienVersendaalLucienVersendaal Moderator, Lightspeed Staff Posts: 723 moderator

    Hi @api_issues,

    Okay I see. Correct when having an Omnishop it isn't possible to update products with eCom API, this because Retail is leading.

    I've tested some things out and was manage to get the stock level on the products.rain file with AJAX. So in my test shop it looks like this now.

    Please give me your shop number and I will implement it for you as well.

  • api_issuesapi_issues Member Posts: 4

    AWESOME!!

    Shop id is 222693

    Thank-you @LucienVersendaal

Sign In or Register to comment.