Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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