Building a Shopify App using Python and Flask

garettbeuk
Shopify Partner
4 0 19

Hi all,

 

I created my first Shopify app recently for the app challenge, I used Python and found it took me quite a while to fully understand the entire app flow (there's a lot to digest). I decided to create a very small, simple but complete app for Shopify. I've posted it to GitHub and it is free to use for anyone:

https://github.com/garettB/shopify-flask-example

 

Hopefully this helps anyone starting out wanting to use Python get going a bit faster.

 

If you have questions or issues, just let me know here and I'll be happy to help where I can.

Replies 17 (17)
MGerace
Tourist
9 1 3

Thank you for sharing this :cathappy:

Your walk through is going to a 404 https://github.com/garettB/shopify-flask-example/blob/master

garettbeuk
Shopify Partner
4 0 19
Thanks for letting me know! This link should work for you:
https://github.com/garettB/shopify-flask-example/
drew13579
New Member
2 0 3

Hi Garett,

Thanks for sharing your tutorial! It is very helpful. I am having an issue where right after I select my development store to test the app, it takes me to a page that says:

"Oauth error invalid_request: The redirect_uri is not whitelisted"

I have double checked that the ngrok link in the Shopify app setup is the same as the one in config.py. Any help would be greatly appreciated. Thanks!!

drew13579
New Member
2 0 3

Actually, I figured it out. I wasn't using https everywhere. Sorry!

cheesecakemania
Tourist
11 0 3

Thank you, this is very helpful!

AvidBrio
Shopify Expert
294 17 27

@garettbeuk  thanks for the amazing app solution  

I am trying to build an app that syncs the store data into custom ERP, so I want to get the order data from Shopify and send it to  ERP. can you tell me how I can access those orders data

If you find our comment helpful, hit the like button and accept it as a solution.
Want us to implement custom changes in your store? Contact us
Email me directly - jim@avidbrio.com
garettbeuk
Shopify Partner
4 0 19

@AvidBrio thanks, glad you found it helpful!

I haven't done what you're explaining via an app; it may be good to post separately and get some input from someone with experience.

If you figure out how to accomplish it using an app, I hope my boilerplate continues to be useful to you.

AvidBrio
Shopify Expert
294 17 27

@garettbeuk   how to get the order data in-app?

If you find our comment helpful, hit the like button and accept it as a solution.
Want us to implement custom changes in your store? Contact us
Email me directly - jim@avidbrio.com
AvidBrio
Shopify Expert
294 17 27

@garettbeuk   Based on your code  https://github.com/garettB/shopify-flask-example/blob/master/src/shopify_client.py   how to call Shopify API (For example order data ) can you please help

If you find our comment helpful, hit the like button and accept it as a solution.
Want us to implement custom changes in your store? Contact us
Email me directly - jim@avidbrio.com
zahraazeem98
Tourist
11 1 1

Hi Garett! Thanks for sharing your work with the community. Can you include a scripttag creation demo in the project as well?

garettbeuk
Shopify Partner
4 0 19

Hi @zahraazeem98 , the code as a `create_script_tag` function in the shopify_client, is it not working for you?

I wanted to keep the code away from doing anything apart from a boilerplate, but if you're experiencing issues adding the script tag creation code let me know what you've tried and I can try to help out.

zahraazeem98
Tourist
11 1 1

@garettbeuk thanks for responding back. I was wondering that how can make the js file run with the flask? What I'm doing right now is that I created a scripttag.js file in the src directory and called the create_script_tag function in the app installation function to create a scripttag when the app is installed. Now that the scripttag is created, it's unable to get that file. So, do I need to host that file some elsewhere or is there any way to link it with the python script? 

TigersAndTacos
Tourist
6 0 4

Really nice stuff! 

I also did something similar but it contains a bit more stuff and has a code structure that you can easily adapt to fit your needs. Checkout the blog post on this page that also contains the link to the repo.

Fredrik — Creator of bugs since 1999
SteveTT
Shopify Partner
38 4 13

Thanks TigersAndTacos & esp. garettbeuk!!

There doesn't seem to be many Python developers on Shopfy 😞

I'm not sure if I found it on your blog or ...? but are you using 

https://github.com/ablesense/bootstrap-polaris

Are they any problems/issues with it? Is this the only bootstrap+polaris?

Thanks!

TigersAndTacos
Tourist
6 0 4

🙏 @SteveTT , Yes, I'm using the bootstrap polaris that you linked to, its quite ok to work with if you are familiar with Bootstrap 4. Ill make sure to update the blog post to make it clear and give some cred to the people behind that project.

Fredrik — Creator of bugs since 1999
SteveTT
Shopify Partner
38 4 13

bootstrap-polaris is a real lifesaver coming from Bootstrap!

I had a question about it and perhaps a someone will read this and know the answer. Is it possible to for the banner (in bootstrap-polaris) to be dismissable? It seems to be a Shopify requirement:

https://polaris.shopify.com/components/feedback-indicators/banner#navigation

Or what would be an alternate way show into, errors, warnings, etc?

TigersAndTacos
Tourist
6 0 4

It doesnt look like the banners are dismiss-able in bootstrap-polaris. 
Creating that JS snippet shouldnt take much time to do, can see if I get some time between work and kids to create a PR for it.

Meanwhile you could display information using the toast, not ideal but at least something that should make it a bit clear for the user. The JS parts of it can be found here: https://github.com/ablesense/bootstrap-polaris/blob/master/demo/bootstrap-polaris.js

Fredrik — Creator of bugs since 1999