• Resolved Adriders

    (@adriders)


    Hi There,

    We want to sort the upsells by sku. Found a filter, it works for price. When I fill the sku it is not working.

    
    function filter_woocommerce_upsells_orderby( $orderby ) { 
        return 'price'; 
    }; 
    add_filter( 'woocommerce_upsells_orderby', 'filter_woocommerce_upsells_orderby', 10, 1 );  
    
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support kellymetal a11n

    (@kellymetal)

    Hi there,

    Taking a look at the woocommerce_upsell_display function in the /woocommerce/includes/wc-template-functions.php file where that woocommerce_upsells_orderby filter appears, I see the following:

    
    $orderby Supported values - rand, title, ID, date, modified, menu_order, price.
    

    It looks like those are the only accepted sorting methods, and the only ones that have existing functions for sorting product arrays, as defined in the wc_products_array_orderby function in /woocommerce/includes/wc-product-functions.php.

    So it appears sorting the Upsells by SKU will require more customization than just a short snippet to get working. If you need assistance with coding or custom development, we recommend reaching out to a developer from one of the services at https://woocommerce.com/customizations/.

    I hope that helps! Have a wonderful day!

    Thread Starter Adriders

    (@adriders)

    Thanks for your response. I added some jQuery that is doing the sorting now.

    Have a nice day ??

    Plugin Support kellymetal a11n

    (@kellymetal)

    Glad to hear you were able to get things sorted out using jQuery! Nice work : )

    Have a wonderful day!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘upsells order by sku’ is closed to new replies.