Shopify Question Hub

Q: How to write PHP code in shopify?

A: Basically, shopify is platform which is working on liquid coding. You can use HTML, CSS, JS, jQuery for development in shopify.

If you want to use php in shopify then you have to use other domain and server.  Example:- Create any file on server with php language. Then use shopify API to connect php file in shopify. You can create shopify app using php. There is Private App and Public App. Shopify app can be created using many other language but the best way to build app is using php code.


Q: Shopify cart count Automatic

A: you can use below code for update cart count.

Option 1

$( document ).ajaxComplete(function() {
    //Do stuff here
// Fetch the cart in JSON and change cart quantity on the fly after first product added to cart
  function doPoll(){
    setTimeout(function() {
      $.getJSON('/cart.js', function(cart) {
    }, 1000);
Option 2
<div class="cart-count">{{ cart.item_count }}</div>
ShopifyAPI.onCartUpdate = function(cart){
    //do something new with the cart contents


Q: How to get page name in shopify?


The page object

The page object has the following attributes:

Returns the author of a page.


Returns the content of a page.


Returns the handle of the page.

Returns the id of the page.


Returns the timestamp of when the page was created. Use the date filter to format the timestamp.


Returns the name of the custom page template assigned to the page, without the page. prefix nor the .liquid extension. Returns nil if a custom template is not assigned to the page.


<!-- on -->
{{ page.template_suffix }}




Returns the title of a page.


Returns the relative URL of the page.


{{ page.url }}




Q: Get all collection name in shopify.

A:- To get all collection name you need to create forloop under liquid code. as below.

{% for collection in collections %}

<h1>{{ collection.title }}</h1>

{% endfor %}

For more details of collections CLICK HERE


Q: Shopify contact form Validation

A: To validation of shopify contact form you can use below steps for different form fields.

Step 1: Make sure that your form will be Start and End between below tags.

{% form 'contact' %}

{% endform %}

Step: 2: 

The contact form code is between the Liquid tags that you found in the previous step. This is where the default form fields are found, with each field separated by an empty line. Every theme is different, but a contact form field looks similar to this:

Example form field

You will paste the code for your custom field(s) before, after, or in between the existing fields, depending on your preference. The code that you add will depend on the type of form field that you want to create.

After you have added the code for your custom form field(s), click Save.

Types of form fields

The following are example form fields that you can paste to your contact form template and modify to suit your needs.

Text field

To create a text field for your contact form, paste and customize the following code:

<label for="ContactFormBirthday">Birthday</label>

<input type="text" id="ContactFormBirthday" name="contact[Birthday]" placeholder="Birthday" />

Radio buttons

To create a set of radio buttons for your contact form, paste and customize the following code:

<label>Do you prefer tea or coffee?</label><br />

<input type="radio" id="ContactFormTea" name="contact[Tea or Coffee]" value="Tea" /> Tea<br />

<input type="radio" id="contactFormCoffee" name="contact[Tea or Coffee]" value="Coffee" /> Coffee

To create a drop-down menu for your contact form, paste and customize the following code:

<label for="ContactFormFlavor">Choose a flavor</label>

<select id="ContactFormFlavor" name="contact[Flavor]"> <option>Chocolate</option>





To create a checkbox for your contact form, paste and customize the following code:

<label for="ContactFormKitten">Would you like a free kitten?</label><br />

<input type="checkbox" id="ContactFormKitten" name="contact[Kitten]" value="Yes, please!" /> Yes, please!

Customize your form fields

To customize your form fields, you will edit the code from the above examples before saving them to your contact form template.

The name attribute

It is important that <input> and <select> elements have a name attribute that is set to contact[Some Text], where Some Text identifies what question the field is looking to answer. The name attribute acts as the label for the information when the contact email is compiled and sent. The only part of the name attribute that you should edit is the text between the square brackets.

The value attribute

The value attribute is included for radio buttons and checkboxes to indicate the value of the customer's selection. You can change the wording to suit your needs.

The label element

Each type of form field has a <label> element. The label shows the title for each form field. The for attribute links a label to an associated <input> or <select> element. In some themes, the labels for form fields are hidden, and only the placeholder text is shown.

The placeholder attribute

The placeholder attribute can be applied to an <input> element. For a text field, the placeholder text is what shows in the text box by default, before a response is typed in. In some themes, the labels for form fields are hidden, and only the placeholder text is shown:

Placeholder text

The for attribute

The for attribute links a <label> element to an <input> or <select> element that has an <id> with the same assigned value. In the following example, ContactFormBirthday is the assigned for value of the <label> element, as well as the id of the <input> element:

<label for="ContactFormBirthday">Birthday</label>

<input type="text" id="ContactFormBirthday" name="contact[Birthday]" placeholder="Birthday" />


Q: Shopify API Library

A: Shopify provides a suite of official software libraries for interacting with various API resources.

Shopify Admin API libraries

Shopify provides several official libraries for interacting with the Admin API. Members of the Shopify developer community have created similar libraries covering other languages and technology stacks.

Official Shopify Admin API libraries

1. Shopify_api

Shopify’s official Ruby gem for interacting with the Admin API

2. shopify_python_api

Shopify’s official Python library for interacting with the Admin API


1. Shopify API Node

Shopify Storefront API SDKs

Shopify provides a number of software development kits and libraries to help you build with the Storefront API:

1. Javascript Buy SDK

Use the Unity Buy SDK to add Shopify commerce features to video games made with Unity


Q: Shopify remove multiple items from CART

A: You can find the cart.liquid file in you theme. There you can find out the the code similar to this.

{% for line in cart.items %}
{% endfor %}

 so add a remove link in side this loop.
<a href="/cart/change?line={{ forloop.index }}&quantity=0">Clear Cart</a>

Leave a comment

Please note, comments must be approved before they are published