AI Verified

Name

Change sales badge text for specific product

About

Change the text of the sales badge on a specific product

Language

PHP

Rating

Voted: 0 by 0 user(s)

How to Setup Snippet

1. Make sure you have set a sales price on the product in question 2. Find the id of the product where you want to change the badge text and set that on line #3 3. Change the text on line #4 from Black Friday Sale! to whatever you want / need the default woocommerc text here is "Sale"

Codevault

George Snippet Library

Scroll down to see more snippets from this codevault.

Wordpress Compatability

The author has indicated that this snippet is compatable up to wordpress version: 6.1

Our AI bot has checked this snippet is compatable up to wordpress version: 6.1

Code Snippet Plugin Sync

Free & Pro

Download this snippet by clicking the download button, then head over to the Code Snippet Plugin settings in your wordpress admin dashboard, select the import menu then upload this file to import into your wordpress site.

Pro Only (Coming Soon)

You will be able to click a button and sync this snippet to your wordpress site automatically and from your dashboard manage all code snippets across all your wordpress sites that have the Code Snippets Pro plugin installed.

History

Last modified:

13/11/2022

Important Note

This snippet has the following status:

AI Verified

This snippet has been tested by our AI bot, see any comments below.

AI Bot Comments:

Found 0 vulnerabilities

Change sales badge text for specific product

 
                    
1function gncy_custom_sales_badge_text($text, $post, $_product) {
2 global $product;
3 if ( $product->get_id() == 1703 ) {
4 $html = '<span class="onsale">Black Friday Sale!</span>';
5 return $html;
6 }
7}
8 
9add_filter( 'woocommerce_sale_flash', 'gncy_custom_sales_badge_text', 10, 3);

0

Related Snippets

Please see some snippets below related to this snippet..

WooCommerce

AI Verified

0

Display All Products Purchased by User

Added: 1 year ago

Last Updated: 1 year ago

WooCommerce

AI Verified

1

WooCommerce Disable Payment Gateway Based On Shipping Method

Added: 1 year ago

Last Updated: 2 weeks ago

If you do not have the facility to take payments other than cash for in-person shipping methods like local pickup, you may wish to disable the appropriate payment gateways and force the customer to pa...

WooCommerce

AI Verified

0

WooCommerce Custom Checkbox Field For The Product Editor

Added: 1 year ago

Last Updated: 1 year ago

This guide shows you how to create a custom checkbox field type in the product editor of WooCommerce. The Sold Individually field is an example checkbox field. A custom checkbox field allows your shop...

Other Snippets in this Codevault

These are some popular snippets from this users codevault..

WooCommerce

AI Verified

5

Delete Woocommerce images after deleting product

Added: 1 year ago

Last Updated: 1 month ago

Automatically Delete WooCommerce Images After Deleting a Product. If you use the same image of multiple products the image will not be deleted for those

WooCommerce

AI Verified

2

Add Alphabetical Sorting to Woocommerce

Added: 1 year ago

Last Updated: 3 weeks ago

Sorts products alphabetically in Woocommerce

WooCommerce

AI Verified

1

Remove categories from the shop and other pages in Woocommerce

Added: 1 year ago

Last Updated: 1 year ago

Remove any categories from WooCommerce frontend