Core and plugin files should never be edited directly, as any updates could overwrite your changes. If you look in WooCommerce source at the get_price_html
method, there are a number of filters available to modify the output of the function.
See add_filter
in Codex for more info on adding filters to apply_filters
calls.
From get_price_html
in class-wc-product
:
return apply_filters('woocommerce_get_price_html', $price, $this);
So to add your own filter:
add_filter( 'woocommerce_get_price_html', 'wpa83367_price_html', 100, 2 );
function wpa83367_price_html( $price, $product ){
return 'Was:' . str_replace( '<ins>', ' Now:<ins>', $price );
}
Related Posts:
- Share users and WooCommerce memberships between two installations
- What’s the difference between WC() and $woocommerce
- Show only geolocated user country into Woocommerce checkout country fields
- Add product attribute to Woocommerce’s blocks in Gutenberg
- The correct way to override WooCommerce product gallery from a plugin [closed]
- How to have specific prices for some particular pin codes in woocommerce? [closed]
- How do I get the latest note on the order at woocommerce? [closed]
- Woocommerce Login Redirect not working [closed]
- global $post; in WooCommerce
- Woocommerce template single-product.php in theme folder not working
- How can i create a WooCommerce product programatically or using sql query?
- Is it safe to update WooCommerce data update?
- Output JSON object with woocommerce products
- Display description on cart page
- Which hook should I use to capture $_POST(‘password’) via profile update and password reset
- Fatal Error in WordPress WooCommerce theme “Call to undefined function wc_get_theme_slug_for_templates()”
- Problems adding in-store product managers
- differentiate hooks and filters on the same page [closed]
- Signup Form that adds customer to MailChimp, redirects to checkout, and fills in form data
- how to pass a woocommerce product name to contact form7 [closed]
- Woocommerce Subscription Pricing/Billing Schedule
- ‘profile_update’ hook alternative for WooCommerce user meta data
- How to add a user custom field into Woocommerce emails?
- WooCommerce Product URL re-writing
- Automatically running Scheduled Actions
- Hook to use when customer placing order
- Woocommerce Rest Api Categories problem [closed]
- wc-ajax=get_variation slow speed in WooCommerce
- Add custom CSS class to product images
- Calculate tax on sales price excluding discount [closed]
- One file for all virtual, downloadable product variations [closed]
- Remove “?add-to-cart=product-id” from Add to Cart URL when on the Cart page
- How to show total amount on woocommerce?
- Changing a text label into an image
- Custom Price for WooCommerce [closed]
- Disable Order Review Page when the id product
- Set both meta_query and tax_query using wp_query->set
- Is there a preset CSS class when shopping cart isn’t empty?
- How to translate text in function.php with WPML [closed]
- Woocommerce product options [closed]
- WordPress SMS API integration without plugin error
- Protecting WooCommerce Customizations with Update
- Setting WooCommerce SKU programmatically [closed]
- How to edit mobile view of my wordpress website without affecting the desktop view? [closed]
- Code specific for specific products
- Change Firstname & Lastname order in the order-processing e-mail templates
- WooCommerce: How to insert filtered attribute(s) in page title of archive?
- Multiple Pricing [closed]
- WOOF product filter prevent from loading on wordpress search result page
- Adding product on sale into specific category after creation
- Trying to run Javascript on AJAX call
- How to select the first product variant as a default?
- WooCommerce – dynamically loading checkout page using ajax not showing payment methods for guest
- Two Filter Issue [closed]
- Show notice to user based on User Meta
- Pass values to ajax
- Send Email to Custom Field in Custom Post Type when order is Completed
- Fragments to Update Cart Counter not working on homepage – Woocommerce
- WooCommerce Review Author Hook on Review Submission
- woocommerce ad custom button with custom link after add to cart for every product
- How to track product price changes?
- Woocommerce Flexslider touch functionality on desktop not working
- Filter orders in Admin area based on logged in user
- Exclude Specific Product Category for showing up in its parent category page
- How to fire a disabled WooCommerce New Order notification?
- Set up PayPal with wrong email by mistake
- Does WP-WooC support filters at database?
- How to send welcome email once user buys the subscription
- Removed Sidebar in single product page
- How to echo woocomerce attributes values in dropdown box
- Add new page in WooCommerce My Account page
- Woocommerce section name? [closed]
- how to change value return by _stock_status
- Retrieve Woocommerce Cart Url with javascript/jquery [closed]
- Tags pages for different Custom Post Types and WooCommerce Products sharing Post Tags
- woocommerce_email_recipient_new_order not triggered
- Load custom post template
- get_posts only getting most recent product
- How to only show featured products in wooCommerce using function.php function
- How to insert link, with lightbox, that opens specific page content only
- Remove plugin function and add it back in via functions.php
- deactivate product-page image slider on mobile
- Vendor Listing by Location
- Woocommerece category page showing in stock product as out of stock
- Increase product variation limit in woocommerce
- WooCommerce widget “WooCommerce Products” template [closed]
- WooCommerce show decimals in totals [closed]
- Woocommerce woocommerce_breadcrumb_defaults filter [closed]
- Woocommerce Mandatory Field on Shipping Details [closed]
- Create a shortcode to show product tag name on tag archive
- How to access Woo Commerce products from within custom theme? [closed]
- Use Homepage as “Shop” for Woocommerce [closed]
- How to display India country first in country selection drop down list in WordPress
- registration_errors not working
- Translate Woocommerce tab
- Woocommerce -> gallery images per variation without a plugin? [closed]
- Why is my WordPress admin not working
- Create bookings after subscription renewal
- Change variants URL
- Use a woocommerce hook to create a table and populate it with a query