Jump to content

rajasekaran1965

New Members
  • Posts

    7
  • Joined

  • Last visited

rajasekaran1965's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi Thank you very much for your reply. Your first code is working fine for get the users referred by the current user. //Get the data of the users referred by the current user $query = "SELECT id, firstname, lastname FROM {$members_table_name} WHERE refid = {$_SESSION['user_id']}"; But second and third code not worked for me. here with i attached the required php files. my actual need is to create a new table and update the referrers names obtained from current table. New table columns should be like below Column 1 refid = user_id (should copy from wp_affiliates_tbl column (refid) Column 2 email = email id (should copy from wp_affiliates_tbl column (email) Column 3 referrer(1) = referrer of user_id (should copy from wp_affiliates_tbl column(referrer) Column 4 referrer(2) = referrer of referrer(1) (this i need to get and update the table) Column 5 referrer(3) = referrer of referrer(2) (this i need to get and update the table) Column 6 referrer(4) = referrer of referrer(3) (this i need to get and update the table) Column 7 referrer(5) = referrer of referrer(4) (this i need to get and update the table) Column 8 referrer(6) = referrer of referrer(5) (this i need to get and update the table) Column 9 referrer(7) = referrer of referrer(6) (this i need to get and update the table) I dont know much about php, can u please help me regarding thiswp-affiliate-platform.zip
  2. Hi I need a sql query help from you guys. It is a sql query for get all upline referrer details from database for particular person when new person register his details are storing in wp_members_tbl with uername, password, firstname, lastname, email, phone, address, referrer etc. Below the query is for user $wp_aff_members_db = $wpdb->get_row("SELECT * FROM $members_table_name WHERE refid = '".$_SESSION['user_id']."'", OBJECT); And below the query is for this user's upline referrer $wp_aff_members_db = $wpdb->get_row("SELECT * FROM $members_table_name WHERE refid = '$referrer'", OBJECT); Now i need the query for find and get this referrer's upline referrer. Please help me with a solution Regards
  3. Hi Thanks for your reply File mga_functions.php is for reference purpose only and i am not using that. I am using wp_aff_includes.php only. I modified the function wp_aff_award_second_tier_commission() like below but not working. Just go through the modification and also please make the correction and help me please. If you want i will send full set if files also. function wp_aff_award_second_tier_commission($txn_id) { global $wpdb; // tiers $is_tier_comm = get_option('wp_aff_use_2tier'); //$tier_levels = get_option('wp_aff_tier_levels'); $tier_levels = "7"; $second_tier_commission_level = get_option('wp_aff_2nd_tier_commission_level'); // parent referrer $parent_referrer = $wpdb->get_var("SELECT DISTINCT(`parent_referrer`) FROM $affiliates_tiers_table_name WHERE `referrer_id`='{$referrer->referrer_id}'"); // loop $level = 1; $sub_affiliates=array(); // loop while(intval($parent_referrer)>0){ // next level $level++; // gather all subs $sub_affiliates[$level] = $parent_referrer; // parent $parent_referrer = $wpdb->get_var("SELECT `parent_referrer` FROM $affiliates_tiers WHERE `referrer_id`='{$parent_referrer}'"); // break if($level==($tier_levels)) break; } // set price if(count($sub_affiliates)>0){ $tier=2; foreach($sub_affiliates as $level=>$parent_referrer){ $commission_amount = round(($second_tier_commission_level * $sale_amount)/100,2); $is_tier_comm = "yes"; global $wpdb; $aff_sales_table = WP_AFF_SALES_TBL_NAME; $updatedb = "INSERT INTO $aff_sales_table (refid,date,time,browser,ipaddress,payment,sale_amount,txn_id,item_id,buyer_email,campaign_id,buyer_name,is_tier_comm) VALUES ('$wp_aff_affiliates_db->referrer','$clientdate','$clienttime','','','$commission_amount','$sale_amount','$txn_id','$item_id','$buyer_email','$campaign_id','$buyer_name','$is_tier_comm')"; $results = $wpdb->query($updatedb); // insert $tier++; } } }
  4. Hi QuickOldCar I am unable to modify the existing function. Can u please modify the function "function wp_aff_award_second_tier_commission" in the attached file. I need to pay upline commissions for up to 7 levels(7tier). Right now it is paying only 2 levels (2 tier). Please help me. filewp_aff_includes.php
  5. Hi I need to modify the below code for multiple tiers. Currently it is working for second tier and i need it to extend up to seven tiers. I attached one file which is having function (function mga_create_tier_commissions($sale_id)) for multiple tiers and i need modify like that function in this below code. Please help me. mga_functions.php function wp_aff_award_second_tier_commission($wp_aff_affiliates_db,$sale_amount,$txn_id,$item_id,$buyer_email,$buyer_name='') { global $aff_tx_msg; if (get_option('wp_aff_use_2tier') && !empty($wp_aff_affiliates_db->referrer)) { $aff_tx_msg .= '<br />Using tier model'; wp_affiliate_log_debug("Using tier model",true); $award_tier_commission = true; } if ($award_tier_commission) { if(!empty($wp_aff_affiliates_db->sec_tier_commissionlevel)){ $second_tier_commission_level = $wp_aff_affiliates_db->sec_tier_commissionlevel; wp_affiliate_log_debug("Using the affiliate specific 2nd tier commission for this referral. 2nd tier commission level: ".$second_tier_commission_level,true); } else{ $second_tier_commission_level = get_option('wp_aff_2nd_tier_commission_level'); wp_affiliate_log_debug("Using global 2nd tier commission for this referral. 2nd tier commission leve ".$second_tier_commission_level,true); } if (get_option('wp_aff_use_fixed_commission')) { $commission_amount = $second_tier_commission_level; } else { $commission_amount = round(($second_tier_commission_level * $sale_amount)/100,2); } $campaign_id = ""; $is_tier_comm = "yes"; global $wpdb; $aff_sales_table = WP_AFF_SALES_TBL_NAME; $updatedb = "INSERT INTO $aff_sales_table (refid,date,time,browser,ipaddress,payment,sale_amount,txn_id,item_id,buyer_email,campaign_id,buyer_name,is_tier_comm) VALUES ('$wp_aff_affiliates_db- >referrer','$clientdate','$clienttime','','','$commission_amount','$sale_amount','$txn_id','$item_id','$buyer_email','$campaign_id','$buyer_name','$is_tier_comm')"; $results = $wpdb->query($updatedb); $aff_tx_msg .= '<br />Tier commission awarded to: '.$wp_aff_affiliates_db->referrer.'. Commission amount: '.$commission_amount; wp_affiliate_log_debug('Tier commission awarded to: '.$wp_aff_affiliates_db->referrer.'. Commission amount: '.$commission_amount,true); } } return $aff_tx_msg; }
  6. Hi QuickOldCar, Thank you for your interest in this but actually your code not worked in my program. Just check the below functions. first function is awarding commission for direct referral and second function is awarding commission for 2nd tier referral and third function is added by me for 3rd tier commission but it is not worked bcoz it is not getting the parent referral details. So pleas guide me how to get the parent referral function. ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- function wp_aff_award_commission($referrer,$sale_amount,$txn_id,$item_id,$buyer_email,$clientip='',$comm_rate='',$buyer_name='') { global $aff_tx_msg,$aff_error_msg; $commission_award_result = ""; $debug_data = ""; $debug_data .= "Referrer: ".$referrer. ", Sale Amount: ".$sale_amount.", Transaction ID: ".$txn_id.", "; $debug_data .= "Item ID: ".$item_id. ", Buyer Email: ".$buyer_email.", Custom Commission Rate: ".$comm_rate; $aff_tx_msg = $debug_data; wp_affiliate_log_debug($debug_data,true); $clientdate = (date ("Y-m-d")); $clienttime = (date ("H:i:s")); if(empty($clientip)) { $clientip = $_SERVER['REMOTE_ADDR']; } if(empty($txn_id)) { $txn_id = uniqid(); } if (!empty($referrer)) { global $wpdb; $affiliates_table_name = $wpdb->prefix . "affiliates_tbl"; $aff_sales_table = $wpdb->prefix . "affiliates_sales_tbl"; $wp_aff_affiliates_db = $wpdb->get_row("SELECT * FROM $affiliates_table_name WHERE refid = '$referrer'", OBJECT); if(empty($comm_rate)){ $commission_level = $wp_aff_affiliates_db->commissionlevel; } else{ $commission_level = $comm_rate; } if (get_option('wp_aff_use_fixed_commission')) { $commission_amount = $commission_level; } else { $commission_amount = ($commission_level * $sale_amount)/100; } if(WP_AFFILIATE_NO_COMMISSION_FOR_SELF_PURCHASE == '1'){ if(!empty($buyer_email)){ if(wp_aff_check_if_buyer_is_referrer($referrer,$buyer_email)){ wp_affiliate_log_debug('The buyer ('.$buyer_email.') is the referrer ('.$referrer.') so this sale is NOT ELIGIBLE for generating any commission.',true); return true; } } else{ wp_affiliate_log_debug("Buyer email data is missing from the request so the plugin cannot verify the WP_AFFILIATE_NO_COMMISSION_FOR_SELF_PURCHASE option",true); } } $commission_amount = round($commission_amount,2); $c_id=''; if(isset($_COOKIE['c_id'])){ $c_id = $_COOKIE['c_id']; } if(!empty($buyer_name)){ $updatedb = "INSERT INTO $aff_sales_table (refid,date,time,browser,ipaddress,payment,sale_amount,txn_id,item_id,buyer_email,campaign_id,buyer_name) VALUES ('$referrer','$clientdate','$clienttime','','$clientip','$commission_amount','$sale_amount','$txn_id','$item_id','$buyer_email','$c_id','$buyer_name')"; } else{ $updatedb = "INSERT INTO $aff_sales_table (refid,date,time,browser,ipaddress,payment,sale_amount,txn_id,item_id,buyer_email,campaign_id) VALUES ('$referrer','$clientdate','$clienttime','','$clientip','$commission_amount','$sale_amount','$txn_id','$item_id','$buyer_email','$c_id')"; } $results = $wpdb->query($updatedb); if(!$results) { $aff_tx_msg .= "<br />The database update query failed for table: ".$aff_sales_table; wp_affiliate_log_debug("The database update query failed for table: ".$aff_sales_table,false); } else { $aff_tx_msg .= '<br />The sale has been registered in the WP Affiliate Platform Database for referrer: '.$referrer.' with amount: '.$commission_amount; wp_affiliate_log_debug('The sale has been registered in the WP Affiliate Platform Database for referrer: '.$referrer.' with amount: '.$commission_amount,true); } wp_aff_send_commission_notification($wp_aff_affiliates_db->email,$txn_id); // 2nd tier commission $commission_award_result = wp_aff_award_second_tier_commission($wp_aff_affiliates_db,$sale_amount,$txn_id,$item_id,$buyer_email,$buyer_name); //This below lines are added by me for tiers 3 to 7 // 3rd tier commission $commission_award_result = wp_aff_award_third_tier_commission($wp_aff_affiliates_db,$sale_amount,$txn_id,$item_id,$buyer_email,$buyer_name); // 4th tier commission $commission_award_result = wp_aff_award_fourth_tier_commission($wp_aff_affiliates_db,$sale_amount,$txn_id,$item_id,$buyer_email,$buyer_name); // 5th tier commission $commission_award_result = wp_aff_award_fifth_tier_commission($wp_aff_affiliates_db,$sale_amount,$txn_id,$item_id,$buyer_email,$buyer_name); // 6th tier commission $commission_award_result = wp_aff_award_sixth_tier_commission($wp_aff_affiliates_db,$sale_amount,$txn_id,$item_id,$buyer_email,$buyer_name); // 7th tier commission $commission_award_result = wp_aff_award_seventh_tier_commission($wp_aff_affiliates_db,$sale_amount,$txn_id,$item_id,$buyer_email,$buyer_name); // Up to above i added in this function } return $commission_award_result; } This function is existing and working fine for second tier function wp_aff_award_second_tier_commission($wp_aff_affiliates_db,$sale_amount,$txn_id,$item_id,$buyer_email,$buyer_name='') { global $aff_tx_msg; $clientdate = (date ("Y-m-d")); $clienttime = (date ("H:i:s")); if (get_option('wp_aff_use_2tier') && !empty($wp_aff_affiliates_db->referrer)) { $aff_tx_msg .= '<br />Using tier model'; wp_affiliate_log_debug("Using tier model",true); $award_tier_commission = true; $duration = get_option('wp_aff_2nd_tier_duration'); if(!empty($duration)) { $join_date = $wp_aff_affiliates_db->date; $days_since_joined = round((strtotime(date("Y-m-d")) - strtotime($join_date) ) / (60 * 60 * 24)); if ($days_since_joined > $duration) { $aff_tx_msg .= '<br />Tier commission award duration expried'; wp_affiliate_log_debug("Tier commission award duration expried! No tier commission will be awarded for this sale.",true); $award_tier_commission = false; } } if ($award_tier_commission) { if(!empty($wp_aff_affiliates_db->sec_tier_commissionlevel)){ $second_tier_commission_level = $wp_aff_affiliates_db->sec_tier_commissionlevel; wp_affiliate_log_debug("Using the affiliate specific 2nd tier commission for this referral. 2nd tier commission level: ".$second_tier_commission_level,true); } else{ $second_tier_commission_level = get_option('wp_aff_2nd_tier_commission_level'); wp_affiliate_log_debug("Using global 2nd tier commission for this referral. 2nd tier commission level: ".$second_tier_commission_level,true); } if (get_option('wp_aff_use_fixed_commission')) { $commission_amount = $second_tier_commission_level; } else { $commission_amount = round(($second_tier_commission_level * $sale_amount)/100,2); } $campaign_id = ""; $is_tier_comm = "yes"; global $wpdb; $aff_sales_table = WP_AFF_SALES_TBL_NAME; $updatedb = "INSERT INTO $aff_sales_table (refid,date,time,browser,ipaddress,payment,sale_amount,txn_id,item_id,buyer_email,campaign_id,buyer_name,is_tier_comm) VALUES ('$wp_aff_affiliates_db->referrer','$clientdate','$clienttime','','','$commission_amount','$sale_amount','$txn_id','$item_id','$buyer_email','$campaign_id','$buyer_name','$is_tier_comm')"; $results = $wpdb->query($updatedb); $aff_tx_msg .= '<br />Tier commission awarded to: '.$wp_aff_affiliates_db->referrer.'. Commission amount: '.$commission_amount; wp_affiliate_log_debug('Tier commission awarded to: '.$wp_aff_affiliates_db->referrer.'. Commission amount: '.$commission_amount,true); } } return $aff_tx_msg; } This function added by me for 3rd tier but not working function wp_aff_award_third_tier_commission($wp_aff_affiliates_db,$sale_amount,$txn_id,$item_id,$buyer_email,$buyer_name='') { global $aff_tx_msg; $clientdate = (date ("Y-m-d")); $clienttime = (date ("H:i:s")); if (get_option('wp_aff_use_3tier') && !empty($wp_aff_affiliates_db->referrer)) { $aff_tx_msg .= '<br />Using tier model'; wp_affiliate_log_debug("Using tier model",true); $award_tier_commission = true; $duration = get_option('wp_aff_3rd_tier_duration'); if(!empty($duration)) { $join_date = $wp_aff_affiliates_db->date; $days_since_joined = round((strtotime(date("Y-m-d")) - strtotime($join_date) ) / (60 * 60 * 24)); if ($days_since_joined > $duration) { $aff_tx_msg .= '<br />Tier commission award duration expried'; wp_affiliate_log_debug("Tier commission award duration expried! No tier commission will be awarded for this sale.",true); $award_tier_commission = false; } } if ($award_tier_commission) { { $third_tier_commission_level = get_option('wp_aff_3rd_tier_commission_level'); wp_affiliate_log_debug("Using global 3rd tier commission for this referral. 3rd tier commission level: ".$third_tier_commission_level,true); } if (get_option('wp_aff_use_fixed_commission')) { $commission_amount = $third_tier_commission_level; } else { $commission_amount = round(($third_tier_commission_level * $sale_amount)/100,2); } $campaign_id = ""; $is_tier_comm = "yes"; global $wpdb; $aff_sales_table = WP_AFF_SALES_TBL_NAME; $updatedb = "INSERT INTO $aff_sales_table (refid,date,time,browser,ipaddress,payment,sale_amount,txn_id,item_id,buyer_email,campaign_id,buyer_name,is_tier_comm) VALUES ('$wp_aff_affiliates_db->referrer','$clientdate','$clienttime','','','$commission_amount','$sale_amount','$txn_id','$item_id','$buyer_email','$campaign_id','$buyer_name','$is_tier_comm')"; $results = $wpdb->query($updatedb); $aff_tx_msg .= '<br />Tier commission awarded to: '.$wp_aff_affiliates_db->referrer.'. Commission amount: '.$commission_amount; wp_affiliate_log_debug('Tier commission awarded to: '.$wp_aff_affiliates_db->referrer.'. Commission amount: '.$commission_amount,true); } } return $aff_tx_msg; } ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Please check and find me the solution
  7. Hi I need to add one more function in my wordpress plugin. below is the sample code working for 2nd tier. Now i need a same function for 3rd and 4th tire. Function explanation I am A and i refer B and if B made any sale means I (A) will get direct commission for that sale. If B refer C and if C made any sale means (B) will get direct commission for that sale. And in this sample code me(A) also get commission for that sale as a 2nd tier. Now C refer D and if D made any sale means © will get direct commission for that sale and (B) will get 2nd tier commission. So here (A) me too should get 3rd tire commission and i need that function. Please help me. function wp_aff_award_second_tier_commission($wp_aff_affiliates_db,$sale_amount,$txn_id,$item_id,$buyer_email,$buyer_name='') { global $aff_tx_msg; $clientdate = (date ("Y-m-d")); $clienttime = (date ("H:i:s")); if (get_option('wp_aff_use_2tier') && !empty($wp_aff_affiliates_db->referrer)) { $aff_tx_msg .= '<br />Using tier model'; wp_affiliate_log_debug("Using tier model",true); $award_tier_commission = true; $duration = get_option('wp_aff_2nd_tier_duration'); if(!empty($duration)) { $join_date = $wp_aff_affiliates_db->date; $days_since_joined = round((strtotime(date("Y-m-d")) - strtotime($join_date) ) / (60 * 60 * 24)); if ($days_since_joined > $duration) { $aff_tx_msg .= '<br />Tier commission award duration expried'; wp_affiliate_log_debug("Tier commission award duration expried! No tier commission will be awarded for this sale.",true); $award_tier_commission = false; } } if ($award_tier_commission) { if(!empty($wp_aff_affiliates_db->sec_tier_commissionlevel)){ $second_tier_commission_level = $wp_aff_affiliates_db->sec_tier_commissionlevel; wp_affiliate_log_debug("Using the affiliate specific 2nd tier commission for this referral. 2nd tier commission level: ".$second_tier_commission_level,true); } else{ $second_tier_commission_level = get_option('wp_aff_2nd_tier_commission_level'); wp_affiliate_log_debug("Using global 2nd tier commission for this referral. 2nd tier commission level: ".$second_tier_commission_level,true); } if (get_option('wp_aff_use_fixed_commission')) { $commission_amount = $second_tier_commission_level; } else { $commission_amount = round(($second_tier_commission_level * $sale_amount)/100,2); } $campaign_id = ""; $is_tier_comm = "yes"; global $wpdb; $aff_sales_table = WP_AFF_SALES_TBL_NAME; $updatedb = "INSERT INTO $aff_sales_table (refid,date,time,browser,ipaddress,payment,sale_amount,txn_id,item_id,buyer_email,campaign_id,buyer_name,is_tier_comm) VALUES ('$wp_aff_affiliates_db->referrer','$clientdate','$clienttime','','','$commission_amount','$sale_amount','$txn_id','$item_id','$buyer_email','$campaign_id','$buyer_name','$is_tier_comm')"; $results = $wpdb->query($updatedb); $aff_tx_msg .= '<br />Tier commission awarded to: '.$wp_aff_affiliates_db->referrer.'. Commission amount: '.$commission_amount; wp_affiliate_log_debug('Tier commission awarded to: '.$wp_aff_affiliates_db->referrer.'. Commission amount: '.$commission_amount,true); } } return $aff_tx_msg; }
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.