• Resolved lodisy

    (@lodisy)


    Hello,

    as some brands names include char that still cannot be recognized, for example brand name ΛCROИYM® with slug acronym will result a null navigation for the listing.

    Changing the following code does not work:

    protected static function replace_specials_characters($s){
    		$s = preg_replace("/á|à|â|ã|ª/","a",$s);
    		$s = preg_replace("/Á|À|Â|Ã|Λ/","A",$s);//not working
    		$s = preg_replace("/é|è|ê/","e",$s);
    		$s = preg_replace("/É|È|Ê/","E",$s);
    		$s = preg_replace("/í|ì|î/","i",$s);
    		$s = preg_replace("/Í|Ì|Î/","I",$s);
    		$s = preg_replace("/ó|ò|ô|õ|º/","o",$s);
    		$s = preg_replace("/Ó|Ò|Ô|Õ/","O",$s);
    		$s = preg_replace("/ú|ù|û/","u",$s);
    		$s = preg_replace("/Ú|Ù|Û/","U",$s);
    		$s = preg_replace("/Ü/","UE",$s);
        	$s = preg_replace("/ü/","ue",$s);
    		$s = preg_replace('/[^a-zA-Z0-9_.-]/', '', $s);
    		return $s;
    	}
Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter lodisy

    (@lodisy)

    I have changed the code into:

    public static function get_brands( $hide_empty = false, $order_by = 'slug', $order = 'ASC', $only_featured = false, $pwb_term = false )

    and also:

    $brands         = \Perfect_Woocommerce_Brands\Perfect_Woocommerce_Brands::get_brands( true, 'slug', 'ASC' );
    
    $letter = $brand->slug[0];
    

    It works except the ASC order is not correct, seems like order by the create time of the brand ( not sure yet).

    https://i.loli.net/2018/12/22/5c1d32c2b4085.jpg

    • This reply was modified 7 years, 6 months ago by lodisy.
    Thread Starter lodisy

    (@lodisy)

    It works well after I re create brands and assign products to them.

    Plugin Contributor titodevera

    (@titodevera)

    Solved 🙂

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘How to order brands via slug rather than name in a-z listing?’ is closed to new replies.