John Davidson

php - Need help displaying specific text based on product price in woocommerce


This is what I have right now to make text display underneath the product price and information on the shop page:

add_action( 'woocommerce_after_shop_loop_item', 'bbloomer_show_free_shipping_loop', 5 );

function bbloomer_show_free_shipping_loop() {
echo '<p class="shop-badge">Orders over $99 ship FREE</p>';

And that's appearing correctly on the site.

However, I need a NEW message to appear that says "This product ships free" when a product is over $99. It needs to replace the "Orders over $99 ship FREE" that's there now if a product is over $99.

I think it's a simple function, but I can't find exactly what I need anywhere. Any help is appreciated!

My Answer:
Free shipping on orders over $50!';_}_However, I want to display different text based on the product price. For example, if the product price is less than $50, I want to display "Free shipping on orders over $50!" and if the product price is greater than $50, I want to display "Free shipping on all orders!". How can I modify the code to achieve this?

Rate this post

3 of 5 based on 4476 votes


© 2024 - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us