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

  1. zanzaboonda
    Posted 2 years 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.



  2. 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;
    <?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. WPMU DEV - Your WordPress Team
    WPMU DEV Support Staff
    Plugin Author

    Posted 2 years 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!

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • MarketPress - WordPress eCommerce
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic