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 and Rewards / Loyalty Program: let customers pay at most 30% of an order with points. | |
| * | |
| * The 30% is taken from the products in the cart after other coupons, including tax, | |
| * without shipping. It lowers the "Maximum points" setting for each cart, so checkout | |
| * shows the right maximum and never deducts more points than the discount it gives. | |
| * Keep the built-in "Maximum points" setting high so it doesn't cut in first. | |
| */ |
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 | |
| /** | |
| * WPGens Points and Rewards: calculate earned points from the total of eligible products. | |
| * | |
| * - Only products that earn points count. Products with "Disable Points" (or excluded | |
| * by other plugin settings, such as "Exclude Sale Products") are left out. | |
| * - The eligible amount includes VAT and discounts, and excludes shipping. | |
| * - The earning rate from the plugin settings (for example 1 point per 20) is applied | |
| * to the whole eligible amount and rounded up once, not per product unit. | |
| * - The cart/checkout message and the product page message use the same calculation. |
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 | |
| /** | |
| * WPGens Points and Rewards: calculate earned points from the order total. | |
| * | |
| * Awards 1 point for every 20 (store currency) of the order total, rounded up. | |
| * The amount includes VAT and discounts and excludes shipping. | |
| * | |
| * Add to your theme's functions.php or a code snippets plugin. | |
| * If you change the earning rate in the plugin settings, update the 20 below as well. | |
| * |
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 | |
| /** | |
| * Apply a WooCommerce coupon from a URL parameter. | |
| * | |
| * Usage: link to any page with ?coupon=CODE, for example in a Klaviyo email: | |
| * https://yourstore.com/product-category/shoes/?coupon={{ person.dck_woo_coupon }} | |
| * | |
| * The coupon is saved to the customer's session and applied automatically | |
| * as soon as the cart contains a product the coupon is valid for. | |
| * |
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 Premium (WPGens) - don't reward referrals when the order contains a gift voucher. | |
| * | |
| * If a referred customer's order contains any of the listed products, the advocate | |
| * (and the friend) won't get a referral coupon and the referral won't be counted. | |
| * The reason is shown in the referral info box on the order screen. | |
| * | |
| * Add to your child theme's functions.php or via the Code Snippets plugin. | |
| */ |
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 | |
| /** | |
| * Example: Per-rank yearly cap on referral email invitations | |
| * | |
| * Each VIP rank is allowed to send a different number of referral email | |
| * invitations per calendar year. Once a customer reaches their rank's limit, | |
| * the "invite friends by email" action is rejected with a friendly message | |
| * until January 1, when the counter resets automatically. | |
| * | |
| * Example caps used below: Bronze 3, Silver 5, Gold 10, Platinum 15. |
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 | |
| /** | |
| * WPGens Loyalty: hardcoded TranslatePress fallback (ID-based). | |
| */ | |
| // ID-based action translations — id matches the row in the loyalty admin | |
| // (Earning Actions list). Update as needed. | |
| function wpgl_tp_id_map() { | |
| 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
| # AI Knowledge Assistant – Product + Documents RAG Platform | |
| ## Purpose | |
| Build a multi-tenant AI knowledge assistant that can: | |
| - answer questions using organization-specific content | |
| - use both structured product content and uploaded PDFs | |
| - ingest website content from WordPress via REST API | |
| - keep content fresh via sync jobs and webhooks |
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 | |
| /** | |
| * Recalculate points for orders between Jan-Dec 2025 after BGN→EUR currency change. | |
| * Run once via snippets plugin, then disable/delete. | |
| * | |
| * IMPORTANT: First adjust order totals from BGN to EUR, then run this snippet. | |
| */ | |
| add_action('init', function () { | |
| // Safety: only run for admins | |
| if (!current_user_can('manage_options')) 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 | |
| /** | |
| * Auto-apply loyalty coupons on WooCommerce Subscription renewals | |
| * | |
| * When a subscription renewal order is created, this snippet checks if the user | |
| * has any unused loyalty coupons (matching the configured coupon prefix) and | |
| * applies them as a discount fee on the renewal order. | |
| * | |
| * Works with both WooCommerce Subscriptions (official) and ThemeHigh Subscriptions. |
NewerOlder