• Hi

    I want to disable cashback reward program programmatically for wholesalers. The following code does not work

    
    <?php
    class YWP_Tera_Wallet {
    	
    	public function __construct() {
    		add_filter( 'woo_wallet_form_cart_cashback_amount', array( $this, 'desactivate_plugin_wallet' ), 10 );
    		add_filter( 'woo_wallet_form_order_cashback_amount', array( $this, 'desactivate_plugin_wallet1' ), 10, 2 );
    	}
    
    	/**
    	 *  Tera Wallet For wholsale
    	 */
    	function desactivate_plugin_wallet( $amount ) {
    		
    		if ( current_user_can( 'wholsale' ) ) {
    			return 0;
    		} else {
    			return $amount;
    		}
    	}
    
    	/**
    	 *  Tera Wallet For wh
    	 */
    	function desactivate_plugin_wallet1( $amount, $order_id ) {
    		
    		if ( current_user_can( 'wholsale' ) ) {
    			return 0;
    		} else {
    			return $amount;
    		}
    	}
    }
    
    new YWP_Tera_Wallet();

    Thanks

Viewing 1 replies (of 1 total)
  • Plugin Author Subrata Mal

    (@subratamal)

    @yazdaniwp It seems like the code is fine. Please try to check user role using bellow code.

    $user = wp_get_current_user();
    if ( in_array( 'wholsale', (array) $user->roles ) ) {
        //The user has the "wholsale" role
    }
Viewing 1 replies (of 1 total)
  • The topic ‘Disable cashback reward program programmatically’ is closed to new replies.