add_action( 'woocommerce_check_cart_items', 'required_min_cart_subtotal_amount' );
function required_min_cart_subtotal_amount() {
// HERE Set minimum cart total amount
$minimum_amount = 200;
// Total (before taxes and shipping charges)
$cart_subtotal = WC()->cart->subtotal;
// Add an error notice is cart total is less than the minimum required
if( $cart_subtotal < $minimum_amount ) {
// Display an error message
wc_add_notice( '<strong>' . sprintf( __("A minimum total purchase amount of %s is required to checkout."), wc_price($minimum_amount) ) . '</strong>', 'error' );
}
}
General
Change WooCommerce Archive products number per page
add_filter( 'loop_shop_per_page', 'my_new_products_per_page', 9999 );
function my_new_products_per_page( $pr_per_page ) {
$pr_per_page = 16;
return $pr_per_page;
}
Change “$0.00” to “Free”
add_filter( 'woocommerce_get_price_html', 'ecommercehints_change_zero_price_display', 10, 2 );
function ecommercehints_change_zero_price_display( $price, $product ) {
if (empty($product->get_price()) || $product->get_price() == 0) { // If price is not entered or set to 0
$price = __( 'Free', 'woocommerce' );
}
return $price;
}
Change “Add to cart” text
add_filter( 'woocommerce_product_add_to_cart_text', function( $text ) {
if ( 'Add to cart' == $text ) {
$text = __( 'Buy Now', 'woocommerce' );
}
return $text;
} );