Cannot access the "name" property on a product variant metafield

Cannot access the "name" property on a product variant metafield

lindahlcorp
Shopify Partner
7 0 2

This is very odd. 

 

I am using metafields to display a variant product on a PDP as a "cross sell":

lindahlcorp_0-1713385655213.png

 

 

When I print out the JSON, I can see the object has the property "name":

 

{
  "id": 0123456789344,
  "title": "Default Title",
  "option1": "Default Title",
  "option2": null,
  "option3": null,
  "sku": "tester-00771",
  "requires_shipping": true,
  "taxable": false,
  "featured_image": null,
  "available": true,
  "name": "NAME GOES HERE",
  "public_title": null,
  "options": [
    "Default Title"
  ],
  "price": 2500,
  "weight": 127,
  "compare_at_price": null,
  "inventory_management": "shopify",
  "barcode": "0123456789",
  "requires_selling_plan": false,
  "selling_plan_allocations": []
}

 

 

However "name" is not accessible on the object, it renders "null":

 

{% assign cross_sell_product = product.metafields.product.tester_cross_sell.value %}

{{ cross_sell_product.name }}

 

 

I've tried all sorts of variations including randomly throwing ".value" around to see if anything works. 

 

Also oddly enough, neither variants nor products objects should have a "name" property per Shopify docs: 

https://shopify.dev/docs/api/liquid/objects/product

https://shopify.dev/docs/api/liquid/objects/variant 

Freelance Shopify Developer & Ecommerce Operator
Replies 0 (0)