Created
September 14, 2018 15:28
-
-
Save nczz/31ea2f4411c717164631f12f72a82a68 to your computer and use it in GitHub Desktop.
WooCommerce 一張訂單限定一款商品
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 | |
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