问题
I am using this woocommerce filter in my function file
add_filter ('add_to_cart_redirect', 'redirect_to_checkout');
function redirect_to_checkout() {
global $woocommerce;
$checkout_url = $woocommerce->cart->get_checkout_url();
return $checkout_url;
}
How can i get on/off system to this filter with redux framework. I already created Option in redux.
回答1:
Just add redux global variable between function
add_filter ('add_to_cart_redirect', 'redirect_to_checkout');
function redirect_to_checkout() {
global $xpanel; if ( isset( $xpanel['woo-option'] ) && $xpanel['woo-option'] == TRUE ) {
global $woocommerce;
$checkout_url = $woocommerce->cart->get_checkout_url();
return $checkout_url;
}
}
来源:https://stackoverflow.com/questions/47870868/how-to-on-off-woocommerce-filter-with-redux-framework