summaryrefslogtreecommitdiff
path: root/src-migrate/types/cart.ts
blob: 5a2cf4a94b1bcedc5f11dbc595f0072315fc0a48 (plain)
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
import { CategoryPromo } from "./promotion";

type Price = {
  price: number;
  discount_percentage: number;
  price_discount: number;
};

export type CartProduct = {
  id: number;
  image: string;
  parent: {
    id: number;
    name: string;
  };
  display_name: string;
  name: string;
  code: string;
  price: Price;
  qty: number;
  weight: number;
  package_weight: number;
};

export type CartItem = {
  cart_id: number;
  quantity: number;
  selected: boolean;
  can_buy: boolean;
  cart_type: 'product' | 'promotion';
  id: number;
  name: string;
  stock: number;
  weight: number;
  attributes: string[];
  parent: {
    id: number;
    name: string;
    image: string;
  };
  price: Price;
  manufacture: {
    id: number;
    name: string;
  };
  has_flashsale: boolean;
  subtotal: number;

  code?: string;

  image?: string;
  remaining_time?: number;
  promotion_type?: {
    value?: CategoryPromo;
    label?: string;
  };
  limit_qty?: {
    all?: number;
    user?: number;
    transaction?: number;
  };
  remaining_qty?: {
    all?: number;
    user?: number;
    transaction?: number;
  };
  used_percentage?: number;
  products?: CartProduct[];
  free_products?: CartProduct[];
  package_price?: number;
};

export type CartProps = {
  product_total: number;
  products: CartItem[];
};