• Resolved Hasan Al Khaled

    (@hasanalkhaled)


    Hi, How can I put these two conditions in wallet usage.
    the customer only able to use maximum 50% of wallet balance during checkout.
    the customer cannot use wallet balance on sale items.

    After searching I found similar articles for first condition but could you please help me where to put this custom code.
    https://wordpress.org/support/topic/terawallet-limit-settings/

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Hasan Al Khaled

    (@hasanalkhaled)

    Hi, just to update that first condition of putting wallet amount usage has been resolved.

    add_filter('is_valid_payment_through_wallet', '__return_false');
    add_filter('woo_wallet_partial_payment_amount', 'woo_wallet_partial_payment_amount_callback', 10);
    
    function woo_wallet_partial_payment_amount_callback($amount) {
        if (sizeof(wc()->cart->get_cart()) > 0) {
    		$wallet_balance = woo_wallet()->wallet->get_wallet_balance(get_current_user_id(), 'edit');
            $cart_total = get_woowallet_cart_total();
    		$partial_payment_amount = ($wallet_balance * 30) / 100;
    		if($cart_total >= $partial_payment_amount){
    			$amount = $partial_payment_amount;
    		} 
    	}
        return $amount;
    }

    But the second condition of restricting wallet for specific product category is still not resolved

    add_filter('woo_wallet_payment_is_available', 'woo_wallet_payment_is_available_callback');
    if(!function_exists('woo_wallet_payment_is_available_callback')){
    	function woo_wallet_payment_is_available_callback($is_available){
    			
    		$categories   = array('cashback-products');
    		$has_category = false;
    			
    		// Loop through cart items
    		foreach ( WC()->cart->get_cart() as $cart_item ) {
    			// Check for product categories
    			if ( has_term( $categories, 'product_cat', $cart_item['product_id'] ) ) {
    				$is_available = false;				
    			}
    			return $is_available;
    		}				
    	}
    }
    Plugin Author Subrata Mal

    (@subratamal)

    @hasanalkhaled Please use those codes in the active theme functions.php file.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Terawallet Balance usage condition’ is closed to new replies.