@sadiqodunsi
Use below code.
add_filter('is_enable_wallet_partial_payment', '__return_false');
Thank you.
Hi,
Thank you for the quick response. I am not sure how I can use this code conditionally that it runs when a product with payment category is in cart. I already have the function to detect if payment category is in cart. I tried the following but no luck.
// I added a payment product category to wallet product
function paystack_gateway_disable($available_gateways) {
if (!is_admin()) {
if (payments_category_is_in_the_cart()) {
unset($available_gateways['wallet']);
add_filter('is_enable_wallet_partial_payment', '__return_false');
}
}
return $available_gateways;
}
add_filter('woocommerce_available_payment_gateways', 'paystack_gateway_disable');
Additionally, I noticed that even when I used your snippet directly. The partial payment text below still shows:
%s will be debited from your wallet and %s will be paid through other payment method.
Kind regards,
Sadiq
-
This reply was modified 2 years, 9 months ago by
sadiqodunsi.
Hello,
I am still waiting to get a response from you.
Thank you
Sadiq
Please let us know the definition of payments_category_is_in_the_cart function.
/**
* Function to check if a specific product category is in the cart
* Usage: if ((payments_category_is_in_the_cart())
*/
function payments_category_is_in_the_cart() {
// Add your special category slugs here
$categories = array( 'payments' );
// Products currently in the cart
$cart_ids = array();
// Categories currently in the cart
$cart_categories = array();
// Find each product in the cart and add it to the $cart_ids array
foreach( WC()->cart->get_cart() as $cart_item_key => $values ) {
$cart_product = $values['data'];
$cart_ids[] = $cart_product->get_id();
}
// Connect the products in the cart w/ their categories
foreach( $cart_ids as $id ) {
$products_categories = get_the_terms( $id, 'product_cat' );
// Loop through each product category and add it to our $cart_categories array
foreach ( $products_categories as $products_category ) {
$cart_categories[] = $products_category->slug;
}
}
// If one of the special categories are in the cart, return true.
if ( ! empty( array_intersect( $categories, $cart_categories ) ) ) {
return true;
} else {
return false;
}
}
Hello,
I am still waiting for your response.
Thanks
Sadiq
Hello,
I am still in need of this. Hope to get a response.
Thanks
Sadiq
didnt exactly understand your issue but came across your post looking for my own solution. I was able to resolve my issue using this plugin, maybe it can help you:
WooCommerce Payment Gateways per Product or Category
https://wordpress.org/plugins/payment-gateways-per-product-categories-for-woocommerce/
-
This reply was modified 2 years, 5 months ago by
namorim83.
Did you found a workaround for this ? I got exactly the same need, i want to disable partial payment if there is a subscription product in the cart, but keep it enabled for other products.
I found that the code add_filter(‘is_enable_wallet_partial_payment’, ‘__return_false’); won’t work inside the ‘woocommerce_available_payment_gateways’ filter.
The following code : add_filter(‘woo_wallet_disable_partial_payment’, ‘__return_true’); works fine if called inside :
add_action( ‘woocommerce_cart_calculate_fees’,’Your_function_to_check_category_in_cart’);
So following your code, this should work for you :
function disable_partial_payment() {
if (payments_category_is_in_the_cart()) {
add_filter(‘woo_wallet_disable_partial_payment’, ‘__return_true’);
}
}
add_action( ‘woocommerce_cart_calculate_fees’,’disable_partial_payment’);
Thank you very much for taking the time to help. I will give this a try later.
Hi @creaweb2b . Thanks for This Code: add_filter(‘woo_wallet_disable_partial_payment’, ‘__return_true’);
It worked for me but I had to Modify it first by changing ‘ to ‘ as seen below.
add_filter(‘woo_wallet_disable_partial_payment’, ‘__return_true’);