由于某种原因,当我运行WooCommerce_Available_Payment_Gateways过滤器时,它在 checkout 页面上运行了两次
作为一个测试,我让它在 checkout 页面上 echo 123123,它显示1231235555(在Else语句中)<;-这意味着它运行了两次,并且以某种方式绕过/满足了这两个条件
我如何防止这种行为?
function selected_custom_checkout_gateways( $available_gateways ) {
global $woocommerce;
if(
isset( $_GET[ 'checkoutid' ] ) &&
$_GET[ 'checkoutid' ] == '50'
){
echo 123123;
unset( $available_gateways[ 'cod' ] ) ;
unset( $available_gateways[ 'cheque' ] ) ;
return $available_gateways;
exit;
}else{
echo 5555;
return $available_gateways;
}
}
Condition to filter and see which `IF` statement logic is hitting.