vtex / vtex.js

VTEX SDK for JavaScript
MIT License
120 stars 52 forks source link

Add documentation for setCustomData method #61

Open polishq opened 4 years ago

polishq commented 4 years ago

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.

LIZBETHJAICO commented 2 years ago

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

cristiancustomsoft commented 1 year ago

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 :)