WooCommerce for Pollora, the Laravel framework for WordPress: write the shop's templates in Blade, answer Route::wp('shop') and Route::wp('product'), render the Coming Soon page from your theme, and listen to WooCommerce's orders, taxes and attributes as Laravel events.
This used to live in the framework, as
Pollora\ThirdParty\WooCommerce. The old class names still resolve, to this package.
composer require pollora/woocommerceRequires PHP 8.3+, pollora/framework 13.39+ and WooCommerce. The service provider is discovered by Laravel; nothing runs unless WooCommerce is active.
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.
Filter pollora/woocommerce/template_paths to add a folder to the search.
Route::wp() knows WooCommerce's conditionals:
Route::wp('shop', [ShopController::class, 'index']);
Route::wp('product', [ProductController::class, 'show']);| Alias | Condition |
|---|---|
shop |
is_shop |
product |
is_product |
cart |
is_cart |
checkout |
is_checkout |
account |
is_account_page |
product_category |
is_product_category |
product_tag |
is_product_tag |
wc_endpoint |
is_wc_endpoint_url |
A project's own wordpress.plugin_conditions.woocommerce entries 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 instead.
The framework lets a CDN or a reverse proxy store the pages of anonymous visitors, and a guest with a cart is anonymous. Through the framework's pollora/route/private_response filter, the package marks as private the response of a guest who:
- has a WooCommerce session, including one the request just created (adding to the cart);
- holds, or is being sent, one of WooCommerce's cart, session or recently viewed cookies;
- is on the cart, checkout or account page;
- sees a store in Coming Soon mode through its private link.
Everyone else is cached as before. This needs a pollora/framework release that has the filter; an earlier one never calls it, and still sends these pages as public: until you upgrade, make your cache skip the cart pages and the requests carrying woocommerce_items_in_cart or wp_woocommerce_session_*.
What the package cannot see, you mark yourself:
- a currency or location a plugin keeps in a cookie of its own, outside WooCommerce's session;
- WooCommerce's Geolocate default customer location: prices and taxes then follow the visitor's IP address, with no cookie. Geolocate (with page caching support) puts the location in the URL and needs nothing.
add_filter('pollora/route/private_response', fn (bool $private): bool => $private || isset($_COOKIE['my_currency']));This filter only reaches the pages Pollora's WordPress routes answer. It does not make a cache skip an already stored page: a cache whose key ignores cookies still serves the anonymous copy to a visitor with a cart, so keep your cache's own WooCommerce cookie rules.
WooCommerce's actions arrive as Laravel events, in Pollora\WooCommerce\Events:
| Event | From |
|---|---|
OrderStatusChanged |
woocommerce_order_status_changed |
AttributeCreated, AttributeUpdated, AttributeDeleted |
woocommerce_attribute_* |
TaxRateCreated, TaxRateUpdated, TaxRateDeleted |
woocommerce_tax_rate_* |
SettingUpdated |
WooCommerce options (updated_option) |
Event::listen(OrderStatusChanged::class, function (OrderStatusChanged $event): void {
$event->order; // WC_Order
$event->newStatus;
});The classes moved:
| Was | Is |
|---|---|
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. Install the package: a framework that no longer ships WooCommerce does nothing for it without this one.
MIT. See LICENSE.