WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
payment methods by product category (3 posts)

  1. philbee
    Member
    Posted 1 year ago #

    Hi all,

    is there a safe way to define payment methods per product category in WooCommerce?

    My client has some products that can only be bought using COD, while most products in the shop also accept credit cards and even payment on the premises.

    I've searched the plugin pages and haven't found anything yet.

    Thanks a lot in advance for any help or hint.

    http://wordpress.org/extend/plugins/woocommerce/

  2. qrafts
    Member
    Posted 1 year ago #

    I'm trying to convert this code to product_category:

    add_filter('woocommerce_available_payment_gateways','filter_gateways',1);
    
    function filter_gateways($gateways){
    global $woocommerce;
     foreach ($woocommerce->cart->cart_contents as $key => $values ) {
    //store product id's in array
    $highpriceditems = array(56,57);			
    
      if(in_array($values['product_id'],$highpriceditems)){	
    
                                        unset($gateways['paypal']);
    break;
                                    }}
    return $gateways;
    }

    From this post

  3. Sean Donovan
    Member
    Posted 1 year ago #

    @qrafts - I added code that does what you want to the post you referenced.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic