@gilbert
To add an order by dropdown to WooCommerce, you can follow these steps:
1 2 3 4 5 6 7 |
add_filter( 'woocommerce_catalog_orderby', 'custom_woocommerce_catalog_orderby' ); function custom_woocommerce_catalog_orderby( $sortby ) { $sortby['alphabetical'] = __( 'Sort by name: A to Z', 'woocommerce' ); $sortby['price-desc'] = __( 'Sort by price: high to low', 'woocommerce' ); $sortby['price-asc'] = __( 'Sort by price: low to high', 'woocommerce' ); return $sortby; } |
Please note that this code will add the custom sorting options 'Sort by name: A to Z', 'Sort by price: high to low', and 'Sort by price: low to high'. You can customize these options or add more sorting options by modifying the code accordingly.