Bagisto is a popular open-source eCommerce platform built on Laravel. Its flexible architecture makes it easy to extend features without modifying the core.
By default, Bagisto provides seven product types: Simple, Configurable, Virtual, Downloadable, Grouped, Bundle, and Booking.
However, some projects require custom behavior because a specialized product may not fit an existing product type.
For example, Gift Cards, Memberships, Software Licenses, Event Tickets, and Coupons all have unique business rules.
If you want to create a custom product type in Bagisto, this blog walks you through the complete implementation without modifying the core.
In this blog , you’ll learn how to create a custom product type in Bagisto. We’ll use a Coupon product only as an implementation example.
Although the example uses Coupons, the same approach works for any custom product type with different business logic.
How Custom Product Types Work in Bagisto
Every product in Bagisto stores a type value. This value tells Bagisto which product type class should manage the product.
When a product is loaded, Bagisto reads the type and resolves the corresponding class through the registered product type configuration.
That class handles product-specific features such as pricing, inventory, cart preparation, and checkout behavior.
This modular architecture lets you create a custom product type in Bagisto without modifying the core, making future upgrades easier.
Creating a Custom Product Type in Bagisto
A custom product type is useful whenever your product needs functionality beyond the built-in product types.
For example, a Membership may activate a subscription after purchase, while a Software License may generate a license key.
Similarly, a Coupon product behaves like a digital item because it doesn’t require shipping or warehouse inventory.
Regardless of the product, the implementation process remains the same. Only the business logic changes.
| Product Type | Example Behavior |
|---|---|
| Coupon | Skip shipping and inventory |
| Gift Card | Generate redemption codes |
| Membership | Activate subscriptions |
| Software License | Generate license keys |
| Event Ticket | Generate downloadable tickets |
In this Blog , we’ll implement a Coupon product type and demonstrate the overall architecture clearly.
Step 1: Create the Custom Package Structure
Before registering a custom product type in Bagisto, create a dedicated package to keep your implementation separate from the core framework.
This approach follows Bagisto’s modular architecture and makes future upgrades easier because your custom code remains isolated.
Create the following directory structure inside the packages/Webkul directory.
|
1 2 3 4 5 6 7 8 |
packages/Webkul/Custom/ ├── src/ │ ├── Config/ │ │ └── product-types.php │ ├── Providers/ │ │ └── CustomServiceProvider.php │ └── Type/ │ └── Coupon.php |
Step 2: Register the Product Type
Bagisto discovers product types from the product-types configuration. The first step is creating a configuration file.
Create the following file.
|
1 |
packages/Webkul/Custom/src/Config/product-types.php |
Add the following code.
|
1 2 3 4 5 6 7 8 9 |
<?php return [ 'coupon' => [ 'key' => 'coupon', 'name' => 'Coupon', 'class' => 'Webkul\Custom\Type\Coupon', 'sort' => 8, ], ]; |
What Does This Configuration Do?
The key uniquely identifies the product type. Bagisto stores this value in the product’s type column.
The name label appears in the Product Type dropdown.
The class tells Laravel which class should manage the product type. We’ll create this class shortly.
The sort value controls where the product type appears in the Admin Panel list
Step 3: Merge the Configuration
Creating the configuration file isn’t enough. Laravel must also load it when your package boots.
Create the following file.
|
1 |
packages/Webkul/Custom/src/Providers/CustomServiceProvider.php |
Add the following code.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<?php namespace Webkul\Custom\Providers; use Illuminate\Support\ServiceProvider; class CustomServiceProvider extends ServiceProvider { public function register() { $this->mergeConfigFrom( dirname(__DIR__) . '/Config/product-types.php','product_types' ); } } |
Why Is This Step Required?
The mergeConfigFrom() method combines your configuration with Bagisto’s existing product types.
Without this step, Bagisto won’t discover your custom product type during application startup.
Once the configuration is registered, Bagisto is ready to load the class that defines your product’s behavior.
Step 4: Create the Product Type Class
Every custom product type requires a class that extends Bagisto’s AbstractType.
For this blog , we’ll create a Coupon product. The same structure works for any custom product type.
Create the following file.
|
1 |
packages/Webkul/Custom/src/Type/Coupon.php |
Add the following code.
|
1 2 3 4 5 6 7 8 9 10 |
<?php namespace Webkul\Custom\Type; use Webkul\Product\Type\AbstractType; class Coupon extends AbstractType { } |
Step 5: Register the Custom Package
After creating the package files, register the package so Laravel can discover and load your custom product type.
Then, register the PSR-4 Namespace
Open the root composer.json file and add the following namespace under the autoload section.
|
1 2 3 4 5 |
"autoload": { "psr-4": { "Webkul\\Custom\\": "packages/Webkul/Custom/src" } } |
Next, regenerate Composer’s autoload files.
|
1 |
composer dump-autoload |
and Register the Service Provider
Open the bootstrap/providers.php file and register your package’s service provider.
|
1 2 3 4 5 6 7 8 9 |
<?php use Webkul\Custom\Providers\CustomServiceProvider; return [ // Other providers... CustomServiceProvider::class, ]; |
Finally, clear the application cache so Laravel reloads the updated configuration.
|
1 |
php artisan optimize:clear |
After executing the command, Laravel clears the application’s cached configuration, routes, views, events, and compiled files.
This ensures that the newly registered service provider, Composer autoload mappings, and product type configuration are loaded correctly by the application.
Conclusion
Bagisto’s product type architecture makes it easy to extend the platform without modifying its core.
By registering a custom package and extending AbstractType, you can introduce new product behavior with minimal effort.
This blog used a Coupon product only as an implementation example.
The same workflow applies to Gift Cards, Memberships, Software Licenses, Event Tickets, Service Plans, and many other custom products.
Once you understand the architecture, creating a custom product type in Bagisto becomes a straightforward extension instead of a complex customization.
Thanks for reading this blog. I hope it helped you understand how we can create a custom product type in Bagisto.
If you found this post helpful, please share your feedback in the comments. Your insights help us create better content for the community.
You can visit the hire laravel developers This platform provides a pool of experienced Laravel developers.
For exploring the available extensions for Bagisto, you can also check out extensions.