Set prices button from the variations notice is not updating the right amount of variations (#40876)
* Improve has_price filter so it can matches when the price record does not exist or it's empty/null * Get the exact variation ids of those ones that do not have price * Add changelog files * Fix linter errors
This commit is contained in:
parent
613a63b0ef
commit
8827e42bd7
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: patch
|
||||||
|
Type: fix
|
||||||
|
|
||||||
|
Get the exact variation ids of those ones that do not have price
|
|
@ -124,8 +124,11 @@ export function Edit( {
|
||||||
EXPERIMENTAL_PRODUCT_VARIATIONS_STORE_NAME
|
EXPERIMENTAL_PRODUCT_VARIATIONS_STORE_NAME
|
||||||
).getProductVariations< Pick< ProductVariation, 'id' >[] >( {
|
).getProductVariations< Pick< ProductVariation, 'id' >[] >( {
|
||||||
product_id: productId,
|
product_id: productId,
|
||||||
|
order: 'asc',
|
||||||
|
orderby: 'menu_order',
|
||||||
has_price: false,
|
has_price: false,
|
||||||
_fields: [ 'id' ],
|
_fields: [ 'id' ],
|
||||||
|
per_page: totalCountWithoutPrice,
|
||||||
} );
|
} );
|
||||||
handlePrompt( {
|
handlePrompt( {
|
||||||
onOk( value ) {
|
onOk( value ) {
|
||||||
|
@ -187,8 +190,8 @@ export function Edit( {
|
||||||
update &&
|
update &&
|
||||||
update.find(
|
update.find(
|
||||||
( variation ) =>
|
( variation ) =>
|
||||||
variation.regular_price ||
|
'regular_price' in variation ||
|
||||||
variation.sale_price
|
'sale_price' in variation
|
||||||
) )
|
) )
|
||||||
) {
|
) {
|
||||||
invalidateResolution(
|
invalidateResolution(
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: patch
|
||||||
|
Type: fix
|
||||||
|
|
||||||
|
Improve has_price filter so it can matches when the price record does not exist or it's empty/null
|
|
@ -906,13 +906,39 @@ class WC_REST_Product_Variations_Controller extends WC_REST_Product_Variations_V
|
||||||
|
|
||||||
// Price filter.
|
// Price filter.
|
||||||
if ( is_bool( $request['has_price'] ) ) {
|
if ( is_bool( $request['has_price'] ) ) {
|
||||||
$args['meta_query'] = $this->add_meta_query( // WPCS: slow query ok.
|
if ( $request['has_price'] ) {
|
||||||
$args,
|
$args['meta_query'] = $this->add_meta_query( // phpcs:ignore Standard.Category.SniffName.ErrorCode slow query ok.
|
||||||
array(
|
$args,
|
||||||
'key' => '_price',
|
array(
|
||||||
'compare' => $request['has_price'] ? 'EXISTS' : 'NOT EXISTS',
|
'relation' => 'AND',
|
||||||
)
|
array(
|
||||||
);
|
'key' => '_price',
|
||||||
|
'compare' => 'EXISTS',
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'key' => '_price',
|
||||||
|
'compare' => '!=',
|
||||||
|
'value' => null,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$args['meta_query'] = $this->add_meta_query( // phpcs:ignore Standard.Category.SniffName.ErrorCode slow query ok.
|
||||||
|
$args,
|
||||||
|
array(
|
||||||
|
'relation' => 'OR',
|
||||||
|
array(
|
||||||
|
'key' => '_price',
|
||||||
|
'compare' => 'NOT EXISTS',
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'key' => '_price',
|
||||||
|
'compare' => '=',
|
||||||
|
'value' => null,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter product based on stock_status.
|
// Filter product based on stock_status.
|
||||||
|
|
Loading…
Reference in New Issue