I create an arbitrary field in the admin panel of the Woocommerce "Select products with search" field is similar to the choice of Krossel and Apel.
?> <p class="form-field product_field_type"> <label for="product_field_type">Выбор товаров</label> <select id="product_field_type" name="product_field_type[]" class="wc-product-search" multiple="multiple" style="width: 50%;" data-placeholder="<?php esc_attr_e( 'Search for a product…', 'woocommerce' ); ?>" data-action="woocommerce_json_search_products_and_variations" data-exclude="<?php echo intval( $post->ID ); ?>"> <?php $product_field_type_ids = get_post_meta( $post->ID, '_product_field_type_ids', true ); $product_ids = ! empty( $product_field_type_ids ) && isset($product_field_type_ids) ? array_map( 'absint', $product_field_type_ids ) : array(); if ( $product_ids ) { foreach ( $product_ids as $product_id ) { $product = wc_get_product( $product_id ); $product_name = $product->get_formatted_name(); echo '<option value="' . esc_attr( $product_id ) . '" ' . selected(true, true, false ) . '>' . esc_html( $product->get_formatted_name() ) . '</option>'; } } ?> When filling out this field-list, the goods after the selection are sorted by name, but this is also the case in the standard cross-fields and upsel fields.How to make the selected products remain in the order in which they were chosen?