Hi @kingcooper,
You can use the woocommerce_checkout_process
hook to prevent checkout if the shipping cost is below $1.97 and display an error message. Simply add the following code to your theme’s functions.php
file or a custom plugin:
add_action('woocommerce_checkout_process', function() {
$shipping_total = WC()->cart->get_shipping_total();
if ($shipping_total < 1.97) {
wc_add_notice('Shipping cost must be at least $1.97 to proceed with checkout.', 'error');
}
});
This function retrieves the total shipping cost using WC()->cart->get_shipping_total();
. If the amount is below $1.97, it prevents checkout and displays an error message. Please note that the code above is a sample code. If it doesn’t work for you, you may need to consult with an expert as giving customization codes is beyond our support scope.
Alternatively, you can use a conditional plugin to enforce this rule without coding. You can find relevant plugins by searching for “Conditional Shipping and Payments WooCommerce” or checking this quick search: Google Search.