Răsfoiți Sursa

chore(docs): Update some examples to latest APIs

Michael Bromley 5 ani în urmă
părinte
comite
a117a95a9f

+ 1 - 1
docs/content/docs/developer-guide/job-queue/index.md

@@ -36,7 +36,7 @@ It is also possible to implement your own JobQueueStrategy to enable other persi
 
 ## Using Job Queues in a plugin
 
-If you create a [Vendure plugin]({{< relref "/docs/plugins" >}}) which involves some long-running tasks, you can also make use of the job queue. See the [JobQueue plugin example]({{< relref "plugin-examples" >}}#using-the-jobqueueservice) for a detailed annotated example.
+If you create a [Vendure plugin]({{< relref "/docs/plugins" >}}) which involves some long-running tasks, you can also make use of the job queue. See the [JobQueue plugin example]({{< relref "using-job-queue-service" >}}) for a detailed annotated example.
 
 {{< alert "primary" >}}
 Note: The [JobQueueService]({{< relref "job-queue-service" >}}) combines well with the [WorkerService]({{< relref "worker-service" >}}).

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

@@ -71,7 +71,7 @@ export const minimumOrderAmount = new PromotionCondition({
    * must resolve to a boolean value indicating whether the condition has
    * been satisfied.
    */
-  check(order, args) {
+  check(ctx, order, args) {
     if (args.taxInclusive) {
       return order.subTotal >= args.amount;
     } else {
@@ -132,7 +132,7 @@ export const orderPercentageDiscount = new PromotionOrderAction({
    * It should return a negative number representing the discount in
    * pennies/cents etc. Rounding to an integer is handled automatically.
    */
-  execute(order, args) {
+  execute(ctx, order, args) {
       return -order.subTotal * (args.discount / 100);
   },
 });

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

@@ -43,7 +43,7 @@ export const maxWeightChecker = new ShippingEligibilityChecker({
    * (This example assumes a custom field "weight" is defined on the
    * ProductVariant entity)
    */
-  check: (order, args) => {
+  check: (ctx, order, args) => {
     const totalWeight = order.lines
       .map((l) => (l.productVariant.customFields as any).weight * l.quantity)
       .reduce((total, lineWeight) => total + lineWeight, 0);
@@ -89,7 +89,7 @@ export const externalShippingCalculator = new ShippingCalculator({
       label: [{ languageCode: LanguageCode.en, value: 'Tax rate' }],
     },
   },
-  calculate: async (order, args) => {
+  calculate: async (ctx, order, args) => {
     // `shippingDataSource` is assumed to fetch the data from some
     // external data source.
     const { rate, deliveryDate, courier } = await shippingDataSource.getRate({

+ 3 - 2
packages/core/src/config/promotion/promotion-action.ts

@@ -46,6 +46,7 @@ export interface PromotionActionConfig<T extends ConfigArgs> extends Configurabl
 
 /**
  * @description
+ * Configuration for a {@link PromotionItemAction}
  *
  * @docsCategory promotions
  * @docsPage promotion-action
@@ -107,7 +108,7 @@ export abstract class PromotionAction<T extends ConfigArgs = {}> extends Configu
  * const itemPercentageDiscount = new PromotionItemAction({
  *     code: 'item_percentage_discount',
  *     args: { discount: 'percentage' },
- *     execute(orderItem, orderLine, args) {
+ *     execute(ctx, orderItem, orderLine, args) {
  *         return -orderLine.unitPrice * (args.discount / 100);
  *     },
  *     description: 'Discount every item by { discount }%',
@@ -141,7 +142,7 @@ export class PromotionItemAction<T extends ConfigArgs = ConfigArgs> extends Prom
  * const orderPercentageDiscount = new PromotionOrderAction({
  *     code: 'order_percentage_discount',
  *     args: { discount: 'percentage' },
- *     execute(order, args) {
+ *     execute(ctx, order, args) {
  *         return -order.subTotal * (args.discount / 100);
  *     },
  *     description: 'Discount order by { discount }%',