• Resolved Francesco Cantinelli

    (@francescocantinelli)


    Hello, I need some help.
    I need to sort the woocommerce product archive alphabetically. At the moment I have mostly succeeded with an additional string to the default woocommerce sorting, but I still have 5-6 products left that do whatever they want.

    The snippet I’m using is this:

    1) `*Ordine Alfabetico Prodotti*/
    function quadlayers_alphabetical_shop_ordering( $sort_args ) {
    $orderby_value = isset( $_GET[‘orderby’] ) ? woocommerce_clean( $_GET[‘orderby’] ) : apply_filters( ‘woocommerce_default_catalog_orderby’, get_option( ‘woocommerce_default_catalog_orderby’ ) );
    if ( ‘alphabetical’ == $orderby_value ) {
    $sort_args[‘orderby’] = ‘title’;
    $sort_args[‘order’] = ‘asc’;
    $sort_args[‘meta_key’] = ”;
    }
    return $sort_args;
    }
    add_filter( ‘woocommerce_get_catalog_ordering_args’, ‘quadlayers_alphabetical_shop_ordering’ );`

    2) /*Creazione casello*/
    function quadlayers_custom_wc_catalog_orderby( $sortby ) {
    $sortby[‘alphabetical’] = ‘Sort by Name: Alphabetical’;
    return $sortby;}
    add_filter( ‘woocommerce_default_catalog_orderby_options’, ‘quadlayers_custom_wc_catalog_orderby’ );
    add_filter( ‘woocommerce_catalog_orderby’, ‘quadlayers_custom_wc_catalog_orderby’ );`

    I don’t understand why they are all in alphabetical order except some …

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Francesco Cantinelli

    (@francescocantinelli)

    In the products panel they are sorted.

    In the front-end, 4, 5 are not sorted.

    I had a look at this example: EYEPETIZER / ALEN C.4-42F shows on the page after
    EYEPETIZER / AMELIE C.9-44F which of course is the wrong way round. I looked at the page source and in there they are in the correct order. Look at the “li” tags. So I think the snippet you are using is good. The incorrect order is being generated by some code in your theme which is using absolute positioning to place the products on the page.

    To confirm that the issue is coming from your theme, temporarily try the Storefront theme and see if the order on the page is now correct.

    If this test does show that the incorrect order is being caused by the theme placing the products on the page, this forum can’t help much. Forum members don’t have access to commercial themes or to their code.

    Your way forward is firstly to update your theme. You have version 2.4, but the latest version is 2.5. The changelog shows this has several fixes, including compatibility with later versions of WooCommerce.

    Your next thing to try would be to raise the issue with the theme vendor’s support service. They are best placed to know their theme and its code.

    Your other approach is to see if your theme has other options for showing the products. The absolute positioning will be coming from a “masonry” layout or something similar. Look for any product layout options that are not “masonry”.

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

The topic ‘Alphabetical Sorting Product’ is closed to new replies.