Display a “Free Shipping” label directly in the WooCommerce product loop for items that individually meet the free shipping threshold.
This snippet checks the product’s gross price and compares it to the minimum amount defined in WooCommerce’s Free Shipping method settings. If the product price alone qualifies for free shipping, the label is shown immediately in the product list – no cart interaction required.
add_action( 'woocommerce_after_shop_loop_item', 'custom_show_free_shipping_label_inline', 11 );
function custom_show_free_shipping_label_inline() {
global $product;
if ( ! $product->is_virtual() && $product->is_in_stock() ) {
$product_price = (float) wc_get_price_including_tax( $product );
$free_shipping_min_amount = 0;
// Ingyenes szállítási határ lekérdezése adminból
$zones = WC_Shipping_Zones::get_zones();
foreach ( $zones as $zone ) {
foreach ( $zone['shipping_methods'] as $method ) {
if ( $method->id === 'free_shipping' && isset( $method->min_amount ) && $method->enabled === 'yes' ) {
$free_shipping_min_amount = (float) $method->min_amount;
break 2;
}
}
}
if ( $free_shipping_min_amount > 0 && $product_price >= $free_shipping_min_amount ) {
echo '<div class="free-ship">Díjmentes szállítás</div>';
}
}
}
What it does
- Adds a Free Shipping label in the shop / category product loop
- Uses the actual free shipping minimum from WooCommerce settings
- Checks the product’s tax-inclusive price
- Excludes virtual products
- Only shows for in-stock items
When to use
- You offer free shipping above a certain order value
- You want to highlight products that already qualify on their own
- You want clearer shipping incentives directly on listing pages
Notes
- The label markup (
.free-ship) can be styled freely via CSS - If you use multiple shipping zones, this snippet takes the first active free shipping method it finds
- For variable products, this checks the displayed price, not per-variation thresholds
Reviews
There are no reviews yet.