add_filter(‘user_has_cap’, function($allcaps, $cap, $args, $user) { if (!in_array(‘shop_manager’, $user->roles)) { return $allcaps; } $target_user_id = $args[0] ?? null; if (!$target_user_id) { return $allcaps; } $target_user = get_userdata($target_user_id); if (!$target_user) { return $allcaps; } // Only allow actions on specific roles…Continue reading
add_filter(‘editable_roles’, function($roles) { if (current_user_can(‘shop_manager’)) { if (!isset($roles[‘trade’]) && isset($GLOBALS[‘wp_roles’]->roles[‘trade’])) { $roles[‘trade’] = $GLOBALS[‘wp_roles’]->roles[‘trade’]; } if (!isset($roles[‘branch’]) && isset($GLOBALS[‘wp_roles’]->roles[‘branch’])) { $roles[‘branch’] = $GLOBALS[‘wp_roles’]->roles[‘branch’]; } if (!isset($roles[‘sister’]) && isset($GLOBALS[‘wp_roles’]->roles[‘sister’])) { $roles[‘sister’] = $GLOBALS[‘wp_roles’]->roles[‘sister’]; } if (!isset($roles[‘fulltimer’]) && isset($GLOBALS[‘wp_roles’]->roles[‘fulltimer’])) { $roles[‘fulltimer’] =…Continue reading
add_action(‘admin_menu’, function() { add_submenu_page( ‘woocommerce’, ‘Store Credit Report’, ‘Store Credit Report’, ‘manage_options’, ‘store-credit-report’, ‘render_store_credit_report_page’ ); }); function render_store_credit_report_page() { global $wpdb; $year = isset($_GET[‘year’]) ? intval($_GET[‘year’]) : date(‘Y’); $month = isset($_GET[‘month’]) ? intval($_GET[‘month’]) : date(‘n’); $export = isset($_GET[‘export’]) ? true…Continue reading
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
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 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
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
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
// 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
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