Skip to content

Instantly share code, notes, and snippets.

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 Oscar-Abad-Folgueira/d750d668908fd84fb520234cb4aa56f5 to your computer and use it in GitHub Desktop.
Save Oscar-Abad-Folgueira/d750d668908fd84fb520234cb4aa56f5 to your computer and use it in GitHub Desktop.
Establecer cantidad de compra de productos en WooCommerce de 2 en 2
<?php
/**
* @snippet Establecer cantidad de compra de productos en WooCommerce de 2 en 2
* @author Oscar Abad Folgueira
* @author_url https://www.oscarabadfolgueira.com
* @snippet_url https://www.oscarabadfolgueira.com/establecer-que-solo-se-puedan-comprar-cantidad-de-2-en-2-en-woocommerce/
*/
add_filter( 'woocommerce_quantity_input_args', 'woocommerce_quanty_imput_step', 10, 2 ); // Simple products
function woocommerce_quanty_imput_step( $args, $product ) {
if ( is_singular( 'product' ) ) {
$args['input_value'] = 2; // Valor de comienzo
}
$args['step'] = 2; // de 2 en 2.
$args['min_value'] = 2; // Valor mínimo de cantidad
return $args;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment