Ondersteuning » Plugin vragen » Woocommerce variation sort

  • In woocommerce/single-product/add-to-cart/variable.php i found the part where the dropdown menu is being formed. I want to sort the variations like natsort(); so like:
    1
    2
    10

    At the moment the variable products are being sorted on alphabet:
    1
    10
    2

    Is there a way to edit the code below to sort it that way?

    <?php foreach ( $attributes as $attribute_name => $options ) : ?>

    <tr>
    <td class=”label”><label for=”<?php echo sanitize_title( $attribute_name ); ?>”><?php echo wc_attribute_label( $attribute_name ); ?></label></td>
    <td class=”value”>

    <?php
    $selected = isset( $_REQUEST[ ‘attribute_’ . sanitize_title( $attribute_name ) ] ) ? wc_clean( $_REQUEST[ ‘attribute_’ . sanitize_title( $attribute_name ) ] ) : $product->get_variation_default_attribute( $attribute_name );
    wc_dropdown_variation_attribute_options( array( ‘options’ => $options, ‘attribute’ => $attribute_name, ‘product’ => $product, ‘selected’ => $selected ) );
    ?>
    </td>
    </tr>

    <?php endforeach;?>

1 reactie aan het bekijken (van in totaal 1)
  • Hey Joey,

    Sorting is done in the backend of woocommerce, if you go to attributes under products and click the gear icon on the right of the attribute you want to order. You can drag and drop the different attributes and put them in any order you want. This is visible in the frontend dropdown.

    Good luck!

1 reactie aan het bekijken (van in totaal 1)
  • Het onderwerp ‘Woocommerce variation sort’ is gesloten voor nieuwe reacties.