vtex/vtex.js

Add documentation for setCustomData method

polishq opened this issue · 2 comments

Currently readers might assume that vtexjs.checkout.sendAttachment() can be used to set customData on the orderForm. Please update documentation to include a section on how to set custom data fields on an account and how to use setCustomData to fill the custom fields with data.

entonces no se usa vtexjs.checkout.sendAttachment() para datos personalizados? . llegaste encontrar la solución podrías explicar cómo lo hiciste.

First you need to make a new app in your orderform configuration. To do that:

Make a GET request here: https://{{vendor}}.vtexcommercestable.com.br/api/checkout/pvt/configuration/orderForm

Copy the response and change the apps section. Add a new object there

"apps": [
	{
		"fields": [
			"YOUR_FIELD"
		],
		"id": "YOUR_APP"
	}
],

Make a PUT request on the same endpoint with your updated payload.

After that, you can add custom data using the next method from checkout js:

vtexjs.checkout.setCustomData({app: 'YOUR_APP', field: 'YOUR_FIELD', value: 'VALUE_HERE'});

Hope it helps :)