在 Woocommerce 结账时根据购物车总数更改支付网关选项
Change payment gateway option based on cart total in Woocommerce checkout
对于我的 woocommerce 商店,我在 functions.php 中有这个过滤器。它强制使用 "woocommerce Stripe Gateway" 插件的 3DS。
add_filter('wc_stripe_require_3ds','__return_true');
效果很好。
我希望此过滤器仅对超过 50 欧元的订单有效。
我试过这个但它不起作用,订单在没有 3DS 的情况下得到验证。
$minsecure = 50;
$order = new WC_Order( $order_id );
$total = $order->get_total();
if($total>$minsecure) {
add_filter('wc_stripe_require_3ds','__return_true');
}
我也尝试获取购物车金额而不是订单金额,但我不知道在 "order" 点击和确认页面之间要获取哪个过滤器才能激活.
感谢任何帮助。
我会去检查订单价格是否超过 50
if( WC()->cart->subtotal > 50 )
所以该片段看起来像
add_action('woocommerce_cart_updated', 'wc_stripe_require_3ds', 90);
function wc_stripe_require_3ds ( $cart ){
if( WC()->cart->subtotal > 50 ) {
add_filter('wc_stripe_require_3ds','__return_true');
}
}
试一试。
对于我的 woocommerce 商店,我在 functions.php 中有这个过滤器。它强制使用 "woocommerce Stripe Gateway" 插件的 3DS。
add_filter('wc_stripe_require_3ds','__return_true');
效果很好。
我希望此过滤器仅对超过 50 欧元的订单有效。
我试过这个但它不起作用,订单在没有 3DS 的情况下得到验证。
$minsecure = 50;
$order = new WC_Order( $order_id );
$total = $order->get_total();
if($total>$minsecure) {
add_filter('wc_stripe_require_3ds','__return_true');
}
我也尝试获取购物车金额而不是订单金额,但我不知道在 "order" 点击和确认页面之间要获取哪个过滤器才能激活.
感谢任何帮助。
我会去检查订单价格是否超过 50
if( WC()->cart->subtotal > 50 )
所以该片段看起来像
add_action('woocommerce_cart_updated', 'wc_stripe_require_3ds', 90);
function wc_stripe_require_3ds ( $cart ){
if( WC()->cart->subtotal > 50 ) {
add_filter('wc_stripe_require_3ds','__return_true');
}
}
试一试。