Skip to content

Instantly share code, notes, and snippets.

@vishalbasnet23
Created June 9, 2015 03:52
Show Gist options
  • Save vishalbasnet23/858f358735331539e5fa to your computer and use it in GitHub Desktop.
Save vishalbasnet23/858f358735331539e5fa to your computer and use it in GitHub Desktop.
Allow Single Quantity in Cart Woocommerce
add_filter ( 'woocommerce_before_cart' , 'allow_single_quantity_in_cart' );
function allow_single_quantity_in_cart() {
global $woocommerce;
$cart_contents = $woocommerce->cart->get_cart();
$keys = array_keys ( $cart_contents );
foreach ( $keys as $key ) {
$woocommerce->cart->set_quantity ( $key, 1, true );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment