Skip to content

Instantly share code, notes, and snippets.

@psahalot
Created December 2, 2015 16:39
Show Gist options
  • Save psahalot/2e2df59635ed2bdc5a08 to your computer and use it in GitHub Desktop.
Save psahalot/2e2df59635ed2bdc5a08 to your computer and use it in GitHub Desktop.
Empty WooCommerce cart before adding new product
add_filter( 'woocommerce_add_cart_item_data', 'ps_empty_cart', 10, 3);
function ps_empty_cart( $cart_item_data, $product_id, $variation_id ) {
global $woocommerce;
$woocommerce->cart->empty_cart();
// Do nothing with the data and return
return $cart_item_data;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment