Why user comment is not in email order confirmation html opencart 2? - opencart2.3

I noticed that in opencart 2.3.0.2 the order confirmation for admin contains the comments from the user, and the email that the user gets doesn't.
The user gets only the text version with the comment, not the HTML version with the comment.
In 2012 2013 the problem was that the comment wasn't passed at all into the emails.
https://github.com/opencart/opencart/pull/94
https://github.com/opencart-ce/opencart-ce/issues/12
It seems the problem was solved only partially.

The solution is:
Edit:
catalog/model/checkout/order.php
Put this code:
$data['ip'] = $order_info['ip'];
$data['order_status'] = $order_status;
if ($comment && $notify) {
$data['comment'] = nl2br($comment);
} else {
$data['comment'] = '';
}
if ($comment) {
if ($order_info['comment']) {
$data['comment'] = nl2br($comment) . '<br/><br/><strong>Comment:</strong><br/>' . $order_info['comment'];
} else {
$data['comment'] = nl2br($comment);
}
} else {
if ($order_info['comment']) {
$data['comment'] = $order_info['comment'];
} else {
$data['comment'] = '';
}
}
instead of:
$data['ip'] = $order_info['ip'];
$data['order_status'] = $order_status;
if ($comment && $notify) {
$data['comment'] = nl2br($comment);
} else {
$data['comment'] = '';
}
Or you can install this mod https://www.opencart.com/index.php?route=marketplace/extension/info&extension_id=32499&filter_search=add%20comment&filter_category_id=8&filter_license=0

Related

How to change option name in Drupal 8 form element?

I have sort link 'Best' in exposed form. I want after user click this link, link title changes to 'New'
I'm try this, but it don't work:
function helper_form_views_exposed_form_alter(array &$form, FormStateInterface $form_state, $form_id) {
if($form['#id']== 'views-exposed-form-pozdravleniya-taxonomy-term-page-1') {
$form['sort_by']['#title'] = '';
$form['sort_by']['#options']['created'] = '';
if ($form['sort_by']['#value'] == 'count') {
$form['sort_by']['#options']['count'] = 'New';
}
}
}
Also I'm try this, it don't work too:
function helper_form_views_exposed_form_alter(array &$form, FormStateInterface $form_state, $form_id) {
if($form['#id']== 'views-exposed-form-pozdravleniya-taxonomy-term-page-1') {
$form['sort_by']['#title'] = '';
$form['sort_by']['#options']['created'] = '';
if ($form_state->getValue('sort_by') == 'count') {
$form['sort_by']['#options']['count'] = 'New';
}
}
}
Screenshot form dump
Try with
$form_state->getUserInput()['sort_by']

make a custom error message and prevent duplicate mail id from inserting in db

I have checked email unique in codeigniter. In else past I diplayed error. But the system error is not convenient. how to customise error...
i have tried giveng javascript alert instead of that error message... but after that alert the data are storing in database.. Actually the data should not store in database if the email is not unique..
public function add_applicants() {
// $field_name=$this->input->post('photo');
$data = $this->input->post();
$mobile = $this->db->get_where('applicants',array('mobile_number'=>$this->input->post('mobile_number')));
if($mobile->num_rows()>0)
{
throw new Exception("Mobile Number Already Registered");
}
$email = $this->db->get_where('applicants',array('email_id'=>$this->input->post('email_id')));
if($email->num_rows()>0)
{
throw new Exception("Email_id Already Registered");
}
$school_id= $this->input->post('school_code');
$name_of_exam= $this->input->post('name_of_exam');
$name= $this->input->post('name_candiadte');
switch($name_of_exam){
case '1':
$exam='NMMS';
break;
case '2':
$exam='NTS';
break;
}
$school_code = $this->Welcome_Model->getschoolData($school_id);
if (isset($_FILES['photo']) == 1) {
$config['upload_path'] = FCPATH . 'uploads/'. $school_code->name_of_the_school.'/'. $exam ;
$this->upload_path = $config['upload_path'];
if ($this->validate_upload_path() == TRUE) {
$config['upload_path'] = $this->upload_path;
// print_r($this->upload_path) ;
// die();
}
$config['allowed_types'] = 'jpg';
$config['max_size'] = 2000;
$config['remove_spaces'] = TRUE;
$config['overwrite'] = true;
$config['file_name'] = $name.'-'.date('Ymdhis') . '.jpg';
$file_name = $config['file_name'];
$this->load->library('upload', $config);
$this->upload->initialize($config);
if (!$this->upload->do_upload('photo')) {
$this->upload->display_errors();
}
}
$data['photo'] = $file_name;
$insetapplicants = $this->Welcome_Model->insertApplicants($data);
if ($insetapplicants == 'Success') {
echo "<script>
alert('New Applicants Added Successfully');
// window.location.href='dashboard';
</script>";
}
}

How to set expiration of newsletter confirmation link in magento 2

