shopify_python_api destroy()

Solved
MG_Liu
Tourist
4 0 2

Hi Friends,

Sorry if this is a beginner question. Can someone explain what destroy is and how often do I need to use it? 

I have a simple script that updates the tracking information on my orders. This is working great, but do I need to use a destroy after every save()? 

 

I found it in the shopify_python_api example:

https://github.com/Shopify/shopify_python_api

product = shopify.Product()
product.title = "Shopify Logo T-Shirt"
product.id # => 292082188312
product.save() # => True
shopify.Product.exists(product.id) # => True
product = shopify.Product.find(292082188312)
# Resource holding our newly created Product object
# Inspect attributes with product.attributes
product.price = 19.99
product.save() # => True
product.destroy()
# Delete the resource from the remote server (i.e. Shopify)

 

0 Likes
BStubbs
Shopify Partner
127 14 52

This is an accepted solution.

hi @MG_Liu 

save() wwill save the changes you’ve made to the object to the merchant’s store  

destroy() will delete the object from the merchant’s Shopify store. If it’s called on a Product object then that product will be deleted from the merchant’s Shopify store.

I don’t know why you would bother making changes to an object and then immediately delete it? Why not just delete it at the start?

Was this helpful? Press like!
Did it fix the problem? Mark it as the solution for others!
Buy me a beer? Well, sure!
0 Likes
MG_Liu
Tourist
4 0 2

Hi @BStubbs,

Thank you so much for that clarification. That's what I thought it does, but this is the example that Shopify_python_api gives. So I was a bit confused from i.

 

Thank you for that! 

BStubbs
Shopify Partner
127 14 52

No worries, keep in mind that was just an example of how to use the different functions of the package, not a guide on how to implement it for your project.

Good luck with the app!

Was this helpful? Press like!
Did it fix the problem? Mark it as the solution for others!
Buy me a beer? Well, sure!
0 Likes