Select Your Favourite
Category And Start Learning.

How To Build Shopify Apps with PHP (Update 2021)

We have a Shopify App Development Course! Be one of the first students!

Are you looking for an in-depth guide on how to create Shopify apps? Click the enroll button !

Introduction

We are aware that there are hundreds of PHP tutorials online on how to create a Shopify app using PHP, but in this course, we’ll tackle all the components that you may want to add to your Shopify app like displaying products and such.

Now before we proceed, Shopify made an update with their API where they version their API quarterly also known as API versioning. It is important to know that Shopify will always make updates to their API so if you are developing Shopify apps, then you should also keep your apps updated.

What is Shopify PHP?

There’s no such thing called “Shopify PHP”, but to make it understandable to you. PHP is a programming language for web development that can be used to develop a Shopify app. Though there are PHP Frameworks that you can use as well to build a Shopify app like Laravel.

 

Is it hard to do Shopify App Development?

Building your own Shopify Apps is very easy, all you need is to understand how the API works. Shopify is a Rails application, there are lots of Shopify repository that you can use for FREE to integrate your website to Shopify API. Here’s the list:

Personally, I use this Shopify API Client made by Alex here:
Shopify Generating API Token Guide

To begin, you have to create a new Shopify app in your Shopify Developer account, so if you don’t have an account yet, you can sign up by visiting developers.shopify.com

Shopify App Development Tutorial PHP - WeeklyHow

Building Your Own Shopify App with PHP

In this article, we’re going to learn how to make a Shopify application from the scratch using PHP, if you already have a Shopify developer account this is the first page you’re going to see:

Developer Shopify Dashboard
Developer Shopify Dashboard

Proceed to left navigation panel and click the Apps category

Shopify App Development Tutorial PHP

Click Create app and select what type of app you wish to build. Custom app or Public app? For custom apps, you can only install the app to one Shopify store with no need for Shopify to review your app. However, with public apps, Shopify will need to review your app in order for Shopify stores to install your Shopify app.

Shopify App Development Tutorial PHP

After selecting, that should give you the following form.

App Name – The name of the Shopify application you’re about to create.
App URL – The URL of your website where you’re going to upload your Shopify files
Whitelisted Redirection URL(s) – This is where you’re going to list your generate token script or URLs you need as you authenticate your Shopify.

For web hosting, we recommend getting it from Hostinger as it’s more compatible for Shopify especially if you’re just getting started.

Hostinger free hosting plan for everyone
  • Compatible with Shopify
  • LightSpeed Web Server
  • Free domain and SSL certificate
  • 30-day money-back guarantee

Once you’re done, filling the form, click Create app

Image of Shopify App Development using PHP
Here’s everything you need to start building your Shopify App

Now that we have our first Shopify app created, it’s time to make our website connected using these API credentials. To do this, download at least one of the Shopify repositories that I have provided in this article.

Create Shopify Apps for Storefront

Customize and add more features to your Shopify store using Shopify apps!

To continue with this project, you may proceed to this article.

In part 2, we’ll be using the credentials that we have to connect it to PHP. If you’re interested, proceed to this article below:

 

