Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import { Cart } from './cart.js';
import { CountryTax } from './country_tax.js';
import { Entity } from '../entity.js';
import { Product } from './product.js';
import { RequestOptions } from '../request.js';
import { Variation } from './variation.js';
import { VariationsGroup } from './variations_group.js';
import { DomainTag } from './domain_tag.js';
import { Draft } from './draft.js';
export class CartItem extends Entity {
protected static resourceName = 'cart_items';
protected static singularName = 'cartItem';
protected static pluralName = 'cartItems';
@CartItem.property({type: Date})
public archived?: Date | null;
@CartItem.property()
public id?: number;
@CartItem.property()
public quantity?: number;
@CartItem.property({type: String})
public notes?: string | null;
@CartItem.property()
public creationDate?: Date;
@CartItem.property()
public currency?: string;
@CartItem.property()
public subtotalCost?: number;
@CartItem.property()
public taxAmount?: number;
@CartItem.property()
public totalCost?: number;
@CartItem.property()
public product?: Product;
@CartItem.property()
public cart?: Cart;
@CartItem.property({embeddedByDefault: false})
public taxType?: CountryTax;
@CartItem.property({arrayType: 'VariationsGroup'})
public variationsGroups?: VariationsGroup[];
@CartItem.property({arrayType: 'Variation'})
public variations?: Variation[];
@CartItem.property({arrayType: 'DomainTag'})
public tags?: DomainTag[];
@CartItem.property({arrayType: 'Draft'})
public ownDrafts?: Draft[];
public requiresShipment = () => {
Iif (this.product === undefined) {
throw 'product is undefined, did you forget to embed it?';
}
Iif (this.product.needsShipping === undefined) {
throw 'needsShipping is undefined, did you forget to embed it?';
}
return this.product.needsShipping;
};
public calculate = () => {
const resource = '/cart-item-cost-estimate/';
const data = this.toFormData({excludeOld: false});
const fetchOptions: RequestOptions = {method: 'POST', body: data};
fetchOptions.query = [];
fetchOptions.query.push(['skip_rights', 'y']);
return this.merchi.authenticatedFetch(resource, fetchOptions).
then((data: any) => { this.fromJson(data, {makeDirty: true});
return this;});
};
}
|