Skip to content

Instantly share code, notes, and snippets.

👨‍💻
developing ...

Antonio Blanco eggemplo

👨‍💻
developing ...
Block or report user

Report or block eggemplo

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:e67c7e0421849adcc8df
add_filter('woocommerce_coupon_is_valid', 'my_woocommerce_coupon_is_valid', 10, 2 );
function my_woocommerce_coupon_is_valid ( $valid, $coupon ) {
if ( !class_exists("Affiliates_Service" ) ) {
require_once( AFFILIATES_CORE_LIB . '/class-affiliates-service.php' );
}
$aff_id = Affiliates_Service::get_referrer_id();
if ( ( $aff_id ) && ( $aff_id !== "1" ) ) {
return false;
} else {
return $valid;
View gist:0dc1b50e3e146961a9ed
$data = "\n";
if ( count($referrals) > 0 ) {
foreach ( $referrals as $referral ) {
$array_data = unserialize($referral->data);
if ( isset($array_data['your-subject'])) {
$data .= $array_data['your-subject']['title'] . ":" . $array_data['your-subject']['value'] . "\n";
}
}
}
@eggemplo
eggemplo / gist:aefb68573545dbd4e7e3
Created Jul 20, 2015
addAffiliatesTokens to Contact Form 7
View gist:aefb68573545dbd4e7e3
function addAffiliatesTokens($array) {
if (! class_exists ( "Affiliates_Service" )) {
include_once (AFFILIATES_CORE_LIB . '/class-affiliates-service.php');
}
$affiliate_id = Affiliates_Service::get_referrer_id ();
if ($affiliate_id) {
if ($affiliate_id !== affiliates_get_direct_id ()) {
if ($user_id = affiliates_get_affiliate_user ( $affiliate_id )) {
@eggemplo
eggemplo / gist:23da1b83bf0e54f2c878
Created Jul 20, 2015
addAffiliatesTokens to Contact Form 7
View gist:23da1b83bf0e54f2c878
function addAffiliatesTokens($array) {
if (! class_exists ( "Affiliates_Service" )) {
include_once (AFFILIATES_CORE_LIB . '/class-affiliates-service.php');
}
$affiliate_id = Affiliates_Service::get_referrer_id ();
if ($affiliate_id) {
if ($affiliate_id !== affiliates_get_direct_id ()) {
if ($user_id = affiliates_get_affiliate_user ( $affiliate_id )) {
View groups_gform_activate_user
add_action( 'gform_activate_user', 'my_gform_activate_user', 10, 3 );
function my_gform_activate_user ( $user_id, $user_data, $signup_meta ) {
$lead = RGFormsModel::get_lead( $signup_meta['lead_id'] );
if ( isset( $lead['form_id'] ) && ( $form = RGFormsModel::get_form_meta( $lead['form_id'] ) ) ) {
$on_registration = isset( $form['groups']['on_registration']['enabled'] ) ? $form['groups']['on_registration']['enabled'] : false;
$on_submission_field = isset( $form['groups']['on_submission']['field'] ) ? $form['groups']['on_submission']['field'] : null;
if ( $on_registration ) {
View my_affiliates_permanent
function my_affiliates_permanent( $atts ){
$output = "";
if ( is_user_logged_in() ) {
$user = wp_get_current_user();
$affiliate_id = get_user_meta( $user->ID, Affiliates_Permanent::REFERRER, true );
$aff_user = affiliates_get_affiliate_user( $affiliate_id );
if ( $aff_user ) {
$user_info = get_userdata( $aff_user );
View affiliates_permanent_my_users
function my_affiliates_permanent_my_users( $atts ){
$output = "";
if ( is_user_logged_in() ) {
$user = wp_get_current_user();
if ( null !== ( affiliates_get_user_affiliate( $user->ID ) ) ) {
$affiliate_id = affiliates_get_user_affiliate( $user->ID );
$args = array(
'meta_key' => Affiliates_Permanent::REFERRER,
'meta_value' => $affiliate_id
View Affiliates_Custom_Method_only_coupon.php
<?php
/**
* Plugin Name: Affiliates Custom Method - Only Coupons
* Description: Custom method: Only if a coupon, then commissions are assigned
* Version: 1.0
* Author: eggemplo
* Author URI: http://www.eggemplo.com
*/
class ACM {
View filter_woocommerce_json_search_found_customers.php
add_filter( 'woocommerce_json_search_found_customers', 'my_woocommerce_json_search_found_customers', 10 , 1 );
function my_woocommerce_json_search_found_customers ( $found_customers ) {
foreach ( $found_customers as $key=>$customer ) {
// use id to check if user is VIP
$is_a_member = false;
require_once( ABSPATH . 'wp-includes/pluggable.php' );
if ( $group1 = Groups_Group::read_by_name( 'VIP1' ) || $group2 = Groups_Group::read_by_name( 'VIP2' ) ) {
$is_a_member = ( Groups_User_Group::read( $customer->ID , $group1->group_id ) || Groups_User_Group::read( $customer->ID , $group2->group_id ) );
}
View facilitator.php
add_action ( 'woocommerce_checkout_order_processed', 'add_facilitator_commission' );
/**
* Record a product referral when a new order has been saved.
* @param int $order_id
*/
function add_facilitator_commission( $order_id ) {
$product_options = array();
// You need to replicate this code for each product. In this case, 10 is the product ID
You can’t perform that action at this time.