Request variations only when the product has variations (#46963)
* Make variations api request conditional * Add changelog
This commit is contained in:
parent
f0765081fe
commit
e21a78f8f0
|
@ -0,0 +1,4 @@
|
|||
Significance: minor
|
||||
Type: dev
|
||||
|
||||
Request variations only when the product has variations #46963
|
|
@ -49,6 +49,11 @@ export function Edit( {
|
|||
'product',
|
||||
'status'
|
||||
);
|
||||
const [ productHasOptions ] = useEntityProp< string >(
|
||||
'postType',
|
||||
'product',
|
||||
'has_options'
|
||||
);
|
||||
const [ productAttributes ] =
|
||||
useProductEntityProp< Product[ 'attributes' ] >( 'attributes' );
|
||||
|
||||
|
@ -78,13 +83,14 @@ export function Edit( {
|
|||
);
|
||||
|
||||
return {
|
||||
totalCountWithoutPrice:
|
||||
getProductVariationsTotalCount< number >(
|
||||
totalCountWithoutPriceRequestParams
|
||||
),
|
||||
totalCountWithoutPrice: productHasOptions
|
||||
? getProductVariationsTotalCount< number >(
|
||||
totalCountWithoutPriceRequestParams
|
||||
)
|
||||
: 0,
|
||||
};
|
||||
},
|
||||
[ totalCountWithoutPriceRequestParams ]
|
||||
[ productHasOptions, totalCountWithoutPriceRequestParams ]
|
||||
);
|
||||
|
||||
const {
|
||||
|
|
Loading…
Reference in New Issue