Magento 2 sucess/faliure message displaying + concatenated string. - magento

Hello I am new to Magento (Magento 2.1) My problem is that when any message like sign up successfully or order successfully it is displayed word joining with + sign instead of space. like :
please help.

Provide the code where you concatenate the message. The message should be
$this->messageManager->addError( __('This is your error message.') );
//or
$this->messageManager->addError( __('Invalid %s or %s', 'login', 'password') );
//or replace with variables

Related

Show validation error for phone number format on website page odoo 12

I'm working on sign up process for the user. Where I taking the phone from the user before sign up. And I want to show the validation when wrong phone number format.
My phone number format code in controller file is below:
def passwordless_signup(self, values, qcontext):
.
.
.
if values['phone']:
phone_fields = self._get_phone_fields_to_validate()
for phone_field in phone_fields:
number = values['phone']
fmt_number = request.env['res.partner'].phone_format(number)
request.params.update({phone_field: number})
.
.
.
return request.render("auth_signup.reset_password", qcontext)
On Ubuntu Terminal, I'm getting below error and I want to show this as validation for user:
File "/opt/odoo12/odoo/addons/phone_validation/tools/phone_validation.py", line 25, in phone_parse
raise UserError(_('Invalid number %s: probably incorrect prefix') % number)
odoo.exceptions.UserError: ('Invalid number 4545545: probably incorrect prefix', '')
Thanks in advance
You have to catch the exception and add as error key with error message as the value in the qcontext dictionary to render that as warning provided to the frontend.
if values['phone']:
phone_fields = self._get_phone_fields_to_validate()
for phone_field in phone_fields:
number = values['phone']
try:
fmt_number = request.env['res.partner'].phone_format(number)
request.params.update({phone_field: number})
except Exception as e:
qcontext['error'] = str(e)
in phone_validation.py add: from odoo import exceptions and in _get_phone_fields_to_validate method add
if not {is_valid_phone}:
raise exceptions.ValidationError('Invalid number %s: probably incorrect prefix' % {your_phone_value})
else:
return {your_phone_value}

special character in message are encoded when it's delivered

I'm using Laravel-4-Nexmo package to send sms but the message is encoded on delivery .
$receiverNumber = "xxxxxxxxxxx"
$message = "hi from nexmo ? ";
$options = array( 'status-report-req' => 1 );
$Nexmo = Nexmo::sendSMS('me', $receiverNumber , $message , $options);
and received message looks like this :
hi+from+nexmo+%3F+
I would like to receive as
hi from nexmo ?
I look forward to see what could be the solution
Probably the mentioned package does not encode the given message so you should use urlencode($yourString) before using the pacckage
I do not know what was wrong with my code above, and I decided to use similar package and it works now. you can find the package here https://github.com/Artistan/nexmo

Edit joomla registration admin email

I want to change the email the admin gets when when a new user is being registered.
I want to add field he gets about the user.
I tried changing the en-GB.com_user file
(although eventually I need it in Russian, but that's besides the point)
It didn't help.
When I tried a language override, I couldn't register new users at all.
I'm still guessing I can do it through language override by adding the right text
I just don't have a clue of what to write instead of : %s \n E-mail: %s \n
what does the \n %s \n mean?
I guess that somehow I need to change the COM_USERS_EMAIL_ACTIVATE_WITH_ADMIN_ACTIVATION_BODY
but HOW and WHERE?
I have figured it out.
Find /home/joomla/public_html/components/com_users/models/registration.php
and add:
$emailBody = JText::sprintf(
'COM_USERS_EMAIL_ACTIVATE_WITH_ADMIN_ACTIVATION_BODY',
$data['sitename'],
$data['name'],
$data['email'],
$data['username'],
$data['yourdatabasecolumn'],
$data['siteurl'].'index.php?option=com_users&task=registration.activate&token='.$data['activation']
);
Find /home/joomla/public_html/language/en-GB/en-GB.com_users.ini
and add:
COM_USERS_EMAIL_ACTIVATE_WITH_ADMIN_ACTIVATION_BODY="Hello administrator,\n\nA new user has registered at %s.\nThe user has verified his email, and requests that you approve his account.\nThis email contains their details:\n\n Name : %s \n Email: %s \n Username: %s \n Yourdatabasename : %s \nYou can activate the user by clicking on the link below:\n %s \n"
everything must be in the right order

Subject in PHPmail $head gets doubled and in wrong encoding

Im using IPN to send mail to customers after a purchase. Everythings going well except one small annoying thing. When I test to buy a product with my mail as buyer the mail in my mail inbox looks like this: http://snag.gy/grrMy.jpg <- it has double subject after itself and the first one not changed into UTF-8 - why is this? And if I click on that mail suddenly only the UTF-8 coded subject will show (as intended) like this: http://snag.gy/k5VyF.jpg
Here is the PHP code that I use:
$to = filter_var($ipn_post_data[payer_email], FILTER_SANITIZE_EMAIL);
$date = date('Y-m-d');
$subject = "Tack för Ert köp! / Thank you for your order!";
$headerFields = array(
'Date: ' . date('r', $_SERVER['REQUEST_TIME']),
"Subject: =?UTF-8?Q?".imap_8bit($subject)."?=",
"From: {$to}",
"MIME-Version: 1.0",
"Content-Type: text/html;charset=utf-8"
);
mail($to, $subject, $message, implode("\r\n", $headerFields));
So the only "problem" really is that whn inbox the mails subject gets doubled with the first one with wrong encoding and it looks bad. Anyone that has input on this?
You pass $subject to mail() twice -- once in the second argument, and once in the fourth as part of $headerFields.
Try passing null as the second argument instead.

zend mail giving mail in unreadable format when using in magento

Used the following code.
$mail = new Zend_Mail();
$mail->setBodyHtml($message)
->setFrom('abc#gty.com', 'abc')
->addTo($to, 'admin')
->setSubject($subj);
This is the part i wrote.
I am getting proper html in $message. The $ variable used above are from retrieved post value. The mail which I am receiving contains contents like :
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
in the starting part rest all the mail content are fine.Thanks in advance
From myunderstanding,i conclude with this part utf-8 adding in your code
$mail = new Zend_Mail('utf-8');
$mail->setBodyHtml($message)
->setFrom('abc#gty.com', 'abc')
->addTo($to, 'admin')
->setSubject($subj);
Hope this helps you.

Resources