如何使用redux框架打开/关闭woocommerce过滤器

问题描述 投票:0回答:1

我在我的函数文件中使用这个woocommerce过滤器

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;
}

如何使用redux框架打开/关闭此过滤器的系统。我已经在redux中创建了Option。

wordpress woocommerce redux-framework
1个回答
0
投票

只需在函数之间添加redux全局变量

  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;

        }
    } 
© www.soinside.com 2019 - 2024. All rights reserved.