Updated 7 September 2022
In Bagisto there are 7 types of products e.g – Simple, Configurable, Virtual, Downloadable, Grouped, Bundled, and Booking. In Bagisto we can also create our custom product type. To create follow the given steps below
Create a file called product_types.php in Webkul\Custom\src\Config in which write the below code
1 2 3 4 5 6 7 8 9 10 |
<?php return [ 'coupon' => [ 'key' => 'coupon', 'name' => 'Coupon', 'class' => 'Webkul\Custom\Type\Coupon', 'sort' => 7 ], ]; |
After creating the above file merge the file in the Service provider in Webkul/Custom/src/Providers/CustomServiceProvider.php by using $this->mergeConfigFrom(“path”,”namespace”) as illustrated below
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
<?php namespace Webkul\Custom\Providers; use Illuminate\Support\ServiceProvider; /** * CustomServiceProvider * * @copyright 2020 Webkul Software Pvt. Ltd. (http://www.webkul.com) */ class CustomServiceProvider extends ServiceProvider { /** * Register services. * * @return void */ public function register() { $this->mergeConfigFrom( dirname(__DIR__) . '/Config/product_types.php', 'product_types' ); } } |
Now create a folder name Type in Webkul\Custom\src in which create a file Coupon.php which extends a class Webkul\Product\Type\AbstractType as illustrated below
1 2 3 4 5 6 7 8 9 10 11 |
<?php namespace Webkul\Custom\Type; use Webkul\Product\Type\AbstractType; class Coupon extends AbstractType { } ?> |
Run a command php artisan optimize
So, that was much about the “How to create your own product type” for any queries or doubts reach out to us at [email protected]. You can also raise a ticket at our HelpDesk System.
If you have more details or questions, you can reply to the received confirmation email.
Back to Home
Be the first to comment.