Unset payment gateway for specific categories (Woocommerce)
$10-30 USD
Fechado
Publicado há quase 3 anos
$10-30 USD
Pago na entrega
I have a code for unset some payments gateways when there are some products added to the cart.
Its working fine when user make the purchase process from frontend.., but when the order is added from admin panel and payment link sent to customer from there, its not working.
Here is the code used:
add_filter( 'woocommerce_available_payment_gateways', 'bbloomer_unset_gateway_by_category' );
function bbloomer_unset_gateway_by_category( $available_gateways ) {
if ( is_admin() ) return $available_gateways;
if ( ! is_checkout() ) return $available_gateways;
$unset = false;
$category_ids = array( 61, 89, 58, 90, 93, 95, 91, 98, 106);
foreach ( WC()->cart->get_cart_contents() as $key => $values ) {
$terms = get_the_terms( $values['product_id'], 'product_cat' );
foreach ( $terms as $term ) {
if ( in_array( $term->term_id, $category_ids ) ) {
$unset = true;
break;
}
}
}
if ( $unset == true )
unset( $available_gateways['bacs'] );
return $available_gateways;
}
Here is the payment link that is not working:
[login to view URL]
Hi Man!
"Want a WordPress Website Or to modify it?"
This is Amir Anwar in your service with the presence of gigantic skills in WordPress Development.
I can give you a number of features in your WordPress Site (New Or Old).
I can give you the service of a number of unique developments stated,
*Custom Plugin Development
*Portfolio sites
*Listing Sites
*Multi-vendor sites
*Ecommerce Stores
*Service Providing sites
*Plugin modification
*BuddyPress sites
And more a number of features i can provide yolu with the quality and clean working.
Regards,
Amir Anwar