Product Item URL

Hi,

I am having this issue on the checkout. My URL is : https://snipcart-ecommerce.herokuapp.com.
What should I write on the product button a data -item-url?
data-item-url=“https://snipcart-ecommerce.herokuapp.com/” this is not working. Could someone please help me out ?

Thanks in Advance

Hi @Nerea, thanks for reaching out!

When you use a SPA we cannot fetch the product data for the validation, as it is not in the page HTML.
In those cases you need to use ou JSON validation.

Let me know if you have further questions.

Thanks :slight_smile:

Hi!

Thanks for the info.

Could you please give me more info about it? How should the code look like?

Thanks in advance,

Nerea

Hi @Nerea.

For that, you should add an API endpoint with the details for each product.
For example, your product button would look like:

<button class="snipcart-add-item"
  data-item-id="starry-night"
  data-item-price="79.99"
  data-item-url="https://products.site.com/api/product/starry-night"
  data-item-name="The Starry Night">
  Add to cart
</button>

And then the URL https://products.site.com/api/product/starry-night should return the product info with the structure described in the documentation in JSON format, like:

{
  "id": "starry-night",
  "price": 79.99,
  "url": "https://products.site.com/api/product/starry-night"
}

Hello @nelitow , could you elaborate how to address custom fields in the JSON crawler? I have a product, that has a couple variants that affect the price, hence I think these variants must be mentioned in the JSON. However, there is no information in the documentation concerning this.