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 | |
/** | |
* Handles all WordPress and WooCommerce hook integrations for the points system | |
*/ | |
class WPGL_Points_Hooks | |
{ | |
private static $instance = null; | |
/** |
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 | |
/** | |
* Refer a Friend Product Share Link HTML | |
* | |
* Available variables: $rafLink (Referral link), $share_text(share text option) | |
* | |
* @see https://wpgens.com/docs/how-to-edit-template-files-and-keep-them-after-plugin-update/ | |
* @version 3.2.0 | |
*/ |
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 | |
/** | |
* Refer a Friend integration with points | |
*/ | |
class WPGL_Refer_A_Friend | |
{ | |
private static $instance = null; | |
public static function init() |
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
**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 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 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 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_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 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 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 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 | |
/** | |
* 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 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_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; |
NewerOlder