• Resolved lastnoob

    (@lastnoob)


    I would like to change the default ‘Coupon “%s” does not exist!’ error message of Woocommerce. However, this seems to be a much harder task than I imagined – found no trace of it in the docs.

    The relevant part of the woocommerce code is located in /includes/class-wc-coupon.php. How do I change it from my child theme’s functions.php? Obviously I do not want to change the plugin’s file directly.

    Is there a hook or filter or something that I could use? I couldn’t find them in the docs.

    Thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello,
    @lastnoob you can use the following filter.
    apply_filters( 'woocommerce_coupon_error', $err, $err_code, $this )

    Thread Starter lastnoob

    (@lastnoob)

    @indreshyadav Thank you so much!!

    Could you give me an example, please as I’m not sure where should I actually change the text and google fails me ??

    Thank you again, I appreciate it!

    Hello,
    @lastnoob
    you can use following code.

    add_filter( 'woocommerce_coupon_error','coupon_error_message_change',10,3 );
    
    public function coupon_error_message_change($err, $err_code, $parm )
    {
       switch ( $err_code ) {
    	case 105:
    	/* translators: %s: coupon code */
    	$err = sprintf( __( 'Coupon "%s" does not test!', 'woocommerce' ), $parm->get_code() );
           break;
     }
    return $err;
    }

    you can modify message.

    • This reply was modified 4 years, 9 months ago by indreshyadav.
    • This reply was modified 4 years, 9 months ago by indreshyadav.
    • This reply was modified 4 years, 9 months ago by indreshyadav.

    Hello,
    @lastnoob if your problem is solved, so please resolved this ticket.

    Plugin Support Yuki K a11n.

    (@yukikatayama)

    Automattic Happiness Engineer

    We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Change Coupon notice/error message’ is closed to new replies.