• Resolved Laser Ulm

    (@laser1ulm)


    Hi!

    I have a little problem (I guess^^)
    On my shop site there are all products and I can select by dropdown to show the newest products first.
    But on sub sites (I have different sub sites with products from one category) the order is turned around, so the newest products are at the end of the list.
    On these sites all products of this category are shown with
    [product_category category="dakota" per_page="12" columns="3" orderby="" paginate="true"]
    Changing orderby to desc, ASC or adding orderby=”date-desc” doesn’t change this behavior (only all other orders are wrong too^^)

    Any ideas?
    Thanks and regards
    Laser

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

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Laser Ulm

    (@laser1ulm)

    Ok, I made it – with a real dirty hack…
    (So if anybody knows a better way 😉 )

    I just copied the whole part with ordering (without search) from wc-template-functions.php to
    the functions.php of the child theme and changed the array date to date-desc.
    I just wonder why now it’s ok in the shop site too…

    /**
    	 * Output the product sorting options.
    	 */
    	function woocommerce_catalog_ordering() {
    		if ( ! wc_get_loop_prop( 'is_paginated' ) || ! woocommerce_products_will_display() ) {
    			return;
    		}
    		$show_default_orderby    = 'menu_order' === apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby', 'menu_order' ) );
    		$catalog_orderby_options = apply_filters(
    			'woocommerce_catalog_orderby', 
    			array(
    				'popularity' => __( 'Sort by popularity', 'woocommerce' ),
    				'rating'     => __( 'Sort by average rating', 'woocommerce' ),
    				'date-desc'       => __( 'Sort by latest', 'woocommerce' ),
    				'price'      => __( 'Sort by price: low to high', 'woocommerce' ),
    				'price-desc' => __( 'Sort by price: high to low', 'woocommerce' ),
    			) 
    		);
    		// phpcs:disable WordPress.Security.NonceVerification.Recommended
    		$orderby = isset( $_GET['orderby'] ) ? wc_clean( wp_unslash( $_GET['orderby'] ) ) : $default_orderby;
    		// phpcs:enable WordPress.Security.NonceVerification.Recommended
    
    		if ( wc_get_loop_prop( 'is_search' ) ) {
    			$catalog_orderby_options = array_merge( array( 'relevance' => __( 'Relevance', 'woocommerce' ) ), $catalog_orderby_options );
    
    			unset( $catalog_orderby_options['menu_order'] );
    		}
    
    		if ( ! $show_default_orderby ) {
    			unset( $catalog_orderby_options['menu_order'] );
    		}
    
    		if ( ! wc_review_ratings_enabled() ) {
    			unset( $catalog_orderby_options['rating'] );
    		}
    
    		if ( ! array_key_exists( $orderby, $catalog_orderby_options ) ) {
    			$orderby = current( array_keys( $catalog_orderby_options ) );
    		}
    
    		wc_get_template(
    			'loop/orderby.php',
    			array(
    				'catalog_orderby_options' => $catalog_orderby_options,
    				'orderby'                 => $orderby,
    				'show_default_orderby'    => $show_default_orderby,
    			)
    		);
    	}
    

    Rgds
    Laser

    Mirko P.

    (@rainfallnixfig)

    Hello Laser @laser1ulm

    We’ve not seen much activity on this thread but it looks like you’re all set now. It’s good to know that you’ve managed to find a way to fix this and thanks for sharing what you’ve done.

    I’m going to close the topic now – you can open a new topic if you have more questions.

    Cheers.

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

The topic ‘Orderby date on sub sites’ is closed to new replies.