Ecommerce Shopify WordPress Discussion

Shopify Storefront API – Adding metafield to order not working

I'm currently trying to use the cartMetafieldsSet query in the Storefront API to add user generated information on to the order. The below query seems to successfully add the metafield onto the cart object, however after proceeding to the checkout and paying, the metafield on the order is blank. I have a couple of questions Does anyone know why the metafield isn't showing on my order? Is there a difference between cartMetafieldsSet on the Storefront API and the metafieldsSet on the admin API? // GraphQL Query mutation cartMetafieldsSet($metafields: [CartMetafieldsSetInput!]!) { cartMetafieldsSet(metafields: $metafields) { metafields { # Metafield fields createdAt description value } } } // Variables { "metafields": [ { "key": "custom.test", "ownerId": "CART_ID", "type": "multi_line_text_field", "value": "This is a test value" } ] } Here is how I defined my metafield in Shopify Thanks for your help!
You're mixing two concepts. A cart is not an order. A cart metafield can be set with Storefront API sure. You do that to affect checkout. In checkout you get a cart, and you look at the metafield, and perhaps that helps in checkout. But once Shopify has converted a checkout to an order, what makes you think you are going to find a metafield set on the cart? If you want to capture information in a cart, use cart attributes or a note. Those show up in order fine.

February 13, 2024

TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.