Skip to content

Commit

Permalink
Store: Reset product category and product IDs when switching to "appl…
Browse files Browse the repository at this point in the history
…ies to all products" (Automattic#24481)
  • Loading branch information
justinshreve authored Apr 26, 2018
1 parent 3f7597f commit 0502e6a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions client/extensions/woocommerce/state/sites/promotions/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,15 @@ export function createCouponUpdateFromPromotion( promotion ) {
let freeShipping = promotion.freeShipping;
let discountType = promotion.type;
const meta = [ { key: 'promotion_type', value: promotion.type } ];
const productIds = ( appliesTo && appliesTo.productIds ) || undefined;
const productCategoryIds = ( appliesTo && appliesTo.productCategoryIds ) || undefined;

let productIds = ( appliesTo && appliesTo.productIds ) || undefined;
let productCategoryIds = ( appliesTo && appliesTo.productCategoryIds ) || undefined;

// If 'all' was selected, pass in empty arrays to reset product ids and category ids
if ( appliesTo.all ) {
productIds = [];
productCategoryIds = [];
}

// If end date is null, that means it was enabled but not selected, so use today as default.
const endDate = null === promotion.endDate ? new Date().toISOString() : promotion.endDate;
Expand Down

0 comments on commit 0502e6a

Please sign in to comment.