Skip to content

Instantly share code, notes, and snippets.

@andrasguseo
Last active April 24, 2020 16:42
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrasguseo/940d73f1c024ae232896dd3cd2ae23c0 to your computer and use it in GitHub Desktop.
Save andrasguseo/940d73f1c024ae232896dd3cd2ae23c0 to your computer and use it in GitHub Desktop.
Hide the quantity field on the WooCommerce cart page
<?php
/*
* For the following plugins:
* The Events Calendar, Event Tickets, Event Tickets Plus, WooCommerce
*
* The function hides the quantity form field from the cart page
* so users cannot change the product / ticket quantity there.
* It shows the number as plain text.
* Note: it only allows you to put 1 of all products in the cart!!!
* Useful if you are collecting attendee information with Event Tickets Plus
* Add to your child theme's functions.php file
*/
function wc_remove_quantity_field_from_cart( $return, $product ) {
if ( is_cart() ) return true;
}
add_filter( 'woocommerce_is_sold_individually', 'wc_remove_quantity_field_from_cart', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment