• Resolved caldejesus

    (@portokie)


    I was able to rename the product sorting options as they are displayed in the drop down, but now I would like the slug on the url to match the new name. For example, this part of the URL: `?orderby=title-desc’ I would like it to say ‘?orderby=name-z-to-a’ instead.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Support RK a11n

    (@riaanknoetze)

    Hi there,

    That would require a fair amount of custom coding and wouldn’t be covered by regular localisation.

    Given that this is a fairly complex development topic, I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    I can also recommend the following places for more development-oriented questions:

    1. WooCommerce Slack Community: https://woocommerce.com/community-slack/
    2. Advanced WooCommerce group on Facebook: https://www.facebook.com/groups/advanced.woocommerce/
    Thread Starter caldejesus

    (@portokie)

    Thanks, I registered and asked the question on slack, but didn’t receive a response there either.

    I wouldn’t expect there to be too much coding involved. Probably a short code I can add to functions.php like I did to rename the sorting options in the drop down. I just don’t know what it would be though.

    Thread Starter caldejesus

    (@portokie)

    I still haven’t found a solution to this, unfortunately.

    Stef

    (@serafinnyc)

    The only way I know how to do that would be to come in and add custom fields for all those Z to A products. And if you have a thousand products you’re going to be there awhile.

    You say you added a custom sort? Can I see your snippet?

    Thread Starter caldejesus

    (@portokie)

    I renamed “sort by date” to “sort by year/set” in the drop down menu. Unfortunately, I have to import all my listings in the correct sort order every time for that to work, which is kind of a pain. What I truly wanted to do was to be able to create new sort options for this, rather than by date, to sort by tag or whatever I wanted. I tried that route first with no luck.

    /**
    * @snippet     Rename a Default Sorting Option @ WooCommerce Shop
    * @how-to     Watch tutorial @ https://businessbloomer.com/?p=19055
    * @sourcecode      https://businessbloomer.com/?p=75511
    * @author     Rodolfo Melogli
    * @testedwith     WooCommerce 3.5.2
    * @donate $9     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'] = __( 'Sort by Price: Low to High', 'woocommerce' );   
        $options['price-desc'] = __( 'Sort by Price: High to Low', 'woocommerce' );   
       return $options;
    }
    Plugin Support RK a11n

    (@riaanknoetze)

    Swinging back to my earlier reply, the code changes would be extensive. In terms of the code snippet you shared, that only changes the titles, it doesn’t add any additional sorting logic.

    Thread Starter caldejesus

    (@portokie)

    Correct. So since I’m unable to create a new sort option from scratch for sorting by tag or some other field, this was the best workaround I could come up with. I guess nobody but me will really care if they see ?orberby=date when sorting by Year/Set. It just bugs me. Plus I have to delete and then re-import all of my inventory every time I add new inventory to keep it sorted correctly.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How to rename sorting option slugs’ is closed to new replies.