Skip to content

Instantly share code, notes, and snippets.

@nczz
Created September 14, 2018 15:28
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 nczz/31ea2f4411c717164631f12f72a82a68 to your computer and use it in GitHub Desktop.
Save nczz/31ea2f4411c717164631f12f72a82a68 to your computer and use it in GitHub Desktop.
WooCommerce 一張訂單限定一款商品
<?php
add_filter( 'woocommerce_add_cart_item_data', 'mxp_wc_custom_add_to_cart' );
function mxp_wc_custom_add_to_cart( $cart_item_data ) {
WC()->cart->empty_cart(true);
WC()->session->set('cart', array());
return $cart_item_data;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment