Hello Shopify Friends,
So you have started your Shopify online store and now it’s the time to add products to your Shopify Store. Adding products to the Shopify store is one of the most important steps in building success. You need to display your products in the best version so that the customers can know and love what you have for them in your store.
You can add a product in Shopify using the Admin panel. But here we will learn about adding Products to Shopify using Laravel.
Let’s learn How to Add Product in Shopify using Laravel
Steps to Add Product in Shopify using Laravel:
Step 1: Integrate osiset/laravel-shopify addon with your Shopify app.
Note: You can get customer data either in the controller or in the view file.
Step 2: If you are fetching product data in the controller then add the following class in your controller file after namespace:
use Illuminate\Support\Facades\Auth;
Step 3: Use the following code to add the product.
<?php $products_array = array( "product" => array( "title" => 'title of product', "body_html" => 'description', "vendor" => "vendor of product", "published" => true , "variants" => array( array( "sku" => 'sku of product', "price" => 'product price', "taxable" => false, "inventory_quantity"=> 'available quantity', ) ) ) ); $shop=Auth::user(); $products=$shop->api()->rest('POST','/admin/api/2021-07/products.json',$products_array); ?>
Note: The above code snippet consists of common fields for products. You can change it as per your requirement.
Conclusion:
That’s it! This way you can Add Product in Shopify using Laravel. After the products have been added, you need to integrate different payment methods on your Shopify Store.
If somehow you encountered errors, drop a comment below and we will solve it as soon as possible. Share the article with your Shopify developer friends and stay updated for more solutions.
Happy Coding!