How to on/off woocommerce filter with redux framework

我怕爱的太早我们不能终老 提交于 2019-12-11 16:30:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!