Payment method based

Hello, I will like to know how I can get this to work for my site. Any suggestion or solution is welcomed.

I will like payments to vendors from customers for services rendered to be COD. However,
I will like credit card payments for vendors for membership and renewals.

I have found a plugin " WooCommerce Conditional Shipping and Payments" that disable payments method based on condition. eg. user role conditions can be set to hide payment methods when a user is a subscriber, customer, etc.

What are the user roles types for HivePress? Thanks a million

The easiest way would be using some WooCommerce extension that enables different gateways depending on the product details. Products generated by the WooCommerce extension are marked as Virtual, also they have the Visibility set to Hidden so this may work if there’s an extension for targeting these details. I also found this snippet php - Hide payment method based on product type in WooCommerce - Stack Overflow Let me know if there are no matching extensions and I’ll check if it’s possible to adapt this snippet for HivePress Marketplace.

1 Like

Thanks for the suggestions I will give them a try and update you on the progress. However, I like the last part of adapting the snippet for the HivePress Marketplace :smile:

Please try this PHP snippet but please note that it can require further customization

add_filter('woocommerce_available_payment_gateways', 'conditional_payment_gateways', 10, 1);
function conditional_payment_gateways( $available_gateways ) {
    if( is_admin() ){
		return $available_gateways;

    foreach (WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
        $prod_variable = $prod_simple = $prod_subscription = false;
        // Get the WC_Product object
        $product = wc_get_product($cart_item['product_id']);
		$listing = HivePress\Models\Listing::query()->filter(['id__in' => [$product->get_parent_id()]])->get_first_id();
				$prod_simple = true;
				$prod_variable = true;
				$prod_subscription = true;
    // Remove Cash on delivery (cod) payment gateway for simple products
    // Remove Paypal (paypal) payment gateway for variable products
    // Remove Bank wire (Bacs) payment gateway for subscription products

    return $available_gateways;
1 Like

Excellent this did the trick it will be nice to also integrate it into the plugin as an option. Thanks to the Hive team.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.