如何解决是否有一个javascript / react库,可根据所选数量动态定价产品?
我正在尝试在电子商务平台中纳入分层定价结构,除了与shopify和woocommerce有关的内容外,我没有找到其他与该主题相关的材料。我希望有一个图书馆或类似的东西可以帮助实现这一目标。
我希望能够输入基于数量的价格:
数量价格
0-1000 $ 5每个
1001-2000 $ 4每个
2001-3000 $ 3每个
我不确定如何进行结构化。
这是我当前的产品型号-
import mongoose from 'mongoose'
const ProductSchema = new mongoose.Schema({
name: {
type: String,trim: true,required: 'Name is required'
},image: {
data: Buffer,contentType: String
},description: {
type: String,trim: true
},category: {
type: String,required: true
},subCategory: {
type: String,//required: true
},quantity: {
type: Number,required: "Quantity is required"
},price: {
type: Number,required: "Price is required"
},updated: Date,created: {
type: Date,default: Date.now
},shop: {type: mongoose.Schema.ObjectId,ref: 'Shop'}
})
export default mongoose.model('Product',ProductSchema)
由于我无法在此找到任何库或文档,我想我应该在模型中包含价格a,b,c,然后在前端根据每个价格/数量做出一个switch语句?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。