Skip to content

Write a WooCommerce shop in Blade with Pollora: the pollora/woocommerce package, Blade templates for the shop, Route::wp() conditions, the Coming Soon page and WooCommerce events as Laravel events.

Pollora can write a WooCommerce shop in Blade, route its pages with Route::wp() and listen to its actions as Laravel events. It is the package pollora/woocommerce: the framework used to ship this integration, and does not any more.

A project that runs WooCommerce must install the package. Without it the shop has no Blade templates, no Route::wp() conditions (shop, product, cart…), no Coming Soon page and no WooCommerce events, and nothing says so. php artisan pollora:doctor (and Tools › Site Health) warns when WooCommerce is active and the package is missing.

Terminal window
composer require pollora/woocommerce

Requires PHP 8.3+, Pollora 13.39+ and WooCommerce. Laravel discovers the service provider; nothing runs unless WooCommerce is active. pollora:make:theme offers to install it with the apiary storefront theme (see Theming).

WooCommerce looks for a template in the theme, then in its own folder. The package adds the Blade variant of each candidate to the search, so resources/views/woocommerce/single-product.blade.php answers where woocommerce/single-product.php would, and a child theme’s override folder is honoured. Template parts (wc_get_template_part()) and wc_get_template() resolve the same way.

Add a folder to the search with the pollora/woocommerce/template_paths filter.

Route::wp() knows WooCommerce’s conditionals (see Routing):

Route::wp('shop', [ShopController::class, 'index']);
Route::wp('product', [ProductController::class, 'show']);
AliasCondition
shopis_shop
productis_product
cartis_cart
checkoutis_checkout
accountis_account_page
product_categoryis_product_category
product_tagis_product_tag
wc_endpointis_wc_endpoint_url

The entries you set in wordpress.plugin_conditions.woocommerce (see WordPress Configuration) win over these defaults.

WooCommerce renders its Coming Soon page itself and exits, which skips Blade. With a view woocommerce.coming-soon in your theme (or woocommerce.coming-soon-store-only when only the store pages are hidden), the package renders that one instead.

WooCommerce’s actions arrive as Laravel events, in Pollora\WooCommerce\Events (see Events & Listeners):

EventComes from
OrderStatusChangedwoocommerce_order_status_changed
AttributeCreated, AttributeUpdated, AttributeDeletedwoocommerce_attribute_*
TaxRateCreated, TaxRateUpdated, TaxRateDeletedwoocommerce_tax_rate_*
SettingUpdatedWooCommerce options (updated_option)
use Illuminate\Support\Facades\Event;
use Pollora\WooCommerce\Events\OrderStatusChanged;
Event::listen(OrderStatusChanged::class, function (OrderStatusChanged $event): void {
$event->order; // WC_Order
$event->newStatus;
});
WasIs
Pollora\ThirdParty\WooCommerce\…Pollora\WooCommerce\…
Pollora\Events\WordPress\Plugins\WooCommerce\…Pollora\WooCommerce\Events\…

The old names keep working and are removed in the next major release. Nothing else changes in a project’s code: install the package, and the shop, its routes and its events are back.