• Resolved maurosp91

    (@maurosp91)


    Hi,
    I need to hide Cash on Pickup method based on the shop name.
    My code looks like this but I can’t get any data from the order inside this hook.
    How can I solve this?

    
    add_filter( 'woocommerce_available_payment_gateways' , 'change_payment_gateway');
    
    function change_payment_gateway( $gateways ){
    
        $COD = array(
            "Shop1"=>"yes", 
            "Shop2"=>"no", 
            "Shop3"=>"yes"
        );
    	
    	$cartItems = WC()->cart->get_cart();
        foreach ( $cartItems as $cartItemKey => $cartItem ) {
    	    $vendorId   = get_post_field( 'post_author', $cartItem['product_id'] );
    	}
       	
    	$shopName = dokan()->vendor->get( $vendorId )->get_shop_name();
    
    	
    	if(!$vendorId) {
    		return;
    	}
    
    	if(empty($shopName)) {
    		return;
    	}
    
        if( $COD[$shopName] === "no"){
            unset( $gateways['cod'] );
       }
       return $gateways;
    
    }
    

    Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Jahidul Hassan Mojumder

    (@jahidulhassan)

    Hi @maurosp91,

    Showing multiple shipping for multiple vendors for an order on the checkout page is a premium feature of the Dokan plugin.

    According to the forum guidelines, commercial products are not supported in these forums.

    Thread Starter maurosp91

    (@maurosp91)

    It’s not multiple shippings. It’s part of dokan lite.

    I’ll explain what I am doing with more details:

    I will provide customers 2 payment options: cash on delivery and QR scanning payment on delivery as well (I manage the delivery service)
    I’m just using cash on pick up method to emulate a second type of cash on delivery (because I need dokan to know that QR money goes straight to vendors wallets).

    Therefore, I need to find a way to unset QR code payment method (emulated by COP) if a vendor just want cash.

    I only need help to get the vendor Id at the checkout page using the hook
    woocommerce_available_payment_gateways

    Thanks a lot!

    • This reply was modified 2 years, 4 months ago by maurosp91.
    Plugin Support Jahidul Hassan Mojumder

    (@jahidulhassan)

    Hi @maurosp91,

    According to our support policy, we are unable to review custom codes from our users. Still, I had the chance to have a look at your code. It seems like your foreach loop was not implemented properly. The conditions are written out of the scope of the loop while they are supposed to be written within the scope. In this regard, I would like to suggest having a closer look at your code. I hope this helps.

    Cheers!

    Plugin Support Jahidul Hassan Mojumder

    (@jahidulhassan)

    Hi @maurosp91,

    Due to inactivity, we are marking this topic as resolved. Feel free to open a new one if you face any further issues.

    Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Get store name at checkout’ is closed to new replies.