Closed Yokann closed 7 years ago
Maybe should i use a new provider that i call before the RouteProvider
Can you try from the functions.php
file to add a route condition and let me know if it works better?
Or if you're familiar with the service provider you can create a new one that loads before the route one. Or use the RouteProvider and set your conditions before in the register()
method.
Yes it works fine if i add the conditions in the beginning of function.php
.
I also create a new provider , it works to :
class WoocommerceService extends ServiceProvider
{
/**
* Define theme routes namespace.
*/
public function register()
{
Action::add( 'after_setup_theme', [$this, 'addThemeSupport'] );
Filter::add('themosisRouteConditions', [$this, 'addRouteConditions']);
}
public function addRouteConditions($conds)
{
$conds['product'] = 'is_product';
$conds['shop'] = 'is_shop';
$conds['cart'] = 'is_cart';
$conds['checkout'] = 'is_checkout';
$conds['account'] = 'is_account_page';
$conds['product_category'] = 'is_product_category';
return $conds;
}
public function addThemeSupport() {
add_theme_support( 'woocommerce' );
}
}
Cool, I'm glad your issue is solved. I should probably add a note regading the filter on the documentation. Thanks!
Bonjour, I am trying to add some woocommerce conditions with
themosisRouteConditions
filter from thetheme/admin
directory. If i look in function.php, the RouteProvider is load before any of these files. My conditions are ignored.So i think it's impossible to use
add_filter('themosisRouteConditions', ...);
fromtheme/admin
directory. Did i missed something ?Thank you.