feat: Custom line items (#10408)
* feat: Custom line items * fix tests * fix migration * Allow custom items in update line item workflow * throw if line item doesn't have a price * minor things * wip * fix flows * fix test * add default * add to type
This commit is contained in:
@@ -2512,6 +2512,7 @@ moduleIntegrationTestRunner<ICartModuleService>({
|
||||
requires_shipping: true,
|
||||
is_discountable: true,
|
||||
is_tax_inclusive: false,
|
||||
is_custom_price: false,
|
||||
raw_compare_at_unit_price: null,
|
||||
raw_unit_price: {
|
||||
value: "100",
|
||||
@@ -2617,6 +2618,7 @@ moduleIntegrationTestRunner<ICartModuleService>({
|
||||
requires_shipping: true,
|
||||
is_discountable: true,
|
||||
is_tax_inclusive: false,
|
||||
is_custom_price: false,
|
||||
raw_compare_at_unit_price: null,
|
||||
raw_unit_price: {
|
||||
value: "200",
|
||||
|
||||
@@ -617,6 +617,16 @@
|
||||
"default": "false",
|
||||
"mappedType": "boolean"
|
||||
},
|
||||
"is_custom_price": {
|
||||
"name": "is_custom_price",
|
||||
"type": "boolean",
|
||||
"unsigned": false,
|
||||
"autoincrement": false,
|
||||
"primary": false,
|
||||
"nullable": false,
|
||||
"default": "false",
|
||||
"mappedType": "boolean"
|
||||
},
|
||||
"compare_at_unit_price": {
|
||||
"name": "compare_at_unit_price",
|
||||
"type": "numeric",
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import { Migration } from '@mikro-orm/migrations';
|
||||
|
||||
export class Migration20241218091938 extends Migration {
|
||||
|
||||
async up(): Promise<void> {
|
||||
this.addSql('alter table if exists "cart_line_item" add column if not exists "is_custom_price" boolean not null default false;');
|
||||
}
|
||||
|
||||
async down(): Promise<void> {
|
||||
this.addSql('alter table if exists "cart_line_item" drop column if exists "is_custom_price";');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import { model } from "@medusajs/framework/utils"
|
||||
import Cart from "./cart"
|
||||
import LineItemTaxLine from "./line-item-tax-line"
|
||||
import LineItemAdjustment from "./line-item-adjustment"
|
||||
import LineItemTaxLine from "./line-item-tax-line"
|
||||
|
||||
const LineItem = model
|
||||
.define(
|
||||
@@ -28,6 +28,7 @@ const LineItem = model
|
||||
requires_shipping: model.boolean().default(true),
|
||||
is_discountable: model.boolean().default(true),
|
||||
is_tax_inclusive: model.boolean().default(false),
|
||||
is_custom_price: model.boolean().default(false),
|
||||
compare_at_unit_price: model.bigNumber().nullable(),
|
||||
unit_price: model.bigNumber(),
|
||||
metadata: model.json().nullable(),
|
||||
|
||||
Reference in New Issue
Block a user