Skip to content

Commit

Permalink
Merge branch 'coupons'
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbromley committed Oct 10, 2019
2 parents d985dd3 + 02ebd9c commit 95bf868
Show file tree
Hide file tree
Showing 36 changed files with 1,489 additions and 221 deletions.
16 changes: 16 additions & 0 deletions packages/admin-ui/src/app/common/generated-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,9 @@ export type CreateProductVariantOptionInput = {
export type CreatePromotionInput = {
name: Scalars['String'],
enabled: Scalars['Boolean'],
startsAt?: Maybe<Scalars['DateTime']>,
endsAt?: Maybe<Scalars['DateTime']>,
couponCode?: Maybe<Scalars['String']>,
conditions: Array<ConfigurableOperationInput>,
actions: Array<ConfigurableOperationInput>,
};
Expand Down Expand Up @@ -2188,6 +2191,7 @@ export type Order = Node & {
billingAddress?: Maybe<OrderAddress>,
lines: Array<OrderLine>,
adjustments: Array<Adjustment>,
couponCodes: Array<Scalars['String']>,
payments?: Maybe<Array<Payment>>,
fulfillments?: Maybe<Array<Fulfillment>>,
subTotalBeforeTax: Scalars['Int'],
Expand Down Expand Up @@ -2629,6 +2633,9 @@ export type Promotion = Node & {
id: Scalars['ID'],
createdAt: Scalars['DateTime'],
updatedAt: Scalars['DateTime'],
startsAt?: Maybe<Scalars['DateTime']>,
endsAt?: Maybe<Scalars['DateTime']>,
couponCode?: Maybe<Scalars['String']>,
name: Scalars['String'],
enabled: Scalars['Boolean'],
conditions: Array<ConfigurableOperation>,
Expand All @@ -2638,6 +2645,9 @@ export type Promotion = Node & {
export type PromotionFilterParameter = {
createdAt?: Maybe<DateOperators>,
updatedAt?: Maybe<DateOperators>,
startsAt?: Maybe<DateOperators>,
endsAt?: Maybe<DateOperators>,
couponCode?: Maybe<StringOperators>,
name?: Maybe<StringOperators>,
enabled?: Maybe<BooleanOperators>,
};
Expand All @@ -2659,6 +2669,9 @@ export type PromotionSortParameter = {
id?: Maybe<SortOrder>,
createdAt?: Maybe<SortOrder>,
updatedAt?: Maybe<SortOrder>,
startsAt?: Maybe<SortOrder>,
endsAt?: Maybe<SortOrder>,
couponCode?: Maybe<SortOrder>,
name?: Maybe<SortOrder>,
};

Expand Down Expand Up @@ -3403,6 +3416,9 @@ export type UpdatePromotionInput = {
id: Scalars['ID'],
name?: Maybe<Scalars['String']>,
enabled?: Maybe<Scalars['Boolean']>,
startsAt?: Maybe<Scalars['DateTime']>,
endsAt?: Maybe<Scalars['DateTime']>,
couponCode?: Maybe<Scalars['String']>,
conditions?: Maybe<Array<ConfigurableOperationInput>>,
actions?: Maybe<Array<ConfigurableOperationInput>>,
};
Expand Down
22 changes: 22 additions & 0 deletions packages/common/src/generated-shop-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1301,6 +1301,10 @@ export type Mutation = {
* third argument 'customFields' will be available.
*/
adjustOrderLine?: Maybe<Order>;
/** Applies the given coupon code to the active Order */
applyCouponCode?: Maybe<Order>;
/** Removes the given coupon code from the active Order */
removeCouponCode?: Maybe<Order>;
transitionOrderToState?: Maybe<Order>;
setOrderShippingAddress?: Maybe<Order>;
setOrderShippingMethod?: Maybe<Order>;
Expand Down Expand Up @@ -1358,6 +1362,14 @@ export type MutationAdjustOrderLineArgs = {
quantity?: Maybe<Scalars['Int']>;
};

export type MutationApplyCouponCodeArgs = {
couponCode: Scalars['String'];
};

export type MutationRemoveCouponCodeArgs = {
couponCode: Scalars['String'];
};

export type MutationTransitionOrderToStateArgs = {
state: Scalars['String'];
};
Expand Down Expand Up @@ -1460,17 +1472,23 @@ export type Order = Node & {
id: Scalars['ID'];
createdAt: Scalars['DateTime'];
updatedAt: Scalars['DateTime'];
/** A unique code for the Order */
code: Scalars['String'];
state: Scalars['String'];
/** An order is active as long as the payment process has not been completed */
active: Scalars['Boolean'];
customer?: Maybe<Customer>;
shippingAddress?: Maybe<OrderAddress>;
billingAddress?: Maybe<OrderAddress>;
lines: Array<OrderLine>;
/** Order-level adjustments to the order total, such as discounts from promotions */
adjustments: Array<Adjustment>;
couponCodes: Array<Scalars['String']>;
promotions: Array<Promotion>;
payments?: Maybe<Array<Payment>>;
fulfillments?: Maybe<Array<Fulfillment>>;
subTotalBeforeTax: Scalars['Int'];
/** The subTotal is the total of the OrderLines, before order-level promotions and shipping has been applied. */
subTotal: Scalars['Int'];
currencyCode: CurrencyCode;
shipping: Scalars['Int'];
Expand Down Expand Up @@ -1842,6 +1860,10 @@ export type Promotion = Node & {
id: Scalars['ID'];
createdAt: Scalars['DateTime'];
updatedAt: Scalars['DateTime'];
startsAt?: Maybe<Scalars['DateTime']>;
endsAt?: Maybe<Scalars['DateTime']>;
couponCode?: Maybe<Scalars['String']>;
perCustomerUsageLimit?: Maybe<Scalars['Int']>;
name: Scalars['String'];
enabled: Scalars['Boolean'];
conditions: Array<ConfigurableOperation>;
Expand Down
26 changes: 26 additions & 0 deletions packages/common/src/generated-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,10 @@ export type CreateProductVariantOptionInput = {
export type CreatePromotionInput = {
name: Scalars['String'],
enabled: Scalars['Boolean'],
startsAt?: Maybe<Scalars['DateTime']>,
endsAt?: Maybe<Scalars['DateTime']>,
couponCode?: Maybe<Scalars['String']>,
perCustomerUsageLimit?: Maybe<Scalars['Int']>,
conditions: Array<ConfigurableOperationInput>,
actions: Array<ConfigurableOperationInput>,
};
Expand Down Expand Up @@ -2157,17 +2161,23 @@ export type Order = Node & {
id: Scalars['ID'],
createdAt: Scalars['DateTime'],
updatedAt: Scalars['DateTime'],
/** A unique code for the Order */
code: Scalars['String'],
state: Scalars['String'],
/** An order is active as long as the payment process has not been completed */
active: Scalars['Boolean'],
customer?: Maybe<Customer>,
shippingAddress?: Maybe<OrderAddress>,
billingAddress?: Maybe<OrderAddress>,
lines: Array<OrderLine>,
/** Order-level adjustments to the order total, such as discounts from promotions */
adjustments: Array<Adjustment>,
couponCodes: Array<Scalars['String']>,
promotions: Array<Promotion>,
payments?: Maybe<Array<Payment>>,
fulfillments?: Maybe<Array<Fulfillment>>,
subTotalBeforeTax: Scalars['Int'],
/** The subTotal is the total of the OrderLines, before order-level promotions and shipping has been applied. */
subTotal: Scalars['Int'],
currencyCode: CurrencyCode,
shipping: Scalars['Int'],
Expand Down Expand Up @@ -2606,6 +2616,10 @@ export type Promotion = Node & {
id: Scalars['ID'],
createdAt: Scalars['DateTime'],
updatedAt: Scalars['DateTime'],
startsAt?: Maybe<Scalars['DateTime']>,
endsAt?: Maybe<Scalars['DateTime']>,
couponCode?: Maybe<Scalars['String']>,
perCustomerUsageLimit?: Maybe<Scalars['Int']>,
name: Scalars['String'],
enabled: Scalars['Boolean'],
conditions: Array<ConfigurableOperation>,
Expand All @@ -2615,6 +2629,10 @@ export type Promotion = Node & {
export type PromotionFilterParameter = {
createdAt?: Maybe<DateOperators>,
updatedAt?: Maybe<DateOperators>,
startsAt?: Maybe<DateOperators>,
endsAt?: Maybe<DateOperators>,
couponCode?: Maybe<StringOperators>,
perCustomerUsageLimit?: Maybe<NumberOperators>,
name?: Maybe<StringOperators>,
enabled?: Maybe<BooleanOperators>,
};
Expand All @@ -2636,6 +2654,10 @@ export type PromotionSortParameter = {
id?: Maybe<SortOrder>,
createdAt?: Maybe<SortOrder>,
updatedAt?: Maybe<SortOrder>,
startsAt?: Maybe<SortOrder>,
endsAt?: Maybe<SortOrder>,
couponCode?: Maybe<SortOrder>,
perCustomerUsageLimit?: Maybe<SortOrder>,
name?: Maybe<SortOrder>,
};

Expand Down Expand Up @@ -3372,6 +3394,10 @@ export type UpdatePromotionInput = {
id: Scalars['ID'],
name?: Maybe<Scalars['String']>,
enabled?: Maybe<Scalars['Boolean']>,
startsAt?: Maybe<Scalars['DateTime']>,
endsAt?: Maybe<Scalars['DateTime']>,
couponCode?: Maybe<Scalars['String']>,
perCustomerUsageLimit?: Maybe<Scalars['Int']>,
conditions?: Maybe<Array<ConfigurableOperationInput>>,
actions?: Maybe<Array<ConfigurableOperationInput>>,
};
Expand Down
6 changes: 6 additions & 0 deletions packages/core/e2e/__snapshots__/promotion.e2e-spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,11 @@ Object {
"code": "promo_condition",
},
],
"couponCode": "TEST123",
"enabled": true,
"endsAt": "2019-11-30T23:00:00.000Z",
"name": "test promotion",
"startsAt": "2019-10-29T23:00:00.000Z",
}
`;

Expand Down Expand Up @@ -110,7 +113,10 @@ Object {
"code": "promo_condition2",
},
],
"couponCode": "TEST1235",
"enabled": true,
"endsAt": "2019-05-31T22:00:00.000Z",
"name": "test promotion",
"startsAt": "2019-05-29T22:00:00.000Z",
}
`;
6 changes: 6 additions & 0 deletions packages/core/e2e/fixtures/e2e-products-promotions.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name , slug , description , assets , facets , optionGroups , optionValues , sku , price , taxCategory , stockOnHand , trackInventory , variantAssets , variantFacets
item-1 , item-1 , , , , , , I1 , 1.00 , standard , 100 , false , ,
item-12 , item-12 , , , , , , I12 , 10.00 , standard , 100 , false , ,
item-60 , item-60 , , , , , , I60 , 50.00 , standard , 100 , false , ,
item-sale-1 , item-sale-1 , , , promo:sale , , , I10 , 1.00 , standard , 100 , false , ,
item-sale-12 , item-sale-12 , , , promo:sale , , , I12S , 10.00 , standard , 100 , false , ,
3 changes: 3 additions & 0 deletions packages/core/e2e/graphql/fragments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,9 @@ export const PROMOTION_FRAGMENT = gql`
id
createdAt
updatedAt
couponCode
startsAt
endsAt
name
enabled
conditions {
Expand Down
Loading

0 comments on commit 95bf868

Please sign in to comment.