Jump to content
Sign in to follow this  
bmcewan

Purchase Without Account Updated & Admin Functionality

Recommended Posts

TerryK,

 

Heres my next try:

 

tep_db_query("update " . TABLE_ORDERS . " O set O.purchased_without_account = '1'  where orders_id = '" . (int)$orders['orders_id'] . "'");

 

 

I think this one will work! Let me know how it goes.

Edited by safoo

Share this post


Link to post
Share on other sites

Hi Safoo,

 

Thanks for trying... again. Unfortunately, no luck with this one, again...

 

The error I got was:

 

2000 - You have an error in your SQL syntax near 'O set O.purchased_without_account = '1' where orders_id = '107'' at line 1

update orders O set O.purchased_without_account = '1' where orders_id = '107'

[TEP STOP]

 

Maybe I'm confused... ( Okay, I'm always confused! )

 

The code above is supposed to be added to catalog/checkout_success.php, right? Or should it be in /catalog/admin/orders.php???

 

Thanks,

 

Terry


Terry Kluytmans

 

Contribs Installed: Purchase Without Account (PWA); Big Images, Product Availability, Description in Product Listing, Graphical Infobox, Header Tags Controller, Login Box, Option Type Feature, plus many layout changes & other mods of my own, like:

 

Add order total to checkout_shipment

Add order total to checkout_payment

Add radio buttons at checkout_shipping (for backorder options, etc.)

Duplicate Table Rate Shipping Module

Better Product Review Flow

 

* If at first you don't succeed, find out if there's a prize for the loser. *

Share this post


Link to post
Share on other sites

checkout success....ok i'll try myself this time. Last night I was trying in phpmyadmin and the old attempts were causing error but this one was working. I'll let you know how it works for me.

Share this post


Link to post
Share on other sites

TerryK,

 

The code:

tep_db_query("update " . TABLE_ORDERS . " O set O.purchased_without_account = '1' ?where orders_id = '" . (int)$orders['orders_id'] . "'");

 

worked for me. It accepted the order and put it in the database with Orders.purchased_without_account as '1'.

 

I put it in catalog/checkout_sucess.php right after:

// Added a check for a Guest checkout and cleared the session - 030411 
if (tep_session_is_registered('noaccount')) {

 

and right before:

tep_db_query("delete from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . tep_db_input($customer_id) . "'");

 

Try it again and see what happens. if not, try going into phpmyadmin and trying this code:

 

update orders O set O.purchased_without_account = '1' where orders_id = '107'

 

Now I got to test the email part.

Edited by safoo

Share this post


Link to post
Share on other sites

TerryK,

 

I tested the email addition in admin/orders.php and it seems to work properly for me. you want to try the code again? First just try the 1 line in checkout_success.php. See if it lets you checkout.

Share this post


Link to post
Share on other sites

Safoo,

 

I still can't get this to work, for some reason. :(

 

Could you post your checkout_success.php file for me? Maybe by comparing the code I can figure out why...

 

TIA,

 

Terry


Terry Kluytmans

 

Contribs Installed: Purchase Without Account (PWA); Big Images, Product Availability, Description in Product Listing, Graphical Infobox, Header Tags Controller, Login Box, Option Type Feature, plus many layout changes & other mods of my own, like:

 

Add order total to checkout_shipment

Add order total to checkout_payment

Add radio buttons at checkout_shipping (for backorder options, etc.)

Duplicate Table Rate Shipping Module

Better Product Review Flow

 

* If at first you don't succeed, find out if there's a prize for the loser. *

Share this post


Link to post
Share on other sites

A lot of my code may be different than yours. You can use 'beyond compare' (just google for it if you don't have it) to find where our code matches.

 

checkout_sucess.php

 

<?php
/*
 $Id: checkout_success.php,v 1.49 2003/07/24 23:03:53 Strider Exp $
 $Id: checkout_success.php,v 1.49 2003/06/09 23:03:53 hpdl Exp $
 $Id: checkout_success.php,v 1.6.2.1 2003/05/03 23:41:23 wilt Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License

 Shoppe Enhancement Controller - Copyright (c) 2003 WebMakers.com
 Linda McGrath - osCommerce@WebMakers.com
*/

 require('includes/application_top.php');

// if the customer is not logged on, redirect them to the shopping cart page
 if (!tep_session_is_registered('customer_id')) {
   tep_redirect(tep_href_link(FILENAME_DEFAULT));
 }

 if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'update')) {
   $notify_string = 'action=notify&';
   $notify = $HTTP_POST_VARS['notify'];
   if (!is_array($notify)) $notify = array($notify);
   for ($i=0, $n=sizeof($notify); $i<$n; $i++) {
     $notify_string .= 'notify[]=' . $notify[$i] . '&';
   }
   if (strlen($notify_string) > 0) $notify_string = substr($notify_string, 0, -1);

//    tep_redirect(tep_href_link(FILENAME_DEFAULT, $notify_string));
// Added a check for a Guest checkout and cleared the session - 030411 
if (tep_session_is_registered('noaccount')) { 
tep_session_destroy(); 
tep_redirect(tep_href_link(FILENAME_DEFAULT, '', 'NONSSL')); 
} 
else { 
tep_redirect(tep_href_link(FILENAME_DEFAULT, $notify_string, 'SSL')); 
}
 }

 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CHECKOUT_SUCCESS);

// BOF: WebMakers.com Added: PayPal IPN
 $paypalipn_query = tep_db_query("select o.orders_status,p.* from " . TABLE_ORDERS . " o LEFT JOIN " . TABLE_PAYPALIPN_TXN . " p on p.item_number = o.orders_id AND o.customers_id = '" . (int)$customer_id . "' order by o.date_purchased desc limit 1");
 $paypalipn = tep_db_fetch_array($paypalipn_query);

 if ($paypalipn['ipn_result']=='VERIFIED') {
   if ($paypalipn['payment_status']=='Completed') {
     $NAVBAR_TITLE_2 = PAYPAL_NAVBAR_TITLE_2_OK;
     $HEADING_TITLE = PAYPAL_HEADING_TITLE_OK; 
     $TEXT_SUCCESS = PAYPAL_TEXT_SUCCESS_OK; 
   } else if ($paypalipn['payment_status']=='Pending') { 
     $NAVBAR_TITLE_2 = PAYPAL_NAVBAR_TITLE_2_PENDING; 
     $HEADING_TITLE = PAYPAL_HEADING_TITLE_PENDING; 
     $TEXT_SUCCESS = PAYPAL_TEXT_SUCCESS_PENDING; 
   }; 
   $cart->reset(TRUE); 
 } else if ($paypalipn['ipn_result']=='INVALID') { 
   $NAVBAR_TITLE_2 = PAYPAL_NAVBAR_TITLE_2_FAILED; 
   $HEADING_TITLE = PAYPAL_HEADING_TITLE_FAILED; 
   $TEXT_SUCCESS = PAYPAL_TEXT_SUCCESS_FAILED; 
 } else if ($paypalipn['orders_status']==99999) { 
     $NAVBAR_TITLE_2 = PAYPAL_NAVBAR_TITLE_2_PENDING; 
     $HEADING_TITLE = PAYPAL_HEADING_TITLE_PENDING; 
     $TEXT_SUCCESS = PAYPAL_TEXT_SUCCESS_PENDING; 
 } else { 
   $NAVBAR_TITLE_2 = NAVBAR_TITLE_2; 
   $HEADING_TITLE = HEADING_TITLE; 
   $TEXT_SUCCESS = TEXT_SUCCESS; 
 };

 $breadcrumb->add(NAVBAR_TITLE_1);
// MS2  $breadcrumb->add(NAVBAR_TITLE_2);
 $breadcrumb->add($NAVBAR_TITLE_2);
// EOF: WebMakers.com Added: PayPal IPN

 $global_query = tep_db_query("select global_product_notifications from " . TABLE_CUSTOMERS_INFO . " where customers_info_id = '" . (int)$customer_id . "'");
 $global = tep_db_fetch_array($global_query);

 if ($global['global_product_notifications'] != '1') {
   $orders_query = tep_db_query("select orders_id from " . TABLE_ORDERS . " where customers_id = '" . (int)$customer_id . "' order by date_purchased desc limit 1");
   $orders = tep_db_fetch_array($orders_query);

   $products_array = array();
   $products_query = tep_db_query("select products_id, products_name from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$orders['orders_id'] . "' order by products_name");
   while ($products = tep_db_fetch_array($products_query)) {
     $products_array[] = array('id' => $products['products_id'],
                               'text' => $products['products_name']);
   }
 }
// Added a check for a Guest checkout and cleared the session - 030411 
if (tep_session_is_registered('noaccount')) {
tep_db_query("update " . TABLE_ORDERS . " O set O.purchased_without_account = '1'  where orders_id = '" . (int)$orders['orders_id'] . "'"); 
tep_db_query("delete from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . tep_db_input($customer_id) . "'"); 
tep_db_query("delete from " . TABLE_CUSTOMERS . " where customers_id = '" . tep_db_input($customer_id) . "'"); 
tep_db_query("delete from " . TABLE_CUSTOMERS_INFO . " where customers_info_id = '" . tep_db_input($customer_id) . "'"); 
tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . tep_db_input($customer_id) . "'"); 
tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . tep_db_input($customer_id) . "'"); 
tep_db_query("delete from " . TABLE_WHOS_ONLINE . " where customer_id = '" . tep_db_input($customer_id) . "'"); 
tep_session_destroy(); 

}   
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="0" cellpadding="0">
 <tr>
   <td width="<?php echo BOX_WIDTH; ?>" valign="top" align="left"  bgcolor="F0F0F0" cellspacing="0" cellpadding="0"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="0">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
   </table></td>
   
   <!--safoo added separator-->    
<td border="0" width="5" ><?php echo tep_draw_separator('pixel_trans.gif', '8', '1'); ?></td>
<!-- body_text //-->
   <td width="100%" valign="top"><?php echo tep_draw_form('order', tep_href_link(FILENAME_CHECKOUT_SUCCESS, 'action=update', 'SSL')); ?><table border="0" width="100%" cellspacing="0" cellpadding="0">
     <tr>
       <td><table border="0" width="100%" cellspacing="4" cellpadding="2">
         <tr>
<?php // BOF: WebMakers.com Added: PayPal IPN ?>
           <td valign="top"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_man_on_board.gif', $HEADING_TITLE); ?></td>
           <td valign="top" class="main"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?><div align="center" class="pageHeading"><?php echo $HEADING_TITLE; ?></div><br><?php echo $TEXT_SUCCESS; ?><br><br>
<?php // EOF: WebMakers.com Added: PayPal IPN ?>
<?php
 if ($global['global_product_notifications'] != '1') {
   echo TEXT_NOTIFY_PRODUCTS . '<br><p class="productsNotifications">';

   $products_displayed = array();
   for ($i=0, $n=sizeof($products_array); $i<$n; $i++) {
     if (!in_array($products_array[$i]['id'], $products_displayed)) {
       echo tep_draw_checkbox_field('notify[]', $products_array[$i]['id']) . ' ' . $products_array[$i]['text'] . '<br>';
       $products_displayed[] = $products_array[$i]['id'];
     }
   }

   echo '</p>';
 } else {
   echo TEXT_SEE_ORDERS . '<br><br>' . TEXT_CONTACT_STORE_OWNER;
 }
?>
           <h3><?php echo TEXT_THANKS_FOR_SHOPPING; ?></h3></td>
         </tr>
       </table></td>
     </tr>
<?php require('add_checkout_success.php'); //ICW CREDIT CLASS/GV SYSTEM ?>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
     <tr>
       <td align="right" class="main"><?php echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr>
           <td width="25%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
             <tr>
               <td width="50%" align="right"><?php echo tep_draw_separator('pixel_silver.gif', '1', '5'); ?></td>
               <td width="50%"><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></td>
             </tr>
           </table></td>
           <td width="25%"><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></td>
           <td width="25%"><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></td>
           <td width="25%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
             <tr>
               <td width="50%"><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></td>
               <td width="50%"><?php echo tep_image(DIR_WS_IMAGES . 'checkout_bullet.gif'); ?></td>
             </tr>
           </table></td>
         </tr>
         <tr>
           <td align="center" width="25%" class="checkoutBarFrom"><?php echo CHECKOUT_BAR_DELIVERY; ?></td>
           <td align="center" width="25%" class="checkoutBarFrom"><?php echo CHECKOUT_BAR_PAYMENT; ?></td>
           <td align="center" width="25%" class="checkoutBarFrom"><?php echo CHECKOUT_BAR_CONFIRMATION; ?></td>
           <td align="center" width="25%" class="checkoutBarCurrent"><?php echo CHECKOUT_BAR_FINISHED; ?></td>
         </tr>
       </table></td>
     </tr>
<?php if (DOWNLOAD_ENABLED == 'true') include(DIR_WS_MODULES . 'downloads.php'); ?>
   </table></form></td>
<!-- body_text_eof //-->
<!--safoo added separator-->
<td border="0" width="5"><?php echo tep_draw_separator('pixel_trans.gif', '8', '1'); ?></td>
   <td width="<?php echo BOX_WIDTH; ?>" valign="top" align="right" bgcolor="F0F0F0"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="0">
<!-- right_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>
<!-- right_navigation_eof //-->
   </table></td>
 </tr>
</table>
<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

Share this post


Link to post
Share on other sites

Thanks, Safoo. I compared your code to mine, and it's the same for this page, yet I"m still getting the same error message. That means the problem must be either in my /admin/orders.php file or in the database field, I guess. I dunno... I'm stumped. :(

 

Terry


Terry Kluytmans

 

Contribs Installed: Purchase Without Account (PWA); Big Images, Product Availability, Description in Product Listing, Graphical Infobox, Header Tags Controller, Login Box, Option Type Feature, plus many layout changes & other mods of my own, like:

 

Add order total to checkout_shipment

Add order total to checkout_payment

Add radio buttons at checkout_shipping (for backorder options, etc.)

Duplicate Table Rate Shipping Module

Better Product Review Flow

 

* If at first you don't succeed, find out if there's a prize for the loser. *

Share this post


Link to post
Share on other sites

What is your sql version? Mine is 4.0.18. I think that may be it since you were getting an error with the query:

update orders O set O.purchased_without_account = '1' where orders_id = '107'

in your phpmyadmin and I did not get any errors when I tried it.

Share this post


Link to post
Share on other sites

Does anyone have a glue why i have this error in the admin order.php ?

 

1064 - You have an error in your SQL syntax near 'limit 0, 20' at line 1

 

select o.orders_id, o.customers_name, o.payment_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name, ot.text as order_total from orders o left join orders_total ot on (o.orders_id = ot.orders_id), orders_status s where o.orders_status = s.orders_status_id and s.language_id = '2' and s.orders_status_id = '3' and ot.class = 'ot_total' order by limit 0, 20

 

[TEP STOP]

Share this post


Link to post
Share on other sites

Hi all

 

Does anyone have a solution they can post for the problem of people closing their browser after entering their details but before finishing checkout.

 

The solution I can see for it is to do another check when someone enters their details.

If the email address is NOT in the DB then PWA would progress as normal.

If the email address exists in the DB AND the purchased_without_account field is '1' the customer details could be deleted before being re-registered.

If the email address exists in the DB and purchased_without_account ='0' then the customer is asked to login.

 

Does anyone have it working like this yet? If so can they detail how to do it? If not, anyone know how to go about implementing it?

 

I will work on this myself if there isn't already a solution out there.

 

Tim

Share this post


Link to post
Share on other sites

Actually the newest version seems to already check for this. If you look in order_info_process.php, after line 264, first it checks for an existing customer email, and if it is found it then checks the purchased_without_account field before displaying an error. If the PWA flag is 1, then the checkout continues correctly.

 

What version are you running? I just tested my installation and did not have a problem when I closed the browser before completing checkout and then tried to checkout again.

Share this post


Link to post
Share on other sites

TerryK

 

I think I have the solution for you. You can check if the orders.customers_id is 0, in which case do not include the link in the email. I don't know why I did not think of that before and use it myself! The customers_id is stored in the 'orders' tables, but it is always set to 0 for PWA orders, so it should work and you do not have to worry about the PWA field that we added to the orders table.

 

So the only change would be applied to admin/orders.php. Try it and let me know.

Edited by safoo

Share this post


Link to post
Share on other sites
Does anyone have a glue why i have this error in the admin order.php ?

 

1064 - You have an error in your SQL syntax near 'limit 0, 20' at line 1

 

select o.orders_id, o.customers_name, o.payment_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name, ot.text as order_total from orders o left join orders_total ot on (o.orders_id = ot.orders_id), orders_status s where o.orders_status = s.orders_status_id and s.language_id = '2' and s.orders_status_id = '3' and ot.class = 'ot_total' order by limit 0, 20

 

[TEP STOP]

the above syntax is wrong as ORDER BY requires an argument wich has been omitted and hence the following LIMIT causes the error

order by "I AM MISSING" limit 0, 20

 

regards

 

ralf


sometimes I change code before reading the comments, sometimes code doesn't even have comments, sometimes I rechange code after I read the code others wrote :-)

Share this post


Link to post
Share on other sites

Safoo

 

I see now it does check for purchesed_without_account adn update the old account if it exists.

 

One thing I noticed is that if you enter an entirely different address the post code and phone number are not updated but rather are left as they were from the previous account.

 

I'd rather have this updating to whatever the user has entered most recently.

 

What do I need to change?

 

Thanks

Tim

Share this post


Link to post
Share on other sites

Would it be possible to put something in the admin side so that on a regular basis it automatically deletes any user accounts that are more than a day old and have purchased_without_account set to 1?

 

That would save you having to go in and delete them manually.

Share this post


Link to post
Share on other sites

OK, I have changed my copy so that all the new information that a customer enters to a previouslyt used PWA account is updated.

 

I changed this (Order_Info_Process.php line 312)

          // PWA 0.70 update returning customer's address book:
         $address_book_update = array('customers_id' => $customer_id,
                        'entry_firstname' => $firstname,
                        'entry_lastname' => $lastname,
                        'entry_street_address' => $street_address,
                        'entry_city' => $city,
                        'entry_country_id' => $country);
         if (ACCOUNT_GENDER == 'true') $address_book_update['entry_gender'] = $gender;
  	 if (ACCOUNT_COMPANY == 'true') $address_book_update['entry_company'] = $company;
  	 if (ACCOUNT_SUBURB == 'true') $address_book_update['entry_suburb'] = $suburb;
  	 if (ACCOUNT_STATE == 'true') {
     if ($zone_id > 0) {
    	 $address_book_update['entry_zone_id'] = $zone_id;
    	 $address_book_update['entry_state'] = '';
     } else {
    	 $address_book_update['entry_zone_id'] = '0';
    	 $address_book_update['entry_state'] = $state;
     }
  	 }
         tep_db_perform(TABLE_ADDRESS_BOOK, $address_book_update, 'update', "address_book_id = '".$customer_default_address_id."'");
   } // if-else $pass_ok

 

to this

          // PWA 0.70 update returning customer's address book:
         $customer_update = array('customers_firstname' => $firstname,
                             'customers_lastname' => $lastname,
                             'customers_telephone' => $telephone,
                             'customers_fax' => $fax);
   if (ACCOUNT_GENDER == 'true') $customer_update['customers_gender'] = $gender;
      tep_db_perform(TABLE_CUSTOMERS, $customer_update, 'update', "customers_id = '".$customer_id."'");
   
   $address_book_update = array('customers_id' => $customer_id,
         'entry_firstname' => $firstname,
                 'entry_lastname' => $lastname,
                 'entry_street_address' => $street_address,
                 'entry_postcode' => $postcode,
                 'entry_city' => $city,
                 'entry_country_id' => $country);
                   if (ACCOUNT_GENDER == 'true') $address_book_update['entry_gender'] = $gender;
  	 if (ACCOUNT_COMPANY == 'true') $address_book_update['entry_company'] = $company;
  	 if (ACCOUNT_SUBURB == 'true') $address_book_update['entry_suburb'] = $suburb;
  	 if (ACCOUNT_STATE == 'true') {
     if ($zone_id > 0) {
    	 $address_book_update['entry_zone_id'] = $zone_id;
    	 $address_book_update['entry_state'] = '';
     } else {
    	 $address_book_update['entry_zone_id'] = '0';
    	 $address_book_update['entry_state'] = $state;
     }
  	 }
         tep_db_perform(TABLE_ADDRESS_BOOK, $address_book_update, 'update', "address_book_id = '".$customer_default_address_id."'");
   } // if-else $pass_ok

 

Just seems a little more safe to update everything.

 

Tim

Share this post


Link to post
Share on other sites

Safoo

 

The customer_id in the orders table doesn't seem to be set to 0 for a PWA order. In my DB it seems to be set to whatever the customer id was at the tie of purchase before the customer was removed from the customers table.

 

Tim

Share this post


Link to post
Share on other sites

tlelliot77,

 

I think you are right. I'm still trying to think of a way for TerryK to fix the problem of URL being set to customers in the email?

 

I will try your script for updating the address info. Also, it would be smart to have a link to purge all customer info in the few databases for customers who did not complete PWA checkout and have not returned in X number of days. Should be very simple.

Share this post


Link to post
Share on other sites
TerryK

 

I think I have the solution for you. You can check if the orders.customers_id is 0, in which case do not include the link in the email. I don't know why I did not think of that before and use it myself! The customers_id is stored in the 'orders' tables, but it is always set to 0 for PWA orders, so it should work and you do not have to worry about the PWA field that we added to the orders table.

 

So the only change would be applied to admin/orders.php. Try it and let me know.

Hi Safoo,

 

Instead of tying into the customer ID, we should be able to use the customers_info_date_account_created field from the CUSTOMERS_INFO table, which will be blank for anyone who proceeds to checkout without creating an account. The only thing I can't figure out is how to write an 'if' statement to check for it. Any ideas?

 

Thanks for all your help on this!!!

 

Terry


Terry Kluytmans

 

Contribs Installed: Purchase Without Account (PWA); Big Images, Product Availability, Description in Product Listing, Graphical Infobox, Header Tags Controller, Login Box, Option Type Feature, plus many layout changes & other mods of my own, like:

 

Add order total to checkout_shipment

Add order total to checkout_payment

Add radio buttons at checkout_shipping (for backorder options, etc.)

Duplicate Table Rate Shipping Module

Better Product Review Flow

 

* If at first you don't succeed, find out if there's a prize for the loser. *

Share this post


Link to post
Share on other sites

Terry K, Safoo

 

I have the email working how you want it to now.

 

For a normal order it includes the link to the account_history_info.php. For a PWA order it doesn't. I did this mainly by following your instructions as follows.

 

Added a new field to orders table:

ALTER TABLE orders ADD purchased_without_account TINYINT(1) UNSIGNED DEFAULT '0' NOT NULL;

Changed the deregister if statement in checkout_success.php (line 61 in my store) to:

// Added a check for a Guest checkout and cleared the session - 030411 
if (tep_session_is_registered('noaccount')) { 
 $order_update = array('purchased_without_account' => '1');
 tep_db_perform(TABLE_ORDERS, $order_update, 'update', "orders_id = '".$orders['orders_id']."'");
//  tep_db_query("insert into " . TABLE_ORDERS . " (purchased_without_account) values ('1') where orders_id = '" . (int)$orders['orders_id'] . "'");
 tep_db_query("delete from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . tep_db_input($customer_id) . "'"); 
 tep_db_query("delete from " . TABLE_CUSTOMERS . " where customers_id = '" . tep_db_input($customer_id) . "'"); 
 tep_db_query("delete from " . TABLE_CUSTOMERS_INFO . " where customers_info_id = '" . tep_db_input($customer_id) . "'"); 
 tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . tep_db_input($customer_id) . "'"); 
 tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . tep_db_input($customer_id) . "'"); 
 tep_db_query("delete from " . TABLE_WHOS_ONLINE . " where customer_id = '" . tep_db_input($customer_id) . "'"); 
 tep_session_destroy(); 
}

 

Changed the email section in admin/orders.php from:

            $email = STORE_NAME . "\n" . EMAIL_SEPARATOR . "\n" . EMAIL_TEXT_ORDER_NUMBER . ' ' . $oID . "\n" . EMAIL_TEXT_INVOICE_URL . ' ' . tep_catalog_href_link(FILENAME_CATALOG_ACCOUNT_HISTORY_INFO, 'order_id=' . $oID, 'SSL') . "\n" . EMAIL_TEXT_DATE_ORDERED . ' ' . tep_date_long($check_status['date_purchased']) . "\n\n" . $notify_comments . sprintf(EMAIL_TEXT_STATUS_UPDATE, $orders_status_array[$status]);
           tep_mail($check_status['customers_name'], $check_status['customers_email_address'], EMAIL_TEXT_SUBJECT, $email, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);

           $customer_notified = '1';
         }

 

to:

// start pwa changes 	 
$pwa_check_query= tep_db_query("select purchased_without_account from " . TABLE_ORDERS . " where orders_id = '" . tep_db_input($oID) . "'");
$pwa_check= tep_db_fetch_array($pwa_check_query);
 if ($pwa_check['purchased_without_account'] != '1'){

           $email = STORE_NAME . "\n" . EMAIL_SEPARATOR . "\n" . EMAIL_TEXT_ORDER_NUMBER . ' ' . $oID . "\n" . EMAIL_TEXT_INVOICE_URL . ' ' . tep_catalog_href_link(FILENAME_CATALOG_ACCOUNT_HISTORY_INFO, 'order_id=' . $oID, 'SSL') . "\n" . EMAIL_TEXT_DATE_ORDERED . ' ' . tep_date_long($check_status['date_purchased']) . "\n\n" . $notify_comments . sprintf(EMAIL_TEXT_STATUS_UPDATE, $orders_status_array[$status]);
 } else {
   $email = STORE_NAME . "\n" . EMAIL_SEPARATOR . "\n" . EMAIL_TEXT_ORDER_NUMBER . ' ' . $oID . "\n" . EMAIL_TEXT_DATE_ORDERED . ' ' . tep_date_long($check_status['date_purchased']) . "\n\n" . $notify_comments . sprintf(EMAIL_TEXT_STATUS_UPDATE, $orders_status_array[$status]);
 }
           tep_mail($check_status['customers_name'], $check_status['customers_email_address'], EMAIL_TEXT_SUBJECT, $email, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);

           $customer_notified = '1';
         }

 

It seems to be working OK for the testing I've done. Hope this helps.

 

Nearly there now

 

Tim

Share this post


Link to post
Share on other sites

tlelliot77,

 

Were you getting an error using

tep_db_query("update " . TABLE_ORDERS . " O set O.purchased_without_account = '1'  where orders_id = '" . (int)$orders['orders_id'] . "'");

 

I have that code and it works fine for me. I hope your method works for TerryK. I am going to implement your method for updating *all* customer info soon. Thanks.

Share this post


Link to post
Share on other sites

Thanks, Safoo and Tim, for all your help! I deleted my table field and started over again, then re-entered Tim's final code, and it worked this time. Woohoo!!!!! :)

 

You're both awesome -- thanks again!

 

Terry


Terry Kluytmans

 

Contribs Installed: Purchase Without Account (PWA); Big Images, Product Availability, Description in Product Listing, Graphical Infobox, Header Tags Controller, Login Box, Option Type Feature, plus many layout changes & other mods of my own, like:

 

Add order total to checkout_shipment

Add order total to checkout_payment

Add radio buttons at checkout_shipping (for backorder options, etc.)

Duplicate Table Rate Shipping Module

Better Product Review Flow

 

* If at first you don't succeed, find out if there's a prize for the loser. *

Share this post


Link to post
Share on other sites

Good stuff.

 

Safoo, To be honest I didn't try it with the code you put in - I just saw a way of doing it and tried it. It worked so I used it. I'm sure the code you put in works just as well. There's always more than one way to skin a cat.

 

Now I just need to fix it so my login box and the "Log off" and "my account" links don't appear for a PWA customer. No rest for the wicked.

 

Tim

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×