Product variations should inherit parent product properties (#36234)
Remove manage_stock 'parent' value before saving the variation
This commit is contained in:
parent
ef3d15fcd4
commit
8bada412d4
|
@ -0,0 +1,4 @@
|
|||
Significance: minor
|
||||
Type: add
|
||||
|
||||
Add manage_stock parent value to product variation type definition
|
|
@ -55,13 +55,21 @@ export interface ProductVariationImage {
|
|||
|
||||
export type ProductVariation = Omit<
|
||||
Product,
|
||||
'name' | 'slug' | 'attributes' | 'images'
|
||||
'name' | 'slug' | 'attributes' | 'images' | 'manage_stock'
|
||||
> & {
|
||||
attributes: ProductVariationAttribute[];
|
||||
/**
|
||||
* Variation image data.
|
||||
*/
|
||||
image?: ProductVariationImage;
|
||||
/**
|
||||
* Stock management at variation level. It can have a
|
||||
* 'parent' value if the parent product is managing
|
||||
* the stock at the time the variation was created.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
manage_stock: boolean | 'parent';
|
||||
};
|
||||
|
||||
type Query = Omit< ProductQuery, 'name' >;
|
||||
|
|
|
@ -36,8 +36,14 @@ export const ProductVariationFormActions: React.FC = () => {
|
|||
const onSave = async () => {
|
||||
setIsSaving( true );
|
||||
updateProductVariation< Promise< ProductVariation > >(
|
||||
{ id: variationId, product_id: productId },
|
||||
values
|
||||
{ id: variationId, product_id: productId, context: 'edit' },
|
||||
{
|
||||
...values,
|
||||
manage_stock:
|
||||
values.manage_stock === 'parent'
|
||||
? undefined
|
||||
: values?.manage_stock,
|
||||
}
|
||||
)
|
||||
.then( () => {
|
||||
createNotice(
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
Significance: minor
|
||||
Type: add
|
||||
|
||||
Remove manage_stock 'parent' value before saving the variation
|
Loading…
Reference in New Issue