What is a Shopify app? - It’s basically an interface into the Shopify environment which allows you to manage you shop data. You could also call it a “plugin” if you want. You can learn more about Shopify apps on their getting started page.

Why should I create a Shopify app with 46elks? - You might for instance want to send SMS to your customers about shipments and order updates. Maybe you are having a campaign and want to advertise your products or services. Why not lower the barrier for your customers and allow them to order products via SMS? All this is possible.

Getting started

  1. Create a Shopify developer account.
  2. Create a new store (do steps 1-4 and 8).
  3. Add one or more products.
  4. Create one or more test orders.
  5. Ensure you have a domain and a server to upload your files into.

Please note that your developer account and your store are two separate accounts. Keep that in mind as some parts of the tutorial might be confusing otherwise.

Create your Shopify app

Let's begin with creating the app so that we have something to work with.

  1. Login to your developer account.

  2. From the dashboard, click on ”apps” in the left navigation panel.

  3. On the next page, click "Create app"

  4. Now select ”Custom app”

  5. Please note that “Custom app” is only suitable if you are building something for yourself or for a single merchant (which we will do in this tutorial).

    If you want your app to be accessible for multiple merchants you must select “Public app”.

  6. Fill out the form with information about your app.

    • app name – The name of your application. You can call it whatever you want.

    • app URL – The URL of the domain where you are going to upload the Shopify app files later on. Here we use “app-domain.com" as an example.

    • Whitelisted Redirection URL(s) - Copy and paste the following three lines and change app-domain.com to your own app domain.

  7. Click Create app at the top of the page

Your Shopify app is now created! You'll be redirected to your app dashboard and there you'll find your API keys which you are going to need in a later step.

Install your app

In the previous step we created a container for our new app and right now we can't do much with it. We need to install it into our store to get a Shopify access token, only then we can begin implementing the logic and retrieve data.

  1. Let's start with downloading the source code we are going to use. (The code is created by the Shopify developer Alex Markov).

  2. Open the file "install.php". It looks something like this:

  3. Set $scopes to read_orders, write_products, write_orders.

    These determine what our app is able to do within our store. You can add and subtract to the list to suit your need. A full list of available scopes and what they do can be found on Admin API access scopes.

  4. Set $api_key to the API Key you have been assigned (you'll find it in the app dashboard as shown after you installed your app).

  5. In $redirect_uri change "app-domain.com" to your own domain.

  6. Save the changes.

  7. Open the file "generate_token.php". It sholud have the following code:

  8. Set $api_key to the API Key you have been assigned (same as in step 4).

  9. Set $shared_secret to your API secret which can be found in your app dashboard. (It’s called “API secret key” in the dashboard).

  10. Save the changes.

  11. Upload all the files to your app domain.

Now that the code is in place we are ready to actually install our app within our store. We'll use a special link that looks something like this:

  1. Change app-domain.com to your own domain.

  2. Change mystore to your own Shopify store name.

  3. Open the link in your browser and you'll be redirected to the installation page.

  4. Click "Install app".

    If you are unable to install the app, please confirm that you are signed in to your store and try again.

After you've installed your app you'll get your Shopify token. Save it, you'll need it later.

Add some logic into your app

In the previous step we installed our app and right now it’s only an empty container. Let’s put some logic into it.

Once we’ve added the code below we'll be able to get all data about the ordered products.

  1. Create a new file called "index.php" and insert the following code into it:

  2. Set $token to the Shopify token you got after installing the app.

  3. Set $shop to your store name.

  4. Upload the "index.php" file to your domain.

Now we are going to test the app within our store.

  1. Login to your Shopify store.

  2. Go to your store dashboard and click on "apps" in the left sidebar.

  3. Click on your app's name in the list you are presented with.

  4. Now you should see information regarding the orders.

Please check out the Shopify API to see what else you can do. In the above example we used the order API.

Implement SMS features

The last thing we are going to do is implementing the SMS feature. There are many possibilities for how you can use SMS in your store. Here we are going to implement a feature which allows the customers to order a product.

Please note that the following code is just an example to get you started. It's not a plug-and-play solution. You'll need to enhance it to suit your needs. In the example below we will send a POST request to the order API.

  1. Create a new file called "new-order.php" and add the following code into it:

  2. Set $token to your Shopify token.

  3. Set $shop to your store name.

  4. Save your changes and upload the file to your app domain.

Now, to receive incoming orders via SMS you'll need a special number and connect that number to the script we just created. This is done in three simple steps:

  1. Create a 46elks account.

  2. Allocate a virtual number.

  3. Configure sms url on your virtual number and set it to https://app-domain.com/new-orders.php (change app-domain.com to your own domain)

You are done! You customers can now send an SMS to your virtual number with the variant ID of your product and you'll see the order being created in you admin panel.

Now that you know the basics of how to create a Shopify app and integrate it with 46elks, you could also try to implement a feature to send SMS to your customers.

Happy coding! 🥳