From a917b0a109b048343fa884d51f7f2d578f9cddae Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Tue, 29 Nov 2022 16:29:55 +0200 Subject: [PATCH] docs: small fixes across the documentation (#2692) * docs: various bug fixes * docs: add the import in other storage plugins * docs: fixed the placement of manual taxes doc --- docs/content/add-plugins/minio.md | 18 +++++++++++------- docs/content/add-plugins/s3.md | 4 ++++ docs/content/add-plugins/spaces.md | 4 ++++ .../how-to-create-notification-provider.md | 2 +- .../backend/taxes/manual-calculation.md | 14 ++++++-------- www/docs/sidebars.js | 10 +++++----- 6 files changed, 31 insertions(+), 21 deletions(-) diff --git a/docs/content/add-plugins/minio.md b/docs/content/add-plugins/minio.md index 762bfbb3f5..c51c5a31b0 100644 --- a/docs/content/add-plugins/minio.md +++ b/docs/content/add-plugins/minio.md @@ -187,18 +187,22 @@ If you’re using a [Next.js](../starters/nextjs-medusa-starter.md) storefront, If this configuration is not added, you’ll receive the error ["next/image Un-configured Host”](https://nextjs.org/docs/messages/next-image-unconfigured-host). -In `next.config.js` add the following option in the exported object: +In `next.config.js` add the following option in the exported object: ```jsx -module.exports = { - //other options - images: { +const { withStoreConfig } = require("./store-config") + +//... + +module.exports = withStoreConfig({ + //... + images: { domains: [ - "127.0.0.1", - //any other domains... + //... + "127.0.0.1", ], }, -} +}) ``` Where `127.0.0.1` is the domain of your local MinIO server. diff --git a/docs/content/add-plugins/s3.md b/docs/content/add-plugins/s3.md index 4a73480b8e..5bc30f8a6b 100644 --- a/docs/content/add-plugins/s3.md +++ b/docs/content/add-plugins/s3.md @@ -157,6 +157,10 @@ If this configuration is not added, you’ll receive the error ["next/image Un- In `next.config.js` add the following option in the exported object: ```jsx +const { withStoreConfig } = require("./store-config") + +//... + module.exports = withStoreConfig({ //... images: { diff --git a/docs/content/add-plugins/spaces.md b/docs/content/add-plugins/spaces.md index 946633c830..84348f02d6 100644 --- a/docs/content/add-plugins/spaces.md +++ b/docs/content/add-plugins/spaces.md @@ -144,6 +144,10 @@ If this configuration is not added, you’ll receive the error ["next/image Un- In `next.config.js` add the following option in the exported object: ```jsx +const { withStoreConfig } = require("./store-config") + +//... + module.exports = withStoreConfig({ //... images: { diff --git a/docs/content/advanced/backend/notification/how-to-create-notification-provider.md b/docs/content/advanced/backend/notification/how-to-create-notification-provider.md index fec5c942b0..fcbfc6fc1f 100644 --- a/docs/content/advanced/backend/notification/how-to-create-notification-provider.md +++ b/docs/content/advanced/backend/notification/how-to-create-notification-provider.md @@ -16,7 +16,7 @@ You also need to [setup Redis](../../../tutorial/0-set-up-your-development-envir ## Create a Notification Provider -Creating a Notification Provider is as simple as creating a TypeScript or JavaScript file in `src/services`. The name of the file is the name of the provider (for example, `sendgrid.ts`). A Notification Provider is essentially a Service that extends the `NotificationService` from `medusa-interfaces`. +Creating a Notification Provider is as simple as creating a TypeScript or JavaScript file in `src/services`. The name of the file is the name of the provider (for example, `sendgrid.ts`). A Notification Provider is essentially a Service that extends the `AbstractNotificationService` from `@medusajs/medusa`. For example, create the file `src/services/email-sender.ts` with the following content: diff --git a/docs/content/advanced/backend/taxes/manual-calculation.md b/docs/content/advanced/backend/taxes/manual-calculation.md index cb2fadc45a..c3bbedeb85 100644 --- a/docs/content/advanced/backend/taxes/manual-calculation.md +++ b/docs/content/advanced/backend/taxes/manual-calculation.md @@ -18,7 +18,7 @@ The [Calculate Cart Taxes](https://docs.medusajs.com/api/store/#tag/Cart/operati This calculates and retrieves the taxes on the cart and each of the line items in that cart. -### Use CartService +### Use CartService's retrieve Method The `CartService` class has a method `retrieve` that gets a cart by ID. In that method, taxes are calculated only if automatic taxes calculation is enabled for the region the cart belongs to. @@ -36,13 +36,11 @@ You can learn how to [retrieve and use services](../services/create-service.md#u ::: -### Use decorateLineItemsWithTotals function in Endpoints +### Use CartService's decorateTotals Method -If you want to calculate the taxes of line items on the storefront in an endpoint and return the necessary fields in the result, you can use the `decorateLineItemsWithTotals` method in your endpoint: +Another way you can use the `CartService` to calculate taxes is using the method `decorateTotals`: ```jsx -//at the beginning of the file -import { decorateLineItemsWithTotals } from "@medusajs/medusa/dist/api/routes/store/carts/decorate-line-items-with-totals" export default () => { //... @@ -54,16 +52,16 @@ export default () => { //... //retrieve taxes of line items - const data = await decorateLineItemsWithTotals(cart, req, { + const data = await decorateTotals(cart, { force_taxes: true - }); + }) return res.status(200).json({ cart: data }); }) } ``` -The `decorateLineItemsWithTotals` method accepts an options object as a third parameter. If you set `force_taxes` to `true` in that object, the totals of the line items can be retrieved regardless of whether the automatic calculation is enabled in the line item’s region. +The `decorateTotals` method accepts the cart as a first parameter and an options object as a second parameter. If you set `force_taxes` to `true` in that object, the totals of the line items can be retrieved regardless of whether the automatic calculation is enabled in the line item’s region. ### Use TotalsService diff --git a/www/docs/sidebars.js b/www/docs/sidebars.js index 72214c8b38..68364cfe6f 100644 --- a/www/docs/sidebars.js +++ b/www/docs/sidebars.js @@ -209,6 +209,11 @@ module.exports = { id: "advanced/storefront/how-to-implement-checkout-flow", label: "Implement Checkout" }, + { + type: "doc", + id: "advanced/backend/taxes/manual-calculation", + label: "Calculate Taxes Manually" + }, { type: "doc", id: "advanced/storefront/use-sales-channels", @@ -230,11 +235,6 @@ module.exports = { id: "advanced/admin/import-prices", label: "Import Prices" }, - { - type: "doc", - id: "advanced/backend/taxes/manual-calculation", - label: "Calculate Taxes Manually" - }, { type: "doc", id: "advanced/backend/price-lists/use-api",