Generation

generate functionMon, 06 Feb 2023

create a function for woocommerce to add a "cash on delivery" support which will have a fee of 2$.

add_filter( 'woocommerce_available_payment_gateways', 'bbloomer_unset_cod_for_virtual' ); function bbloomer_unset_cod_for_virtual( $available_gateways ) { global $woocommerce; // Set the ID of the gateway to be removed here $unset_gateway = 'cod'; if ( isset( $available_gateways[$unset_gateway] ) && $woocommerce->cart->needs_shipping() ) { unset( $available_gateways[$unset_gateway] ); } return $available_gateways; }

Questions about programming?Chat with your personal AI assistant