COWOA and Gift Certificates
Wanted to assemble this info in ONE place. I had to search all over the forum for this information so I figured I'd help save others the trouble of looking for this data.
First, the salient point is this: Customers who DO NOT have a regular store account cannot USE or PURCHASE gift certificates. PERIOD. If you offer gift certificates, you MUST put something in the product description which indicates this or you will find your self doing a LOT of backend work to back out these sales transactions. See: Checkout without Account and Gift Certificates
If a customer converts from COWOA to a regular store account you may find that if you use any of the admin e-mail functions that they will get duplicate e-mails. This is particularly troubling if they have shopped more than once using COWOA, and then signup for a regular account using the same e-mail they previously used for COWOA. If you send this particular customer a gift certificate, you will find that they will receive MULTIPLE gift vouchers.
To fix this, I found this code:
Quote:
Originally Posted by
damiantaylor
I think I've fixed the duplicate email address/duplicate email send bug.
Zen Cart doesn't usually allow more than one account to have the same email address so I needed to limit the number of emails sent to 1 if a specific email address was selected.
The duplicate emails can get costly when sending Gift Certificates from Admin :shocking:
In file includes/functions/audience.php, I have changed function get_audience_sql_query to:
Code:
function get_audience_sql_query($selected_entry, $query_category='email') {
// This is used to take the query_name selected in the drop-down menu or singular customer email address and
// generate the SQL Select query to be used to build the list of email addresses to be sent to
// it only returns a query name and query string (SQL SELECT statement)
// the query string is then used in a $db->Execute() command for later parsing and emailing.
global $db;
$query_name='';
$queries_list = $db->Execute("select query_name, query_string from " . TABLE_QUERY_BUILDER . " " .
"where query_category like '%" . $query_category . "%'");
// "where query_category = '" . $query_category . "'");
while (!$queries_list->EOF) {
if ($selected_entry == $queries_list->fields['query_name']) {
$query_name = $queries_list->fields['query_name'];
$query_string = parsed_query_string($queries_list->fields['query_string']);
//echo 'GET_AUD_EM_ADDR_QRY:<br />query_name='.$query_name.'<br />query_string='.$query_string;
}
$queries_list->MoveNext();
}
//if no match found against queries listed in database, then $selected_entry must be an email address
if ($query_name=='' && $query_category=='email') {
$cust_email_address = zen_db_prepare_input($selected_entry);
$query_name = $cust_email_address;
$query_string = "select customers_firstname, customers_lastname, customers_email_address
from " . TABLE_CUSTOMERS . "
where customers_email_address = '" . zen_db_input($cust_email_address) . "' limit 1";
}
//send back a 1-row array containing the query_name and the SQL query_string
return array('query_name'=>$query_name, 'query_string'=>$query_string);
}
It was suggested that you should instead restrict the query to JUST COWOA customers.. the problem with that solution is that you will NOT be able to send e-mails to COWOA customers, and this may not be an entirely desirable result.
Re: COWOA and Gift Certificates
ENTRY_EMAIL_ADDRESS_COWOA_ERROR_EXISTS
appears when I go to check out as a guest. The only thing I can add is that this is only happening with Yahoo emails that may or may not have been used during a previous guest checkout.
Re: COWOA and Gift Certificates
Quote:
Originally Posted by
DivaVocals
It was suggested that you should instead restrict the query to JUST COWOA customers.. the problem with that solution is that you will NOT be able to send e-mails to COWOA customers, and this may not be an entirely desirable result.
I tend to make a mess of things so had to spend some time looking back at my code... I started some time back with the first COWOA, then changed to FEC which had COWOA. Then I've modified things sense so not sure how this will look to you. I noticed it's still not been addressed in the new version of FEC.
I had the same issues with multiple email addresses due to more then one entry as COWOA users. Then I had one customer that after 6 checkouts without an account decided to create one. Now I had 5 entries as COWOA and one standard account with the same email.
I hate copping with such, so went back into the code and fixed the source of it all, lest it works for me.
I found that in includes/modules/YOUR_TEMPLATE/no_account.php creates the account, but never checks to see if one is already there. So I modified it as done in create_account which checks to see if COWOA account exists and updates it to become a standard account... with the modified code I'm checking for an existing COWOA account with the same email address and updating it instead of creating a new one. Thus, only one COWOA account exist for that same email address. I have the one account, but still get the orders and mailing addresses each time they order. Then if they do create a standard account, all the past orders, mailing address fall back to that user... I haven't found any problems so far.
Nab a bit of code on both sides of the modified section so to help where it all fits in...
Code:
// create billing address
$sql_data_array = array('customers_firstname' => $firstname,
'customers_lastname' => $lastname,
'customers_email_address' => $email_address,
'customers_nick' => $nick,
'customers_telephone' => $telephone,
'customers_fax' => $fax,
'customers_newsletter' => (int)$newsletter,
'customers_email_format' => $email_format,
'customers_default_address_id' => 0,
'customers_password' => zen_encrypt_password($password),
'COWOA_account' => $cowoa,
'customers_authorization' => (int)CUSTOMERS_APPROVAL_AUTHORIZATION
);
////////////bof modified for existing cowoa member ////////////////////////////////////
// check if COWOA account exists for email_address
$cowoa_accounts = 0;
if (FEC_NOACCOUNT_COMBINE == 'true') {
$cowoa_account = $db->Execute("SELECT customers_id, customers_default_address_id FROM " . TABLE_CUSTOMERS . "
WHERE customers_email_address = '" . $email_address . "'
ORDER BY customers_id DESC
LIMIT 1;");
$cowoa_accounts = $cowoa_account->RecordCount();
}
if ($cowoa_accounts > 0) {
// cowoa account exists, use that
$db_action = 'update';
$sql_data_array['customers_id'] = $_SESSION['customer_id'] = $cowoa_account->fields['customers_id'];
$sql_data_array['customers_default_address_id'] = $address_id = $cowoa_account->fields['customers_default_address_id'];
$sql_data_array['COWOA_account'] = 1;
$db_customers_where = 'customers_id = "' . $cowoa_account->fields['customers_id'] . '"';
} else {
$db_action = 'insert';
$db_customers_where = '';
}
//end modified
if ((CUSTOMERS_REFERRAL_STATUS == '2' and $customers_referral != '')) $sql_data_array['customers_referral'] = $customers_referral;
if (ACCOUNT_GENDER == 'true') $sql_data_array['customers_gender'] = $gender;
if (ACCOUNT_DOB == 'true') $sql_data_array['customers_dob'] = (empty($_POST['dob']) || $dob_entered == '0001-01-01 00:00:00' ? zen_db_prepare_input('0001-01-01 00:00:00') : zen_date_raw($_POST['dob']));
zen_db_perform(TABLE_CUSTOMERS, $sql_data_array, $db_action, $db_customers_where); //added for modified cowoa
if ($db_action == 'insert') {
$_SESSION['customer_id'] = $db->Insert_ID();
}
$sql_data_array = array('customers_id' => $_SESSION['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') $sql_data_array['entry_gender'] = $gender;
if (ACCOUNT_COMPANY == 'true') $sql_data_array['entry_company'] = $company;
if (ACCOUNT_SUBURB == 'true') $sql_data_array['entry_suburb'] = $suburb;
if (ACCOUNT_STATE == 'true') {
if ($zone_id > 0) {
$sql_data_array['entry_zone_id'] = $zone_id;
$sql_data_array['entry_state'] = '';
} else {
$sql_data_array['entry_zone_id'] = '0';
$sql_data_array['entry_state'] = $state;
}
}
if ($db_action == 'update') {
$sql_data_array['address_book_id'] = $address_id;
$db_address_table_where = 'address_book_id = ' . $address_id;
} else {
$db_address_table_where = '';
}
zen_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array, $db_action, $db_address_table_where);
if ($db_action == 'insert') {
$address_id = $db->Insert_ID();
$sql = "update " . TABLE_CUSTOMERS . "
set customers_default_address_id = '" . (int)$address_id . "'
where customers_id = '" . (int)$_SESSION['customer_id'] . "'";
$db->Execute($sql);
$sql = "insert into " . TABLE_CUSTOMERS_INFO . "
(customers_info_id, customers_info_number_of_logons,
customers_info_date_account_created)
values ('" . (int)$_SESSION['customer_id'] . "', '0', now())";
$db->Execute($sql);
}
//////////// eof modified for existing cowoa member ////////////////////////////////////
if (enable_shippingAddress()) {
// create shipping address
Hopefully it makes some scene to you... I've been running it like this for almost a year and haven't found any problems. Both in live and testing it's working out, running now on zencart 1.5.1
The other thing I did so I can just email COWOA users was to make a entry for it in the quary_builder. This is just my phpmyadmin dump. Could do the same for none standard accounts by adding a COWOA_account = 0 check.
Code:
INSERT INTO `query_builder` (`query_id`, `query_category`, `query_name`, `query_description`, `query_string`, `query_keys_list`) VALUES
(, 'email', 'COWOA Customers Only', 'Returns COWOA customers name and email address for sending mass emails (ie: for newsletters, coupons, GVs, messages, etc).', 'select customers_email_address, customers_firstname, customers_lastname from TABLE_CUSTOMERS where COWOA_account = 1 order by customers_lastname, customers_firstname, customers_email_address', '');
Re: COWOA and Gift Certificates
Quote:
Originally Posted by
davewest
I tend to make a mess of things so had to spend some time looking back at my code... I started some time back with the first COWOA, then changed to FEC which had COWOA. Then I've modified things sense so not sure how this will look to you. I noticed it's still not been addressed in the new version of FEC.
I had the same issues with multiple email addresses due to more then one entry as COWOA users. Then I had one customer that after 6 checkouts without an account decided to create one. Now I had 5 entries as COWOA and one standard account with the same email.
I hate copping with such, so went back into the code and fixed the source of it all, lest it works for me.
I found that in includes/modules/YOUR_TEMPLATE/no_account.php creates the account, but never checks to see if one is already there. So I modified it as done in create_account which checks to see if COWOA account exists and updates it to become a standard account... with the modified code I'm checking for an existing COWOA account with the same email address and updating it instead of creating a new one. Thus, only one COWOA account exist for that same email address. I have the one account, but still get the orders and mailing addresses each time they order. Then if they do create a standard account, all the past orders, mailing address fall back to that user... I haven't found any problems so far.
Nab a bit of code on both sides of the modified section so to help where it all fits in...
Code:
// create billing address
$sql_data_array = array('customers_firstname' => $firstname,
'customers_lastname' => $lastname,
'customers_email_address' => $email_address,
'customers_nick' => $nick,
'customers_telephone' => $telephone,
'customers_fax' => $fax,
'customers_newsletter' => (int)$newsletter,
'customers_email_format' => $email_format,
'customers_default_address_id' => 0,
'customers_password' => zen_encrypt_password($password),
'COWOA_account' => $cowoa,
'customers_authorization' => (int)CUSTOMERS_APPROVAL_AUTHORIZATION
);
////////////bof modified for existing cowoa member ////////////////////////////////////
// check if COWOA account exists for email_address
$cowoa_accounts = 0;
if (FEC_NOACCOUNT_COMBINE == 'true') {
$cowoa_account = $db->Execute("SELECT customers_id, customers_default_address_id FROM " . TABLE_CUSTOMERS . "
WHERE customers_email_address = '" . $email_address . "'
ORDER BY customers_id DESC
LIMIT 1;");
$cowoa_accounts = $cowoa_account->RecordCount();
}
if ($cowoa_accounts > 0) {
// cowoa account exists, use that
$db_action = 'update';
$sql_data_array['customers_id'] = $_SESSION['customer_id'] = $cowoa_account->fields['customers_id'];
$sql_data_array['customers_default_address_id'] = $address_id = $cowoa_account->fields['customers_default_address_id'];
$sql_data_array['COWOA_account'] = 1;
$db_customers_where = 'customers_id = "' . $cowoa_account->fields['customers_id'] . '"';
} else {
$db_action = 'insert';
$db_customers_where = '';
}
//end modified
if ((CUSTOMERS_REFERRAL_STATUS == '2' and $customers_referral != '')) $sql_data_array['customers_referral'] = $customers_referral;
if (ACCOUNT_GENDER == 'true') $sql_data_array['customers_gender'] = $gender;
if (ACCOUNT_DOB == 'true') $sql_data_array['customers_dob'] = (empty($_POST['dob']) || $dob_entered == '0001-01-01 00:00:00' ? zen_db_prepare_input('0001-01-01 00:00:00') : zen_date_raw($_POST['dob']));
zen_db_perform(TABLE_CUSTOMERS, $sql_data_array, $db_action, $db_customers_where); //added for modified cowoa
if ($db_action == 'insert') {
$_SESSION['customer_id'] = $db->Insert_ID();
}
$sql_data_array = array('customers_id' => $_SESSION['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') $sql_data_array['entry_gender'] = $gender;
if (ACCOUNT_COMPANY == 'true') $sql_data_array['entry_company'] = $company;
if (ACCOUNT_SUBURB == 'true') $sql_data_array['entry_suburb'] = $suburb;
if (ACCOUNT_STATE == 'true') {
if ($zone_id > 0) {
$sql_data_array['entry_zone_id'] = $zone_id;
$sql_data_array['entry_state'] = '';
} else {
$sql_data_array['entry_zone_id'] = '0';
$sql_data_array['entry_state'] = $state;
}
}
if ($db_action == 'update') {
$sql_data_array['address_book_id'] = $address_id;
$db_address_table_where = 'address_book_id = ' . $address_id;
} else {
$db_address_table_where = '';
}
zen_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array, $db_action, $db_address_table_where);
if ($db_action == 'insert') {
$address_id = $db->Insert_ID();
$sql = "update " . TABLE_CUSTOMERS . "
set customers_default_address_id = '" . (int)$address_id . "'
where customers_id = '" . (int)$_SESSION['customer_id'] . "'";
$db->Execute($sql);
$sql = "insert into " . TABLE_CUSTOMERS_INFO . "
(customers_info_id, customers_info_number_of_logons,
customers_info_date_account_created)
values ('" . (int)$_SESSION['customer_id'] . "', '0', now())";
$db->Execute($sql);
}
//////////// eof modified for existing cowoa member ////////////////////////////////////
if (enable_shippingAddress()) {
// create shipping address
Hopefully it makes some scene to you... I've been running it like this for almost a year and haven't found any problems. Both in live and testing it's working out, running now on zencart 1.5.1
The other thing I did so I can just email COWOA users was to make a entry for it in the quary_builder. This is just my phpmyadmin dump. Could do the same for none standard accounts by adding a COWOA_account = 0 check.
Code:
INSERT INTO `query_builder` (`query_id`, `query_category`, `query_name`, `query_description`, `query_string`, `query_keys_list`) VALUES
(, 'email', 'COWOA Customers Only', 'Returns COWOA customers name and email address for sending mass emails (ie: for newsletters, coupons, GVs, messages, etc).', 'select customers_email_address, customers_firstname, customers_lastname from TABLE_CUSTOMERS where COWOA_account = 1 order by customers_lastname, customers_firstname, customers_email_address', '');
Hey Dave...
Thanks for the share, and you are soooo right.. The e-mail list fix is a bandaid, but certainly not a long term solution.. ULTIMATELY what you posted is the RIGHT solution.. I'm afraid this is a bit over my limited skillset to figure out.. FEC's COWOA is just different enough from this module's COWOA to make it over my head to figure out what code to "borrow" from this.. I have an idea as to what I need to do, but it would be trial and error before I got it all worked out.. As an example, my first attempt to "borrow" the right code lead to a SQL duplicate record error.. I'll keep playing, but time is an issue for me, and I don't really have much to keep going at it by trial and error..
Hoping a more astute member of the community can jump in here and provide some guidance..
Again thanks for the share and the push in the right direction..
Re: COWOA and Gift Certificates
Quote:
Originally Posted by
DivaVocals
Hey Dave...
Thanks for the share, and you are soooo right.. The e-mail list fix is a bandaid, but certainly not a long term solution.. ULTIMATELY what you posted is the RIGHT solution.. I'm afraid this is a bit over my limited skillset to figure out.. FEC's COWOA is just different enough from this module's COWOA to make it over my head to figure out what code to "borrow" from this.. I have an idea as to what I need to do, but it would be trial and error before I got it all worked out.. As an example, my first attempt to "borrow" the right code lead to a SQL duplicate record error.. I'll keep playing, but time is an issue for me, and I don't really have much to keep going at it by trial and error..
Hoping a more astute member of the community can jump in here and provide some guidance..
Again thanks for the share and the push in the right direction..
OK... may have to slow down for the holidays, but I'm redesigning one of my site with a responsive template. Decided to start fresh so all I have in right now is the template with the 1.5.2 base. I'll drop back and install the COWOA now so I can see where everything is and where to make the changes. Then test and pack it up for you if it works as my current version. This is the 'COWOA Updated and Combined for v1.5.x' right and not the integrated one! Although I'm not sure where the differences are.
Oh.. the duplicate database error comes if the code tries to insert a last login entry for a non-standard account.. the user is not truly logged in, so bounces an error on the customer ID..
I don't mind sharing... wasn't sure I was answering right, was trying to look up code and code a fix for my website at the same time... had to code in an checkbox telling me they read the instructions how to bid before they are allowed to bid... people are amazing... keeps me on my toes I guess. Well drop you a note when I'm done and ready to pass it off... don't have time to support a mod right now.
Re: COWOA and Gift Certificates
There are only two versionsof COWOA in the downloads.. one fir v1.3.9 and one for v1.5.x.
No worries on the time.. just appreciate you sharing your code.. :smile: Your response was the right answer.. shoulda been part of COWOA all along..
Quote:
Originally Posted by
davewest
OK... may have to slow down for the holidays, but I'm redesigning one of my site with a responsive template. Decided to start fresh so all I have in right now is the template with the 1.5.2 base. I'll drop back and install the COWOA now so I can see where everything is and where to make the changes. Then test and pack it up for you if it works as my current version. This is the 'COWOA Updated and Combined for v1.5.x' right and not the integrated one! Although I'm not sure where the differences are.
Oh.. the duplicate database error comes if the code tries to insert a last login entry for a non-standard account.. the user is not truly logged in, so bounces an error on the customer ID..
I don't mind sharing... wasn't sure I was answering right, was trying to look up code and code a fix for my website at the same time... had to code in an checkbox telling me they read the instructions how to bid before they are allowed to bid... people are amazing... keeps me on my toes I guess. Well drop you a note when I'm done and ready to pass it off... don't have time to support a mod right now.
Re: COWOA and Gift Certificates
I installed COWOA a few weeks ago and everything seemed to be ok, now that I am testing it I notice that the email link takes the customer to the login page. I have searched and searched and I can't find the account_history_info&order page anywhere, how do I fix this?
Re: COWOA Updated and Combined for ZC v1.5.x
I installed COWOA a few weeks ago and everything seemed to be ok, now that I am testing it I notice that the email link takes the customer to the login page. I have searched and searched and I can't find the account_history_info&order page anywhere, how do I fix this?
Re: COWOA Updated and Combined for ZC v1.5.x
Quote:
Originally Posted by
lat9
P.S. Off-subject, but when I did a fresh install of COWOA on a fresh install of Zen Cart 1.5.1, the define TEXT_CHECKOUT_LOGOFF_CUSTOMER appears to be missing from the orders_status page.
That P.S. is from a post a little over a year ago. I did a fresh install of v2.4 and the define is still missing. What are the TEXT_CHECKOUT_LOGOFF_CUSTOMER and TEXT_CHECKOUT_LOGOFF_GUEST defines "supposed" to say?