WooCommerce does not provide an option to order global attributes per product by default. However, you can add this functionality by customizing your WordPress theme or by using a plugin.

Here are two possible solutions:

Custom code solution:

You can add custom code to your WordPress theme’s functions.php file to create a custom meta box for the product edit screen that allows you to set the order for each global attribute.

add_action( 'add_meta_boxes', 'add_global_attribute_order_meta_box' );
function add_global_attribute_order_meta_box() {
  add_meta_box( 'global-attribute-order', 'Global Attribute Order', 'display_global_attribute_order_meta_box', 'product', 'side', 'default' );
}

function display_global_attribute_order_meta_box( $post ) {
  $attributes = wc_get_attribute_taxonomies();
  $attribute_order = get_post_meta( $post->ID, '_global_attribute_order', true );
  
  echo '<ul>';
  foreach ( $attributes as $attribute ) {
    $selected = '';
    if ( ! empty( $attribute_order[ $attribute->attribute_name ] ) ) {
      $selected = $attribute_order[ $attribute->attribute_name ];
    }
    echo '<li>' . $attribute->attribute_label . ': <input type="number" name="_global_attribute_order[' . $attribute->attribute_name . ']" value="' . $selected . '" /></li>';
  }
  echo '</ul>';
}

add_action( 'save_post', 'save_global_attribute_order' );
function save_global_attribute_order( $post_id ) {
  if ( isset( $_POST['_global_attribute_order'] ) ) {
    update_post_meta( $post_id, '_global_attribute_order', $_POST['_global_attribute_order'] );
  }
}

Plugin solution:

You can use a plugin such as the Product Attribute Order and Taxonomy Terms Order plugins, which provide a user-friendly interface for ordering global attributes for each product. These plugins allow you to rearrange the order of the global attributes for each product, and the order will be displayed on the front-end product page.

(Visited 118 times, 1 visits today)
Was this article helpful?
YesNo
Close Search Window