This file contains 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 | |
/** | |
* Refer a Friend integration with points | |
*/ | |
class WPGL_Refer_A_Friend | |
{ | |
private static $instance = null; | |
public static function init() |
This file contains 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
**Custom Point Actions & Integrations** | |
You can add custom point actions by using the `wpgens_loyalty_update_points` action. Here are some examples: | |
```php | |
// Award points for a custom action | |
function award_custom_points($user_id, $points, $description) { | |
do_action( | |
'wpgens_loyalty_update_points', |
This file contains 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 meta box to order page | |
add_action('add_meta_boxes', 'add_points_refund_box'); | |
function add_points_refund_box() { | |
if (class_exists('Automattic\WooCommerce\Internal\DataStores\Orders\CustomOrdersTableController')) { | |
$controller = wc_get_container()->get('Automattic\WooCommerce\Internal\DataStores\Orders\CustomOrdersTableController'); | |
$screen = $controller->custom_orders_table_usage_is_enabled() | |
? wc_get_page_screen_id('shop-order') | |
: 'shop_order'; |
This file contains 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_action( 'woocommerce_add_to_cart', 'wpgens_auto_apply_coupons_on_add_to_cart', 10, 6 ); | |
function wpgens_auto_apply_coupons_on_add_to_cart( $cart_item_key, $product_id, $quantity, $variation_id, $variation, $cart_item_data ) { | |
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) | |
return; | |
if ( ! is_user_logged_in() ) | |
return; |
This file contains 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 points | |
do_action( | |
'wpgens_loyalty_update_points', | |
$user_id, // User ID | |
$points_amount, // Points to add (positive) or remove (negative) | |
WPGL_Points_Activity_Type::EARN, // Activity type (EARN or DEDUCT) | |
WPGL_Points_Source_Type::PLACE_ORDER, // Source type (see below) | |
$reference_id = null, // Optional reference ID (e.g., order ID) |
This file contains 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 | |
/** | |
* Email Body | |
* | |
* @see https://wpgens.com/docs/how-to-edit-template-files-and-keep-them-after-plugin-update/ | |
* @version 2.0.0 | |
*/ | |
if ( ! defined( 'ABSPATH' ) ) { | |
exit; // Exit if accessed directly |
This file contains 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_raf_code', 'gens_raf_code', 10, 1); | |
function gens_raf_code($raf_code) { | |
$current_user = wp_get_current_user(); | |
if (!user_has_friends($current_user->ID)) { | |
return 'Referral code is available only to users with friends'; | |
} | |
return $raf_code; |
This file contains 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_raf_code', 'gens_raf_code', 10, 1); | |
function gens_raf_code($raf_code) { | |
$current_user = wp_get_current_user(); | |
$total_spent = get_user_total_spent($current_user->ID); | |
if ($total_spent < 300) { | |
return 'Referral code is available only to users who have spent at least 300'; | |
} |
This file contains 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_action('gens_after_generate_user_coupon', 'add_product_ids_to_raf_coupon', 10, 4); | |
function add_product_ids_to_raf_coupon($user_id, $type, $order, $coupon_id) { | |
// Logic to determine which variation IDs to add | |
$variation_ids = array(123, 456, 789); // Replace with your actual variation IDs | |
// Get existing product IDs | |
$existing_ids = get_post_meta($coupon_id, 'product_ids', true); |
NewerOlder