Skip to content

Commit

Permalink
feat(core): Add code field to ShippingMethodQuote
Browse files Browse the repository at this point in the history
Closes #780
  • Loading branch information
michaelbromley committed Mar 23, 2021
1 parent ea5a9f2 commit 847b4e2
Show file tree
Hide file tree
Showing 14 changed files with 30 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3004,6 +3004,7 @@ export type ShippingMethodQuote = {
id: Scalars['ID'];
price: Scalars['Int'];
priceWithTax: Scalars['Int'];
code: Scalars['String'];
name: Scalars['String'];
description: Scalars['String'];
/** Any optional metadata returned by the ShippingCalculator in the ShippingCalculationResult */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2764,6 +2764,7 @@ export type ShippingMethodQuote = {
id: Scalars['ID'];
price: Scalars['Int'];
priceWithTax: Scalars['Int'];
code: Scalars['String'];
name: Scalars['String'];
description: Scalars['String'];
/** Any optional metadata returned by the ShippingCalculator in the ShippingCalculationResult */
Expand Down
1 change: 1 addition & 0 deletions packages/common/src/generated-shop-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,7 @@ export type ShippingMethodQuote = {
id: Scalars['ID'];
price: Scalars['Int'];
priceWithTax: Scalars['Int'];
code: Scalars['String'];
name: Scalars['String'];
description: Scalars['String'];
/** Any optional metadata returned by the ShippingCalculator in the ShippingCalculationResult */
Expand Down
1 change: 1 addition & 0 deletions packages/common/src/generated-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2966,6 +2966,7 @@ export type ShippingMethodQuote = {
id: Scalars['ID'];
price: Scalars['Int'];
priceWithTax: Scalars['Int'];
code: Scalars['String'];
name: Scalars['String'];
description: Scalars['String'];
/** Any optional metadata returned by the ShippingCalculator in the ShippingCalculationResult */
Expand Down
1 change: 1 addition & 0 deletions packages/core/e2e/graphql/generated-e2e-admin-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2764,6 +2764,7 @@ export type ShippingMethodQuote = {
id: Scalars['ID'];
price: Scalars['Int'];
priceWithTax: Scalars['Int'];
code: Scalars['String'];
name: Scalars['String'];
description: Scalars['String'];
/** Any optional metadata returned by the ShippingCalculator in the ShippingCalculationResult */
Expand Down
5 changes: 4 additions & 1 deletion packages/core/e2e/graphql/generated-e2e-shop-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,7 @@ export type ShippingMethodQuote = {
id: Scalars['ID'];
price: Scalars['Int'];
priceWithTax: Scalars['Int'];
code: Scalars['String'];
name: Scalars['String'];
description: Scalars['String'];
/** Any optional metadata returned by the ShippingCalculator in the ShippingCalculationResult */
Expand Down Expand Up @@ -2992,7 +2993,9 @@ export type RemoveItemFromOrderMutation = {
export type GetShippingMethodsQueryVariables = Exact<{ [key: string]: never }>;

export type GetShippingMethodsQuery = {
eligibleShippingMethods: Array<Pick<ShippingMethodQuote, 'id' | 'price' | 'name' | 'description'>>;
eligibleShippingMethods: Array<
Pick<ShippingMethodQuote, 'id' | 'code' | 'price' | 'name' | 'description'>
>;
};

export type SetShippingMethodMutationVariables = Exact<{
Expand Down
1 change: 1 addition & 0 deletions packages/core/e2e/graphql/shop-definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ export const GET_ELIGIBLE_SHIPPING_METHODS = gql`
query GetShippingMethods {
eligibleShippingMethods {
id
code
price
name
description
Expand Down
16 changes: 14 additions & 2 deletions packages/core/e2e/shop-order.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -876,8 +876,20 @@ describe('Shop orders', () => {
shippingMethods = result.eligibleShippingMethods;

expect(shippingMethods).toEqual([
{ id: 'T_1', price: 500, name: 'Standard Shipping', description: '' },
{ id: 'T_2', price: 1000, name: 'Express Shipping', description: '' },
{
id: 'T_1',
price: 500,
code: 'standard-shipping',
name: 'Standard Shipping',
description: '',
},
{
id: 'T_2',
price: 1000,
code: 'express-shipping',
name: 'Express Shipping',
description: '',
},
]);
});

Expand Down
1 change: 1 addition & 0 deletions packages/core/src/api/schema/common/common-types.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ type ShippingMethodQuote {
id: ID!
price: Int!
priceWithTax: Int!
code: String!
name: String!
description: String!
"Any optional metadata returned by the ShippingCalculator in the ShippingCalculationResult"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export class OrderTestingService {
price: priceIncludesTax ? netPriceOf(price, taxRate) : price,
priceWithTax: priceIncludesTax ? price : grossPriceOf(price, taxRate),
name: result.method.name,
code: result.method.code,
description: result.method.description,
metadata: result.result.metadata,
};
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/service/services/order.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,7 @@ export class OrderService {
priceWithTax: priceIncludesTax ? price : grossPriceOf(price, taxRate),
description: eligible.method.description,
name: eligible.method.name,
code: eligible.method.code,
metadata,
};
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2764,6 +2764,7 @@ export type ShippingMethodQuote = {
id: Scalars['ID'];
price: Scalars['Int'];
priceWithTax: Scalars['Int'];
code: Scalars['String'];
name: Scalars['String'];
description: Scalars['String'];
/** Any optional metadata returned by the ShippingCalculator in the ShippingCalculationResult */
Expand Down
2 changes: 1 addition & 1 deletion schema-admin.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion schema-shop.json

Large diffs are not rendered by default.

0 comments on commit 847b4e2

Please sign in to comment.