Skip to content

Instantly share code, notes, and snippets.

@wpeliteplugins
Created February 9, 2017 17:49
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 wpeliteplugins/44105d980f86dc334403caa6f580bedb to your computer and use it in GitHub Desktop.
Save wpeliteplugins/44105d980f86dc334403caa6f580bedb to your computer and use it in GitHub Desktop.
Change error message - WooCommerce minumum/maximum quantities
<?php
// To change error message:
// The minimum allowed quantity for ABC is 5 (you currently have x in your cart).
add_filter('woo_min_allowed_product_qty_err', 'woo_min_allowed_product_qty_err_message', 10, 4 );
function woo_min_allowed_product_qty_err_message( $err_msg, $_product, $minimum_quantity, $in_cart ) {
$err_msg = __( 'Your message here', 'woo_min_max_quantities' );
return $err_msg;
}
// To change error message:
// The maximum allowed quantity for ABC is 40 (you currently have x in your cart).
add_filter('woo_max_allowed_product_qty_err', 'woo_max_allowed_product_qty_err_message', 10, 4 );
function woo_max_allowed_product_qty_err_message( $err_msg, $_product, $maxumum_quantity, $in_cart ) {
$err_msg = __( 'Your message here', 'woo_min_max_quantities' );
return $err_msg;
}
?>
@wpeliteplugins
Copy link
Author

You need to add this code in your theme functions.php file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment