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

Product inventory out of sync after purchase #61

Closed
justenh opened this issue Mar 19, 2023 · 6 comments
Closed

Product inventory out of sync after purchase #61

justenh opened this issue Mar 19, 2023 · 6 comments
Labels
evaluating Issue needs further investigation

Comments

@justenh
Copy link

justenh commented Mar 19, 2023

I've been using this plugin for a custom storefront and learned today that Shopify does not trigger the "products/update" web-hook when an item is purchased, which means that the data Craft has regarding inventory will be out-of-date the moment someone purchase the product. Is there planned support for adding other web-hooks that could trigger product syncs?

This is the particular field in question.
$this->getDefaultVariant()['inventory_quantity'];

@justenh justenh added the bug Something isn't working label Mar 19, 2023
@lukeholder lukeholder added evaluating Issue needs further investigation and removed bug Something isn't working labels Apr 3, 2023
@justenh
Copy link
Author

justenh commented Apr 5, 2023

@lukeholder thanks for moving this into "evaluating". Relatedly, would there be a possibility for us to trigger a product sync via cli to handle these situations?

@johndwells
Copy link

Shopify does not trigger the "products/update" web-hook when an item is purchased

@justenh any chance you have a link to documentation that stipulates this? It's so hard to find reputable information that isn't outdated or not relevant for the API.

@lukeholder
Copy link
Member

lukeholder commented Jun 9, 2023

I have gone ahead and added support for updating the product (and variants) when an inventory level is updated.

This will be in the next release.

Please note this will require making sure your API credential key's "Admin API access scopes" includes:

read_product_listings, read_products, read_inventory, write_inventory

After upgrading you will also need to revisit the webhooks page in the shopify plugin CP and click 'create' to make sure the inventory_levels/update event is being listened to on the webhooks.

To get the fix early, change your craftcms/shopify requirement in composer.json to:

"require": {
  "craftcms/shopify": "dev-develop#167a6b36da3acbe0cea971665faa1d5dee619e6e as 3.1.1",
  "...": "..."
}

Then run composer update.

@justenh
Copy link
Author

justenh commented Jun 12, 2023

@lukeholder Thanks for the update!

What action is performed where "write_inventory" needs to be granted? Is this part of the incoming update?

@lukeholder
Copy link
Member

@justenh apologies that is a error in the docs/readme. It should just be read only for inventory. I will fix shortly.

@lukeholder
Copy link
Member

This is now out in 3.2.0!

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

No branches or pull requests

3 participants