Auto credit referral amount to wallet2019-09-04T18:05:48+05:30

Home Forums Wallet AffiliateWP Auto credit referral amount to wallet

Viewing 1 post (of 1 total)
  • Author
    Posts
  • Subrata Mal
    Keymaster
    Post count: 207

    Please use below code in theme function.php file to set auto paid referral status.

    if (!function_exists('can_receive_woo_wallet_credit')) {
    
        function can_receive_woo_wallet_credit($affiliate_id) {
            $ret = false;
            // Get global setting.
            $global_woo_wallet_credit_enabled = affiliate_wp()->settings->get('woo-wallet-all-affiliates');
    
            if ($global_woo_wallet_credit_enabled) {
                $ret = true;
            } else {
                $ret = affwp_get_affiliate_meta($affiliate_id, 'woo_wallet_credit_enabled', true);
            }
            return $ret;
        }
    
    }
    
    if (!function_exists('AffiliateWP_Woo_Wallet_Autopay')) {
    
        function AffiliateWP_Woo_Wallet_Autopay() {
            if (!current_user_can('manage_payouts')) {
                return;
            }
            $new_get_affiliate = new Affiliate_WP_Referrals_DB;
            $array_aff = $new_get_affiliate->get_referrals(
                    array(
                        'number' => -1,
                        'offset' => 0,
                        'referrals_id' => 0,
                        'affiliate_id' => 0,
                        'reference' => '',
                        'context' => '',
                        'status' => '',
                        'orderby' => 'referral_id',
                        'order' => 'DESC',
                        'search' => false
            ));
            foreach ($array_aff as $aff) {
                if (can_receive_woo_wallet_credit($aff->affiliate_id)) {
                    $ref = $aff->referral_id;
                    $ref_status = $aff->status;
                    if ($ref_status == "unpaid") {
                        affwp_set_referral_status($ref, "paid");
                    }
                }
            }
        }
    
    }
    add_action('init', 'AffiliateWP_Woo_Wallet_Autopay');
Viewing 1 post (of 1 total)
  • The topic ‘Auto credit referral amount to wallet’ is closed to new replies.
WhatsApp