Okay
  Public Ticket #3019259
woocommerce changes via functions.php
Closed

Comments

  •  3
    natah started the conversation

    Hi! 

    I tried the following code to make changes at woocommerce but nothing is working. can you please check and correct the code ?

    /**
    * @snippet       Remove Sorting Option @ WooCommerce Shop
    * @    https://businessbloomer.com/bloomer-armada/
    */
    add_filter( 'woocommerce_catalog_orderby', 'bbloomer_remove_sorting_option_woocommerce_shop' );
      function bbloomer_remove_sorting_option_woocommerce_shop( $options ) {
       unset( $options['popularity'] );  
       unset( $options['menu_order'] );
       return $options;
    }  
    // Note: you can unset other sorting options by adding more "unset" calls... here's the list: 'menu_order', 'popularity', 'rating', 'date', 'price', 'price-desc'

    -------------------------------------------

    /**
    * @snippet       Rename a Sorting Option @ WooCommerce Shop
    * @     https://businessbloomer.com/bloomer-armada/
    */
      add_filter( 'woocommerce_catalog_orderby', 'bbloomer_rename_sorting_option_woocommerce_shop' );
      function bbloomer_rename_sorting_option_woocommerce_shop( $options ) {
       $options['price'] = 'Low to High Price';   
        $options['price-desc'] = 'High to Low Price';
       return $options;
    }

    -------------------------------------------




  •  2,958
    Andrew replied

    Hi Natah,

    Could you try and attach the filter with the priority and number of arguments attached.
    We mean for example:

    add_filter( 'woocommerce_catalog_orderby', 'bbloomer_remove_sorting_option_woocommerce_shop', 10, 1 ); 

    10 is the priority and 1 is the number of arguments.
    Also could you check with the source of this code as they are in a better position to assist.

    Thanks. 

  •  3
    natah replied

    it is working!

    thank you for your help