WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
[Plugin: WooCommerce] Reorder content on single product (6 posts)

  1. Soundyoucansee
    Member
    Posted 2 years ago #

    How do you reorder where each bit of information is going. I would like to have the title and then the description before the price.

    Is this easily done?

    http://wordpress.org/extend/plugins/woocommerce/

  2. Steve
    Member
    Posted 1 year ago #

    Hi,

    Did you have any luck with this?
    I'm trying to do the exact same thing, I'm pretty sure hooks need to be added to the functions.php file.

    I have been testing how to move bits and bobs but can't find out how to reorder the shop page so the "orderby" drop down menu appears at the top rather than the bottom.

    My progress so far is here:
    http://wordpress.org/support/topic/plugin-woocommerce-customize?replies=3

  3. jmek
    Member
    Posted 1 year ago #

    I've just figured out how to do this (mostly) with hooks. Add the following to functions.php (add it as all one line):

    add_action('woocommerce_before_main_content','woocommerce_catalog_ordering', 20 );

    This puts the orderby drop-down menu even with the breadcrumbs (breadcrumbs align left, orderby aligns right). I'd really like to have it between the page title and the product grid, but I haven't been able to find the right hook for that.

  4. helgatheviking
    Member
    Posted 1 year ago #

    Take a look at the archive-product.php template in the Woocommerce templates folder to get a sense of what hooks are available where. Woocommerce code is extremely well-commented. Not sure about the current version, but in the archive-product.php of the 1.7 beta, but there is this patch of code:

    do_action('woocommerce_before_main_content');
    	?>
    
    		<h1 class="page-title"><?php woocommerce_page_title(); ?></h1>
    
    		<?php do_action( 'woocommerce_archive_description' ); ?>
    
    		<?php if ( is_tax() ) : ?>
    			<?php do_action( 'woocommerce_taxonomy_archive_description' ); ?>
    		<?php elseif ( ! empty( $shop_page ) && is_object( $shop_page ) ) : ?>
    			<?php do_action( 'woocommerce_product_archive_description', $shop_page ); ?>
    		<?php endif; ?>
    
    		<?php if ( have_posts() ) : ?>
    
    			<?php
    				/**
    				 * woocommerce_pagination hook
    				 *
    				 * @hooked woocommerce_pagination - 10
    				 * @hooked woocommerce_result_count - 20
    				 * @hooked woocommerce_catalog_ordering - 30
    				 */
    				do_action( 'woocommerce_before_shop_loop' );
    			?>

    so the woocommerce_archive_description hook would come right after the page title. Or if you have posts then woocommerce_before_shop_loop would come after the archive title+descriptions.

  5. jmek
    Member
    Posted 1 year ago #

    Both the woocommerce_archive_description and the woocommerce_before_shop_loop hooks put the orderby drop-down below the h1 title in such a way that the product grid is squeezed to the left to make room for a new column containing just the orderby drop-down. I've tried moving it with CSS, but it seems locked in a block div. What I really need is a hook in the same div as the h1 title; that is, a hook between woocommerce_before_main_content and woocommerce_archive_description. But I don't see one either in the archive-product.php or in the WooCommerce docs.

    Any ideas about a way to add the code to archive-product.php in my child theme? I suspect I need to add a function and an if statement, but I have very minimal php skills, so I would need the actual snippet.

  6. agamemnus
    Member
    Posted 1 year ago #

    Jmek, I have the exact same need as you. I want the order-by dropdown to be placed next to the title, on the right side. Seems illogical to do it any other way.

    For the time being, you may want to use Javascript. I added this to
    my_theme_wrapper_end (the link explains what that function does):

    echo '<script style="javascript">';
    echo 'document.getElementsByClassName("page-title")[0].appendChild (document.getElementsByClassName("woocommerce_ordering")[0])';
    echo '</script>';

    I also modified the css style of the thing:

    .woocommerce_ordering {float: right; margin:0; margin-top:6px}

    Don't forget, you will need that css code to run after the woocommerce css so as to over-ride the margins on woocommerce_ordering -- it originally has a margin-bottom of 2em.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic