In AnQi CMS, when you go througharchive/listto get the document list through the interface, the returned data includespriceandstockThese fields are crucial for building e-commerce website models.They are not just simple numbers, but the core elements that support product display, transaction process, and inventory management.

laying the foundation for the product: the intuitive expression of price and inventory

first, price(price) andstock(Inventory)Directly convert any “document” into a commercial product with commercial attributes.In the e-commerce scenario, whether it is physical goods or virtual services, price is the primary factor in users' consumption decisions, while inventory directly determines the purchaseability of the product.The Anqi CMS incorporates these two fields into the document model, meaning you do not need to perform complex custom development to set the basic trading attributes of your products.

It is worth noting that,priceThe field is stored in "yuan" units, which is a common practice in e-commerce systems, to avoid precision problems that may arise from floating-point calculations.When displaying on the front end, you just need to divide it by 100 to get the amount in 'yuan' units. AndstockThe field clearly shows the current remaining quantity of the product, which has a direct impact on consumers' understanding of product scarcity and prompting purchase behavior.

Fine-tuned operation: the art of inventory management.

From the perspective of website operation,stockThe field is the key to implementing fine-grained inventory management. Byarchive/listThe inventory data obtained can help us implement various operational strategies:

  1. To prevent overselling:Before the user places an order, the system can query the product in real timestockEnsure there is enough inventory to complete the transaction. Once the item is successfully purchased, the inventory quantity will also decrease accordingly, effectively avoiding over-selling and maintaining the merchant's reputation.
  2. Inventory alert and replenishment:When the inventory of the product is below a certain threshold, operations personnel canstockreceive timely alerts through data, arrange for procurement or production, and ensure that the product is not out of stock.
  3. Promotion strategy:For products with tight inventory, you can take promotional measures such as time-limited sales and flash sales, using the scarcity of the product to stimulate the purchase desire of users.On the contrary, for goods with excess inventory, it can also be quickly cleared through price discounts and promotions.

Optimizing user experience: the cornerstone of transparency and decision-making

For consumers,priceandstockTransparent display of fields greatly optimizes the shopping experience:

  1. Fast decision-making:Users can clearly see the price in the product list and quickly filter out products that meet their budget.At the same time, clear inventory information (such as "In stock", "Only 5 left", "Sold out") can help users decide whether to make an immediate purchase, reducing hesitation time.
  2. Filter and sort:Thougharchive/listThe request parameters do not directly list options for filtering by price or stock, but as part of the returned data, front-end developers can use these fields to implement custom price range filtering, sorting by price, and sorting by stock, which greatly improves the efficiency of users in searching for products.
  3. Reduce misunderstandings:Clear pricing and inventory information avoids misunderstandings or disputes arising from information asymmetry, enhancing users' trust and satisfaction.

Expand and integrate: Build a comprehensive e-commerce solution

AnQi CMS willpriceandstockAs a core document attribute, it also provides a good expansion foundation for more complex e-commerce functions. For example, combiningarchive/detailThe interface allows users to view the detailed information of a product, including its specific price and inventory. When the user makes a purchase,orderCreatethe interface will be based ongoods_id(product ID) andquantity(Quantity) to create an order and handle the inventory deduction logic in this process. Subsequently,ordersthe interface can query the order list containing the price and inventory snapshot of these products.

Moreover, if your product has multiple specifications (such as different colors, sizes), and the prices and inventories of each specification are different, you can take advantage of the flexibility of Anqi CMS's 'document model' to set more detailed price and inventory information for different SKUs (stock keeping units) through 'extra fields (extra)', and even combine custom logic to handle them.

In short,archive/listThe interface returnspriceandstockThe field is a pair of powerful properties that AnQi CMS provides for e-commerce document models out of the box.They are not only the basis for displaying product information, but also an indispensable core element for driving product sales, optimizing inventory management, and enhancing the user shopping experience.Reasonably utilize and manage these fields, which can bring greater commercial value to your Anqi CMS e-commerce website.


Frequently Asked Questions (FAQ)

Q1:priceWhy is the unit of the field 'fen'? How to handle it when displayed on the front end? A1: priceThe field is in "cents" to avoid precision problems caused by floating-point numbers (such as 12.99 yuan) when storing and calculating internally.This is a common practice in many e-commerce systems. When displaying on the front-end page, you only need to display the obtainedpriceDivide the value by 100 to convert it to an amount in 'yuan' units, for example, to9900displayed as99.00.

Q2: If my products have multiple specifications (such as different colors, sizes, corresponding different prices and inventories),priceandstockhow should the field reflect? A2: archive/listorarchive/detaildirectly returned in the interface'spriceandstockIt usually represents the main price and total inventory of the "document" (i.e., the product), or the price and inventory of a default specification.If your product has a complex specification system, each specification has an independent price and inventory. It is recommended to use the "extra field" function in the "document model" of Anqicms.You can customize fields to store information about different specifications of SKUs, including the price and inventory of each SKU.When displaying on the front end, you can dynamically render different specification selectors based on these additional fields, and update the displayed price and inventory in real-time after the user selects a different specification.

Q3: When the product stock is zero, will the product automatically disappear from the list? How to set it? A3: archive/listThe interface itself will not bestockWhen it is zero, the item will be automatically filtered out. It will only return the actual inventory quantity.If you wish for items with zero inventory not to be displayed in the list, or to be shown as 'Out of Stock' but not available for purchase, this requires you to make adjustments during front-end development based onstockThe value of the field should be written to implement the corresponding judgment logic. For example, after obtaining the product list, you can traverse the data and whenstockWhen it is 0, the product will not be rendered, or the "Add to Cart" button will be grayed out and the text "Sold out" will be displayed.This flexibility allows you to control the display of zero-inventory products according to your actual operational needs.