/** Adds script to header ** Scroll to top of page – only on Pager facet interaction ** For more info see: ** https://facetwp.com/help-center/facets/facet-types/pager/#how-to-add-pagination-scrolling **/ add_action( ‘wp_head’, function() { ?>Continue reading
add_action( ‘woocommerce_before_add_to_cart_quantity’, ‘bbloomer_echo_qty_front_add_cart’ ); function bbloomer_echo_qty_front_add_cart() { global $product; if ( $product->get_min_purchase_quantity() == $product->get_max_purchase_quantity() ) return; echo ‘ Quantity: ‘; }Continue reading
// Function to concatenate author names (brands) and save them in a meta field function save_concatenated_authors_meta($post_id) { // Check if this is a product post type if (get_post_type($post_id) !== ‘product’) { return; } // Retrieve the list of authors (brands)…Continue reading
function update_concatenated_authors_for_all_products() { // Get all products $args = array( ‘post_type’ => ‘product’, ‘posts_per_page’ => -1, // Get all products ‘post_status’ => ‘publish’, ); $products = get_posts($args); foreach ($products as $product) { // Reuse the function to update the concatenated…Continue reading
add_action(‘woocommerce_cart_calculate_fees’, ‘apply_subscriber_discount’, 10, 1); function apply_subscriber_discount($cart) { if (is_admin() && !defined(‘DOING_AJAX’)) return; // Ensure it only runs on the front-end $user = wp_get_current_user(); // Apply 10% discount only if the user has the role ‘subscriber’ if (in_array(‘subscriber’, (array) $user->roles)) {…Continue reading
add_action(‘woocommerce_admin_order_data_after_order_details’, ‘add_custom_shipping_method_backend’); function add_custom_shipping_method_backend($order_id) { // Manually get the order object $order = wc_get_order($order_id); if (!$order || !is_a($order, ‘WC_Order’)) { echo ‘ Error: Order is invalid. Please reload the page or check your setup. ‘; return; } ?> Royal Mail…Continue reading
/* function process_bacs_subscription_payments() { $today = date(‘Y-m-d’); $max_runs = 25; // ✅ Set a limit to prevent infinite loops $run_count = 0; while ($run_count < $max_runs) { // Get the next subscription that is due today $args = array( 'post_type'…Continue reading
function add_store_credit_on_subscription_renewal($order_id) { $logger = wc_get_logger(); $order = wc_get_order($order_id); if (!$order) { $logger->error(“⚠️ Store Credit Error: Order {$order_id} not found on first attempt.”, array( ‘source’ => ‘store-credit-renewal’ )); sleep(2); // Wait 2 seconds and try again $order = wc_get_order($order_id); if…Continue reading
add_action(‘woocommerce_cart_calculate_fees’, ‘apply_branch_discount_by_category’, 20, 1); function apply_branch_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 “branch” role if (!in_array(‘branch’, (array) $user->roles)) { return; }…Continue reading