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
|
||||
).getProductVariations< Pick< ProductVariation, 'id' >[] >( {
|
||||
product_id: productId,
|
||||
order: 'asc',
|
||||
orderby: 'menu_order',
|
||||
has_price: false,
|
||||
_fields: [ 'id' ],
|
||||
per_page: totalCountWithoutPrice,
|
||||
} );
|
||||
handlePrompt( {
|
||||
onOk( value ) {
|
||||
|
@ -187,8 +190,8 @@ export function Edit( {
|
|||
update &&
|
||||
update.find(
|
||||
( variation ) =>
|
||||
variation.regular_price ||
|
||||
variation.sale_price
|
||||
'regular_price' in variation ||
|
||||
'sale_price' in variation
|
||||
) )
|
||||
) {
|
||||
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.
|
||||
if ( is_bool( $request['has_price'] ) ) {
|
||||
$args['meta_query'] = $this->add_meta_query( // WPCS: slow query ok.
|
||||
if ( $request['has_price'] ) {
|
||||
$args['meta_query'] = $this->add_meta_query( // phpcs:ignore Standard.Category.SniffName.ErrorCode slow query ok.
|
||||
$args,
|
||||
array(
|
||||
'relation' => 'AND',
|
||||
array(
|
||||
'key' => '_price',
|
||||
'compare' => $request['has_price'] ? 'EXISTS' : 'NOT EXISTS',
|
||||
'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.
|
||||
|
|
Loading…
Reference in New Issue