Shopify Python API Delete A Customer Metafield
Is there a way to use the Shopify Python API to DELETE a metafield by ID or value?
Couldn't find a thing in the documentation
This is what I tried:
This is the method I just found out, I cycle through the entire product catalog (I think it could work with other resources too), then through each metafield until I find the metafield I want. Then I call metafield.destroy(). Like this:
for product in products: for metafield in product.metafields(): if metafield.namespace == "global": metafield.destroy()
Originally I was working to do
product.delete(metafield) but I kept getting a 406 error that I'm not sure how to resolve yet.
Note that I am fine destroying my metafields this way because each metafield I use (to this point) is a unique product identifier, and not shared by any other resource and so destroying the entire metafield would have no negative consequences. I am not aware if this method destroys the metafield entirely, but would test the following case before using on shared metafields:
Assume product A has metafield X Assume product B has metafield X destroy metafield X from product A does product B still have metafield X?
Perhaps you can adapt this solution to something that works for your needs.
EDIT: Shopify's python online documentation is horrid. I used dir() and help() to find all of this.
- → What are the pluses/minuses of different ways to configure GPIOs on the Beaglebone Black?
- → Django, code inside <script> tag doesn't work in a template
- → React - Django webpack config with dynamic 'output'
- → GAE Python app - Does URL matter for SEO?
- → Put a Rendered Django Template in Json along with some other items
- → session disappears when request is sent from fetch
- → Python Shopify API output formatted datetime string in django template
- → Shopify app: adding a new shipping address via webhook
- → Shopify + Python library: how to create new shipping address
- → shopify python api: how do add new assets to published theme?
- → Access 'HTTP_X_SHOPIFY_SHOP_API_CALL_LIMIT' with Python Shopify Module