Drop-down country list in Contac Us

Open to all! Ask other shopowners for help.
Post Reply
Tanya
Member
Posts: 19
Joined: Tue Mar 09, 2021 3:16 pm
Phoenix Version:
Has thanked: 9 times

Drop-down country list in Contac Us

Post by Tanya »

I would like to add drop-down country list in Contact Us page. Not sure how to do that.

Now, I have copied contact_us.php in to templates/override and copy Full Name div and changed to Country. So I only have input field for Country not dropdown.
Last edited by Tanya on Wed Jun 15, 2022 5:41 am, edited 2 times in total.


Join The Code Co-op to get access to your library in the Code Co-op Forum
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Drop-down country list in Contac Us

Post by ecartz »

You can see an example with a dropdown at https://github.com/CE-PhoenixCart/Phoen ... L182..L187

Code: Select all

$input = new Select($name, array_merge(
  [['id' => '', 'text' => PULL_DOWN_DEFAULT]],
  $GLOBALS['db']->fetch_all("SELECT countries_id AS id, countries_name AS text FROM countries")
));
Tanya
Member
Posts: 19
Joined: Tue Mar 09, 2021 3:16 pm
Phoenix Version:
Has thanked: 9 times

Re: Drop-down country list in Contac Us

Post by Tanya »

@ecartz Thank you very much. I can add drop-down country list in Contac Us and also include country name in email which send from contact_us.php

For email which send from contact_us.php.
According to https://github.com/CE-PhoenixCart/Phoen ... y-to-email, I have set E-Mail From: noreply@mysite.com. And in email.php I have added my email in Reply-To. So Reply-To have 2 email addresses, my email and customer email

How to set send the mail to 2 email addresses, my email and customer email.
User avatar
burt
Core Team
Posts: 4550
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 times

Re: Drop-down country list in Contac Us

Post by burt »

You may have been able to do this with a Hook (rather than using a template file).

I'll try to make such a hook as it'll be good to see how it could (in theory) be done (obviously if it does then work, the hook could be replicated to add in other data to the contact_us form).

If I make it, I'll upload it to this thread for testing.
I am not here to build for you.
I am here to build with you. Let's help each other.
User avatar
burt
Core Team
Posts: 4550
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 times

Re: Drop-down country list in Contac Us

Post by burt »

Tanya wrote: Mon Jun 13, 2022 3:03 pm How to set send the mail to 2 email addresses, my email and customer email.
Add similar after this piece:

// to store owner from customer
Notifications::mail(STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, sprintf(EMAIL_SUBJECT, STORE_NAME), $enquiry, $name, $email_address);

as so:

// to customer from store owner
Notifications::mail($name, $email_address, sprintf(EMAIL_SUBJECT, STORE_NAME), $enquiry, $name, $email_address, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);

I don't quite see why the customer would need to have an email sent to them containing the data they just gave you, as they probably know what they wrote :D But, it's your shop and your needs...the above is how I may do it.
I am not here to build for you.
I am here to build with you. Let's help each other.
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Drop-down country list in Contact Us

Post by ecartz »

Tanya wrote: Mon Jun 13, 2022 3:03 pm How to set send the mail to 2 email addresses, my email and customer email.
The easiest way is to send two copies of the email, like checkout and newsletters do.

But it's a bad idea to set up your Contact Us form to send emails to an email address entered in the form. Because that means that a spammer can use your form to send emails as if they were from you. It works during checkout because

1. The prospective spammer can't enter arbitrary content.
2. It requires a payment. And a spammer won't want to waste a perfectly good stolen credit card on sending a single spam email.

The Contact Us form does accept arbitrary content and doesn't require registration much less an order payment. It should not send to the customer (except possibly a form email like "Thank you for submitting a message.").
User avatar
burt
Core Team
Posts: 4550
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 times

Re: Drop-down country list in Contac Us

Post by burt »

Hook, completely untested, but looks like it should work to add the "Customer Location" to the email.
includes.zip
Note:
I am not saying this is the right way or the best way to add in extra data to the email.
It is simply a way that you may or may not have thought of.
You do not have the required permissions to view the files attached to this post.
I am not here to build for you.
I am here to build with you. Let's help each other.
Tanya
Member
Posts: 19
Joined: Tue Mar 09, 2021 3:16 pm
Phoenix Version:
Has thanked: 9 times

Re: Drop-down country list in Contac Us

Post by Tanya »

But it's a bad idea to set up your Contact Us form to send emails to an email address entered in the form. Because that means that a spammer can use your form to send emails as if they were from you.
@ecartz Thank you very much for your explanation. I haven't thought about it.


Hook, completely untested, but looks like it should work to add the "Customer Location" to the email.
@burt It worked like a charm! I never thought to use a hook this way.

In email the "Customer Location" show under the enquiry, is it possible to move it up to show before enquiry.
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Drop-down country list in Contac Us

Post by ecartz »

Tanya wrote: Mon Jun 13, 2022 8:33 pm In email the "Customer Location" show under the enquiry, is it possible to move it up to show before enquiry.
Change to

Code: Select all

    return $GLOBALS['enquiry'] = sprintf(CUSTOMERS_LOCATION, Country::fetch_name(Text::input($_POST['country']))) . $GLOBALS['enquiry'];
Alternately, change to

Code: Select all

    return $GLOBALS['enquiry'] = sprintf(CUSTOMERS_LOCATION, $GLOBALS['enquiry'], Country::fetch_name(Text::input($_POST['country'])));
and change the language constant appropriately. E.g.

Code: Select all

const CUSTOMERS_LOCATION = "Customers Location: %2$s\n\n%1$s";


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply