• Resolved CyberMama

    (@cybermama)


    Hi – with the pro version is it possible the change the error messages that display if someone selects an invalid payment/shipping method?

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Soft79

    (@josk79)

    No, but you can use this filter for that:

    
    add_filter( 'woocommerce_coupon_message', 
      function( $msg, $msg_code, $coupon ) {
        // ...change message if required...
        return $msg; 
      }, 10, 3
    );
    
    
    Thread Starter CyberMama

    (@cybermama)

    Ah ok – thanks. Would I paste this is the functions.php file or…
    I tried changing the message in the plugin and it broke the site entirely!

    Plugin Author Soft79

    (@josk79)

    Yes, in functions.php. You probably need to change this snippet a bit (if you have the php knowledge), but this is the idea:

    
    add_filter( 'woocommerce_coupon_message', 
      function( $msg, $msg_code, $coupon ) {
        if ($msg_code == WJECF_Controller::E_WC_COUPON_PAYMENT_METHOD_NOT_MET)
          $msg = "That is not the right payment method!!!!";
        if ($msg_code == WJECF_Controller::E_WC_COUPON_SHIPPING_METHOD_NOT_MET)
          $msg = "That is not the right shipping method!!!!";
        return $msg; 
      }, 10, 3
    );
    
    Plugin Author Soft79

    (@josk79)

    Yes, in functions.php. You probably need to change this snippet a bit (if you have the php knowledge), but this is the idea:

    
    add_filter( 'woocommerce_coupon_message', 
      function( $msg, $msg_code, $coupon ) {
        if ($msg_code == WJECF_Controller::E_WC_COUPON_PAYMENT_METHOD_NOT_MET)
          $msg = "That is not the right payment method!!!!";
        if ($msg_code == WJECF_Controller::E_WC_COUPON_SHIPPING_METHOD_NOT_MET)
          $msg = "That is not the right shipping method!!!!";
        return $msg; 
      }, 10, 3
    );
    
    Thread Starter CyberMama

    (@cybermama)

    Thanks very much.

    I’m not massively good at php to be honest – could I put this in the theme’s functions.php and just amend the message? Would it work?
    I guess I can try… ??

    Plugin Author Soft79

    (@josk79)

    Yeah, should work. Good luck!

    Thread Starter CyberMama

    (@cybermama)

    So I added this to the bottom of the child theme’s functions.php file. It didn’t break the site this time (like the last time I tried to edit the code in the plugin itself) but it didn’t change the error message either… any idea where I might be going wrong? Is the new message too long?

    add_filter( ‘woocommerce_coupon_message’,
    function( $msg, $msg_code, $coupon ) {
    if ($msg_code == WJECF_Controller::E_WC_COUPON_PAYMENT_METHOD_NOT_MET)
    $msg = “Not valid. Please choose a different payment method!”;
    if ($msg_code == WJECF_Controller::E_WC_COUPON_SHIPPING_METHOD_NOT_MET)
    $msg = “Free shipping not available with coupon. Please refresh page and choose a different shipping method.”;
    return $msg;
    }, 10, 3
    );

    Plugin Author Soft79

    (@josk79)

    Try replacing the 10 with 999

    Thread Starter CyberMama

    (@cybermama)

    Nope… still not happening… am editing in TextEdit and it tends to change the ” symbols but I’m checking they’re fixed. Shouldn’t change again after saving and uploading to server should they?

    Plugin Author Soft79

    (@josk79)

    Hi,

    I just tested in one of my environments. This should work better:

    add_filter( 'woocommerce_coupon_error', 
      function( $err, $err_code, $coupon ) {
        if ($err_code == WJECF_Controller::E_WC_COUPON_PAYMENT_METHOD_NOT_MET)
          $err = "Not valid. Please choose a different payment method!";
        if ($err_code == WJECF_Controller::E_WC_COUPON_SHIPPING_METHOD_NOT_MET)
          $err = "Free shipping not available with coupon. Please refresh page and choose a different shipping method.";
        return $err; 
      }, 999, 3
    );
    
    Thread Starter CyberMama

    (@cybermama)

    Perfect – you’re an absolute star. Thank you so much.

    Plugin Author Soft79

    (@josk79)

    You’re welcome! Thank you for the kind words.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Change message & work with min spend’ is closed to new replies.