Marxism report

add_action(‘admin_menu’, function() { add_submenu_page( ‘woocommerce’, ‘Store Credit (Manual Orders)’, ‘Marxism Report’, ‘manage_woocommerce’, ‘store-credit-manual-orders’, ‘render_store_credit_manual_orders_page’ ); }); function render_store_credit_manual_orders_page() { global $wpdb; $date_start = isset($_GET[‘start’]) ? sanitize_text_field($_GET[‘start’]) : ”; $date_end = isset($_GET[‘end’]) ? sanitize_text_field($_GET[‘end’]) : ”; $date_clause = ”; if ($date_start…Continue reading

Report Bacs active subscriptions

add_action(‘admin_menu’, function() { add_submenu_page( ‘woocommerce’, ‘BACS Subscribers’, ‘BACS Subscribers’, ‘manage_woocommerce’, ‘bacs-subscribers-report’, ‘render_bacs_subscribers_report’ ); }); function render_bacs_subscribers_report() { global $wpdb; $sql = ” SELECT s.ID AS subscription_id, u.ID AS user_id, u.user_email, um1.meta_value AS first_name, um2.meta_value AS last_name, pm_next.meta_value AS next_payment FROM…Continue reading

Add set expired subscription to active

// ✅ Add admin submenu under “Subscriptions” add_action( ‘admin_menu’, function() { add_submenu_page( ‘woocommerce’, ‘Manual Reactivation’, ‘Manual Reactivation’, ‘manage_woocommerce’, ‘manual-reactivation’, ‘render_manual_reactivation_page’ ); }); // ✅ Render page content function render_manual_reactivation_page() { ?> Manual Reactivation of Subscription Subscription ID: Next Payment Date:Continue reading

Change active bacs subscription amount

add_action(‘init’, function() { if ( ! current_user_can(‘manage_woocommerce’) ) return; $subscription_id = 56904; // change this to the actual subscription ID $new_price = 3; // the new recurring amount $subscription = wcs_get_subscription($subscription_id); if ( ! $subscription ) { error_log(“❌ Subscription $subscription_id…Continue reading

Automatically Add Store Credit on Card Subscription Renewal

function add_store_credit_on_subscription_renewal_card($order_id) { $logger = wc_get_logger(); $log_context = array(‘source’ => ‘store-credit-renewal-card’); $order = wc_get_order($order_id); if (!$order) { $logger->error(“Store Credit Error: Order {$order_id} not found.”, $log_context); return; } // Skip BACS orders (handled by the other snippet) if ($order->get_payment_method() === ‘bacs’)…Continue reading

Bacs Matcher Page

// Add admin submenu under WooCommerce add_action(‘admin_menu’, function () { add_submenu_page( ‘woocommerce’, ‘BACS Matcher’, ‘BACS Matcher’, ‘manage_woocommerce’, ‘bacs-matcher’, ‘render_bacs_matcher_page_v2’ ); }); if (!function_exists(‘render_bacs_matcher_page_v2’)) { function render_bacs_matcher_page_v2() { echo ‘ BACS Account Matcher ‘; // Handle saving matches if (isset($_POST[‘save_matches’]) &&…Continue reading

BACS reconciliation admin

add_action(‘admin_menu’, function () { add_submenu_page( ‘woocommerce’, ‘BACS Reconciliation’, ‘BACS Reconciliation’, ‘manage_woocommerce’, ‘bacs-reconciliation’, ‘render_bacs_reconciliation_page’ ); }); function render_bacs_reconciliation_page() { echo ‘ BACS Reconciliation ‘; echo ‘ ‘; echo ‘ ‘; echo ‘ Start date ‘; echo ‘ End date ‘; echo…Continue reading

Notify if stock arrives that is backordered 2.0

add_action(‘woocommerce_product_set_stock’, function($product) { if (!is_a($product, ‘WC_Product’)) return; $logger = wc_get_logger(); // — detect context — if (defined(‘REST_REQUEST’) && REST_REQUEST) { $context = ‘REST API (likely Slynk)’; } elseif (wp_doing_ajax()) { $context = ‘AJAX’; } elseif (wp_doing_cron()) { $context = ‘Cron…Continue reading

Discounts for Full timer users FE

add_action(‘woocommerce_cart_calculate_fees’, ‘apply_fulltimer_discount_by_category’, 20, 1); function apply_fulltimer_discount_by_category($cart) { if (is_admin() && !defined(‘DOING_AJAX’)) return; // Ensure it only runs on the front-end $user = wp_get_current_user(); // Only apply discount for users with the “fulltimer” role if (!in_array(‘fulltimer’, (array) $user->roles)) { return; }…Continue reading

Mark card renewal orders as complete

add_action(‘woocommerce_subscription_renewal_payment_complete’, function($object) { $logger = wc_get_logger(); $log_context = array(‘source’ => ‘auto-complete-renewal’); // Handle subscription objects vs order IDs $order = null; if (is_a($object, ‘WC_Subscription’)) { $logger->info(“Received subscription {$object->get_id()}, fetching last renewal order”, $log_context); $order = $object->get_last_order( ‘renewal’ ); if (!$order)…Continue reading