📢 Use this project, contribute to it or open issues to help evolve it using Store Discussion.
The Product Customizer allows a product's attachments and/or its subscription to be made available and ready to be defined by users on the product details page.
Example of a product details page with the Product Customizer component displaying the product's attachments.
Example of a product details page with the Product Customizer component displaying the product subscription.
ℹ️ The Product Customizer's integration with the Subscription module is native and automatically enabled by the component. In order to allow your users to set the subscription on the product details page, set up the Subscription v2 in your VTEX account and follow the instructions below to implement the Product Customizer app.
- Add
product-customizer
app to your theme's dependencies in themanifest.json
, for example:
dependencies: {
+ "vtex.product-customizer": "2.x"
}
Now, you are able to use all blocks exported by the product-customizer
app. Check out the full list below:
- In the theme's product template (
store.product
), add theproduct-assembly-options
block to the children list. This will be enough to display the subscription options for the products if the Subscription v2 was previously configured in your VTEX account.
"store.product": {
"children": [
"flex-layout.row#product-breadcrumb",
"flex-layout.row#product-main",
"flex-layout.row#description",
"shelf.relatedProducts",
"product-reviews",
"product-questions-and-answers",
"product-assembly-options"
]
},
- Declare the
product-assembly-options
block and add theassembly-option-input-values
block as its child to display the product's attachments on the product details page.
"product-assembly-options": {
"children": [
"assembly-option-input-values"
]
},
ℹ️ Notice that you can use other blocks, such as the
assembly-option-item-image
, asproduct-assembly-options
's child in order to build the Product Customizer component most suitable for your desired scenario.
- Declare the blocks' props according to the desired scenario. For example:
"product-assembly-options": {
"children": [
"assembly-option-input-values"
]
},
"assembly-option-input-values": {
"props": {
"optionsDisplay": "box"
}
}
Prop name | Type | Description | Default value |
---|---|---|---|
initiallyOpened |
enum |
By default, the customization box is opened if the attachment is required and closed if it's not. You can override this behavior by setting this prop to always , making it be opened even if the attachment is not required. Leave it as required for the default behavior. |
required |
optionsDisplay |
enum |
Define whether the attachment's pre-defined options will be displayed to be selected in a Checkbox (box ) or in a dropdown list (select ) . |
select |
Prop name | Type | Description | Default value |
---|---|---|---|
buttonProps |
object |
Defines how the Customize button will behave. In addition to the collapse prop, the buttonProps object also receives child blocks to build the content of the modal triggered when the button is clicked on. |
undefined |
buttonProps
object:
Prop name | Type | Description | Default value |
---|---|---|---|
collapse |
enum |
Customize button positioning. Possible values are: left or right . |
left |
According to the data entry in the catalog, the Product Customizer takes 3 types of attachments into account when being rendered:
- Free text - Any text can be entered in this field. Users may or may not have a character limit, depending on what was filled in the
Maximum Number of Characters
field in the attachment register. - Predefined options - Users can only choose between an attachment's predefined options, according to what's set in the
Permitted Values
field in the attachment register. The way these options will be displayed can be defined with theoptionsDisplay
prop fromassembly-option-input-values
block. - Boolean - If the options that are predefined in the
Permitted Values
field are eithertrue
oufalse
, users can choose the attachment by simply clicking on a checkbox.
Notice the example below and check out the three attachment types simultaneously displayed for the same product:
Then, check out below how the product attachment displayed above was registered in the admin's Catalog:
ℹ️ Notice that when a product's attachment was registered as required, all attachment options will be automatically made available to users. If the product's attachment is not added as required, the
Add customization
button is rendered, as shown in the example above, giving users the options to add or not to add an attachment to their product.
ℹ️ The Product Customizer uses the new Assembly Options API (the traditional Attachments API will be discontinued). As a result, Checkout still doesn't natively render the customized product option previously selected by the user in the product page. For the product to be correctly displayed with the chosen attachment, it's necessary for now to customize the Checkout page interface for it to read the product data in its context and render it.
In order to apply CSS customizations in this and other blocks, follow the instructions given in the recipe on Using CSS Handles for store customization.
CSS Handles |
---|
booleanInputValue |
inputValueOptionBox |
itemContainer |
modalViewDoneButton |
modalViewProductContainer |
modalViewProductImage |
modalViewProductInfos |
modalViewProductName |
multipleItemQuantitySelector |
optionsInputValue |
optionsInputValueDropdown |
optionsInputValueLabel |
optionsInputValueLabelContainer |
optionsInputValueOptionBoxContainer |
productAssemblyGroupName |
productAssemblyGroupNameRow |
productAssemblyGroupRequiredTag |
productAssemblyOptionItemCustomize |
productAssemblyOptionItemCustomize__label |
productAssemblyOptionItemImage |
productAssemblyOptionItemName |
textInputValue |
Thanks goes to these wonderful people:
leoWorkingGood 💻 |
This project follows the all-contributors specification. Contributions of any kind are welcome!