Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #15978

    Hi

    I have a few problems with the way my products are showing up on the homepage and on the shop pages, as well as the sidebar categories.

    They are all showing up as alphabetical order. I would prefer if the products showed up as most recent. How do I go about this?

    I changed the order of the product categories in the dashboard but these too are also showing alphabetically.

    Any help would be much appreciated.

    http://www.cutecreations.co.uk/wp/shop

    Kind regards

    Kate

    #89683

    Hi,

    In your functions.php file on line 133 , which comes *after* the lines shown:

    ######################################################################
    # CUSTOM THEME FUNCTIONS
    ######################################################################

    please add this on line 133:

    /**
    * This code should be added to functions.php of your theme
    **/
    add_filter('woocommerce_default_catalog_orderby', 'custom_default_catalog_orderby');

    function custom_default_catalog_orderby() {
    return 'date'; // Can also use title and price
    }

    Thanks,

    Nick

    #89684

    Hi Nick

    Thats worked on the shop pages, but on the homepage where it says latest products, it is still pulling them in from alphabetical order.

    Kind regards

    Kate

    #89685

    Hi,

    Hmm.. Sorry about that, instead of the previous one, please try this :

    add_filter('woocommerce_get_catalog_ordering_args', 'am_woocommerce_catalog_orderby');
    function am_woocommerce_catalog_orderby( $args ) {
    $args['meta_key'] = 'date'; // '_price' could go here; uncomment the line below only for price
    //$args['orderby'] = 'meta_value_num';//only used with price.
    $args['order'] = 'desc'; //asc could go here for ascending/descending order
    return $args;
    }

    This should work.

    Ref: http://wcdocs.woothemes.com/user-guide/misc/shortcodes/

    Thanks,

    Nick

    #89686

    Hi Nick

    I’m afraid that didn’t work either. It brought an error up in the shop and didn’t affect the homepage products.

    Kind regards

    Kate

    #89687

    Hi,

    Here is something that looks like it’s big enough to do the job. I am sorry I am getting them from one of the lead develoepr’s websites, so I am surprised they are breaking. This one looks like it s gonna expand functionality as well.

    /**
    * This code should be added to functions.php of your theme
    **/
    add_filter('woocommerce_get_catalog_ordering_args', 'custom_woocommerce_get_catalog_ordering_args');

    function custom_woocommerce_get_catalog_ordering_args( $args ) {
    if (isset($_SESSION['orderby'])) {
    switch ($_SESSION['orderby']) :
    case 'date_asc' :
    $args['orderby'] = 'date';
    $args['order'] = 'asc';
    $args['meta_key'] = '';
    break;
    case 'price_desc' :
    $args['orderby'] = 'meta_value_num';
    $args['order'] = 'desc';
    $args['meta_key'] = '_price';
    break;
    case 'title_desc' :
    $args['orderby'] = 'title';
    $args['order'] = 'desc';
    $args['meta_key'] = '';
    break;
    endswitch;
    }
    return $args;
    }

    add_filter('woocommerce_catalog_orderby', 'custom_woocommerce_catalog_orderby');

    function custom_woocommerce_catalog_orderby( $sortby ) {
    $sortby['title_desc'] = 'Reverse-Alphabetically';
    $sortby['price_desc'] = 'Price (highest to lowest)';
    $sortby['date_asc'] = 'Oldest to newest';
    return $sortby;
    }

    reference: http://wcdocs.woothemes.com/snippets/custom-sorting-options-ascdesc/

    Thanks,

    Nick

    #89688

    Hi,

    I looked at your homepage, and I can’t tell what’s new and what’s old but the page doesn’t load in alphabetical order. and when i select show newest , the page doesn’t change. Please clear your browser cache, perhaps the original plugin did work.

    Deluxe Mystery Bag, Grim Reaper, Chubby Ghost is what comes up for me.

    Thanks,

    Nick

    #89689

    Hi Nick

    I think you’re looking at my Artfire shop. My wordpress site is http://www.cutecreations.co.uk/wp/

    The last code you gave me didn’t have any effect. The first code works in the shop page only but don’t change the order of the products on the homepage – these are still showing up as alphabetical order.

    Kind regards

    Kate

    #89690

    Hi,

    I am sorry, I think your best bet is to ask Woo how to go about implementing this customization on their forum.Since this is an e-commerce plugin, I don’t wan’t to offer you a solution that may create a problem, and neither do you. With something like this its always better to be safe than sorry, thus I recommend you pose the question on their forum, so that you can feel safe knowing the customization came from the developer.

    Thanks,

    Nick

Viewing 9 posts - 1 through 9 (of 9 total)

The topic ‘Change order of products in shop pages and homepage’ is closed to new replies.