|
@@ -4,6 +4,7 @@ import { Column, Entity, JoinTable, ManyToMany } from 'typeorm';
|
|
|
|
|
|
|
|
import { ChannelAware, SoftDeletable } from '../../common/types/common-types';
|
|
import { ChannelAware, SoftDeletable } from '../../common/types/common-types';
|
|
|
import { getConfig } from '../../config/config-helpers';
|
|
import { getConfig } from '../../config/config-helpers';
|
|
|
|
|
+import { HasCustomFields } from '../../config/custom-field/custom-field-types';
|
|
|
import {
|
|
import {
|
|
|
ShippingCalculationResult,
|
|
ShippingCalculationResult,
|
|
|
ShippingCalculator,
|
|
ShippingCalculator,
|
|
@@ -11,6 +12,7 @@ import {
|
|
|
import { ShippingEligibilityChecker } from '../../config/shipping-method/shipping-eligibility-checker';
|
|
import { ShippingEligibilityChecker } from '../../config/shipping-method/shipping-eligibility-checker';
|
|
|
import { VendureEntity } from '../base/base.entity';
|
|
import { VendureEntity } from '../base/base.entity';
|
|
|
import { Channel } from '../channel/channel.entity';
|
|
import { Channel } from '../channel/channel.entity';
|
|
|
|
|
+import { CustomShippingMethodFields } from '../custom-entity-fields';
|
|
|
import { Order } from '../order/order.entity';
|
|
import { Order } from '../order/order.entity';
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -24,7 +26,7 @@ import { Order } from '../order/order.entity';
|
|
|
* @docsCategory entities
|
|
* @docsCategory entities
|
|
|
*/
|
|
*/
|
|
|
@Entity()
|
|
@Entity()
|
|
|
-export class ShippingMethod extends VendureEntity implements ChannelAware, SoftDeletable {
|
|
|
|
|
|
|
+export class ShippingMethod extends VendureEntity implements ChannelAware, SoftDeletable, HasCustomFields {
|
|
|
private readonly allCheckers: { [code: string]: ShippingEligibilityChecker } = {};
|
|
private readonly allCheckers: { [code: string]: ShippingEligibilityChecker } = {};
|
|
|
private readonly allCalculators: { [code: string]: ShippingCalculator } = {};
|
|
private readonly allCalculators: { [code: string]: ShippingCalculator } = {};
|
|
|
|
|
|
|
@@ -47,10 +49,13 @@ export class ShippingMethod extends VendureEntity implements ChannelAware, SoftD
|
|
|
|
|
|
|
|
@Column('simple-json') calculator: ConfigurableOperation;
|
|
@Column('simple-json') calculator: ConfigurableOperation;
|
|
|
|
|
|
|
|
- @ManyToMany(type => Channel)
|
|
|
|
|
|
|
+ @ManyToMany((type) => Channel)
|
|
|
@JoinTable()
|
|
@JoinTable()
|
|
|
channels: Channel[];
|
|
channels: Channel[];
|
|
|
|
|
|
|
|
|
|
+ @Column((type) => CustomShippingMethodFields)
|
|
|
|
|
+ customFields: CustomShippingMethodFields;
|
|
|
|
|
+
|
|
|
async apply(order: Order): Promise<ShippingCalculationResult | undefined> {
|
|
async apply(order: Order): Promise<ShippingCalculationResult | undefined> {
|
|
|
const calculator = this.allCalculators[this.calculator.code];
|
|
const calculator = this.allCalculators[this.calculator.code];
|
|
|
if (calculator) {
|
|
if (calculator) {
|