How to Add File in Shopify Store using Laravel

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!

Previous Article

Steps to Change Index Mode in Magento 2

Next Article

Magento 2: Enable Case Sensitive Admin Login

Write a Comment

Leave a Comment

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

Get Connect With Us

Subscribe to our email newsletter to get the latest posts delivered right to your email.
Pure inspiration, zero spam ✨