* initialized next.js project * finished markdown sections * added operation schema component * change page metadata * eslint fixes * fixes related to deployment * added response schema * resolve max stack issue * support for different property types * added support for property types * added loading for components * added more loading * type fixes * added oneOf type * removed console * fix replace with push * refactored everything * use static content for description * fixes and improvements * added code examples section * fix path name * optimizations * fixed tag navigation * add support for admin and store references * general enhancements * optimizations and fixes * fixes and enhancements * added search bar * loading enhancements * added loading * added code blocks * added margin top * add empty response text * fixed oneOf parameters * added path and query parameters * general fixes * added base path env variable * small fix for arrays * enhancements * design enhancements * general enhancements * fix isRequired * added enum values * enhancements * general fixes * general fixes * changed oas generation script * additions to the introduction section * added copy button for code + other enhancements * fix response code block * fix metadata * formatted store introduction * move sidebar logic to Tags component * added test env variables * fix code block bug * added loading animation * added expand param + loading * enhance operation loading * made responsive + improvements * added loading provider * fixed loading * adjustments for small devices * added sidebar label for endpoints * added feedback component * fixed analytics * general fixes * listen to scroll for other headings * added sample env file * update api ref files + support new fields * fix for external docs link * added new sections * fix last item in sidebar not showing * move docs content to www/docs * change redirect url * revert change * resolve build errors * configure rewrites * changed to environment variable url * revert changing environment variable name * add environment variable for API path * fix links * fix tailwind settings * remove vercel file * reconfigured api route * move api page under api * fix page metadata * fix external link in navigation bar * update api spec * updated api specs * fixed google lint error * add max-height on request samples * add padding before loading * fix for one of name * fix undefined types * general fixes * remove response schema example * redesigned navigation bar * redesigned sidebar * fixed up paddings * added feedback component + report issue * fixed up typography, padding, and general styling * redesigned code blocks * optimization * added error timeout * fixes * added indexing with algolia + fixes * fix errors with algolia script * redesign operation sections * fix heading scroll * design fixes * fix padding * fix padding + scroll issues * fix scroll issues * improve scroll performance * fixes for safari * optimization and fixes * fixes to docs + details animation * padding fixes for code block * added tab animation * fixed incorrect link * added selection styling * fix lint errors * redesigned details component * added detailed feedback form * api reference fixes * fix tabs * upgrade + fixes * updated documentation links * optimizations to sidebar items * fix spacing in sidebar item * optimizations and fixes * fix endpoint path styling * remove margin * final fixes * change margin on small devices * generated OAS * fixes for mobile * added feedback modal * optimize dark mode button * fixed color mode useeffect * minimize dom size * use new style system * radius and spacing design system * design fixes * fix eslint errors * added meta files * change cron schedule * fix docusaurus configurations * added operating system to feedback data * change content directory name * fixes to contribution guidelines * revert renaming content * added api-reference to documentation workflow * fixes for search * added dark mode + fixes * oas fixes * handle bugs * added code examples for clients * changed tooltip text * change authentication to card * change page title based on selected section * redesigned mobile navbar * fix icon colors * fix key colors * fix medusa-js installation command * change external regex in algolia * change changeset * fix padding on mobile * fix hydration error * update depedencies
5.5 KiB
description
| description |
|---|
| Learn what price lists are and how they work in a Medusa backend. Price Lists can be used to override product prices based on different conditions. |
Price Lists
In this document, you’ll learn what price lists are and how they work.
What are Price Lists
Price lists can be used to override products’ prices based on different conditions. Each price list you create can have its own options and conditions. A price list must override at least one product variant’s prices.
Example Use Cases
Price lists can be used for a variety of use cases including:
- Setting different prices for VIP customers.
- Creating sales that run through a specific period of time.
- Implement Buy X for Price Y sale model. In other words, buy X quantity of a product at the price of Y.
Price List Entity Overview
A price list is stored in the database as a PriceList entity. Some of its important attributes are:
type: The price list's type. Can be either asaleor anoverride.status: The status of the price list. Can beactiveordraft. If a price list is adraft, its prices won't be applied even if its conditions are met.starts_at: The date to start applying the price list.ends_at: The date to stop applying the price list.
Price List Conditions
You can control when a price list is applied using a set of conditions. Only when these conditions are met can the price list be applied.
You can use any of the following conditions:
- Start and/or expiry date: You can set a start date, an end date, or both to define when the prices in the list should be applied.
- Customer group: You can choose a customer group to apply the prices for. Customers that belong to this group will see the prices you set in the list, which customers that don’t belong to the group can’t see.
- Minimum and/or maximum quantity: You can specify the minimum quantity, the maximum quantity, or both minimum and maximum quantities of a product variant required to be in the customer’s cart to apply a price in a price list.
- Region: You can specify a specific region where a price in the price list is available in. Only customers accessing your store from that region can see these prices.
- Currency Code: You can specify a currency code where a price in the price list is available in. Only customers accessing your store from regions that use this currency can see these prices.
How are Price Lists Applied
When a product or a line item is retrieved or manipulated on the storefront, Medusa determines its price using a Price Selection Strategy. The price selection strategy determines the best price to apply in a given context. Part of determining the price depends on the price list.
:::info
This section explains how the price selection strategy uses price lists when it determines the price of a product variant. If you want full details on how the price selection strategy works, check out this documentation instead.
:::
Product Variants
When the strategy calculates the prices of a product variant, it retrieves both the original and the calculated prices of the variant.
The original price depends on the selected region or currency code in the current context, where the region has higher precedence.
The calculated price is the lowest price among all retrieved prices. Retrieved prices can include the original price and the price lists that can be applied. Prices are retrieved based on the context.
In the Get Product and List Product endpoints, you must pass either the region_id or currency_code to retrieve the correct prices, as they are part of the price selection strategy context.
Each variant in the response has the following properties:
original_price: The price based on the region or currency selected. You can also retrieve the original price with tax from theoriginal_price_incl_taxproperty.calculated_price: The price retrieved from a price list, if there are any. If no price list matches the current context,calculated_pricewill have the same value asoriginal_price. You can also retrieve the calculated price with tax from thecalculated_price_incl_taxproperty.
If both the region_id and currency_code aren’t passed to the request, the values of these properties will be null.
Line Items
The total of a line item depends on the price of a product variant. When the line item is created, the price of its underlying product variant is retrieved using the same process detailed in the previous section.
Then, the unit_price of the line item is set to the calculated_price property of the product variant.
When creating, retrieving, or updating the line item using the API endpoints, the line item’s totals are calculated. The following properties are returned as part of the endpoints’ responses:
unit_price: The product variant’s calculated price.subtotal: Theunit_pricemultiplied by the quantity of the line item.
Since the line item belongs to a cart, there’s no need to pass the region_id or currency_code to the requests. The cart’s region and currency are used to determine the context of the price selection.