Translate the default error messages
-
Hi!
If Stripe responds with an “card_declined” code, it shows to the user “Your card was declined”, as on: http://screencast.com/t/2ehhsQ9g1P5F
I wish to change (or just translate) this message and explain the client what to do and HOW to solve it. “Your card was declined” is rather vague and a lot of clients get stuck don’t know what to do next.
Can you tell me how to do this? Does your plugin support these translations? Or planning to do so?
Looking forward to your reply. Thanks!
Best regards
Erik Molenaar
-
Please follow this thread i have explained it there how to get on it
Thanks nazrulhassanmca, that seems like a good temporary fix š
BTW: Do you have any plans to include custom error message editing in the plugin settings?
Or even support translations?It would be a dream to customize these error messages to a custom user-friendly error message in the WordPress dashboard instead of hacking the plugin files.
Looking forward to your reply, and thanks again!
-
This reply was modified 9 years, 9 months ago by
Erik Molenaar.
I can add a filter in plugin however you will have to customise error messege according to your need
That would also be an excellent idea. So this way it is just adding the required custom error messages to functions.php?
Yes only custom error messege in functions.php will do
Awesome! Looking forward to your plugin update š
Full List Of gathered error messeges here after that filter in plugin code
add_filter('woocommerce_stripe_woocommerce_addon_error','woocommerce_stripe_woocommerce_addon_error_overide',$error) ; function woocommerce_stripe_woocommerce_addon_error_overide($body){ if($body['error']['type'] == 'invalid_request_error' ){ $error = 'Please make sure you have entered the credit card number.'; } if($body['error']['type'] == 'incorrect_number' ){ $error = 'The card number is incorrect.'; } if($body['error']['type'] == 'invalid_number' ){ $error = 'The card number is not a valid credit card number.'; } if($body['error']['type'] == 'invalid_expiry_month' ){ $error = 'The card\'s expiration month is invalid.'; } if($body['error']['type'] == 'invalid_expiry_year' ){ $error = 'The card\'s expiration year is invalid.'; } if($body['error']['type'] == 'invalid_cvc' ){ $error = 'The card\'s security code is invalid.'; } if($body['error']['type'] == 'expired_card' ){ $error = 'The card has expired.'; } if($body['error']['type'] == 'incorrect_cvc' ){ $error = 'The card\'s security code is incorrect.'; } if($body['error']['type'] == 'incorrect_zip' ){ $error = 'The card\'s zip code failed validation.'; } if($body['error']['type'] == 'card_error' ){ $error = 'The card was declined from stripe.'; } if($body['error']['type'] == 'missing' ){ $error = 'There is no card on a customer that is being charged.'; } if($body['error']['type'] == 'processing_error' ){ $error = 'An error occurred while processing the card.'; } if($body['error']['type'] == 'rate_limit' ){ $error = 'An error occurred due to requests hitting the API too quickly. Please let us know if you\'re consistently running into this error.'; } return $error ; }Full List Of gathered error messeges here after that filter added in plugin code you have to add following to functions.php
add_filter('woocommerce_stripe_woocommerce_addon_error','woocommerce_stripe_woocommerce_addon_error_overide',$error) ; function woocommerce_stripe_woocommerce_addon_error_overide($body){ if($body['error']['type'] == 'invalid_request_error' ){ $error = 'Please make sure you have entered the credit card number.'; } if($body['error']['type'] == 'incorrect_number' ){ $error = 'The card number is incorrect.'; } if($body['error']['type'] == 'invalid_number' ){ $error = 'The card number is not a valid credit card number.'; } if($body['error']['type'] == 'invalid_expiry_month' ){ $error = 'The card\'s expiration month is invalid.'; } if($body['error']['type'] == 'invalid_expiry_year' ){ $error = 'The card\'s expiration year is invalid.'; } if($body['error']['type'] == 'invalid_cvc' ){ $error = 'The card\'s security code is invalid.'; } if($body['error']['type'] == 'expired_card' ){ $error = 'The card has expired.'; } if($body['error']['type'] == 'incorrect_cvc' ){ $error = 'The card\'s security code is incorrect.'; } if($body['error']['type'] == 'incorrect_zip' ){ $error = 'The card\'s zip code failed validation.'; } if($body['error']['type'] == 'card_error' ){ $error = 'The card was declined from stripe.'; } if($body['error']['type'] == 'missing' ){ $error = 'There is no card on a customer that is being charged.'; } if($body['error']['type'] == 'processing_error' ){ $error = 'An error occurred while processing the card.'; } if($body['error']['type'] == 'rate_limit' ){ $error = 'An error occurred due to requests hitting the API too quickly. Please let us know if you\'re consistently running into this error.'; } return $error ; }The $error in the function triggers an PHP Notice in WordPress debug mode:
Notice: Undefined variable: error in /functions.php
Could this be solved by merely renaming this variable?
-
This reply was modified 9 years, 9 months ago by
Erik Molenaar.
-
This reply was modified 9 years, 9 months ago by
The topic ‘Translate the default error messages’ is closed to new replies.