Clean text

add_action(‘admin_footer’, function () { global $post; if (get_post_type($post) !== ‘shop_order’) { return; } $order = wc_get_order($post->ID); if (!$order) { return; } if ($order->get_payment_method() !== ‘linkmoney’) { return; } ?>Continue reading

Disable coupon code applied message

add_filter( ‘woocommerce_coupon_message’, ‘hide_coupon_success_message’, 10, 3 ); function hide_coupon_success_message( $msg, $msg_code, $coupon ) { if ( $msg_code === 200 ) { // 200 is the code for a successful coupon application return ”; // Return an empty string to hide the…Continue reading

Action Scheduler Tuning

add_filter( ‘action_scheduler_retention_period’, function ( $period ) { return 7 * DAY_IN_SECONDS; } ); add_filter( ‘action_scheduler_default_cleaner_statuses’, function ( $statuses ) { $statuses[] = ‘failed’; return $statuses; } ); add_filter( ‘action_scheduler_cleanup_batch_size’, function ( $batch_size ) { return 50; } ); function eg_increase_time_limit(…Continue reading

Get coupons automatically

// Cron event add_action(‘init’, function () { if (!wp_next_scheduled(‘tune_hourly_coupon_import’)) { wp_schedule_event(time(), ‘hourly’, ‘tune_hourly_coupon_import’); } // Optional: manual trigger for testing if (isset($_GET[‘import_tune_coupons’]) && $_GET[‘import_tune_coupons’] === ‘1’) { tune_import_coupons_from_tune(); } }); add_action(‘tune_hourly_coupon_import’, ‘tune_import_coupons_from_tune’); function tune_import_coupons_from_tune() { if (!function_exists(‘wc_get_coupon_id_by_code’)) return; $network_token =…Continue reading

Block Employees From Using Coupons

add_filter(‘woocommerce_coupon_is_valid’, ‘block_employee_coupon_usage’, 10, 3); function block_employee_coupon_usage($valid, $coupon, $discount) { if (is_user_logged_in()) { $user = wp_get_current_user(); if (in_array(’employee’, (array) $user->roles) || in_array(‘owner’, (array) $user->roles)) { wc_add_notice(__(‘Employees are not allowed to use coupons.’, ‘woocommerce’), ‘error’); return false; } } return $valid; }Continue reading

Sync manually created coupons

add_action(‘save_post_shop_coupon’, function($post_id, $post, $update) { if (wp_is_post_revision($post_id) || wp_is_post_autosave($post_id)) { return; } if ($post->post_type !== ‘shop_coupon’) { return; } if ($post->post_status !== ‘publish’ && $post->post_status !== ‘draft’ && $post->post_status !== ‘pending’) { return; } if (get_post_meta($post_id, ‘_tune_imported’, true)) { return;…Continue reading

Meta Checkout URL

/** * Handle Meta (Facebook/Instagram Shops) checkout URLs * Format: /checkout?products=wc_post_id_123:2,wc_post_id_456:1&coupon=CODE */ add_action( ‘template_redirect’, function() { if ( ! isset( $_GET[‘products’] ) ) { return; } // Ensure WooCommerce is loaded and cart is available if ( ! function_exists( ‘WC’…Continue reading

Automatically Apply Coupons from Campaigns

/** * WooCommerce: cookie-driven auto-coupon using the coupon’s own restrictions * – URL: ?bllpromo=COUPONCODE -> sets cookie bllpromo=COUPONCODE for 30 days * – If cookie exists and coupon is valid for the current cart (per ALL restrictions), * the coupon…Continue reading