Skip to content

Instantly share code, notes, and snippets.

@goranefbl
goranefbl / functions.php
Created January 19, 2022 17:33
Create referral code on user thank you page
<?php
add_action( 'woocommerce_thankyou', 'gens_save_check', 10, 1 );
function gens_save_check() {
WPGens_RAF_User::new_user_add_referral_id(get_current_user_id());
}
@goranefbl
goranefbl / share.php
Created December 27, 2021 14:22
For pierre
<?php
/**
* Refer a Friend Product Share HTML
*
* Available variables: $rafLink (Referral link), $title (twitter title option), $twitter_via(twitter via option)
*
* @see http://wpgens.helpscoutdocs.com/article/34-how-to-edit-template-files-and-keep-them-after-plugin-update
* @version 2.3.11
*/
<?php
// Hide refer a friend tab for users without any orders:
add_action('wp','wpgens_custom_account_tabs');
function wpgens_custom_account_tabs(){
if ( !is_account_page() ) { // User is NOT on my account pages
return false;
}
$customer_orders = get_posts( array(
<?php
add_filter('wpgens_raf_code','gens_raf_link',10,1);
function gens_raf_link($raf_id) {
$current_user = wp_get_current_user();
return $current_user->user_email;
}
<?php
add_action('woocommerce_account_dashboard','show_referral');
function show_referral(){
echo do_shortcode('[WOO_GENS_RAF_FULL]');
}
<?php
/**
* RAF & Points & Rewards Plugin Integration
*
* @since 2.1.2
*/
// Add the action setting
<?php
/**
* RAF & Woocommerce Subscription
*
* @since 2.0.0
*/
$gens_subs = get_option("gens_raf_subscription");
if(isset($gens_subs) && $gens_subs === "yes") {
add_filter('wcs_new_order_created','gens_renewal_order_created', 10, 2 );
import { useState, useEffect } from 'react';
import { parseCookies } from 'nookies';
import axios from 'axios';
import qs from 'qs';
import { apiURL } from '../utils/constants';
const useAxios = ({ url, method, body = null, ssrToken, ssrIp }) => {
const [response, setResponse] = useState(null);
const [error, setError] = useState('');
const [loading, setloading] = useState(true);
@goranefbl
goranefbl / functions.php
Created September 16, 2021 11:37
custom body class
add_filter('body_class', 'custom_body_class');
function custom_body_class($classes) {
global $wp;
$vars = $wp->query_vars;
if(array_key_exists('myreferrals', $vars)) {
$classes[] = 'new-class';
}
return $classes;
}
@goranefbl
goranefbl / functions.php
Last active August 24, 2021 12:53
remove guest coupon when added with specific products
<?php
add_action( 'woocommerce_checkout_update_order_review', 'checkout_form_check_custom', 99, 1);
add_action( 'woocommerce_applied_coupon', 'checkout_form_check_custom', 99, 1 );
function checkout_form_check_custom($post_data){
// var_dump(count(WC()->cart->get_cart()));
$guest_coupon_code = get_option( 'gens_raf_guest_coupon_code' );
$coupons = WC()->cart->applied_coupons;
$old_cupon = '';
foreach ($coupons as $coupon) {