Okay
  Public Ticket #3664090
question regarding sorting products
Closed

Comments

  •  1
    Baerbel started the conversation

    In the documentation I found the rules how to sort bulk order form a-z/z-a and beststelling. 

    I wonder if there is a way to sort by SKU?

    Thank you for a short info.

  •  2,219
    WebWizards replied

    Hi there,

    By default, the "a-z" and "z-a" search are based on the product title. However, we can also change it, to make that a a-z / z-a search based on the SKU. 

    For that, you can add the following PHP code snippet to your site:

    add_filter('b2bking_bulkorder_sort_by', function($sortval, $product_id){
        $sku = get_post_meta($product_id, '_sku', true);
        $sortval = $sku;
        
        return $sortval;
    }, 10, 2);
    

    A PHP snippet can be added to functions.php, or by following our guide here: https://woocommerce-b2b-plugin.com/docs/how-to-add-a-snippet-php-or-js/



    The result is that for example if we choose Z -> A, it now sorts as follows by SKU:

    6809976776.png


    If you need it, we can also add some custom CSS, for example to hide the "sort by" area, so there is only a single default option.


    Kind regards,

    Stefan