Forums / Templates, Stylesheets, Page Layout / Need a bit of PHP help (probably very easy!)

Need a bit of PHP help (probably very easy!)

Views: 1,474

Results 1 to 11 of 11
22 Feb 2014, 3:21 AM
#1
brightgirl avatar

brightgirl

New Zenner

Join Date:
Feb 2008
Location:
Ann Arbor, MI
Posts:
26
Plugin Contributions:
0

Need a bit of PHP help (probably very easy!)

I am customizing some of the text in the welcome email (includes/languages/english/CUSTOM/create_account.php)

It is 99% doing what I want, except for the fact that when the email comes through to the user, the words "sign up!" do not appear as a clickable link to https://www.example.com.

The other links in the email DO come through as clickable links, so I'm trying to figure out what I did wrong with my link that it's not working. Like I said, probably a super easy question for someone who's a pro with PHP!

Here is the relevant line of code (I can give the whole thing if necessary, but I'm pretty sure my mistake is in this line, I think?)

define('EMAIL_TEXT', 'You are now registered with the store. Along with purchasing products and services you can also:' . "\n\n<ul>" . '<li>-View your Order History.' . "\n\n" . '<li>-Save items in your Shopping Cart until you remove them or check out.' . "\n\n" . '<li>-Keep more than one address on file in case you want to send a gift to someone.' . "\n\n" . '<li>-Review products to help others make the best decisions about products and services' . "\n\n</ul>" . 'Also, if you are not already on my email list for weekly tips, recipes, support and inspiration, please <a href="http://www.example.com">sign up!</a>' . "\n\n");

Any help greatly appreciated. I've been staring at it for two hours and I'm growing weary of having to delete/set up my "new user" every single time I test it! :sleepy:

22 Feb 2014, 3:40 AM
#2
bislewl avatar

bislewl

Totally Zenned

Join Date:
Dec 2011
Location:
Wisconsin, USA
Posts:
674
Plugin Contributions:
12

Re: Need a bit of PHP help (probably very easy!)

is it possible that it's the email program that is making them clickable?

22 Feb 2014, 3:48 AM
#3
brightgirl avatar

brightgirl

New Zenner

Join Date:
Feb 2008
Location:
Ann Arbor, MI
Posts:
26
Plugin Contributions:
0

Re: Need a bit of PHP help (probably very easy!)

Well, yes, the email program should take all the links and make them clickable (blue in my email program).

The other links in the welcome email message ("please email us at [email protected]", the link to the store under the signature, and the link to the store email in the 2nd to last para all DO come through as clickable. It's only the one I created that doesn't, so that's why I'm assuming I have some incorrect syntax.

I guess I should have included a bit more of the code so you can see the links that ARE working, in addition to the one I create that does not.

define('EMAIL_TEXT', 'You are now registered with the store. Along with purchasing products and services you can also:' . "\n\n<ul>" . '<li>-View your Order History.' . "\n\n" . '<li>-Save items in your Shopping Cart until you remove them or check out.' . "\n\n" . '<li>-Keep more than one address on file in case you want to send a gift to someone.' . "\n\n" . '<li>-Review products to help others make the best decisions about products and services' . "\n\n</ul>" . 'Also, if you are not already on my email list for weekly tips, recipes, support and inspiration, please <a href="http://www.example.com">sign up!</a>' . "\n\n");
define('EMAIL_CONTACT', 'For any support with the store, please email us at: <a href="mailto:' . STORE_OWNER_EMAIL_ADDRESS . '">'. STORE_OWNER_EMAIL_ADDRESS ." </a>\n\n");
define('EMAIL_GV_CLOSURE', "\n" . 'Warmly,' . "\n\n" . STORE_OWNER . "\nFamily Wellness Coach\n\n". '<a href="' . HTTP_SERVER . DIR_WS_CATALOG . '">'.HTTP_SERVER . DIR_WS_CATALOG ."</a>\n\n");

// email disclaimer - this disclaimer is separate from all other email disclaimers
define('EMAIL_DISCLAIMER_NEW_CUSTOMER', 'This email address was given to us by you or by one of our customers. If you did not signup for an account, or feel that you have received this email in error, please send an email to %s ');
22 Feb 2014, 3:52 AM
#4
bislewl avatar

bislewl

Totally Zenned

Join Date:
Dec 2011
Location:
Wisconsin, USA
Posts:
674
Plugin Contributions:
12

Re: Need a bit of PHP help (probably very easy!)

Have you tried replacing?
<a href="http://www.example.com">
with:
<a href="' . HTTP_SERVER . DIR_WS_CATALOG . '">

22 Feb 2014, 4:06 AM
#5
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: Need a bit of PHP help (probably very easy!)

brightgirl:

It is 99% doing what I want, except for the fact that when the email comes through to the user, the words "sign up!" do not appear as a clickable link
Any help greatly appreciated

Try escaping the quotes:

Eg: Change

<a href="http://www.example.com">sign up!</a>'

to

<a href=\"http://www.example.com\">sign up!</a>'

Cheers
RodG

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

22 Feb 2014, 12:48 PM
#6
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,119
Plugin Contributions:
56

Re: Need a bit of PHP help (probably very easy!)

It might be the unordered list that's throwing the link off; you need to close the <li> tags:

define('EMAIL_TEXT', 'You are now registered with the store. Along with purchasing products and services you can also:' . "\n\n<ul>" . '<li>-View your Order History.</li>' . "\n\n" . '<li>-Save items in your Shopping Cart until you remove them or check out.</li>' . "\n\n" . '<li>-Keep more than one address on file in case you want to send a gift to someone.</li>' . "\n\n" . '<li>-Review products to help others make the best decisions about products and services</li>' . "\n\n</ul>" . 'Also, if you are not already on my email list for weekly tips, recipes, support and inspiration, please <a href="http://www.example.com">sign up!</a>' . "\n\n");
22 Feb 2014, 3:25 PM
#7
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Need a bit of PHP help (probably very easy!)

I have seen functioning code before with incomplete <li> tags. Apparently browsers will try to make incomplete HTML work rather than throw it out. I think it used to be common to leave tags hanging, and there is still legacy code floating around and being reused.

22 Feb 2014, 3:34 PM
#8
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,119
Plugin Contributions:
56

Re: Need a bit of PHP help (probably very easy!)

gjh42:

I have seen functioning code before with incomplete <li> tags. Apparently browsers will try to make incomplete HTML work rather than throw it out. I think it used to be common to leave tags hanging, and there is still legacy code floating around and being reused.
Agreed, but this is regarding email viewers which can have their own peculiarities.

23 Feb 2014, 1:11 AM
#9
brightgirl avatar

brightgirl

New Zenner

Join Date:
Feb 2008
Location:
Ann Arbor, MI
Posts:
26
Plugin Contributions:
0

Re: Need a bit of PHP help (probably very easy!)

So, first I tried RodG's suggestion of escaping the quotes in the link. That had no effect.

Then I tried closing all the li tags per lat9's suggestion - actually, I had thought it was strange that they weren't closed in the original code! - but still no effect.

Just for kicks, I also tried bislewl's suggestion, although the link I need there is not a link to the store home page, but a link to the home page of the entire website that contains the store.

So, I STILL don't know what's wrong. It's extra frustrating that there doesn't seem to be a way to view the source code of an email so I can see what it is even doing?? I tried View > Message > Raw Source in Apple Mail but didn't show the HTML code that is behind the email, just all the headers and stuff.

I think my next step will be to create a user account for my husband so that he gets the welcome email and see if it looks any different in his email program (probably not, but it's worth a try)

I am still holding out hope that maybe someone will see this and spot something. It makes no sense that the other links in the email come through as links just fine, but the one I created doesn't!

23 Feb 2014, 1:18 AM
#10
brightgirl avatar

brightgirl

New Zenner

Join Date:
Feb 2008
Location:
Ann Arbor, MI
Posts:
26
Plugin Contributions:
0

Re: Need a bit of PHP help (probably very easy!)

Update: In my husband's email the sign up link is still not clickable NOR is the mailto link for the store's contact email (that was clickable in my email program, but perhaps that is just a difference in the way mail programs handle mailto links). The store link at the bottom IS clickable in his email as well.

So I'm still thinking SOMETHING has got to be wrong with the way I constructed the sign up link...

23 Feb 2014, 1:43 AM
#11
brightgirl avatar

brightgirl

New Zenner

Join Date:
Feb 2008
Location:
Ann Arbor, MI
Posts:
26
Plugin Contributions:
0

Re: Need a bit of PHP help (probably very easy!)

Interesting. My husband's email raw message view DOES show the actual HTML of the email. Only the very last link to the store at the bottom shows up with anchor tags around it. My sign up link and the mailto link for the store (part of the original ZC code) do NOT show up with anchor tags around them even though they are clearly there in the PHP.

I've decided to "solve" this problem for now by just putting "please sign up at www.example.com" in the text string there. Email programs seems to recognize any text starting with www as a link and display it as such. So that's gonna have to be good enough unless someone comes up with other ideas for me. I have other brick walls to go beat my head on! :P