-
-
Save WillBrubaker/609aa54fb50b06d5ebba12ad5986152e to your computer and use it in GitHub Desktop.
Moves WooCommerce Box Office "add to cart" button below the form fields
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' ) ) { | |
if ( method_exists( 'WC_Box_Office', 'init' ) ) { | |
WCBO()->init(); | |
} | |
//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 ); | |
} | |
} |
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
+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 ?