Viewing 1 post (of 1 total)
  • Author
    Posts
  • #5828
    s.garazh2002
    Participant

    Hello! I want payments to be paid automatically. If I create a payment through the rest API, the payment is created, but the partner’s balance is not replenished. I found this code, but it doesn’t solve this problem either.

    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)
  • You must be logged in to reply to this topic.

Login

Register

A link to set a new password will be sent to your email address.

Your personal data will be used to support your experience throughout this website, to manage access to your account, and for other purposes described in our privacy policy.

WhatsApp

get a quote