skip to Main Content

I want to replace a text on my WordPress website enclosed in p tag as follows:

<div class="uael-mc-dropdown_items">
<p class="woocommerce-mini-cart__empty-message">No products in the cart.</p>
</div>

I want to replace the "No products in the cart." text with "No courses in my bag."

Is there any way to do so using js, CSS, or adding some code in my theme functions.php?

3

Answers


  1. you can do this by using js, i added a timeout function that u see the difference, but u just need this one line inside the timeout function

    setTimeout(()=>{
        document.querySelector('.woocommerce-mini-cart__empty-message').innerHTML = 'No courses in my bag';
    },800)
    <div class="uael-mc-dropdown_items">
    <p class="woocommerce-mini-cart__empty-message">No products in the cart.</p>
    </div>
    Login or Signup to reply.
  2. You can use this script tag to override the content of the inner text as you mentioned

    <body>
    .
    .
    .
    <script>
    document.getElementsByClassName('woocommerce-mini-cart__empty- 
    message').innerText ="No courses in my bag.";
    </script>
    </body>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search