<?php
/**
 * Watson WooCommerce template functions
 *
 * @package Watson
 * @version 1.0.0
 */

defined( 'ABSPATH' ) || exit;

/**
 * Wrap result count and ordering in a container
 */
function watson_wrap_result_count_and_ordering() {
    // Remove default hooks
    remove_action('woocommerce_before_shop_loop', 'woocommerce_result_count', 20);
    remove_action('woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30);
    
    // Add our custom wrapper
    add_action('woocommerce_before_shop_loop', 'watson_result_count_ordering_wrapper_start', 19);
    add_action('woocommerce_before_shop_loop', 'woocommerce_result_count', 20);
    add_action('woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30);
    add_action('woocommerce_before_shop_loop', 'watson_result_count_ordering_wrapper_end', 31);
}

/**
 * Output the start of the result count and ordering wrapper
 */
function watson_result_count_ordering_wrapper_start() {
    echo '<div class="watson-shop-filters-wrapper">';
}

/**
 * Output the end of the result count and ordering wrapper
 */
function watson_result_count_ordering_wrapper_end() {
    echo '</div>';
}

// Initialize the wrapper
watson_wrap_result_count_and_ordering();
