4

how to change, in last version Woocommerce, this text - enter image description here

3
  • 1
    Have you tried anything yet? Why not search for the text in the code to see where it comes from?
    – bodangly
    May 25, 2016 at 19:04
  • Yes, I tried, but nothing could ... apparently I'm not very well versed in the code..(
    – Jasper
    May 25, 2016 at 19:25
  • 2
    Describing what you tried helps us avoid time telling you to do things you've already done. And/or it helps us quickly point out errors in the code you have already tried. May 25, 2016 at 21:26

6 Answers 6

9

I hope better way to solve your problem. Just copy and paste your theme of functions.php. Okay

add_filter('woocommerce_catalog_orderby', 'wc_customize_product_sorting');

function wc_customize_product_sorting($sorting_options){
    $sorting_options = array(
        'menu_order' => __( 'Sorting', 'woocommerce' ),
        'popularity' => __( 'Sort by popularity', 'woocommerce' ),
        'rating'     => __( 'Sort by average rating', 'woocommerce' ),
        'date'       => __( 'Sort by newness', 'woocommerce' ),
        'price'      => __( 'Sort by price: low to high', 'woocommerce' ),
        'price-desc' => __( 'Sort by price: high to low', 'woocommerce' ),
    );

    return $sorting_options;
}
5

Here's how you can change the options of the orderby via the woocommerce_catalog_orderby filter.

add_filter( 'woocommerce_catalog_orderby', 'so_37445423_orderby_options', 20 );

function so_37445423_orderby_options( $options ){
    $options['menu_order'] = __('Sort the normal way', 'your-child-theme');
    return $options;
}

I've added the 20 priority, because I'm guessing that your theme is already filtering this and/or hard-coding them into the orderby.php template. I'm guessing this because the default WooCommerce has "Default sorting" instead of "Sort by Default". "Sort by name" is also not a part of core.

0
3

Add this to your themes function.php . Change the translation according to your requirement.

add_filter( 'gettext', 'theme_sort_change', 20, 3 );
function theme_sort_change( $translated_text, $text, $domain ) {

    if ( is_woocommerce() ) {

        switch ( $translated_text ) {

            case 'Sort by newness' :

                $translated_text = __( 'Sort by Newest', 'theme_text_domain' );
                break;
        }

    }

    return $translated_text;
}

Reference : https://wordpress.org/support/topic/change-woocommerce-sort-by-text

0

For the guys, who is looking for it's solution in 2017-2018(Version 4.9.1)...

wp-content > plugins > woocommerce > includes > wc-template-functions.php

Search for: "function woocommerce_catalog_ordering()". Here it's line 831.

        'menu_order' => __( 'Default sorting', 'woocommerce' ),
        'popularity' => __( 'Sort by popularity', 'woocommerce' ),
        'rating'     => __( 'Sort by average rating', 'woocommerce' ),
        'date'       => __( 'Sort by newness', 'woocommerce' ),
        'price'      => __( 'Sort by price: low to high', 'woocommerce' ),
        'price-desc' => __( 'Sort by price: high to low', 'woocommerce' ),

All the text can be change in this function.

1
  • 1
    It is never a good practice to overwrite the core files, as with an update they get updated too.
    – dferenc
    Dec 28, 2017 at 13:56
-2

Why do you want to change them? If you want to change the language, then use a language pack (that might work for changing the texts in English also)

3
  • Because in other languages woocommerce often not fully translated, and in my case part descriptions, menus, answers are not translated, so I translate myself!
    – Jasper
    May 25, 2016 at 19:12
  • So you have already downloaded a translation pack? So why not just translate those untranslated parts in the .po file and make new .mo file out of it.
    – Dope
    May 25, 2016 at 19:40
  • Since the options are saying something other than the default, I would guess your theme has modified the values, which might not have complete language packs. WooCommerce core is translated into a lot of languages. May 25, 2016 at 21:31
-3

I hope better way to solve your problem. Just copy and paste your theme of functions.php. Okay

function wc_customize_product_sorting($sorting_options){
    $sorting_options = array(
        'menu_order' => __( 'Sorting', 'woocommerce' ),
        'popularity' => __( 'Sort by popularity', 'woocommerce' ),
        'rating'     => __( 'Sort by average rating', 'woocommerce' ),
        'date'       => __( 'Sort by newness', 'woocommerce' ),
        'price'      => __( 'Sort by price: low to high', 'woocommerce' ),
        'price-desc' => __( 'Sort by price: high to low', 'woocommerce' ),
    );

    return $sorting_options;
}

add_filter('woocommerce_catalog_orderby', 'wc_customize_product_sorting');

1
  • 1
    Please delete this answer as a duplicate.
    – Ruslan
    Jan 12, 2018 at 7:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.