Moving Woocommerce Order Review to Top of Checkout - wordpress

I'm trying to move the order review section to the top of Woocommerce checkout page and this is working:
remove_action( 'woocommerce_checkout_order_review', 'woocommerce_order_review', 10 );
add_action( 'woocommerce_before_checkout_form', 'woocommerce_order_review', 20 );
But when Checkout opens it scrolls down to the order review section, rather than to the top of the page.

This works:
remove_action( 'woocommerce_checkout_order_review', 'woocommerce_order_review', 10 );
add_action( 'woocommerce_after_checkout_billing_form', 'woocommerce_order_review', 20 );

Moving the review form doesn't automatically move the Your Order heading. This is what I added to functions.php
remove_action( 'woocommerce_checkout_order_review', 'woocommerce_order_review', 10 );
add_action( 'woocommerce_before_checkout_form', 'prefix_wc_order_review_heading', 3 );
add_action( 'woocommerce_before_checkout_form', 'woocommerce_order_review', 4 );
/**
* Add a heading for order review on checkout page.
* This replaces the heading added by WooCommerce since order review is moved to the top of the checkout page.
*/
function prefix_wc_order_review_heading() {
echo '<h3>Your Order</h3>';
}
And to hide the existing Your Order heading (and some spacing for the credit card form), I added this to style.css
.woocommerce-checkout #order_review_heading {
display: none !important;
}
.woocommerce-checkout #order_review {
margin-top: 2rem !important;
}

Related

Move woocommerce tag description below products

We are trying to get our product Tag descriptions to the bottom of the page so the products show first.
I use this code for product category:
// move category description to bottom of pages
remove_action( 'woocommerce_archive_description',woocommerce_taxonomy_archive_description', 10 );
add_action( 'woocommerce_after_shop_loop', 'woocommerce_taxonomy_archive_description', 100 );
but this code not performed on product tag description.
how move product tag description from top of product to under on product?
There is a typo in your code, a single quote is missing in first line.
here is the correct code:
remove_action( 'woocommerce_archive_description', 'woocommerce_taxonomy_archive_description', 10 );
add_action( 'woocommerce_after_shop_loop', 'woocommerce_taxonomy_archive_description', 100 );
it will be better if you move it after the main content wrapper ends by using
add_action( 'woocommerce_after_main_content', 'woocommerce_taxonomy_archive_description', 15 );

Remove Action for Review Order Title (Your order) in WooCommerce

I am trying to remove the title "Your order" from the WooCommerce checkout without editing the template. Here's what I've tried, without success.
add_action( 'woocommerce_checkout_before_order_review_heading', 'youroder_remove_title');
function yourorder_remove_title() {
echo '';
}
remove_action( 'woocommerce_checkout_order_review', 'woocommerce_checkout_before_order_review_heading', 10 );
Can anyone help?
add this to your function.php to remove ordor summary from checkout
remove_action( 'woocommerce_checkout_order_review', 'woocommerce_order_review', 10 );

Remove the Sort by dropdown completely, in WooCommerce

I want to remove the Sort by dropdown completely, in my WooCommerce installation.
http://cswpstage.hostworks.net/product-category/memorabilia/signed-photos/
Thanks!
It depends on the theme that you're using. There are two approaches, CSS and PHP.
I see on your theme you have already hidden it via CSS using
.sort-param-order,
.sort-param-sort {
display: none;
}
If you want to hide it with PHP, you need to look for the action which adds it and remove that action. A search for woocommerce_catalog_ordering will generally return the action you're looking for.
Here is how you remove it via standard WooCommerce:
<?php
/**
* Remove sorting from WooCommerce.
*/
function thenga_remove_filtering() {
remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 );
}
add_action( 'init', 'thenga_remove_filtering' );
And here is how you remove it from the Storefront theme:
<?php
/**
* Remove sorting from Storefront.
*/
function thenga_remove_filtering() {
remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 10 );
remove_action( 'woocommerce_after_shop_loop', 'woocommerce_catalog_ordering', 10 );
}
add_action( 'init', 'thenga_remove_filtering' );

Repositioning Genesis Nav not working - Issue with remove_action()

I'm new to Genesis (and stack overflow).
I used the following code to reposition my primary and secondary navs above my header, which worked, however it also left a copy of both navs below the header in it's original place. So basically duplicated my navs :(
// Reposition the primary navigation menu
remove_action( 'genesis_after_header', 'genesis_do_nav' );
add_action( 'genesis_header', 'genesis_do_nav', 12 );
// Reposition the secondary navigation menu
remove_action( 'genesis_after_header', 'genesis_do_subnav' );
add_action( 'genesis_before_header', 'genesis_do_subnav' );
Any ideas? The test site I'm playing around with is at: http://atelierblanc.pixelboutique.co.uk
Thanks
remove_action() must be called inside a function and cannot be called directly in your plugin or theme.
you may try this :
add_action( 'wp_head', 'remove_my_action' );
function remove_my_action(){
remove_action( 'genesis_after_header', 'genesis_do_nav' );
remove_action( 'genesis_after_header', 'genesis_do_subnav' );
}
you can learn more here :
https://codex.wordpress.org/Function_Reference/remove_action

How To Move Product Variation Descriptions in WooCommerce

I'd like to move my product's variation descriptions in Woocommerce beneath the add to cart button, and I can't find what hook I'm supposed to use. These are the variation's custom descriptions that load on selection in AJAX.
I'm able to hook another custom function beneath the add to cart button. So I think my problem is not knowing the name of the hook and/or if it's a hook versus a filter. I think it's either woocommerce_before_single_variation or woocommerce_before_add_to_cart_button.
Here's several attempts I've tried before with no luck in functions.php:
remove_action( 'woocommerce_after_single_variation','woocommerce_single_product_summary', 20 );
add_action( 'woocommerce_after_single_variation', 'woocommerce_single_product_summary', 9 );
//try #2
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20);
add_action('woocommerce_after_add_to_cart_button', 'woocommerce_single_variation', 35);
Thank you!
The functionality I was looking for is included in WooCommerce 2.4 as a default but is not done on a hook. It's added by jQuery updating a div instead - which I found in woocommerce/js/assets/frontend/add-to-cart-variation.js. So I moved the div's location instead:
add_action ('woocommerce_after_single_variation', 'move_descriptions', 50);
function move_descriptions() {
?>
<div class="woocommerce-variation-description" style="border: 1px solid transparent; height: auto;"></div>
<?php
}
I think this will do,
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20);
add_action('woocommerce_after_add_to_cart_form', 'woocommerce_template_single_excerpt');
Only move Short description if product is variable
add_action('wp_head', 'move_short_desc_for_varition');
function move_short_desc_for_varition() {
#
global $post;
$product = get_product( $post->ID );
if( $product->is_type( 'variable' ) ){
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20);
add_action('woocommerce_after_add_to_cart_form', 'woocommerce_template_single_excerpt');
}
}
The problem is in the priority of the remove hook.
I give you an example (this work for me):
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20);
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30);
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 15 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 10 );
Pay attention and try with differents priorities.

Resources