add_action(‘save_post_product’, function($post_id, $post) { if (defined(‘DOING_AUTOSAVE’) && DOING_AUTOSAVE) return; if ($post->post_status !== ‘publish’) return; $uncategorized_id = get_option(‘default_product_cat’); $categories = wp_get_post_terms($post_id, ‘product_cat’, [‘fields’ => ‘ids’]); // If only uncategorized is selected or none at all if (empty($categories) || (count($categories) === 1…Continue reading
add_action(‘admin_menu’, function () { add_submenu_page( ‘tools.php’, ‘Fix BACS Subscription’, ‘Fix BACS Sub’, ‘manage_options’, ‘fix-bacs-subscription’, function () { if (isset($_POST[‘fix_bacs_sub_id’]) && is_numeric($_POST[‘fix_bacs_sub_id’])) { $sub_id = (int) $_POST[‘fix_bacs_sub_id’]; // Update meta fields update_post_meta($sub_id, ‘_payment_method’, ‘bacs’); update_post_meta($sub_id, ‘_payment_method_title’, ‘Direct Bank Transfer’); update_post_meta($sub_id, ‘_requires_manual_renewal’,…Continue reading
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