|
1
|
--- |
|
2
|
sidebar_label: "Physical and Customs Attributes" |
|
3
|
tags: |
|
4
|
- concept |
|
5
|
- product |
|
6
|
- fulfillment |
|
7
|
- inventory |
|
8
|
products: |
|
9
|
- product |
|
10
|
- fulfillment |
|
11
|
- inventory |
|
12
|
--- |
|
13
|
|
|
14
|
import { Table } from "docs-ui" |
|
15
|
|
|
16
|
export const metadata = { |
|
17
|
title: `Product and Variant Physical and Customs Attributes`, |
|
18
|
} |
|
19
|
|
|
20
|
# {metadata.title} |
|
21
|
|
|
22
|
In this guide, you'll learn how physical and customs attributes behave when set on a product and its variants, and which of these attributes fulfillment providers and inventory items use. |
|
23
|
|
|
24
|
## Overview of Physical and Customs Attributes |
|
25
|
|
|
26
|
Both the [Product](/references/product/models/Product) and [ProductVariant](/references/product/models/ProductVariant) data models define the following physical and customs attributes: |
|
27
|
|
|
28
|
<Table> |
|
29
|
<Table.Header> |
|
30
|
<Table.Row> |
|
31
|
<Table.HeaderCell> |
|
32
|
Attribute |
|
33
|
</Table.HeaderCell> |
|
34
|
<Table.HeaderCell> |
|
35
|
Description |
|
36
|
</Table.HeaderCell> |
|
37
|
</Table.Row> |
|
38
|
</Table.Header> |
|
39
|
<Table.Body> |
|
40
|
<Table.Row> |
|
41
|
<Table.Cell> |
|
42
|
|
|
43
|
`weight` |
|
44
|
|
|
45
|
</Table.Cell> |
|
46
|
<Table.Cell> |
|
47
|
|
|
48
|
The item's weight. |
|
49
|
|
|
50
|
</Table.Cell> |
|
51
|
</Table.Row> |
|
52
|
<Table.Row> |
|
53
|
<Table.Cell> |
|
54
|
|
|
55
|
`length` |
|
56
|
|
|
57
|
</Table.Cell> |
|
58
|
<Table.Cell> |
|
59
|
|
|
60
|
The item's length. |
|
61
|
|
|
62
|
</Table.Cell> |
|
63
|
</Table.Row> |
|
64
|
<Table.Row> |
|
65
|
<Table.Cell> |
|
66
|
|
|
67
|
`height` |
|
68
|
|
|
69
|
</Table.Cell> |
|
70
|
<Table.Cell> |
|
71
|
|
|
72
|
The item's height. |
|
73
|
|
|
74
|
</Table.Cell> |
|
75
|
</Table.Row> |
|
76
|
<Table.Row> |
|
77
|
<Table.Cell> |
|
78
|
|
|
79
|
`width` |
|
80
|
|
|
81
|
</Table.Cell> |
|
82
|
<Table.Cell> |
|
83
|
|
|
84
|
The item's width. |
|
85
|
|
|
86
|
</Table.Cell> |
|
87
|
</Table.Row> |
|
88
|
<Table.Row> |
|
89
|
<Table.Cell> |
|
90
|
|
|
91
|
`origin_country` |
|
92
|
|
|
93
|
</Table.Cell> |
|
94
|
<Table.Cell> |
|
95
|
|
|
96
|
The item's country of origin. |
|
97
|
|
|
98
|
</Table.Cell> |
|
99
|
</Table.Row> |
|
100
|
<Table.Row> |
|
101
|
<Table.Cell> |
|
102
|
|
|
103
|
`hs_code` |
|
104
|
|
|
105
|
</Table.Cell> |
|
106
|
<Table.Cell> |
|
107
|
|
|
108
|
The item's Harmonized System (HS) code. |
|
109
|
|
|
110
|
</Table.Cell> |
|
111
|
</Table.Row> |
|
112
|
<Table.Row> |
|
113
|
<Table.Cell> |
|
114
|
|
|
115
|
`mid_code` |
|
116
|
|
|
117
|
</Table.Cell> |
|
118
|
<Table.Cell> |
|
119
|
|
|
120
|
The item's Manufacturer Identification (MID) code. |
|
121
|
|
|
122
|
</Table.Cell> |
|
123
|
</Table.Row> |
|
124
|
<Table.Row> |
|
125
|
<Table.Cell> |
|
126
|
|
|
127
|
`material` |
|
128
|
|
|
129
|
</Table.Cell> |
|
130
|
<Table.Cell> |
|
131
|
|
|
132
|
The item's material. |
|
133
|
|
|
134
|
</Table.Cell> |
|
135
|
</Table.Row> |
|
136
|
</Table.Body> |
|
137
|
</Table> |
|
138
|
|
|
139
|
These attributes are defined independently on each data model, and every attribute is nullable on both models. |
|
140
|
|
|
141
|
--- |
|
142
|
|
|
143
|
## Attributes Are Not Inherited by Variants |
|
144
|
|
|
145
|
The physical and customs attributes on a product and those on its variants are separate values. Medusa doesn't copy, inherit, or merge them: |
|
146
|
|
|
147
|
- Setting an attribute on a product doesn't set or change it on the product's variants. |
|
148
|
- A variant's attribute is `null` unless you explicitly set it on the variant, even if the parent product has a value for that attribute. |
|
149
|
- In Store and Admin API responses, a variant's attributes always reflect the variant's own stored values. They never fall back to the product's values. |
|
150
|
- Medusa doesn't apply a universal precedence or fallback rule, such as `variant.weight ?? product.weight`, when reading these attributes. |
|
151
|
|
|
152
|
So, if you want a value to be available on a variant, set it on the variant. The value you set on the product is only stored on the product. |
|
153
|
|
|
154
|
<Note title="Tip"> |
|
155
|
|
|
156
|
Set physical and customs attributes on your variants if you use them for fulfillment or shipping integrations, as explained in the [What Fulfillment Providers Read](#what-fulfillment-providers-read) section. |
|
157
|
|
|
158
|
</Note> |
|
159
|
|
|
160
|
--- |
|
161
|
|
|
162
|
## Attributes in the Automatically Created Inventory Item |
|
163
|
|
|
164
|
When you create a variant that has `manage_inventory` enabled without specifying inventory items, Medusa automatically creates an [inventory item](../variant-inventory/page.mdx) and links it to the variant. |
|
165
|
|
|
166
|
Medusa copies the following attributes from the variant to the created inventory item: |
|
167
|
|
|
168
|
- `weight` |
|
169
|
- `length` |
|
170
|
- `height` |
|
171
|
- `width` |
|
172
|
- `origin_country`, |
|
173
|
- `hs_code` |
|
174
|
- `mid_code` |
|
175
|
- `material` |
|
176
|
|
|
177
|
The product's attributes aren't used when creating the inventory item. |
|
178
|
|
|
179
|
<Note> |
|
180
|
|
|
181
|
Medusa copies these attributes from the product variant to the inventory item only when it creates the item. This is a one-time snapshot: later changes to the variant's attributes don't propagate to the inventory item, and changes to the inventory item's attributes don't propagate back to the variant. To keep them in sync, update both. |
|
182
|
|
|
183
|
</Note> |
|
184
|
|
|
185
|
--- |
|
186
|
|
|
187
|
## What Fulfillment Providers Read |
|
188
|
|
|
189
|
Fulfillment providers receive the physical and customs attributes as part of the data Medusa passes to them, but Medusa doesn't merge the product's and variant's attributes for you. |
|
190
|
|
|
191
|
When Medusa calculates a shipping option's price, it passes each item's variant attributes (`weight`, `length`, `height`, `width`, and `material`) to the fulfillment provider. |
|
192
|
|
|
193
|
When Medusa creates a fulfillment, it passes the order to the fulfillment provider with both the variant's attributes (`weight`, `length`, `height`, `width`, `material`, `hs_code`, and `origin_country`) and the product's attributes (`origin_country`, `hs_code`, `mid_code`, and `material`) available on each item. |
|
194
|
|
|
195
|
Since Medusa doesn't apply a fallback, a fulfillment provider that wants to use a product's value when a variant's value isn't set must implement that fallback itself. For example, a provider can read `variant.weight ?? product.weight`. |
|
196
|
|
|
197
|
<Note title="Tip"> |
|
198
|
|
|
199
|
Learn how to create a fulfillment provider in the [Create Fulfillment Provider](/references/fulfillment/provider) guide. |
|
200
|
|
|
201
|
</Note> |