Merge remote-tracking branch 'origin/trunk' into spike/mini-cart-iapi
This commit is contained in:
commit
680ace06c0
|
@ -88,7 +88,8 @@
|
|||
"webpack*"
|
||||
],
|
||||
"packages": [
|
||||
"@woocommerce/block-library"
|
||||
"@woocommerce/block-library",
|
||||
"@woocommerce/storybook"
|
||||
],
|
||||
"isIgnored": true
|
||||
},
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
Significance: patch
|
||||
Type: fix
|
||||
Comment: This is a further fix for #49583, which has not yet been released
|
||||
|
||||
|
|
@ -750,7 +750,6 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da
|
|||
* Action to signal that the value of 'stock_quantity' for a variation has changed.
|
||||
*
|
||||
* @since 3.0
|
||||
* @since 9.2 Added $stock parameter.
|
||||
*
|
||||
* @param WC_Product $product The variation whose stock has changed.
|
||||
*/
|
||||
|
@ -760,7 +759,6 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da
|
|||
* Action to signal that the value of 'stock_quantity' for a product has changed.
|
||||
*
|
||||
* @since 3.0
|
||||
* @since 9.2 Added $stock parameter.
|
||||
*
|
||||
* @param WC_Product $product The variation whose stock has changed.
|
||||
*/
|
||||
|
|
|
@ -284,6 +284,10 @@ function wc_trigger_stock_change_notifications( $order, $changes ) {
|
|||
* @return void
|
||||
*/
|
||||
function wc_trigger_stock_change_actions( $product ) {
|
||||
if ( true !== $product->get_manage_stock() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$no_stock_amount = absint( get_option( 'woocommerce_notify_no_stock_amount', 0 ) );
|
||||
$low_stock_amount = absint( wc_get_low_stock_amount( $product ) );
|
||||
$stock_quantity = $product->get_stock_quantity();
|
||||
|
|
|
@ -432,4 +432,28 @@ class WC_Stock_Functions_Tests extends \WC_Unit_Test_Case {
|
|||
|
||||
remove_action( 'woocommerce_no_stock', $callback );
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox The wc_trigger_stock_change_actions function should only trigger actions if the product is set
|
||||
* to manage stock.
|
||||
*/
|
||||
public function test_wc_trigger_stock_change_actions_bails_early_for_unmanaged_stock() {
|
||||
$action_fired = false;
|
||||
$callback = function () use ( &$action_fired ) {
|
||||
$action_fired = true;
|
||||
};
|
||||
add_action( 'woocommerce_no_stock', $callback );
|
||||
|
||||
$product = WC_Helper_Product::create_simple_product();
|
||||
|
||||
$this->assertFalse( $action_fired );
|
||||
|
||||
$product->set_manage_stock( true );
|
||||
$product->set_stock_quantity( 0 );
|
||||
$product->save();
|
||||
|
||||
$this->assertTrue( $action_fired );
|
||||
|
||||
remove_action( 'woocommerce_no_stock', $callback );
|
||||
}
|
||||
}
|
||||
|
|
1059
pnpm-lock.yaml
1059
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
|
@ -46,9 +46,8 @@
|
|||
"@storybook/react": "6.5.17-alpha.0",
|
||||
"@storybook/theming": "6.5.17-alpha.0",
|
||||
"@woocommerce/eslint-plugin": "workspace:*",
|
||||
"react": "^17.0.2",
|
||||
"react18": "npm:react@^18.3.0",
|
||||
"react-dom": "^17.0.2",
|
||||
"react": "18.3.1",
|
||||
"react-dom": "18.3.1",
|
||||
"typescript": "^5.3.3",
|
||||
"webpack": "^5.89.0",
|
||||
"wireit": "0.14.3"
|
||||
|
|
|
@ -45,7 +45,14 @@ module.exports = ( storybookConfig ) => {
|
|||
|
||||
// We need to use react 18 for the storybook since some dependencies are not compatible with react 17
|
||||
// Once we upgrade react to 18 in repo, we can remove this alias
|
||||
storybookConfig.resolve.alias.react = require.resolve( 'react18' );
|
||||
storybookConfig.resolve.alias.react = path.resolve(
|
||||
__dirname,
|
||||
'./node_modules/react'
|
||||
);
|
||||
storybookConfig.resolve.alias[ 'react-dom' ] = path.resolve(
|
||||
__dirname,
|
||||
'./node_modules/react-dom'
|
||||
);
|
||||
|
||||
storybookConfig.resolve.modules = [
|
||||
path.join( __dirname, '../../plugins/woocommerce-admin/client' ),
|
||||
|
|
Loading…
Reference in New Issue