Adding data-item-weight causes Product crawling error

I’m building a Vue app with Snipcart and I’m facing an error when attempting to add dynamic shipping rates to the checkout.

In order to work with the order validation I’m using a serverless function for Snipcart to crawl JSON. This has all worked fine previously and I’ve successfully tested transactions without the :data-item-weight attribute added. But as soon as I add weight attribute I receive this error when checking out:

A ‘cart-confirmation’ error occured in Snipcart.

Reason: ‘product-crawling-failed’

— Item 1 —
[Item Unique ID] 9b89743f-2b66-4c52-81de-d652312fca67
[Item Name] Through the Window
[Status] InvalidDimensions
[Price in cart] 20
[Crawled prices] []

[Details] null
{kind: ‘cart-confirmation’, reason: ‘product-crawling-failed’, technicalReason: {…}, data: Array(1), code: ‘snipcart.errors.order_validation.product_crawling’, …}

The interesting thing about this…to me at least… is ‘[Status] InvalidDimensions’. Am I not formatting the JSON correctly? All the item weights are in grams, there are no decimals. It seems to calculate the correct shipping rate prior to hitting checkout, so its receiving the item weight via the button… but just not corresponding to the JSON data? I have no idea what the problem could be.

Any help would be appreciated!

Hi there,

The problem seems to be in your JSON response.
Try changing the weight from this:

 "weight": 12

to this:

  "dimensions": {
    "weight": 12

You can find a more complete example here : Order validation – Snipcart Documentation

Hope this helps,

You’re a gem! That was the problem.

Thanks so much for your help!


I’m running into the same issue. I understand @dominic’s response but I’m using Webflow to intergrate Snipcart on my site. Is there a way to integrate this into the button? I’ve tried this in the screenshot but it’s not working. I can also write custom code in Webflow but I’m new to coding and am not sure how Snipcart is talking to Webflow through api.

Any help would be greatly appriciated

Hey there @newtosnipcart

You can absolutely add weight on the button, it is actually the default way to do it! :slight_smile:

The original answer was for a user using the JSON validation, but in your case you can add the data-item-weight attribute with a number in grams as the value.

Example: data-item-weight="12"
Here is more information on this: Products – Snipcart Documentation