Skip to content

Instantly share code, notes, and snippets.

@barryhughes
Created February 20, 2015 15:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barryhughes/6194355de7f1620371bb to your computer and use it in GitHub Desktop.
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
<?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