Add coupon – Store list not sorted

WordPress Business Themes Forums Responsive Themes Coupon Theme Add coupon – Store list not sorted Reply To: Add coupon – Store list not sorted

Discontinued - The forum content is out of date. For theme support please use our support desk here.

WordPress Business Themes Forums Responsive Themes Coupon Theme Add coupon – Store list not sorted Reply To: Add coupon – Store list not sorted

  • JamesD
    JamesD
    Super Guru 1,345 points

    Hello Anthony,

    Place this code in your _functions.php file:

        function _ascending_storelist() {
            global $post;
            // Make sure it's the "Add Coupon" page before adding.
            if( 'add-listing' !== $post->post_name) { return; }
    ?>
    <script>
        var options = jQuery('select#reg_field_tax_store option');
        var arr = options.map(function(_, o) { return { t: jQuery(o).text(), v: o.value }; }).get();
        arr.sort(function(o1, o2) { var t1 = o1.t.toLowerCase(), t2 = o2.t.toLowerCase(); return o1.t > o2.t ? 1 : o1.t < o2.t ? -1 : 0; });
        options.each(function(i, o) { o.value = arr[i].v; jQuery(o).text(arr[i].t); });
    </script>
    <?php
    }
    add_action('wp_footer', '_ascending_storelist');
    May 29, 2019 at 5:58 am
  • Didn't find what you were after?

    Chat with us now

    or contact our support team