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 | |
/** | |
* Multisite Points Synchronization for WPGens Loyalty Program | |
* Keeps points synchronized across all sites in a multisite network | |
*/ | |
class WPGL_Multisite_Points_Sync { | |
private static $syncing = false; // Prevent infinite loops | |
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('wpgens_loyalty_cart_points_before_discount', function($total_points, $cart) { | |
// Calculate the desired points based on actual paid amount | |
$cart_total = $cart->get_total('edit'); | |
$cart_total_without_shipping = $cart_total - $cart->get_shipping_total() - $cart->get_shipping_tax(); | |
// Award 2 points for every euro spent (excluding shipping) | |
$points_per_currency = 2; | |
$desired_points = floor($cart_total_without_shipping * $points_per_currency); |
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 | |
/** | |
* Loyalty (WPGens) – gate features by ROLE instead of user meta. | |
* Default allowed roles: customer, subscriber. | |
* Change with: add_filter('wpgens_loyalty_allowed_roles', fn() => ['customer','vip']); | |
*/ | |
/** Helper: does user have any of the allowed roles? */ | |
function wpgl_user_has_allowed_role( $user_id ): bool { | |
if ( ! $user_id ) return false; |
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 | |
// Only allow users with specific meta field | |
add_filter('wpgens_loyalty_should_allow_points_for_user', function ($should_allow, $user_id, $source, $type, $points_delta) { | |
$is_gdpr_points_consent = get_user_meta($user_id, 'gdpr_points_consent', true); | |
return $is_gdpr_points_consent === 'yes'; | |
}, 10, 5); | |
add_filter('wpgl_show_points_earning_box', function ($should_show) { | |
if (is_user_logged_in()) { |
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 | |
/** | |
* Points Page Template | |
*/ | |
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 | |
/** | |
* Earn Points Template - Custom Override with Newsletter Signup | |
*/ | |
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
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 |
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 | |
/** | |
* Klaviyo Integration | |
*/ | |
class WPGL_Klaviyo | |
{ | |
private static $instance = null; | |
const INTEGRATION_KEY = 'klaviyo'; |
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 | |
// 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; | |
} |
NewerOlder