Trigger event to override inventory locations per order#4276
Open
yoannisj wants to merge 1 commit intocraftcms:5.xfrom
Open
Trigger event to override inventory locations per order#4276yoannisj wants to merge 1 commit intocraftcms:5.xfrom
yoannisj wants to merge 1 commit intocraftcms:5.xfrom
Conversation
- trigger event when getting the inventory locations for given purchasable `craft\commerce\services\InventoryLocations:: EVENT_REGISTER_INVENTORY_LOCATIONS_FOR_PURCHASABLE ` which allows modules and plugins to select a subset of the store’s inventory locations based on the order details - add first argument `$order` to \craft\commerce\base\Purchasable::getStock()` to aggregate stock in order-specific inventory locations only - add first argument `$order` to \craft\commerce\base\Purchasable::hasStock()` to check for stock in order-specific inventory locations only - verify stock available in order-specific inventory locations when checking a purchasable’s availability
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds the following changes in order to allow modules and plugins to select a subset of the store's inventory locations, when Craft-Commerce is accessing a given purchasable's stock. When this is done in the context of an order, then this selection can be made based on the order's details.
craft\commerce\services\InventoryLocations:: EVENT_REGISTER_INVENTORY_LOCATIONS_FOR_PURCHASABLEwhen accessing a given purchasable's stock, which allows modules and plugins to select a subset of the store’s inventory locations$orderto \craft\commerce\base\Purchasable::getStock()` to aggregate stock in order-specific inventory locations only$orderto \craft\commerce\base\Purchasable::hasStock()` to check for stock in order-specific inventory locations onlyRelated issues
The changes make it possible for modules or plugins to implement the use-cases described in #4273 and most use-cases from #4247 .