Extending Shopper
Learn how to extend Shopper with custom features and functionalities
Although Shopper is primarily designed for e-commerce sites and has many associated features, you are free to add or modify existing ones.
Why extend Shopper
One might ask, knowing that the purpose of setting up an e-commerce site is simply to make the whole system work without always wanting to add to it.
For example if you want a blog on your store, a section for a KYC, or maybe a forum, instead of creating another project to manage this you can directly extend Shopper to manage all this in the same administration area.
How to extend Shopper
A screen of your own in the admin panel takes three pieces, each set up once in your application:
- A route file for your admin pages. Point the
custom_filekey ofconfig/shopper/routes.phpto it: its routes share the login, the middleware and the URL prefix of the admin panel. Controllers shows the setup. - The pages.
php artisan make:shopper-pagecreates a Livewire page in the namespace and the view path set by thepageskey ofconfig/shopper/admin.php. - A sidebar entry that links to the pages. A sidebar class listens to the
Shopper\Sidebar\SidebarBuilderevent from theregister()method of a service provider, as Navigation shows.
The config/shopper/admin.php file also holds the URL prefix, the domain, the brand logo and the primary color of the admin panel, described in Configuration.
Extension Points
Each extension point is documented on the page of the feature it changes. The pages of this group cover the admin panel of your application:
| Page | What it covers |
|---|---|
| Control Panel | Extra stylesheets and scripts, a Tailwind theme of your own, the brand logo, and admin routes |
| Navigation | Groups and entries added to the admin sidebar |
| Controllers | Admin pages built with Livewire or with controllers, their breadcrumbs and their authorization |
| Forms | Filament forms in an admin page |
| Slide-overs | Forms opened in a side panel |
| Render Hooks | HTML added at named places of the admin views |
| Sidebar | The sidebar package, in Shopper or in any Laravel application |
| Components | The Blade and Filament components of the admin panel, for your own screens |
A package that extends the admin panel for several stores is an add-on: Extending the Admin Panel lists what an add-on can register.
The pages below replace or extend a part of Shopper itself:
| Extension point | Page |
|---|---|
| Your own class for a Shopper model | Swapping a Model |
| A payment provider | Custom Drivers |
| A shipping carrier | Custom Shipping Drivers |
| A step of the cart calculation | Custom Pipeline |
| A tax provider | Custom Tax Providers |
| A discount condition | Custom Eligibility Rules |
| Price resolution, quantity rules and the price index | Custom Price Resolver, Quantity Rules, Price Index |
| Stock resolution and allocation | Custom Inventory Resolver, Allocating Stock Across Locations |
| Webhook payloads and events | Custom Payloads, Registering Custom Events |
| An import source | Custom Import Sources |
| A sales channel driver and the channel and zone resolvers | Registering a Driver, Channel Resolver, Zone Resolver |
| A search indexer | Custom Indexers |
| A Livewire component of the admin panel | Components, Replacing the Dashboard, Replacing a Widget, Replacing the General Page |
| A settings page | Adding a Settings Page |
| A color theme of the admin panel | Creating a Theme |
| A permission | Creating Custom Permissions |
| A notification sent by Shopper | Replacing a Notification |
| The two-factor code provider | Code Provider |
| Payment method logos | Logo Handling |
| The order number format | Orders |
How not to extend Shopper
It should go without saying, but we'll say it anyway just in case...
Don't ever, for any reason, ever, no matter what, no matter where, or who, or who you are with, or where you are going or...
or where you've been... ever, for any reason, whatsoever, edit the files inside /vendor/shopper. Or any other Composer package.
Anything you do will get blown away and you'll lose those changes forever and ever amen.
You should instead build addons, extensions, and submit pull requests to admin (after checking with the team first if we'll accept them). Thanks!
Last updated on
Edit on GitHub