This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Hook into checkout | |
| * | |
| * @since 2.0.0 | |
| */ | |
| if ( ! defined( 'ABSPATH' ) ) { | |
| exit; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Hook to Woo Tools to add buttons for missing rafs. | |
| * @author WPGens | |
| */ | |
| if ( ! defined( 'ABSPATH' ) ) { | |
| exit; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| add_filter('gens_raf_coupon_amount','change_coupon_amount',10, 2); | |
| function change_coupon_amount($amount,$order_id){ | |
| // get number of referrals | |
| $referrer_id = get_post_meta($order_id,'_wpgens_raf_id',true); | |
| $user = reset(get_users(array('meta_key' => 'gens_referral_id', 'meta_value' => $referrer_id))); | |
| $customer_orders = get_posts( array( | |
| 'numberposts' => - 1, | |
| 'meta_key' => '_customer_user', | |
| 'meta_value' => $user->ID, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| add_filter('gens_raf_should_remove_coupon','gens_raf_code',10,3); | |
| function gens_raf_code($should_remove,$guest_coupon_code,$referrer_id) { | |
| if( is_user_logged_in() ) { | |
| $user = wp_get_current_user(); | |
| $roles = ( array ) $user->roles; | |
| if($roles[0] === "wholesale-customer") { | |
| return true; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| add_action( 'user_register', 'generate_coupon', 10, 1 ); | |
| function generate_coupon( $user_id ) { | |
| if(isset($_COOKIE["gens_raf"])) { | |
| $referral_code = $_COOKIE["gens_raf"]; | |
| global $wpdb; | |
| $results = $wpdb->get_results($wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key='gens_referral_id' AND meta_value = %s", $referral_code)); | |
| if(!empty($results)) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function gens_check_membership_level(){ | |
| $user_id = get_current_user_id(); | |
| $gens_raf = WPGens_RAF::instance(); | |
| remove_action( 'woocommerce_account_menu_items', array( $gens_raf->my_account, 'gens_account_menu_item') ); | |
| remove_action( 'init', array( $gens_raf->my_account, 'gens_myreferral_tab')); | |
| } | |
| gens_check_membership_level(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function custom_user_has_orders($user_email = false){ | |
| $user_id = get_current_user_id(); | |
| if($user_id == 0) { | |
| if($user_email !== false && $user_email != '') { | |
| $email_exists = get_posts( array( | |
| 'numberposts' => 1, | |
| 'meta_key' => '_billing_email', | |
| 'meta_value' => $user_email, | |
| 'post_type' => wc_get_order_types(), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_filter('wpgens_raf_code','gens_raf_code',10,1); | |
| function gens_raf_code($raf_code) { | |
| $user_id = get_current_user_id(); | |
| $args = array( | |
| 'status' => array( 'active', 'complimentary', 'pending' ), | |
| ); | |
| if(!function_exists('wc_memberships_get_user_memberships')) { | |
| return $raf_code; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function change_msg() { return 'some text'; } | |
| add_filter( 'gens_raf_coupon_removal_message', 'change_msg' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| add_filter('gens_raf_generate_coupon', 'dont_generate',10,2); | |
| function dont_generate($generate_coupon,$order_id){ | |
| $order = new WC_Order($order_id); | |
| $user = get_user_by('email', $order->billing_email); | |
| if(!isset($user->ID)){ | |
| return false; |