In my previous blog I have discussed that there is the possibility of extending the shopify feature by making the use of external system or codes that are hosted externally. If you haven’t checked it, I would suggest you to go through it. Those externally hosted code could be in any platform or programming language.

In this blog I will discuss the actual implementation of it with the use case and required code snippets. This example basically explains the request transfer from shopify to any other system or API. This is really helpful to extend the feature of your shopify store that you can’t achieve within Shopify. Shopify has provided these workarounds like API’s , webhooks etc to extend its scope. So let’s get started without any delay!!

Use case/Scenario/Example

Let’s start with the requirement. I have the form in shopify which when submitted in shopify I need those form data which I want to use for my later use or use it in any other system. This is a very simple and trivial example. You can use the same approach to achieve your custom and complicated requirement.

So let’s begin. First of all you will need the form on the shopify. You can add it on page or snippet/section anywhere relevant.

Above code snippet show a simple form that takes contact info from the customer as an input. If you check the form action you will see a url to the php file. This is the php file that is hosted on external server which will handle the form submit request and saves those contact information.

Note: The external system should have SSL enabled (should server on https) or else you will see some issues.

Now when the above form is submitted we will send the AJAX request to the form action url.

We are now ready with the AJAX request. If you see above code we have taken the form data and did an AJAX request to the form URL. That’s it.

Now on the external server end you need to create a file with filename “contact.php”.Let’s see how this file looks.

Note: Please add “Access-Control-Allow-Origin:*” to accept request from your shopify domain.

This way you can send data from shopify to an external system. This will openĀ  a great possibility to enhance your shopify store functionality.