skip to Main Content

I am trying to insert this code to > Elementor > Custom Code to change the Sale Badge Text in WooCommerce

add_filter(‘woocommerce_sale_flash’, ‘edit_sale_badge’); function edit_sale_badge() { return ‘TEXT-GOES-HERE’; }

From this page: https://pluginsforwp.com/blog/change-sale-badge-woocommerce/ – But I dont know how to make it work, can anyone help me? Can PHP be added to Elementor custom code? Thanks!

wrap the code with th PHP but getting the error: php special characters must be escaped

2

Answers


  1. You cant insert php in Elementor Custom Code area.. You must add this via functions.php in your child theme. Or you can add this via other plugins (2).

    Look also here: https://elementor.com/help/custom-code-pro/

    (2): https://de.wordpress.org/plugins/insert-php-code-snippet/

    Login or Signup to reply.
  2. Did you wrap your code with

    <?php and ?> 
    

    So that it looks like the following:

    <?php
    add_filter('woocommerce_sale_flash', 'edit_sale_badge');
    function edit_sale_badge() {
        return 'TEXT-GOES-HERE';
    }
    ?>
    

    In your Link, they add it to the Themes Functions:
    functions.php
    Why not do it also there?

    Note: there is a difference between the following symbols `, ´ and ‘. You want to use the last one.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search