Product filter for WooCommerce In Custom

To create a custom product filter for your WooCommerce shop page entirely in code, you need a two-step implementation: an HTML/PHP interface form injected into the shop layout, and a custom query modifier that intercepts WooCommerce’s main product loop to apply the filtered parameters.

Here is the code which you as a developer easily integrate to your woo site.

<?php

// produc filter start
/** shop locator */
add_shortcode('te_product_filters', 'te_render_product_filters');
function te_render_product_filters()
{
    ob_start();
    ?>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/rangeslider.js/2.3.3/rangeslider.min.css">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/rangeslider.js/2.3.3/rangeslider.min.js"></script>

    <?php
global $wp;
$current_url = home_url(add_query_arg(array() , $wp->request));
?>

    <div>
        <form method="get" id="product-filter-form">
            <div class="te-filter">
                <input type="text" name="search_text"
                    value="<?php echo isset($_GET['search_text']) ? esc_attr(trim($_GET['search_text'])) : ''; ?>"
                    placeholder="Search products..." style="width:100%; padding:6px;">
            </div>
            <div class="te-product-filters">
                <?php
                te_filter_category();
                te_filter_brand();
                te_filter_attributes();
                te_filter_tags();
                te_filter_custom_taxonomies();
                te_filter_price();
                te_filter_rating();
                te_filter_stock();
                te_filter_sale();
                te_filter_featured();
                te_filter_discount();
                te_filter_date();
                te_filter_shipping_class();
                ?>

                <div class="te-filter-actions">
                    <button type="submit">Apply Filters</button>
                    <a href="<?php echo esc_url(get_permalink(wc_get_page_id('shop'))); ?>">
                        <button type="button">Reset All</button>
                    </a>
                </div>
            </div>
        </form>
    </div>

    <script>
        jQuery(function ($) {
            $('#product-filter-form').on('submit', function (e) {
                var searchInput = $('input[name="search_text"]');
                var val = searchInput.val().trim();

                if (val === '') {
                    searchInput.removeAttr('name');
                }
            });
        });
    </script>

    <style>
        #product-filter-form {
            height: 1800px;
            overflow-x: hidden;
            overflow-y: scroll;
        }

        .te-filter-actions {
            margin-top: 20px;
            display: flex;
            gap: 10px;
        }

        .te-filter-actions button {
            padding: 8px 16px;
            cursor: pointer;
        }

        .te-filter-actions button[type="submit"] {
            background: #007cba;
            color: white;
            border: none;
            border-radius: 3px;
        }

        .te-filter-actions button[type="button"] {
            background: #f0f0f0;
            border: 1px solid #ccc;
            border-radius: 3px;
        }

        .te-filter {
            margin-bottom: 9px;
            padding: 10px;
            border: 1px solid #eee;
        }

        .te-filter h4 {
            font-size: 17px;
            margin-top: 0;
            margin-bottom: 10px;
        }

        .te-filter label {
            display: block;
            margin: 5px 0;
            cursor: pointer;
        }
    </style>

    <?php
return ob_get_clean();
}

function te_filter_category()
{
    $terms = get_terms(['taxonomy' => 'product_cat', 'hide_empty' => false]);

    if (empty($terms)) return;

    $selected = isset($_GET['filter_cat']) ? (array)$_GET['filter_cat'] : [];
    echo '<div class="te-filter"><h4>Categories</h4>';

    foreach ($terms as $term)
    {
        $checked = in_array($term->slug, $selected) ? 'checked' : '';
        echo '<label>
        <input type="checkbox" name="filter_cat[]" value="' . esc_attr($term->slug) . '" ' . $checked . '>
            ' . esc_html($term->name) . '
        </label>';
    }

    echo '</div>';
}

function te_filter_attributes()
{
    $attributes = wc_get_attribute_taxonomies();

    if (empty($attributes)) return;

    foreach ($attributes as $attr)
    {
        $taxonomy = 'pa_' . $attr->attribute_name;

        $terms = get_terms(['taxonomy' => $taxonomy, 'hide_empty' => false]);

        if (empty($terms)) continue;

        $selected = isset($_GET['attr_' . $attr->attribute_name]) ? (array)$_GET['attr_' . $attr->attribute_name] : [];

        echo '<div class="te-filter">';
        echo '<h4>' . esc_html($attr->attribute_label) . '</h4>';

        foreach ($terms as $term)
        {
            $checked = in_array($term->slug, $selected) ? 'checked' : '';
            echo '<label>
                <input type="checkbox" name="attr_' . esc_attr($attr->attribute_name) . '[]" value="' . esc_attr($term->slug) . '" ' . $checked . '>
                ' . esc_html($term->name) . '
            </label>';
        }

        echo '</div>';
    }
}

