Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InventoryLevel action #505

Closed
thisislorne opened this issue Nov 5, 2018 · 2 comments
Closed

InventoryLevel action #505

thisislorne opened this issue Nov 5, 2018 · 2 comments

Comments

@thisislorne
Copy link

Using the latest version (5.2.0) and trying to update stock level using the InventoryLevel endpoint.
Have tried the following with no luck.. Not sure if I'm calling this wrong or if this is an issue.

ShopifyAPI::InventoryLevel({'location_id' => '7886569583','inventory_item_id' => variant.inventory_item_id})
*** NoMethodError Exception: undefined method `InventoryLevel' for ShopifyAPI:Module
ShopifyAPI::InventoryLevel.adjust({'location_id' => '7886569583','inventory_item_id' => variant.inventory_item_id,'available_adjustment' => '-1'})
*** NoMethodError Exception: undefined method `adjust' for ShopifyAPI::InventoryLevel:Class

but the following works:

ShopifyAPI::InventoryLevel.element_path({'location_id' => '7886569583','inventory_item_id' => variant.inventory_item_id})
"/admin/inventory_levels.json?inventory_item_id=16357485052015&location_id=7886569583"

Have posted here also.

@richter-alex
Copy link
Member

@thisislorne InventoryLevel#adjust is an instance method, so you'd be invoking it like so:

params = { inventory_item_ids: '123456,567890' }
inventory_levels = ShopifyAPI::InventoryLevel.find(:all, params: params)
# => array_of_inventory_levels

inventory_adjustment = 10 # Add 10
inventory_levels[0].adjust(inventory_adjustment) # target the first inventory_level
# => true

Closing issue.

@nxebre
Copy link

nxebre commented Jan 30, 2021

ActiveResource::ResourceInvalid: Failed. Response code = 422. Response message = Unprocessable Entity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants