Skip to content

Instantly share code, notes, and snippets.

@saipafo
Last active June 4, 2021 07:40
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 saipafo/f506267315f3545176c5afa7a2363bdc to your computer and use it in GitHub Desktop.
Save saipafo/f506267315f3545176c5afa7a2363bdc to your computer and use it in GitHub Desktop.
Exiger un montant minimum dans WooCommerce pour passer une commande
<?php
add_action( 'woocommerce_after_checkout_validation', 'mgris_minimum_order', 10, 2);
function mgris_minimum_order( $fields, $errors ) {
global $woocommerce;
// Modifier la variable $minorder par votre montant minimum.
$minorder = 25;
$panier = $woocommerce->cart->subtotal;
if($panier < $minorder) {
$errors->add( 'validation', sprintf(__('Désolé, pour pouvoir réaliser une commande en ligne, le montant de votre panier doit être supérieur à <strong>' . $minorder . '</strong> €. <br /><a href="%s">Retour à la boutique →</a><br />', 'textdomain'), get_permalink( wc_get_page_id('shop') ) ) );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment