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

Updating Inventory Quantity Without Creating Inventory Level and Location #57

Open
kirthick opened this issue Nov 18, 2023 · 2 comments

Comments

@kirthick
Copy link

Hello Signifly Support,

I trust this message finds you well. I've recently integrated the Signifly/Shopify app, and while most functionalities are working smoothly, I'm facing a challenge regarding inventory management.

Specifically, I need guidance on updating inventory quantities without the need to create a new inventory level and location. It seems that the current process involves these steps, but I'm wondering if there's a more direct method or if this feature will be considered in future updates.

@BrandonKerr
Copy link
Contributor

I'm not part of the Signifly support, but I've worked on inventory changes recently. This can be done using the adjustInventoryLevel function. You'll need

  • some specific information about the product variant that you're updating
  • the Shopify id of the location where you're updating the inventory
  • the stock adjustment

Note that you can't just set the inventory level, Shopify simply doesn't allow it. You have to adjust it.
So for example

// the Shopify ID for the location
$locationId = 1321312312;
// whatever you want the stock level to be
$desiredStock = 100;
// get the variant resource data, using the variant's Shopify ID
$variantResource = $this->shopify->getVariant(12313232);
$variantAttributes = $variantResource->getAttributes();
// get the current inventory level in Shopify
$inventoryQuantity = $variantAttributes["inventory_quantity"];
// calculate the adjustment required
$stockAdjustment = $desiredStock - $inventoryQuantity;

$this->shopify->adjustInventoryLevel($variantAttributes["inventory_item_id"], $locationId, $stockAdjustment);

If you're just adjusting it (e.g. adding 20), you can simplify that a bit and just set the (e.g. 20) to the last parameter. If you're reducing stock, just pass the negative value to adjust by.

Hope that helps.

@kirthick
Copy link
Author

kirthick commented Dec 1, 2023

@BrandonKerr Thanks

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

2 participants