I have newsletter in my magento website. I have enable confirmation before subscription from admin configuration. User are getting confirmation link in mail.
But I want to set expiry of that link. Is magento provide default config ?
How can I set expiry of that link ?
I found the solution. I just did two things.
1) Add created_at field in newsletter_subscriber table.
2) Overwrite the following file
vendor/magento/module-newsletter/Model/Subscriber.php
to
Company/name/Model/Subscriber.php
Overited Subscriber.php file code
public function confirm($code) // existing function
{
$id = $this->getId();
if ($this->validateConfirmLinkToken($id, $code)) {
if ($this->getCode() == $code) {
$this->setStatus(self::STATUS_SUBSCRIBED)
->setStatusChanged(true)
->save();
$this->sendConfirmationSuccessEmail();
return true;
}
return false;
}
}
private function validateConfirmLinkToken($customerId, $code) //check validation for token
{
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$messageManager = $objectManager->get('Magento\Framework\Message\ManagerInterface');
if (empty($customerId) || $customerId < 0) {
$this->_messageManager->addError('Sorry you have not rigts to access this page');
return false;
}
if (!is_string($code) || empty($code)) {
$params = ['fieldName' => 'code'];
//$messageManager->addError('Sorry Your subscription confirmation code is not valid.');
return false;
}
$dcode = $this->getCode();
$dcreated_at = $this->getCreatedAt();
if (trim($dcode) != trim($code)) {
//$messageManager->addError('Sorry Your subscription confirmation code is mismatch.');
return false;
} elseif ($this->isConfirmationLinkTokenExpired($dcode, $dcreated_at)) {
//$messageManager->addError('Sorry Your subscription confirmation code is expired.');
return false;
}
return true;
}
public function isConfirmationLinkTokenExpired($dcode, $dcreated_at) // check expiration token
{
if (empty($dcode) || empty($dcreated_at)) {
return true;
}
$expirationPeriod = '720';
$currentTimestamp = (new \DateTime())->getTimestamp();
$tokenTimestamp = (new \DateTime($dcreated_at))->getTimestamp();
if ($tokenTimestamp > $currentTimestamp) {
return true;
}
$hourDifference = floor(($currentTimestamp - $tokenTimestamp) / (60 * 60));
if ($hourDifference >= $expirationPeriod) {
return true;
}
return false;
}
Hope it will helps to many.
Thanks.

TYPO3 Formhandler Finisher_Mail multiple receivers with to_email + addTolist

I have a formhandler-form and I'm trying to find a good way to send an admin mail to multiple recipients with one mail finisher. The Problem is the recipients are variable. The recipients of the mail depends on the selection of 10 checkboxes in the form. Each selection should have the effect that a new recipient is added. At the moment it's solved with 10 mail finisher like
if {
1 {
conditions {
OR1.AND1 = checkbox_1 = 1
}
isTrue {
finishers.1.config.admin.to_email = p1#mail.com
}
else {
finishers.1.config.admin.disable = 1
}
}
2 {
conditions {
OR1.AND1 = checkbox_2 = 1
}
isTrue {
finishers.2.config.admin.to_email = p2#mail.com
}
else {
finishers.2.config.admin.disable = 1
}
}
...
Is there a better way? I tried to solve this with one finisher and the usage of addToList
if {
1 {
conditions {
OR1.AND1 = checkbox_1 = 1
}
isTrue {
finishers.1.config.admin.to_email := addToList(p1#mail.com)
}
}
2 {
conditions {
OR1.AND1 = checkbox_2 = 1
}
isTrue {
finishers.1.config.admin.to_email := addToList(p2#mail.com)
}
}
...
But it doesn't work. With 4 selected boxes it is still one recipient. Why?
don't forget: typoscript is a configuration language, no programming language.
so you need another logic to build up the multiple receivers.
something like:
:
finishers.1.config.admin.to_email = COA
finishers.1.config.admin.to_email {
10 = TEXT
10.value = p1#mail.com,
10.if.isTrue.data = checkBox_1
20 = TEXT
20.value = p2#mail.com,
20.if.isTrue.data = checkBox_2
30 = TEXT
30.value = p3#mail.com,
30.if.isTrue.data = checkBox_3
stdWrap.substring = 0,-1
}

Login Page Hash issue UPDATE

I am having a issue with my login page reading a function to login
on my register page which I'm proud to say works perfect
this is my password hash code
$password = password_hash($password, PASSWORD_BCRYPT);
my login page has 2 fields
email &
password
I have re cleaned my code and solved the issue some what
functions are working
when I enter email and password it triggers
Warning! Email or Password Incorrect
plus an error at the top
Notice: Undefined index: password in C:\Program Files (x86)\Zend\Apache2\htdocs\CMS\functions\functions.php on line 249
this is line 249
$db_password = $row['password'];
/* Validate Login */
function validate_login()
{
$errors = [];
if ($_SERVER['REQUEST_METHOD'] == "POST") {
$email = clean($_POST['email']);
$password = clean($_POST['password']);
if (empty($email)) {
$errors[] = "Email Required";
}
if (empty($password)) {
$errors[] = "Password Required";
}
if (! empty($errors)) {
foreach ($errors as $error) {
echo validation_errors($error);
}
} else {
if (login_user($email, $password)) {
redirect("../account/profile.php");
} else {
echo validation_errors("Email or Password Incorrect");
}
}
}
} // End Function
/* User Login */
function login_user($email, $password)
{
$sql = "SELECT user_pwd, uid FROM userss WHERE user_email = '" . escape($email) . "'";
$result = query($sql);
if (row_count($result) == 1) {
$row = fetch_array($result);
$db_password = $row['password'];
if (hash_algos($password) == $db_password) {
return true;
} else {
return false;
}
}
}// End Function
It looks like you are missing a closing bracket for your validate_login() function so it is defining the login_user() function only after the first function is called. Therefore as you progress through your validate_login() function you call the login_user() function before it is created since it is created after the if statement completes.
OK I just figured out the issue
if (hash_algos($password) == $db_password) {
return true;
} else {
return false;
}
changed it to this
if(password_verify($password, $db_password)){
return true;
} else {
return false;
}