当购物车中只有虚拟产品时,我想删除结账页面上的一些信息。
以下是删除我想要在结帐页面上显示的内容:
remove_action( 'woocommerce_checkout_terms_and_conditions', 'wc_checkout_privacy_policy_text', 20 );
remove_action( 'woocommerce_checkout_terms_and_conditions', 'wc_terms_and_conditions_page_content', 30 );
remove_action( 'woocommerce_checkout_terms_and_conditions', 'woocontracts_terms_fields', );
remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 );
remove_action( 'woocommerce_checkout_order_review', 'woocommerce_order_review', 10 );
remove_action( 'woocommerce_checkout_after_terms_and_conditions', 'woocontracts_checkout_additional_checkboxes', 10 );
remove_action( 'woocommerce_checkout_process', 'woocontracts_checkout_field_process', 10 );
当购物车中只有虚拟产品时如何制作相同的产品?
我尝试了以下方法:
add_filter( 'woocommerce_checkout_after_terms_and_conditions' , 'bbloomer_simplify_checkout_virtualab' );
function bbloomer_simplify_checkout_virtualab( $fields ) {
$only_virtual = true;
foreach( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
// Check if there are non-virtual products
if ( ! $cart_item['data']->is_virtual() ) $only_virtual = false;
}
if( $only_virtual ) {
remove_action( 'woocommerce_checkout_terms_and_conditions', 'wc_checkout_privacy_policy_text', 20 );
remove_action( 'woocommerce_checkout_terms_and_conditions', 'wc_terms_and_conditions_page_content', 30 );
remove_action( 'woocommerce_checkout_terms_and_conditions', 'woocontracts_terms_fields', );
remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 );
remove_action( 'woocommerce_checkout_order_review', 'woocommerce_order_review', 10 );
return $fields;
}
return $fields;
}
但这不起作用。有什么建议么?
猛跑小猪