The minimum order amount has to be 1500. I try to make add to cart button disabled when the amount is less then needed, and to enable it back when it's 1500 or more. I use this code
add_action( 'woocommerce_single_product_summary', 'woocommerce_total_product_price', 31 );
function woocommerce_total_product_price() {
global $woocommerce, $product;
// let's setup our divs
echo sprintf('<div id="product_total_price" style="margin-bottom:20px;">%s %s</div>',__('Your order amount:','woocommerce'),'<span class="price">'.$product->get_price().'</span><p style="font-weight: bold;">The minimum order amount is<span style="color:red;">1500 ₽</span></p>');
?>
<script>
jQuery(function($){
var price = <?php echo $product->get_price(); ?>,
currency = '<?php echo get_woocommerce_currency_symbol(); ?>';
$('[name=quantity]').change(function(){
if ((this.value < 1500)) {
var product_total = parseFloat(price * this.value);
$('.button.single_add_to_cart_button.button.alt.fa-cart').addClass('minimum-disabled');
$('#product_total_price').html('Your order amount: '+ product_total.toFixed(2) + ' ' + currency + '<p style="font-weight: bold;">The minimum order amount is <span style="color:red;">1500 ₽</span></p>');
}
else{
var product_total = parseFloat(price * this.value);
$('.button.single_add_to_cart_button.button.alt.fa-cart').removeClass('minimum-disabled');
$('#product_total_price .price').html( product_total.toFixed(2) + ' ' + currency);
}
});
});
</script>
<?php
}
But when the amount is became 1500+, the class 'minimum-disabled' doesn't remove. The button still has it. What can be wrong and how to fix it? CSS of this class
.minimum-disabled{
pointer-events: none!important;
background: #dfe1f0!important;
border-color: #dfe1f0!important;
color: rgba(51,51,51,.5);
cursor: no-drop!important;
}
The website is here, you can see it.
There's the needed quantity is 53. You can enter 52 and 53 to see the difference.