Support » Plugin: WooCommerce » Products belonging to certain custom taxonomy terms do not display paypal on th

  • Resolved yuuuuka

    (@yuuuuka)


    I want to hide paypal on the checkout page for items belonging to a particular custom taxonomy term.

    taxonomy is “options”
    term is “notpaypal”

    add_filter('woocommerce_available_payment_gateways', 'woocs_filter_gateways', 1);
    function woocs_filter_gateways($gateway_list)
    {
        global $woocommerce;
        if( has_term( 'notpaypal', 'options' ) ) 
          {
            unset($gateway_list['paypal']);
          }
        return $gateway_list;
    }
    • This topic was modified 3 years, 1 month ago by yuuuuka.
Viewing 1 replies (of 1 total)
  • Thread Starter yuuuuka

    (@yuuuuka)

    https://businessbloomer.com/woocommerce-disable-payment-method-for-specific-category/

    add_filter( 'woocommerce_available_payment_gateways', 'bbloomer_unset_gateway_by_category' );
      
    function bbloomer_unset_gateway_by_category( $available_gateways ) {
    $unset = false;
    $category_ids = array( 8, 37 );
    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['cheque'] );
        return $available_gateways;
    }
Viewing 1 replies (of 1 total)
  • The topic ‘Products belonging to certain custom taxonomy terms do not display paypal on th’ is closed to new replies.