Skip to content

Instantly share code, notes, and snippets.

@goranefbl
goranefbl / points-earn.php
Last active September 11, 2025 11:13
Newsletter override
<?php
/**
* Earn Points Template - Custom Override with Newsletter Signup
*/
if (!defined('ABSPATH')) {
exit;
}
@goranefbl
goranefbl / functions.php
Created September 11, 2025 11:07
points and rewards - limit to roles
add_filter('wpgens_loyalty_update_points', 'filter_points_by_user_role', 5, 6);
function filter_points_by_user_role($user_id, $points_delta, $type, $source, $reference_id = null, $description = null) {
// Define roles that should be excluded from points system
$excluded_roles = ['wholesale_customer', 'restricted_user', 'employee'];
// Get user object
$user = get_userdata($user_id);
if (!$user) {
return false; // User not found
<?php
/**
* Klaviyo Integration
*/
class WPGL_Klaviyo
{
private static $instance = null;
const INTEGRATION_KEY = 'klaviyo';
@goranefbl
goranefbl / class-wpgens-raf-checkout.php
Created August 21, 2025 22:59
class-wpgens-raf-checkout.php
<?php
/**
* Hook into checkout
*
* @since 2.0.0
*/
if (!defined('ABSPATH')) {
exit;
@goranefbl
goranefbl / functions.php
Created July 30, 2025 20:28
prevent coupons when points applied.
<?php
// Add this to your main plugin file or in a hooks class
add_filter('woocommerce_coupon_is_valid', 'prevent_coupons_when_points_applied', 10, 3);
function prevent_coupons_when_points_applied($is_valid, $coupon, $discount_object) {
// Skip validation for loyalty points coupons themselves
if (strpos($coupon->get_code(), 'loyalty_points_') === 0) {
return $is_valid;
}
<?php
/**
* Handles points redemption during checkout process
*/
class WPGL_Points_Checkout
{
private static $instance = null;
const COUPON_PREFIX = 'loyalty_points_';
const EXPIRATION_TIME = 3600; // 1 hour in seconds
<?php
class WPGL_Points_API
{
private static $instance = null;
public static function init()
{
if (self::$instance === null) {
self::$instance = new self();
@goranefbl
goranefbl / class-points-checkout.php
Last active June 4, 2025 13:36
class-points-checkout.php
<?php
/**
* Handles points redemption during checkout process
*/
class WPGL_Points_Checkout
{
private static $instance = null;
const COUPON_PREFIX = 'loyalty_points_';
const EXPIRATION_TIME = 3600; // 1 hour in seconds
@goranefbl
goranefbl / functions.php
Created May 29, 2025 17:04
WPGens Referral Mailchimp Connection
<?php
add_action('wpgens_raf_new_user_referral_id', 'send_referral_to_mailchimp', 10, 2);
function send_referral_to_mailchimp($referral_id, $user_id) {
$user = get_userdata($user_id);
if (!$user) {
return;
}
@goranefbl
goranefbl / script.js
Created May 28, 2025 11:40
copy link
<script>
document.addEventListener('DOMContentLoaded', function () {
document.querySelectorAll('.wpgens-raf-simple-shortcode').forEach(function (el) {
el.addEventListener('click', function (e) {
e.preventDefault();
const textToCopy = el.href;
navigator.clipboard.writeText(textToCopy).then(() => {
const originalText = el.textContent;