How To

How to Add File in Shopify Store using Laravel

Hello Laravel Friends,

In today’s blog file, I will discuss How to Add File in Shopify Store using Laravel.

We sometimes have to add a theme file in our Shopify store to perform any action in the front store. We can add file in the theme by theme id. Get Active Theme ID of Shopify Store.

We have used osiset/laravel-shopify addon to add file to the Shopify store.

Steps to Add File in Shopify Store using Laravel:

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

Note: You can add file in the theme either from the controller or from the view file (blade file).

Step 2: If you are adding file from the controller, then add the following class in your controller file after namespace

use Illuminate\Support\Facades\Auth;

Step 3: Use the following code in php file to add file in theme by theme id:

$data = file_get_contents(storage_path('your path));

        $param = [
            'asset'=>[
                'key'=>'snippets/filename.liquid',
                'value'=>$data
            ]
        ];
        $this->shop->request('put','themes/{theme_id}/assets.json',$param);

Note – The above code will add the file to the snippet folder, but you can also change it as per your requirement.

Conclusion:

Accordingly, you can Add File in Shopify Store using Laravel. If you have any doubts, connect with me through the comment section. Share the tutorial with your other Shopify developer friends and stay in the know so that you do not miss any updates from us.

Happy Coding!

Click to rate this post!
[Total: 4 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…

16 hours 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.…

7 days ago