WordPress.org

Ready to get started?Download WordPress

Forums

MarketPress - WordPress eCommerce
[resolved] Reorder product variations (3 posts)

  1. zanzaboonda
    Member
    Posted 6 months ago #

    Hi there-

    Is it possible to change the order of the variations? We have several scents, which I'd to arrange in alphabetical order.

    Is there an easy way to do this? If so, any help would be appreciated.

    Thanks!

    http://wordpress.org/plugins/wordpress-ecommerce/

  2. WPMU DEV
    Member
    Posted 6 months ago #

    Hi @zanzaboonda,

    Thank you for your question.

    Unfortunately currently there isn't any option in the plugin to change order of variation.

    You can just enter variations in alphabetical order.

    Alternatively you can add the following code in functions.php file of your child theme or use plugin like following to sort variations using JavaScript in front end.

    http://wordpress.org/plugins/add-actions-and-filters/ ( Test the plugin in development site before using it in production site )

    function add_js_in_footer(){ ?>
    <script type="text/javascript">
    var options = jQuery('select.mp_product_variations option');
    var arr = options.map(function(_, o) { return { t: jQuery(o).text(), v: o.value }; }).get();
    arr.sort(function(o1, o2) { 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', 'add_js_in_footer');

    Note: This code will only sort variations if JavaScript is enabled in the browser.

    Best Regards,

  3. WPMUDEV
    WPMU DEV Support Staff
    Plugin Author

    Posted 6 months ago #

    Hey there.

    We haven't heard from you in awhile, so I just wanted to check in to make sure all was good.

    This thread was marked resolved, but please, if you still need help then just respond and open it back up. We can then take it from there. :)

    Hope you have a fantastic day!

Reply

You must log in to post.

About this Plugin

About this Topic