function te_filter_tags()
{
    $terms = get_terms(['taxonomy' => 'product_tag', 'hide_empty' => false]);

    if (empty($terms)) return;

    $selected = isset($_GET['filter_tag']) ? (array)$_GET['filter_tag'] : [];

    echo '<div class="te-filter"><h4>Tags</h4>';

    foreach ($terms as $term)
    {
        $checked = in_array($term->slug, $selected) ? 'checked' : '';
        echo '<label>
            <input type="checkbox" name="filter_tag[]" value="' . esc_attr($term->slug) . '" ' . $checked . '>
            ' . esc_html($term->name) . '
        </label>';
    }

    echo '</div>';
}

function te_get_max_product_price()
{
    global $wpdb;

    // Get max price from simple products
    $max_simple = $wpdb->get_var("
        SELECT MAX(meta_value + 0)
        FROM {$wpdb->postmeta} pm
        INNER JOIN {$wpdb->posts} p ON p.ID = pm.post_id
        WHERE pm.meta_key = '_price'
        AND pm.meta_value IS NOT NULL
        AND pm.meta_value != ''
        AND p.post_status = 'publish'
        AND p.post_type = 'product'
    ");

    // Get max price from variable products (max of variation prices)
    $max_variable = $wpdb->get_var("
        SELECT MAX(meta_value + 0)
        FROM {$wpdb->postmeta} pm
        INNER JOIN {$wpdb->posts} p ON p.ID = pm.post_id
        WHERE pm.meta_key = '_max_variation_price'
        AND pm.meta_value IS NOT NULL
        AND pm.meta_value != ''
        AND p.post_status = 'publish'
        AND p.post_type = 'product'
    ");

    $max_price = max($max_simple, $max_variable);

    return $max_price ? ceil($max_price) : 1000;
}

function te_filter_price()
{
    $store_max_price = te_get_max_product_price();
    
    $current_min = isset($_GET['min_price']) && $_GET['min_price'] !== '' ? intval($_GET['min_price']) : 0;
    $current_max = isset($_GET['max_price']) && $_GET['max_price'] !== '' ? intval($_GET['max_price']) : $store_max_price;
    ?>
    <div class="te-filter price-filter-wrapper">
        <h4>Price Range</h4>
        
        <!-- Hidden inputs - THIS IS THE KEY FIX -->
        <input type="hidden" name="min_price" id="min_price" value="<?php echo $current_min; ?>">
        <input type="hidden" name="max_price" id="max_price" value="<?php echo $current_max; ?>">

        <div class="range-slider-container">
            <div class="range-slider">
                <div class="slider-track"></div>
                <div class="slider-range"></div>
                <div class="slider-handle handle-min" data-type="min"></div>
                <div class="slider-handle handle-max" data-type="max"></div>
            </div>
            
            <div class="price-display">
                <span id="price-range-text">
                    <?php echo get_woocommerce_currency_symbol(); ?> <?php echo $current_min; ?> —
                    <?php echo get_woocommerce_currency_symbol(); ?> <?php echo $current_max; ?>
                </span>
            </div>
        </div>
    </div>

    <style>
        /* Your existing styles + minor improvements */
        .price-filter-wrapper h4 { margin-bottom: 12px; }
        .range-slider { margin: 20px 20px 10px; position: relative; height: 20px; }
        .slider-track, .slider-range { position: absolute; top: 50%; height: 6px; transform: translateY(-50%); border-radius: 3px; }
        .slider-track { left: 0; width: 100%; background: #e0e0e0; }
        .slider-range { background: #007cba; }
        .slider-handle {
            position: absolute; top: 50%; width: 20px; height: 20px;
            background: #fff; border: 2px solid #007cba; border-radius: 50%;
            cursor: pointer; transform: translate(-50%, -50%); box-shadow: 0 1px 3px rgba(0,0,0,0.2);
        }
        .slider-handle:hover { transform: translate(-50%, -50%) scale(1.2); background: #007cba; }
        .price-display { text-align: center; font-weight: 600; color: #333; }
    </style>

    <script>
    jQuery(function ($) {
        var minPrice = <?php echo $current_min; ?>;
        var maxPrice = <?php echo $current_max; ?>;
        var maxLimit = <?php echo $store_max_price; ?>;

        var $minHandle = $('.handle-min');
        var $maxHandle = $('.handle-max');
        var $range = $('.slider-range');
        var $minInput = $('#min_price');
        var $maxInput = $('#max_price');

        function updateUI() {
            var minPercent = (minPrice / maxLimit) * 100;
            var maxPercent = (maxPrice / maxLimit) * 100;

            $minHandle.css('left', minPercent + '%');
            $maxHandle.css('left', maxPercent + '%');
            $range.css({ left: minPercent + '%', width: (maxPercent - minPercent) + '%' });

            $('#price-range-text').text(
                '<?php echo get_woocommerce_currency_symbol(); ?> ' + minPrice + 
                ' — <?php echo get_woocommerce_currency_symbol(); ?> ' + maxPrice
            );

            $minInput.val(minPrice);
            $maxInput.val(maxPrice);
        }

        function getValueFromPosition(clientX) {
            var rect = $('.range-slider')[0].getBoundingClientRect();
            var percent = (clientX - rect.left) / rect.width;
            percent = Math.max(0, Math.min(1, percent));
            return Math.round(percent * maxLimit);
        }

        // Drag handlers
        function handleDrag(e) {
            if (!window.activeHandle) return;
            e.preventDefault();
            var clientX = e.type === 'mousemove' ? e.clientX : e.originalEvent.touches[0].clientX;
            var newValue = getValueFromPosition(clientX);

            if (window.activeHandle === 'min') {
                minPrice = Math.min(newValue, maxPrice - 1);
                minPrice = Math.max(0, minPrice);
            } else {
                maxPrice = Math.max(newValue, minPrice + 1);
                maxPrice = Math.min(maxLimit, maxPrice);
            }
            updateUI();
        }

        function startDrag(e, handle) {
            e.preventDefault();
            window.activeHandle = handle;
            $(document).on('mousemove touchmove', handleDrag);
        }

        function stopDrag() {
            $(document).off('mousemove touchmove', handleDrag);
            window.activeHandle = null;
            // Do NOT auto-submit here
        }

        $minHandle.on('mousedown touchstart', function(e){ startDrag(e, 'min'); });
        $maxHandle.on('mousedown touchstart', function(e){ startDrag(e, 'max'); });

        $(document).on('mouseup touchend', stopDrag);

        // Optional: Live update on drag end (remove if you prefer only on "Apply Filters")
        $(document).on('mouseup touchend', function() {
            if (minPrice !== <?php echo $current_min; ?> || maxPrice !== <?php echo $current_max; ?>) {
                // You can keep live update or remove this block
            }
        });

        // Initial render
        updateUI();
    });
    </script>
    <?php
}

function te_filter_rating()
{
    $selected = isset($_GET['rating']) ? (array)$_GET['rating'] : [];
?>
    <div class="te-filter">
        <h4>Rating</h4>
        <label><input type="checkbox" name="rating[]" value="4" <?php echo in_array('4', $selected) ? 'checked' : ''; ?>> 4★
            & up</label>
        <label><input type="checkbox" name="rating[]" value="3" <?php echo in_array('3', $selected) ? 'checked' : ''; ?>> 3★
            & up</label>
        <label><input type="checkbox" name="rating[]" value="2" <?php echo in_array('2', $selected) ? 'checked' : ''; ?>> 2★
            & up</label>
    </div>
    <?php
}

function te_filter_stock()
{
    $selected = isset($_GET['stock']) ? (array)$_GET['stock'] : [];
?>
    <div class="te-filter">
        <h4>Stock Status</h4>
        <label><input type="checkbox" name="stock[]" value="instock" <?php echo in_array('instock', $selected) ? 'checked' : ''; ?>> In Stock</label>
        <label><input type="checkbox" name="stock[]" value="outofstock" <?php echo in_array('outofstock', $selected) ? 'checked' : ''; ?>> Out of Stock</label>
    </div>
    <?php
}

function te_filter_sale()
{
    $checked = isset($_GET['sale']) ? 'checked' : '';
?>
    <div class="te-filter">
        <h4>Sale</h4>
        <label><input type="checkbox" name="sale" value="1" <?php echo $checked; ?>> On Sale</label>
    </div>
    <?php
}

function te_filter_featured()
{
    $checked = isset($_GET['featured']) ? 'checked' : '';
?>
    <div class="te-filter">
        <h4>Featured</h4>
        <label>
            <input type="checkbox" name="featured" value="1" <?php echo $checked; ?>>
            Featured Products
        </label>
    </div>
    <?php
}

function te_filter_discount()
{
    $selected = isset($_GET['discount']) ? (array)$_GET['discount'] : [];
?>
    <div class="te-filter">
        <h4>Discount</h4>
        <label><input type="checkbox" name="discount[]" value="10" <?php echo in_array('10', $selected) ? 'checked' : ''; ?>> 10% Off</label>
        <label><input type="checkbox" name="discount[]" value="30" <?php echo in_array('30', $selected) ? 'checked' : ''; ?>> 30% Off</label>
        <label><input type="checkbox" name="discount[]" value="50" <?php echo in_array('50', $selected) ? 'checked' : ''; ?>> 50% Off</label>
    </div>
    <?php
}

function te_filter_date()
{
    $selected = isset($_GET['date']) ? (array)$_GET['date'] : [];
?>
    <div class="te-filter">
        <h4>New Products</h4>
        <label><input type="checkbox" name="date" value="7" <?php echo in_array('7', $selected) ? 'checked' : ''; ?>> Last 7
            Days</label>
        <label><input type="checkbox" name="date" value="30" <?php echo in_array('30', $selected) ? 'checked' : ''; ?>> Last
            30 Days</label>
    </div>
    <?php
}

function te_filter_shipping_class()
{
    $terms = get_terms(['taxonomy' => 'product_shipping_class', 'hide_empty' => false]);

    if (empty($terms)) return;

    $selected = isset($_GET['shipping']) ? (array)$_GET['shipping'] : [];

    echo '<div class="te-filter"><h4>Shipping</h4>';

    foreach ($terms as $term)
    {
        $checked = in_array($term->slug, $selected) ? 'checked' : '';
        echo '<label>
            <input type="checkbox" name="shipping[]" value="' . esc_attr($term->slug) . '" ' . $checked . '>
            ' . esc_html($term->name) . '
        </label>';
    }

    echo '</div>';
}

function te_filter_custom_taxonomies()
{
    $taxonomies = get_object_taxonomies('product', 'objects');
    if (empty($taxonomies)) return;

    foreach ($taxonomies as $taxonomy)
    {
        // skip default + attributes
        if (in_array($taxonomy->name, ['product_cat', 'product_tag', 'product_type', 'product_visibility', 'product_shipping_class', 'product_brand'])) continue;

        // skip attributes (pa_)
        if (strpos($taxonomy->name, 'pa_') === 0) continue;

        $terms = get_terms(['taxonomy' => $taxonomy->name, 'hide_empty' => false]);

        if (empty($terms)) continue;

        $selected = isset($_GET[$taxonomy->name]) ? (array)$_GET[$taxonomy->name] : [];

        echo '<div class="te-filter">';
        echo '<h4>' . esc_html($taxonomy->label) . '</h4>';

        foreach ($terms as $term)
        {
            $checked = in_array($term->slug, $selected) ? 'checked' : '';

            echo '<label>
                <input type="checkbox" name="' . esc_attr($taxonomy->name) . '[]" value="' . esc_attr($term->slug) . '" ' . $checked . '>
                ' . esc_html($term->name) . '
            </label>';
        }
        echo '</div>';
    }
}

// brand
function te_filter_brand()
{
    $terms = get_terms(['taxonomy' => 'product_brand', 'hide_empty' => false]);

    if (empty($terms)) return;

    $selected = isset($_GET['filter_brand']) ? (array)$_GET['filter_brand'] : [];

    echo '<div class="te-filter"><h4>Brands</h4>';

    foreach ($terms as $term)
    {
        $checked = in_array($term->slug, $selected) ? 'checked' : '';
        echo '<label>
            <input type="checkbox" name="filter_brand[]" value="' . esc_attr($term->slug) . '" ' . $checked . '>
            ' . esc_html($term->name) . '
        </label>';
    }

    echo '</div>';
}

add_action('pre_get_posts', 'te_apply_product_filters');
function te_apply_product_filters($query)
{
    if (is_admin() || !$query->is_main_query()) return;
    if (!is_shop() && !is_product_taxonomy()) return;

    if (isset($_GET['search_text']) && trim($_GET['search_text']) !== '')
    {
        $query->set('s', sanitize_text_field($_GET['search_text']));
    }

    $tax_query = ['relation' => 'AND'];
    $meta_query = ['relation' => 'AND'];

    /* ======================
       CATEGORY
    ====================== */
    if (!empty($_GET['filter_cat']))
    {
        $tax_query[] = ['taxonomy' => 'product_cat', 'field' => 'slug', 'terms' => (array)$_GET['filter_cat']];
    }

    /* ======================
       TAG
    ====================== */
    if (!empty($_GET['filter_tag']))
    {
        $tax_query[] = ['taxonomy' => 'product_tag', 'field' => 'slug', 'terms' => (array)$_GET['filter_tag']];
    }

    /**
     * custom taxonomy filter
     */
    foreach ($_GET as $key => $values)
    {
        if (taxonomy_exists($key) && !empty($values))
        {
            if (in_array($key, ['product_cat', 'product_tag', 'product_shipping_class', 'product_brand'])) continue;

            // skip attributes
            if (strpos($key, 'attr_') === 0) continue;

            $tax_query[] = ['taxonomy' => $key, 'field' => 'slug', 'terms' => (array)$values];
        }
    }

    /* ======================
       BRAND
    ====================== */
    if (!empty($_GET['filter_brand']))
    {
        $tax_query[] = ['taxonomy' => 'product_brand', 'field' => 'slug', 'terms' => array_map('sanitize_text_field', (array)$_GET['filter_brand']) , ];
    }

    /* ======================
       ATTRIBUTES
    ====================== */
    foreach ($_GET as $key => $values)
    {
        if (strpos($key, 'attr_') === 0 && !empty($values))
        {
            $taxonomy = 'pa_' . str_replace('attr_', '', $key);

            if (taxonomy_exists($taxonomy))
            {
                $tax_query[] = ['taxonomy' => $taxonomy, 'field' => 'slug', 'terms' => (array)$values, 'operator' => 'IN'];
            }
        }
    }

    /* ======================
       SHIPPING CLASS
    ====================== */
    if (!empty($_GET['shipping']))
    {
        $tax_query[] = ['taxonomy' => 'product_shipping_class', 'field' => 'slug', 'terms' => (array)$_GET['shipping']];
    }

    /* ======================
       STOCK
    ====================== */
    if (!empty($_GET['stock']))
    {
        $meta_query[] = ['key' => '_stock_status', 'value' => (array)$_GET['stock'], 'compare' => 'IN'];
    }

    /* ======================
       PRICE (FIXED)
    ====================== */
    if (isset($_GET['min_price']) || isset($_GET['max_price']))
    {
        $min = isset($_GET['min_price']) && $_GET['min_price'] !== '' ? floatval($_GET['min_price']) : 0;
        $max = isset($_GET['max_price']) && $_GET['max_price'] !== '' ? floatval($_GET['max_price']) : PHP_INT_MAX;

        if ($min > 0 || $max < PHP_INT_MAX)
        {
            $meta_query[] = ['relation' => 'OR', ['key' => '_price', 'value' => [$min, $max], 'type' => 'NUMERIC', 'compare' => 'BETWEEN'], ['key' => '_min_variation_price', 'value' => [$min, $max], 'type' => 'NUMERIC', 'compare' => 'BETWEEN']];
        }
    }

    /* ======================
       SALE
    ====================== */
    if (!empty($_GET['sale']))
    {
        $meta_query[] = ['key' => '_sale_price', 'value' => 0, 'compare' => '>', 'type' => 'NUMERIC'];
    }

    /* ======================
       FEATURED
    ====================== */
    if (!empty($_GET['featured']))
    {
        $tax_query[] = ['taxonomy' => 'product_visibility', 'field' => 'name', 'terms' => ['featured']];
    }

    /* ======================
       RATING (FIXED LOGIC)
    ====================== */
    if (!empty($_GET['rating']))
    {
        $min_rating = min((array)$_GET['rating']);

        $meta_query[] = ['key' => '_wc_average_rating', 'value' => floatval($min_rating) , 'compare' => '>=', 'type' => 'DECIMAL'];
    }

    /* ======================
       DATE (FIXED)
    ====================== */
    if (!empty($_GET['date']))
    {
        $days = intval($_GET['date']);
        $query->set('date_query', [['after' => date('Y-m-d', strtotime("-{$days} days")) , 'inclusive' => true]]);
    }

    /* ======================
       APPLY QUERIES
    ====================== */
    if (count($tax_query) > 1)
    {
        $query->set('tax_query', $tax_query);
    }

    if (count($meta_query) > 1)
    {
        $query->set('meta_query', $meta_query);
    }

    /* ======================
    DISCOUNT (EXACT PERCENTAGE - NO ROUNDING)
    ====================== */
    if (!empty($_GET['discount']))
    {
        $selected_discounts = array_map('intval', (array)$_GET['discount']);
        
        add_filter('posts_where', function($where) use ($selected_discounts) {
            global $wpdb;
            
            // Build the IN clause with exact percentages
            $discount_conditions = array();
            foreach ($selected_discounts as $discount) {
                // Calculate exact percentage and compare (with small tolerance for floating point)
                $discount_conditions[] = "ABS(((regular_price - sale_price) / regular_price * 100) - " . intval($discount) . ") < 0.01";
            }
            $discount_sql = implode(' OR ', $discount_conditions);
            
            $where .= " AND {$wpdb->posts}.ID IN (
                SELECT post_id FROM (
                    SELECT 
                        post_id,
                        MAX(CASE WHEN meta_key = '_regular_price' THEN CAST(meta_value AS DECIMAL(10,2)) ELSE 0 END) as regular_price,
                        MAX(CASE WHEN meta_key = '_sale_price' THEN CAST(meta_value AS DECIMAL(10,2)) ELSE 0 END) as sale_price
                    FROM {$wpdb->postmeta}
                    WHERE meta_key IN ('_regular_price', '_sale_price')
                    GROUP BY post_id
                    HAVING 
                        regular_price > 0 
                        AND sale_price > 0 
                        AND ({$discount_sql})
                ) AS price_data
            )";
            
            return $where;
        }, 10, 1);
    }


    /* ======================
       PERFORMANCE BOOST
    ====================== */
    $query->set('no_found_rows', false); // keep pagination working
   
}

add_filter('posts_search', 'te_custom_search_extend', 10, 2);
function te_custom_search_extend($search, $wp_query)
{
    global $wpdb;

    // Only frontend main query
    if (is_admin() || !$wp_query->is_main_query()) return $search;

    // Only Woo pages
    if (!is_shop() && !is_product_taxonomy()) return $search;

    // Only when our filter is used
    if (empty($_GET['search_text'])) return $search;

    $term = esc_sql($wpdb->esc_like($_GET['search_text']));

    return " AND (
        {$wpdb->posts}.post_title LIKE '%{$term}%'
        OR {$wpdb->posts}.post_content LIKE '%{$term}%'
        OR {$wpdb->posts}.post_excerpt LIKE '%{$term}%'
    ) ";
}

// showing country currency symbol 
add_filter( 'woocommerce_currency_symbol', 'custom_currency_symbols', 10, 2 );
function custom_currency_symbols( $currency_symbol, $currency ) {
    $symbols = array(
        'AED' => 'د.إ',
        'AFN' => '؋',
        'ALL' => 'L',
        'AMD' => 'AMD',
        'ANG' => 'ƒ',
        'AOA' => 'Kz',
        'ARS' => '$',
        'AUD' => '$',
        'AWG' => 'ƒ',
        'AZN' => 'AZN',
        'BAM' => 'KM',
        'BBD' => '$',
        'BDT' => '৳',
        'BGN' => 'лв.',
        'BHD' => '.د.ب',
        'BIF' => 'Fr',
        'BMD' => '$',
        'BND' => '$',
        'BOB' => 'Bs.',
        'BRL' => 'R$',
        'BSD' => '$',
        'BTC' => '฿',
        'BTN' => 'Nu.',
        'BWP' => 'P',
        'BYR' => 'Br',
        'BZD' => '$',
        'CAD' => '$',
        'CDF' => 'Fr',
        'CHF' => 'CHF',
        'CLP' => '$',
        'CNY' => '¥',
        'COP' => '$',
        'CRC' => '₡',
        'CUC' => '$',
        'CUP' => '$',
        'CVE' => '$',
        'CZK' => 'Kč',
        'DJF' => 'Fr',
        'DKK' => 'DKK',
        'DOP' => 'RD$',
        'DZD' => 'د.ج',
        'EGP' => 'EGP',
        'ERN' => 'Nfk',
        'ETB' => 'Br',
        'EUR' => '€',
        'FJD' => '$',
        'FKP' => '£',
        'GBP' => '£',
        'GEL' => 'ლ',
        'GGP' => '£',
        'GHS' => '₵',
        'GIP' => '£',
        'GMD' => 'D',
        'GNF' => 'Fr',
        'GTQ' => 'Q',
        'GYD' => '$',
        'HKD' => '$',
        'HNL' => 'L',
        'HRK' => 'Kn',
        'HTG' => 'G',
        'HUF' => 'Ft',
        'IDR' => 'Rp',
        'ILS' => '₪',
        'IMP' => '£',
        'INR' => '₹',
        'IQD' => 'ع.د',
        'IRR' => '﷼',
        'IRT' => 'تومان',
        'ISK' => 'kr.',
        'JEP' => '£',
        'JMD' => '$',
        'JOD' => 'د.ا',
        'JPY' => '¥',
        'KES' => 'KSh',
        'KGS' => 'сом',
        'KHR' => '៛',
        'KMF' => 'Fr',
        'KPW' => '₩',
        'KRW' => '₩',
        'KWD' => 'د.ك',
        'KYD' => '$',
        'KZT' => 'KZT',
        'LAK' => '₭',
        'LBP' => 'ل.ل',
        'LKR' => 'රු',
        'LRD' => '$',
        'LSL' => 'L',
        'LYD' => 'ل.د',
        'MAD' => 'د.م.',
        'MDL' => 'MDL',
        'MGA' => 'Ar',
        'MKD' => 'ден',
        'MMK' => 'Ks',
        'MNT' => '₮',
        'MOP' => 'P',
        'MRO' => 'UM',
        'MUR' => '₨',
        'MVR' => '.ރ',
        'MWK' => 'MK',
        'MXN' => '$',
        'MYR' => 'RM',
        'MZN' => 'MT',
        'NAD' => '$',
        'NGN' => '₦',
        'NIO' => 'C$',
        'NOK' => 'kr',
        'NPR' => '₨',
        'NZD' => '$',
        'OMR' => 'ر.ع.',
        'PAB' => 'B/.',
        'PEN' => 'S/.',
        'PGK' => 'K',
        'PHP' => '₱',
        'PKR' => '₨',
        'PLN' => 'zł',
        'PRB' => 'р.',
        'PYG' => '₲',
        'QAR' => 'ر.ق',
        'RMB' => '¥',
        'RON' => 'lei',
        'RSD' => 'дин.',
        'RUB' => '₽',
        'RWF' => 'Fr',
        'SAR' => 'ر.س',
        'SBD' => '$',
        'SCR' => '₨',
        'SDG' => 'ج.س.',
        'SEK' => 'kr',
        'SGD' => '$',
        'SHP' => '£',
        'SLL' => 'Le',
        'SOS' => 'Sh',
        'SRD' => '$',
        'SSP' => '£',
        'STD' => 'Db',
        'SYP' => 'ل.س',
        'SZL' => 'L',
        'THB' => '฿',
        'TJS' => 'ЅМ',
        'TMT' => 'm',
        'TND' => 'د.ت',
        'TOP' => 'T$',
        'TRY' => '₺',
        'TTD' => '$',
        'TWD' => 'NT$',
        'TZS' => 'Sh',
        'UAH' => '₴',
        'UGX' => 'UGX',
        'USD' => '$',
        'UYU' => '$',
        'UZS' => 'UZS',
        'VEF' => 'Bs F',
        'VND' => '₫',
        'VUV' => 'Vt',
        'WST' => 'T',
        'XAF' => 'Fr',
        'XCD' => '$',
        'XOF' => 'Fr',
        'XPF' => 'Fr',
        'YER' => '﷼',
        'ZAR' => 'R',
        'ZMW' => 'ZK',
    );

    // Return custom symbol if available, otherwise fallback to default
    if ( isset( $symbols[ $currency ] ) ) {
        return $symbols[ $currency ];
    }

    return $currency_symbol;
}

?>

Here is the sample images of it ….

Leave a Reply

Your email address will not be published. Required fields are marked *

Phone +91 9330497982 WhatsApp +91 9330497982 Instagram Follow Us