更新时间:2023-11-30 11:28:22
使用以下内容来防止这个错误(也删除了endif;
):
Use the following to prevent this error (also removed endif;
):
// Filter payment gatways for different shipping methods
add_filter( 'woocommerce_available_payment_gateways', 'my_custom_available_payment_gateways', 10, 1 );
function my_custom_available_payment_gateways( $available_gateways ) {
if( is_admin() ) return $available_gateways; // Only for frontend
$chosen_shipping_rates = (array) WC()->session->get( 'chosen_shipping_methods' );
if ( in_array( 'flat_rate:12', $chosen_shipping_rates ) ) {
unset( $available_gateways['stripe'], $available_gateways['ppec_paypal'] );
}
return $available_gateways;
}
代码位于活动子主题(或活动主题)的 functions.php 文件中.它应该有效.
Code goes in functions.php file of your active child theme (or active theme). It should works.