Skip to content

Instantly share code, notes, and snippets.

@WillBrubaker
Last active April 10, 2017 20:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WillBrubaker/609aa54fb50b06d5ebba12ad5986152e to your computer and use it in GitHub Desktop.
Save WillBrubaker/609aa54fb50b06d5ebba12ad5986152e to your computer and use it in GitHub Desktop.
Moves WooCommerce Box Office "add to cart" button below the form fields
add_action( 'woocommerce_loaded', 'handsome_bearded_guy_move_box_office_cartbutton' );
function handsome_bearded_guy_move_box_office_cartbutton() {
//ensure the function exixts before trying to accecss it - avoids WSOD
if ( function_exists( 'WCBO' ) ) {
//remove the action
remove_action( 'woocommerce_after_add_to_cart_button', array( WCBO()->components->cart, 'render_ticket_fields' ), 20 );
//add it back so that the add to cart button comes after the form fields
add_action( 'woocommerce_before_add_to_cart_button', array( WCBO()->components->cart, 'render_ticket_fields' ), 20 );
}
}
@fearlex
Copy link

fearlex commented Dec 14, 2016

+1

For some reason is not working for me.

Should the priority in the action hooks be the same for add_action and remove_action ?

@fearlex
Copy link

fearlex commented Dec 14, 2016

It has to be

add_action( 'woocommerce_init', 'handsome_bearded_guy_move_box_office_cartbutton' );

For it to work properly.

Thanks for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment