Zen Cart Logo
Forums / General Questions / Order confirmation email with link to info page

Order confirmation email with link to info page

Locked

Views: 3,417

Results 1 to 20 of 20
This thread is locked. New replies are disabled.
15 Feb 2007, 10:20 PM
#1
bradymc avatar

bradymc

New Zenner

Join Date:
Feb 2007
Location:
Dallas area
Posts:
75
Plugin Contributions:
0

Order confirmation email with link to info page

My client has a Fitness Training product that will need the customer to send in their body measurements. Ideally, we'd like to include a link to this "measurement page" in the order confirmation email if they have added this one product to their shopping cart. We're looking to automate the entire process so that the owner won't have to send an email each time someone places an order.

Got any ideas?

17 Feb 2007, 2:28 PM
#2
theoracle avatar

theoracle

Suspended

Join Date:
Aug 2004
Posts:
3,180
Plugin Contributions:
1

Re: Order confirmation email with link to info page

You need to add an additional condition in your includes/classes/order.php file. Althought, if you intend to modify that file, make sure to backup first since this file is not part of the overrides.

21 Feb 2007, 11:12 PM
#3
bradymc avatar

bradymc

New Zenner

Join Date:
Feb 2007
Location:
Dallas area
Posts:
75
Plugin Contributions:
0

Re: Order confirmation email with link to info page

I figured I'd need an if-then statement put in somewhere. But I don't know much about PHP and trying to figure out where in that file to put that statement and exactly how it should be worded is a mystery to me.

My guess...

<?php if ( $products_name == 'whatever I name the product' ) {
    echo "<a href='http://www.mydomain.com/measurements.php' target='_blank'>Click here to complete our initial survey.</a>";
  }
   ?>

Be gentle... like I said, I don't know much about PHP or it's syntax formatting.

Could it not be inserted into the "email_template_checkout.php" file in the email folder?

3 Mar 2007, 1:36 PM
#4
theoracle avatar

theoracle

Suspended

Join Date:
Aug 2004
Posts:
3,180
Plugin Contributions:
1

Re: Order confirmation email with link to info page

Could it not be inserted into the "email_template_checkout.php" file in the email folder?

First thing would be to learn the file extensions, since it's email_template_checkout.html rather than PHP under your email folder. :happy:

As for your request, make a backup of your includes/classes/order.php file (since this is not an override file but a core file).

Then, find:

$email_order .= "\n-----\n" . EMAIL_FOOTER_COPYRIGHT . "\n\n";

(should be approx on line 961 in your editor).

add below:

