What's your biggest current challenge? Have your say in Community Polls along the right column.
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Shopify Python Library - Set metafield value to blank

Shopify Python Library - Set metafield value to blank

monster99d
Shopify Partner
1 0 0

I'm trying to, using the Shopify Python library (which isn't that well documented), set a Metafield value that's currently a type single-line-text to either "" or Nil.

 

I've tried these solutions, and neither of them worked. My metafield definition will update to any other value I submit, but if I try submitting "" or None as the value, it will not change.

#Example code included. I removed parts that do not need to be altered, like creating the customer object etc.

def add_order_metafield(tag, value):
    metafield = shopify.Metafield({
    'key': tag,
    'value': value,
    'type':'single_line_text_field',
    'namespace':'custom'
    })
    
    return metafield

#doesn't work
customer.add_metafield(add_order_metafield('date', ''))

#doesn't work
customer.add_metafield(add_order_metafield('date', None))

#works as intended
customer.add_metafield(add_order_metafield('date', "None"))

 Any advice here would be helpful.

Replies 0 (0)