Browse Source

chore: Remove references to outdated APIs

Michael Bromley 5 years ago
parent
commit
e13ea1ead5

+ 2 - 2
docs/content/docs/developer-guide/promotions.md

@@ -73,9 +73,9 @@ export const minimumOrderAmount = new PromotionCondition({
    */
   check(ctx, order, args) {
     if (args.taxInclusive) {
-      return order.subTotal >= args.amount;
+      return order.subTotalWithTax >= args.amount;
     } else {
-      return order.subTotalBeforeTax >= args.amount;
+      return order.subTotal >= args.amount;
     }
   },
 });

+ 2 - 1
docs/content/docs/developer-guide/shipping.md

@@ -99,7 +99,8 @@ export const externalShippingCalculator = new ShippingCalculator({
 
     return { 
       price: rate, 
-      priceWithTax: rate * ((100 + args.taxRate) / 100),
+      priceIncludesTax: ctx.channel.pricesIncludeTax,
+      taxRate: args.taxRate,
       // metadata is optional but can be used to pass arbitrary
       // data about the shipping estimate to the storefront.
       metadata: { courier, deliveryDate },

+ 1 - 1
packages/core/e2e/product.e2e-spec.ts

@@ -955,7 +955,7 @@ describe('Product resolver', () => {
                 expect(updatedVariant.featuredAsset!.id).toBe('T_4');
             });
 
-            it('updateProductVariants updates taxCategory and priceBeforeTax', async () => {
+            it('updateProductVariants updates taxCategory and price', async () => {
                 const firstVariant = variants[0];
                 const result = await adminClient.query<
                     UpdateProductVariants.Mutation,

+ 1 - 1
packages/core/src/config/order/order-item-price-calculation-strategy.ts

@@ -6,7 +6,7 @@ import { ProductVariant } from '../../entity/product-variant/product-variant.ent
 /**
  * @description
  * The OrderItemPriceCalculationStrategy defines the price of an OrderItem when a ProductVariant gets added
- * to an order via the `addItemToOrder` mutation. By default the {@link DefaultPriceCalculationStrategy}
+ * to an order via the `addItemToOrder` mutation. By default the {@link DefaultOrderItemPriceCalculationStrategy}
  * is used.
  *
  * ### OrderItemPriceCalculationStrategy vs Promotions

+ 18 - 10
packages/core/src/config/shipping-method/shipping-calculator.ts

@@ -20,17 +20,25 @@ export interface ShippingCalculatorConfig<T extends ConfigArgs> extends Configur
  * @example
  * ```ts
  * const flatRateCalculator = new ShippingCalculator({
- *     code: 'flat-rate-calculator',
- *     description: [{ languageCode: LanguageCode.en, value: 'Default Flat-Rate Shipping Calculator' }],
- *     args: {
- *         rate: { type: 'int', config: { inputType: 'money' } },
- *     },
- *     calculate: (order, args) => {
- *         return {
- *             price: args.rate,
- *             priceWithTax: args.rate * ((100 + args.taxRate) / 100),
- *         };
+ *   code: 'flat-rate-calculator',
+ *   description: [{ languageCode: LanguageCode.en, value: 'Default Flat-Rate Shipping Calculator' }],
+ *   args: {
+ *     rate: {
+ *       type: 'int',
+ *       ui: { component: 'currency-form-input' },
  *     },
+ *     taxRate: {
+         type: 'int',
+         ui: { component: 'number-form-input', suffix: '%' },
+       },
+ *   },
+ *   calculate: (order, args) => {
+ *     return {
+ *       price: args.rate,
+ *       taxRate: args.taxRate,
+ *       priceIncludesTax: ctx.channel.pricesIncludeTax,
+ *     };
+ *   },
  * });
  * ```
  *

+ 21 - 14
packages/dev-server/load-testing/graphql/shop/set-shipping-address.graphql

@@ -1,17 +1,21 @@
-mutation SetShippingAddress($address: CreateAddressInput! $customer: CreateCustomerInput!) {
+mutation SetShippingAddress($address: CreateAddressInput!, $customer: CreateCustomerInput!) {
     setOrderShippingAddress(input: $address) {
         ...Cart
-        shippingAddress {
-            ...OrderAddress
+        ... on Order {
+            shippingAddress {
+                ...OrderAddress
+            }
         }
     }
     setCustomerForOrder(input: $customer) {
-        id
-        customer {
+        ... on Order {
             id
-            emailAddress
-            firstName
-            lastName
+            customer {
+                id
+                emailAddress
+                firstName
+                lastName
+            }
         }
     }
 }
@@ -44,13 +48,16 @@ fragment Cart on Order {
         }
     }
     subTotal
-    subTotalBeforeTax
-    totalBeforeTax
+    subTotalWithTax
+    total
+    totalWithTax
     shipping
-    shippingMethod {
-        id
-        code
-        description
+    shippingLines {
+        shippingMethod {
+            id
+            code
+            description
+        }
     }
     total
     adjustments {