// include survey measurements.
    $product_title = "Your_product_title" // Change your product title here.
    if (isset($product_title) && !empty($product_title) && preg_match("/^$product_title/i", $this->products_ordered)) {
    $html_msg['SURVEY_MEASUREMENTS'] = zen_href_link(SURVEY_MEASUREMENTS_URL, '"target="_blank">"' . EMAIL_SURVEY_MEASUREMENTS_CLICK_HERE . '</a>';
    }

Change the following bolded statement:

$product_title = "Your_product_title" // Change your product title here (leave the quotes there though).

for the exact and precise product title name you'd like to fit in (a single one only for now to see if it works the way you like first. If so, multiple product names could be added).

Then, make a backup of the following bolded file. Go to your email/email_template_checkout.html file,

find:

<!-- Footer Section -->
  <div class="footer">
    <div class="copyright">$EMAIL_FOOTER_COPYRIGHT</div>
  </div>

add above:

<! -- Survey measurements -- >
div class="footer">
<div class="measurements">$SURVEY_MEASUREMENTS</div>
</div>

Then, make a backup of the following bolded file. In your includes/languages/<your_language>/checkout_process.php file,

find:

define('EMAIL_TEXT_PAYMENT_METHOD', 'Payment Method');

add below:

define('SURVEY_MEASUREMENTS_URL', 'http://www.mydomain.com/measurements.php');
define('EMAIL_SURVEY_MEASUREMENTS_CLICK_HERE', 'Click here to complete our initial survey.');

Then, modify this block above by changing the URL - pointing to it's original location.

If you're not using the survey measurements on a remote site but on your own site, then simply use this one below:

define('SURVEY_MEASUREMENTS_URL', HTTP_SERVER.'/measurements.php');
define('EMAIL_SURVEY_MEASUREMENTS_CLICK_HERE', 'Click here to complete our initial survey.');

This completes the addition of your survey. Tell me how it went once you have tested your email order. :wink2:

Recall: Backup all bolded files I stated above before proceeding.

3 Mar 2007, 2:13 PM
#5
bradymc avatar

bradymc

New Zenner

Join Date:
Feb 2007
Location:
Dallas area
Posts:
75
Plugin Contributions:
0

Re: Order confirmation email with link to info page

I'm going to try this a little later and let you know how it turns out.

I have two other questions...

  1. If I wanted to make it so that these questionaires were linked to all products in a category, would I just change $product_title = "my_product_title" to $category_title = "my_category_title" and appropriately throughout your fine tutorial?

  2. Is there also a way to add these links to the users account page so that they can have easy access to it?

Thanks for your help.

3 Mar 2007, 2:21 PM
#6
theoracle avatar

theoracle

Suspended

Join Date:
Aug 2004
Posts:
3,180
Plugin Contributions:
1

Re: Order confirmation email with link to info page

Oops - this line will create an error:

$html_msg['SURVEY_MEASUREMENTS'] = zen_href_link(SURVEY_MEASUREMENTS_URL, '"target="_blank">"' . EMAIL_SURVEY_MEASUREMENTS_CLICK_HERE . '</a>';

make sure to replace that with:

$html_msg['SURVEY_MEASUREMENTS'] = '<a href="' . zen_href_link(SURVEY_MEASUREMENTS_URL, '"target="_blank">' . EMAIL_SURVEY_MEASUREMENTS_CLICK_HERE . '</a>';

from your includes/classes/order.php file once you have followed all my instructions above.

3 Mar 2007, 2:24 PM
#7
theoracle avatar

theoracle

Suspended

Join Date:
Aug 2004
Posts:
3,180
Plugin Contributions:
1

Re: Order confirmation email with link to info page

  1. If I wanted to make it so that these questionaires were linked to all products in a category, would I just change $product_title = "my_product_title" to $category_title = "my_category_title" and appropriately throughout your fine tutorial?

My modifications above will only work for products and not for categories yet. I will have to seek more into it if it's feasable the way the Zen Team has coded this.

  1. Is there also a way to add these links to the users account page so that they can have easy access to it?

Perhaps by adding a new SQL table, users could gather the products they have purchased and show each of these products from their user personal account. Is this what you're looking for to do ?

3 Mar 2007, 3:21 PM
#8
theoracle avatar

theoracle

Suspended

Join Date:
Aug 2004
Posts:
3,180
Plugin Contributions:
1

Re: Order confirmation email with link to info page

Slight mistake here. Forgot to close the parenthese.

Replace:

 $html_msg['SURVEY_MEASUREMENTS'] = '<a href="' . zen_href_link(SURVEY_MEASUREMENTS_URL, '"target="_blank">' . EMAIL_SURVEY_MEASUREMENTS_CLICK_HERE . '</a>';  

with:

 $html_msg['SURVEY_MEASUREMENTS'] = '<a href="' . zen_href_link(SURVEY_MEASUREMENTS_URL). '"target="_blank">' . EMAIL_SURVEY_MEASUREMENTS_CLICK_HERE . '</a>';  

This should do the trick to avoid the errors from above. :wink2:

P.S: Sorry for the late fix, I seem to have problems with my ISP's connection.

3 Mar 2007, 8:16 PM
#9
bradymc avatar

bradymc

New Zenner

Join Date:
Feb 2007
Location:
Dallas area
Posts:
75
Plugin Contributions:
0

Re: Order confirmation email with link to info page

Not necessarily the actual product. If they order a specified product, I'd like for this link that I'm adding to their confirmation email to be available to them inside of their personal account once they log into the cart.

Or even adding a "members only page" with this and other pertinent links that all members may need to utilize at some point. I could probably search the forums for this... surely someone's used this idea before.

3 Mar 2007, 8:37 PM
#10
bradymc avatar

bradymc

New Zenner

Join Date:
Feb 2007
Location:
Dallas area
Posts:
75
Plugin Contributions:
0

Re: Order confirmation email with link to info page

Well, I wove it all together and got this:
Parse error: parse error, unexpected T_IF in /html/includes/classes/order.php on line 965

Line 965 contains:

 
if (isset($product_title) && !empty($product_title) && preg_match("/^$product_title/i", $this->products_ordered)) {
    $html_msg['SURVEY_MEASUREMENTS'] = '<a href="' . zen_href_link(SURVEY_MEASUREMENTS_URL). '"target="_blank">' . EMAIL_SURVEY_MEASUREMENTS_CLICK_HERE . '</a>';
    }

It happens when I get to: /index.php?main_page=checkout_shipping

3 Mar 2007, 8:41 PM
#11
theoracle avatar

theoracle

Suspended

Join Date:
Aug 2004
Posts:
3,180
Plugin Contributions:
1

Re: Order confirmation email with link to info page

Not necessarily the actual product. If they order a specified product, I'd like for this link that I'm adding to their confirmation email to be available to them inside of their personal account once they log into the cart.

I don't think this was already done before. That's actually something I could try to implement since this does look like an interesting feature as a MOD.

Or even adding a "members only page" with this and other pertinent links that all members may need to utilize at some point. I could probably search the forums for this... surely someone's used this idea before.

I believe there's already a published MOD, under the downloads section, about when a customer buys all kinds of products (no matter which one), it will be added on a sideboxe window and publicize this product (without the customer's name and info of course). :wink2:

3 Mar 2007, 8:48 PM
#12
theoracle avatar

theoracle

Suspended

Join Date:
Aug 2004
Posts:
3,180
Plugin Contributions:
1

Re: Order confirmation email with link to info page

I just tested your error line and it works perfectly from my end . . . are you sure you implemented my latest fix as a replacement (and made sure you have all the additional blocks I posted with it) ?

3 Mar 2007, 9:03 PM
#13
bradymc avatar

bradymc

New Zenner

Join Date:
Feb 2007
Location:
Dallas area
Posts:
75
Plugin Contributions:
0

Re: Order confirmation email with link to info page

Here's my code from the order.php page from line 958 through line 975:

 
// include disclaimer
    $email_order .= "\n-----\n" . sprintf(EMAIL_DISCLAIMER, STORE_OWNER_EMAIL_ADDRESS) . "\n\n";
    // include copyright
    $email_order .= "\n-----\n" . EMAIL_FOOTER_COPYRIGHT . "\n\n";
 
 // include survey measurements.
    $product_title = "Your RoadMap" // Change your product title here.
    if (isset($product_title) && !empty($product_title) && preg_match("/^$product_title/i", $this->products_ordered)) {
    $html_msg['SURVEY_MEASUREMENTS'] = '<a href="' . zen_href_link(SURVEY_MEASUREMENTS_URL), '"target="_blank">' . EMAIL_SURVEY_MEASUREMENTS_CLICK_HERE . '</a>';
    }
    while (strstr($email_order, ' ')) $email_order = str_replace(' ', ' ', $email_order);
    $html_msg['EMAIL_FIRST_NAME'] = $this->customer['firstname'];
    $html_msg['EMAIL_LAST_NAME'] = $this->customer['lastname'];
    //  $html_msg['EMAIL_TEXT_HEADER'] = EMAIL_TEXT_HEADER;
    $html_msg['EXTRA_INFO'] = '';
    zen_mail($this->customer['firstname'] . ' ' . $this->customer['lastname'], $this->customer['email_address'], EMAIL_TEXT_SUBJECT . EMAIL_ORDER_NUMBER_SUBJECT . $zf_insert_id, $email_order, STORE_NAME, EMAIL_FROM, $html_msg, 'checkout');
3 Mar 2007, 9:07 PM
#14
theoracle avatar

theoracle

Suspended

Join Date:
Aug 2004
Posts:
3,180
Plugin Contributions:
1

Re: Order confirmation email with link to info page

Ok, I figured it out why. The matching variable is just for drawing tables. The orders ID is the only thing that is being used to output the order when the email is about to be sent. If the products_name variable has not been globalized, it would really take sometime to expand something like this.

3 Mar 2007, 9:17 PM
#15
bradymc avatar

bradymc

New Zenner

Join Date:
Feb 2007
Location:
Dallas area
Posts:
75
Plugin Contributions:
0

Re: Order confirmation email with link to info page

So the bottom line is that this will take much more effort than what you've already so graciously put into it? :cry:

3 Mar 2007, 10:02 PM
#16
theoracle avatar

theoracle

Suspended

Join Date:
Aug 2004
Posts:
3,180
Plugin Contributions:
1

Re: Order confirmation email with link to info page

So the bottom line is that this will take much more effort than what you've already so graciously put into it?

Yes. However, I think I have a solution for this. I just took at look at my phpmyadmin and looks quite interesting to make a try.

I will post back when the code will be finalized.

3 Mar 2007, 10:26 PM
#17
theoracle avatar

theoracle

Suspended

Join Date:
Aug 2004
Posts:
3,180
Plugin Contributions:
1

Re: Order confirmation email with link to info page

Ok. Just finished coding this up. Restore your includes/classes/order.php file from your backup (no need to restore the other affected files from the previous page of this topic).

Then, find:

// lets start with the email confirmation
    // make an array to store the html version
    $html_msg=array();

add below:

// Gathers the products name
    $set_products_name = "

    SELECT p.products_name
    FROM ".TABLE_ORDERS_PRODUCTS." p
    LEFT JOIN ".TABLE_ORDERS." o ON (customers_id = ".(int)$_SESSION['customer_id'].")
    WHERE p.orders_id = ".$zf_insert_id." AND o.customers_id = ".(int)$_SESSION['customer_id'];

    $exec_prods_name = $db->Execute($set_products_name);

    while (!$exec_prods_name->EOF) {
    $get_products_name = $exec_prods_name->fields['products_name'];
    } // End of while statement.

    $product_title = "Your_product_title" // Set your real product title here (leave the quotes there).

    if (isset($product_title) && !empty($product_title) && preg_match("/^$product_title/i", $get_products_name)) {
    $html_msg['SURVEY_MEASUREMENTS'] = '<a href="' . zen_href_link(SURVEY_MEASUREMENTS_URL), '"target="_blank">' . EMAIL_SURVEY_MEASUREMENTS_CLICK_HERE . '</a>';
    }

Then, remember to change this line:

$product_title = "Your_product_title" // Set your real product title here (leave the quotes there).

for your own specific product name and that, for now, this is NO multiple products feature but simply a single one to see if it works.

Keep me posted on this. :wink2:

3 Mar 2007, 10:39 PM
#18
bradymc avatar

bradymc

New Zenner

Join Date:
Feb 2007
Location:
Dallas area
Posts:
75
Plugin Contributions:
0

Re: Order confirmation email with link to info page

Same error:
Parse error: parse error, unexpected T_IF in /includes/classes/order.php on line 894

Line 894 is the last if statement:

 
if (isset($product_title) && !empty($product_title) && preg_match("/^$product_title/i", $get_products_name)) { 
    $html_msg['SURVEY_MEASUREMENTS'] = '<a href="' . zen_href_link(SURVEY_MEASUREMENTS_URL), '"target="_blank">' . EMAIL_SURVEY_MEASUREMENTS_CLICK_HERE . '</a>'; 
    }
3 Mar 2007, 10:42 PM
#19
theoracle avatar

theoracle

Suspended

Join Date:
Aug 2004
Posts:
3,180
Plugin Contributions:
1

Re: Order confirmation email with link to info page

Very well. I will send you a PM for further corrections so that this topic does not get overloaded.

4 Mar 2007, 2:09 PM
#20
bradymc avatar

bradymc

New Zenner

Join Date:
Feb 2007
Location:
Dallas area
Posts:
75
Plugin Contributions:
0

Re: Order confirmation email with link to info page

Oracle,

Your PM's are turned off or your inbox is full because the system won't allow me to send you any more.