Created
February 20, 2015 15:38
-
-
Save barryhughes/6194355de7f1620371bb to your computer and use it in GitHub Desktop.
Fixes an issue with WooCommerce Tickets 3.9.1 and adding multiple items to the cart
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
<?php | |
/** | |
* Moves the add-to-cart functionality to a later point in the request (ie, | |
* after the existing cart contents have been populated). | |
*/ | |
function wootix_rehook_add_to_cart() { | |
$wootickets = TribeWooTickets::get_instance(); | |
$callback = array( $wootickets, 'process_front_end_tickets_form' ); | |
// Switch to a later action | |
remove_action( 'wp_loaded', $callback ); | |
add_action( 'wp_loaded', $callback, 50 ); | |
} | |
// Apply fix if this snippet is running within a (mu-)plugin file | |
if ( ! did_action( 'plugins_loaded' ) ) { | |
add_action( 'plugins_loaded', 'wootix_rehook_add_to_cart', 50 ); | |
} | |
// Also apply fix if this snippet is embedded directly in a theme functions.php file | |
elseif ( class_exists( 'TribeWooTickets' ) ) { | |
wootix_rehook_add_to_cart(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment