Shopify

How to Get Active Theme ID of Shopify Store in Shopify-Laravel App

Hello Shopify Friends,

Today I am going to explain How to Get the Active Theme ID of the Shopify Store in the Shopify-Laravel App.

It sometimes happens that we require the currently activated theme ID of your Shopify store to perform some action.

So here is the solution to get active theme data. We have used the osiset/laravel-shopify addon to get theme data. Also checkout the latest Shopify editions with 100+ new products and updates.

Steps to Get Active Theme ID of Shopify Store in Shopify-Laravel App:

Step 1: Integrate osiset/laravel-shopify addon with your Shopify app.

Check – How to Integrate Shopify App with Laravel

Step 2: Visit the below file path.

app\Models\User.php

Use the following code in the User Model file

public function getActiveThemeId()
{
         $active_theme_id = 0;
         $themes=$this->api()->rest('get','/admin/api/2021-07/themes.json');
         $themes=$themes['body']['container']['themes'];

         foreach($themes as $theme)
         {
             if($theme['role']=="main")
             {
                 $active_theme_id=$theme['id'];
             }
         }
         return $active_theme_id;
}

Note: You can use getActiveThemeId() function anywhere using user object

Conclusion:

Accordingly, you can retrieve the ID of the active theme on your Shopify website. If you face any difficulty in getting a theme ID, our Shopify Professional Developers can help you out. Mention the error in the comment box.

Happy Coding!

Click to rate this post!
[Total: 2 Average: 5]
Bharat Desai

Bharat Desai is a Co-Founder at MageComp. He is an Adobe Magento Certified Frontend Developer 🏅 with having 8+ Years of experience and has developed 150+ Magento 2 Products with MageComp. He has an unquenchable thirst to learn new things. On off days you can find him playing the game of Chess ♟️ or Cricket 🏏.

Recent Posts

How to Integrate ChatGPT with Laravel Application?

In this guide, we'll explore how to integrate ChatGPT, an AI-powered chatbot, with a Laravel…

1 day ago

What are Net Sales? How to Calculate Your Net Sales?

In the world of business, understanding financial metrics is crucial for making informed decisions and…

3 days ago

Magento 2 Extensions Digest April 2024 (New Release & Updates)

Welcome to the MageComp Monthly Digest, where we bring you the latest updates, releases, and…

3 days ago

The ABCs of Geofencing: Definition, Features and Uses

In this era, businesses are always on the lookout for ways to engage with their…

4 days ago

How to Delete Product Variant in a Shopify Remix App using GraphQL Mutations?

Managing a Shopify store efficiently involves keeping your product catalog organized. This includes removing outdated…

5 days ago

6 Innovative Tools Revolutionizing E-Commerce Operations

E-commerce has transformed the way consumers shop for products and services and interact with businesses.…

1 week ago