hi
i add this code in class-gens-raf-public.php and change function gens_create_send_coupon and work:
public function gens_create_send_coupon($order_id) {
$rafID = esc_attr(get_post_meta( $order_id, '_raf_id', true));
// Get id of user that made order so that user cant use his own ref link.
$order = new WC_Order( $order_id );
$order_user_id = $order->get_user_id();
$gens_users = get_users( array(
"meta_key" => "gens_referral_id",
"meta_value" => $rafID,
"number" => 1,
"fields" => "ID"
) );
$user_id = $gens_users[0];
// added code
$user_info = get_userdata($user_id);
$user_email = $user_info->user_email;
$couponargs = array( 'post_type' => 'shop_coupon','posts_per_page' => -1, 'meta_key' => 'customer_email', 'meta_value' => $user_email);
$mycoupons = get_posts( $couponargs );
$count = count($mycoupons);
//end
// user ref exists, refID as well, and user is not using his own referral link ? If all good, proceed.
if ( $gens_users && !empty($rafID) && ($user_id != $order_user_id) && $count < 2) {
// Generate Coupon and returns it
$coupon_code = $this->generate_coupons( $user_id );
// Send via Email
$this->gens_send_email( $user_id, $coupon_code );
}
return $order_id;
}
but i want a way to not change in core of plugin.
please help
thanks
-
This reply was modified 8 years, 10 months ago by
movahedian1.
Currently, there is no filter added in a free plugin, only premium, but I’ll add it in the future so once it’s done, you can just copy your code to the new filter.