A company asked me if I’d be able to integrate their WordPress store with Shopify. Specifically, the wanted a form submission to check against their users and create a coupon specifically for them.
Now there’s a decent amount of information about the Shopify API, but I found surprisingly few actual implementations of an API for functioning within WordPress. For those of you interested in a basic start, I’m adding the demo I made for them here.
They ended up going a different direction with the project, so this code didn’t get far, but you should be able to expand and leverage the simple function I built. Or pay me to.
Install this Snippet
Add the following code to your functions.php
The code does the following:
- Creats the shortcode [shopify]
- Creates a coupon called TESTONE whenever called
- replace the $baseurl with your store. I left my test store info there since the free trial long expired
- Replace the text ‘TESTONE’ to change the coupon code
This snippet leverages the price rules api. It first creates a price rule which dictates the discount info, then applies it to the discount code. The price rule in this example is called TEST5