Skip to content

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:

  1. A route file for your admin pages. Point the custom_file key of config/shopper/routes.php to it: its routes share the login, the middleware and the URL prefix of the admin panel. Controllers shows the setup.
  2. The pages. php artisan make:shopper-page creates a Livewire page in the namespace and the view path set by the pages key of config/shopper/admin.php.
  3. A sidebar entry that links to the pages. A sidebar class listens to the Shopper\Sidebar\SidebarBuilder event from the register() 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:

PageWhat it covers
Control PanelExtra stylesheets and scripts, a Tailwind theme of your own, the brand logo, and admin routes
NavigationGroups and entries added to the admin sidebar
ControllersAdmin pages built with Livewire or with controllers, their breadcrumbs and their authorization
FormsFilament forms in an admin page
Slide-oversForms opened in a side panel
Render HooksHTML added at named places of the admin views
SidebarThe sidebar package, in Shopper or in any Laravel application
ComponentsThe 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 pointPage
Your own class for a Shopper modelSwapping a Model
A payment providerCustom Drivers
A shipping carrierCustom Shipping Drivers
A step of the cart calculationCustom Pipeline
A tax providerCustom Tax Providers
A discount conditionCustom Eligibility Rules
Price resolution, quantity rules and the price indexCustom Price Resolver, Quantity Rules, Price Index
Stock resolution and allocationCustom Inventory Resolver, Allocating Stock Across Locations
Webhook payloads and eventsCustom Payloads, Registering Custom Events
An import sourceCustom Import Sources
A sales channel driver and the channel and zone resolversRegistering a Driver, Channel Resolver, Zone Resolver
A search indexerCustom Indexers
A Livewire component of the admin panelComponents, Replacing the Dashboard, Replacing a Widget, Replacing the General Page
A settings pageAdding a Settings Page
A color theme of the admin panelCreating a Theme
A permissionCreating Custom Permissions
A notification sent by ShopperReplacing a Notification
The two-factor code providerCode Provider
Payment method logosLogo Handling
The order number formatOrders

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