Comment List

  • Thanks for sharing the information. It was really helpful.
    Can you please also write article on uninstall of Shopify app?
    Thank you very much. 🙂

  • Hi! Do you know how to add product with variants & images?

    I have this array :

    Array
    (
    [product] => Array
    (
    [title] => TITLE
    [body_html] => DESCRIPTION
    [vendor] => TESTSTORE
    [product_type] =>
    [tags] =>
    [published] => 1
    [variants] => Array
    (
    [0] => Array
    (
    [price] => 1160
    )

    )

    [images] => Array
    (
    [0] => Array
    (
    [src] => urlofimage.jpg
    )

    [1] => Array
    (
    [src] => urlofimage.jpg
    )

    )

    )

    )

    But it does not add the price and images of the product when shopify_call is called. Thanks!

    1. Hi Raff,

      Thank you for reaching out to us!

      Are you referring to displaying product prices and images?
      If so, you may read this article, we have explained here how to use Product API.
      https://weeklyhow.com/how-to-display-product-price-using-shopify-api/

      However, if you’re talking about adding products to the store. You may use POST instead of GET and send an array of product data.

      We’d love to help you more! If you have more questions or issues, please don’t hesitate to let us know.

      Regards,
      Jeremy

  • Thanks Bernard for this great article.
    I tried to follow the youtube tutorial.
    After installed the app to my test development store, and when I clicked the installed app in the ‘Apps” page of the store, I got the error message as follows:

    Forbidden
    You don’t have permission to access this resource.
    Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.

    Please if you could help?

  • Hi Bernard, further to my question yesterday, I found that I can get the token when I input “http://subdomain.mydomain.com/apps/example_app/install.php?shop=mystore” in the google browser. But I cannot access/show the index of/apps/example_app/ folders in the ‘Apps’ page of my shopify store after clicking the installed app.

    Thank you very much for your kind help

  • Hi.
    Following the tutorial I have encountered the error once my app is installed in shopify, when I want to open it from my store it gives me the following error Refused to display {{{URL}} in a frame because it set ‘X-Frame-Options’ to ‘sameorigin’.
    I have hosted on my server.

    I was also doing other tests with ngrok and there if it visualizes me when opening the already installed api but it does not generate the token.

  • HI, Thank you so much for the thorough and clear tutorial. By far it has been the one that demystifies the most the process of creating a Shopify app.
    I have a project, which I thought would be simple to implement, but I realize it is much more work, but I want to learn from this. Basically,I need to add a button to the cart page that emails the cart contents (product names, IDs) to an administrative email address (the reason for this is that the client is not ready to sell products directly yet, but they can send product quotes and samples). The checkout button will be hidden so that functionality of the site (the full checkout) won’t be used at this point.
    Anyways, I found that with the AJAX API, one can detect when the cart is modified and read all the contents in the cart. Which is what I need. The issue now is how to send the email once I read the cart contents. I was wondering if you know what API to use for this. When someone clicks the send button the AJAX API should read the cart contents and pass this JSON data to the app -which will send the email.
    Lastly, do you do consultancy services (paid of course)? I realize I’m already asking for a lot and not expecting all your explanations to be free!

  • Please check I am getting this error when hitting the url “https://collectivebargainingapp.techstriker.com/install.php?shop=https://cba-app-test.myshopify.com/”

    And getting an error that “the app cannot be installed using this link. Contact the app developer for more information”. I am on the app section of the store on which I am installing this app “cba-app-test.myshopify.com”. I also tried to install the app from the partners account on which this store is a development store. There it shows the message that if we install this app on the store then he store will be transfer disabled.

    1. Hi aadrash,

      You can only install your Shopify apps (especially the ones that are not reviewed by Shopify) on development stores. To install the app to a development store, just proceed and accept when it says that the store will have transfer disabled.

      Good luck!

  • I followed the steps in this tutorial. But I am stuck at the installation. Shopify is showing a message that says that before installing Shopify needs to verify this app. Not sure how to overcome this as the Install button is disabled and the Cancel button. Well it cancels everything. Should I need to submit somehow the app to Shopify? How this is done? I haven’t found a way to do it.

    I had one extra step that you didn’t showed here nor in youtube. The create app Wizard asked me for Custom or Public App before asking me the name, url and whitelist urls. In that one step I choosed Public. Also the only hosting I have does not have SSL certificate do I need to buy a certificated for development purposes?

    1. Hi Oscar!

      Thanks for reading our guide! First of all, there are changes that have been made to Shopify app development, and one of them is disabling the ability to install Shopify apps to public Shopify stores. So, to answer your question, yes. You do need to send the Shopify app for reviewing. However, you can also install your Shopify app to a development store for the meantime.

      Second, you need your host/server to have an SSL certificate installed. Otherwise, your app will not load in Shopify stores.

      If you have more questions, please let us know!

  • I followed the steps in this tutorials , Before its working fine my app is doing well , my install.php , generate_token.php and index.php all working. But after i switch my server where i put all my code files. Its start creating problem while install or generating token. My custom app not redirecting to any other page excerpt index.php. I do all changes in app regarding urls. But i don’t get why install.php and generate_token.php is not working on the website. Please help me to know what’s issue in app. Why i am not able to access other pages excerpt index.php. When i put the code of install on the index.php page its given my this issue “&oauth_error=same_site_cookies”

    1. I have got this issue because of close the php close tag in php files remove the close tag in the bottom of the pages most probably that one.
      Other one is issue in the mysql database function not work properly please work with separately php mysql database and confirm everything is working perfectly after that implement the script. if there is no error code is working perfectly.

  • I have got this issue because of close the php close tag in php files remove the close tag in the bottom of the pages most probably that one.
    Other one is issue in the mysql database function not work properly please work with separately php mysql database and confirm everything is working perfectly after that implement the script. if there is no error code is working perfectly.

  • Hello Admin,
    After finding so many solution I got your website link.
    Can you please help me to make my shopify app into shopify app bridge 2.0?
    Please I will be very helpfull for me.
    I have made shopify setup in Codeigniter PHP Framework.
    But as per the latest update from shopify till Jan 2022 it will deprecate.

  • Hello,

    After follow this tutorial, I am facing this issue: [url] refused to connect. on app page.
    Kindly please help me on this.

    Thanks

Leave a comment

Your email address will not be published. Required fields are marked *