Administrator
- Join Date:
- Sep 2009
- Location:
- Stuart, FL
- Posts:
- 14,109
- Plugin Contributions:
- 56
Add Customers from Admin 2.0 (1.5.0 and later) [Support Thread]
jasontomczak, are there any myDebug*.log files in your store's /logs directory?
Views: 41,568
Administrator
jasontomczak, are there any myDebug*.log files in your store's /logs directory?
New Zenner
lat9:
jasontomczak, are there any myDebug*.log files in your store's /logs directory?
Yes. Here it is, with my server path obscured:
[16-Feb-2013 14:32:47] PHP Warning: Invalid argument supplied for foreach() in /store/oooooo/add_customers.php on line 129
Administrator
Would you send me either the full or a partial CSV file via PM so that I can "play" with it and see what's going on?
Administrator
I downloaded your file and can verify that I receive the same behavior (screen just refreshes), but I don't get any log files (I'm running PHP 5.3.8). What version of PHP are you running?
I most likely won't be able to get more into this until tomorrow ...
New Zenner
lat9:
I downloaded your file and can verify that I receive the same behavior (screen just refreshes), but I don't get any log files (I'm running PHP 5.3.8). What version of PHP are you running? I most likely won't be able to get more into this until tomorrow ...
Looks like PHP 5.2.x. Not sure which subversion, but 5.2-something. Tomorrow is fine. Thanks! :D
Administrator
What OS are you running and what program are you using to create the CSV file? The file you sent me has only <CR>, not <CR><LF> at the end of each line.
Administrator
Gotta love https://www.php.net! I'll get an update together within the next couple of days. In the interim, you'll need to edit /YOUR_ADMIN/add_customers_backend.php, adding one line and changing another around line 40:
...
function check_file_upload() {
global $db, $row_positions, $post, $acfa_lines;
$files = $_FILES['bulk_upload'];
$errors = array();
$to_insert = array();
if (!zen_not_null($files['name'])) {
$errors[] = ERROR_NO_UPLOAD_FILE;
} else {
if ($files['error'] != 0) {
$errors[] = sprintf (ERROR_FILE_UPLOAD, $files['error']);
} else {
$pos = strrpos($files['name'],'.')+1;
$allowed_extensions = array ( 'TXT', 'CSV' );
$extension = substr ($files['name'], $pos);
if ( (strlen ($extension) < 1 ) || !in_array(strtoupper($extension), $allowed_extensions) ) {
$errors[] = sprintf (ERROR_BAD_FILE_EXTENSION, $extension) . implode(', ', $allowed_extensions);
} else {
$path = DIR_FS_UPLOADS . $files['name'];
if (!move_uploaded_file($files['tmp_name'], $path)) {
$errors[] = ERROR_CANT_MOVE_FILE;
} else {
chmod($path, 0775);
ini_set("auto_detect_line_endings", true); /*v2.0.3a*/
$lines = file($path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); /*v2.0.3c*/
...
I'll also beef up some of the error-detection that's present in the files ...
New Zenner
lat9:
What OS are you running and what program are you using to create the CSV file? The file you sent me has only <CR>, not <CR><LF> at the end of each line.
Using OS X Mountain Lion and Excel for the CSV. I saved it in Windows Comma Separated format.
New Zenner
lat9:
Gotta love https://www.php.net! I'll get an update together within the next couple of days. In the interim, you'll need to edit /YOUR_ADMIN/add_customers_backend.php, adding one line and changing another around line 40:
...
function check_file_upload() {
global $db, $row_positions, $post, $acfa_lines;
$files = $_FILES['bulk_upload'];
$errors = array();
$to_insert = array();
if (!zen_not_null($files['name'])) {
$errors[] = ERROR_NO_UPLOAD_FILE;
} else {
if ($files['error'] != 0) {
$errors[] = sprintf (ERROR_FILE_UPLOAD, $files['error']);
} else {
$pos = strrpos($files['name'],'.')+1;
$allowed_extensions = array ( 'TXT', 'CSV' );
$extension = substr ($files['name'], $pos);
if ( (strlen ($extension) < 1 ) || !in_array(strtoupper($extension), $allowed_extensions) ) {
$errors[] = sprintf (ERROR_BAD_FILE_EXTENSION, $extension) . implode(', ', $allowed_extensions);
} else {
$path = DIR_FS_UPLOADS . $files['name'];
if (!move_uploaded_file($files['tmp_name'], $path)) {
$errors[] = ERROR_CANT_MOVE_FILE;
} else {
chmod($path, 0775);
ini_set("auto_detect_line_endings", true); /v2.0.3a/
$lines = file($path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); /v2.0.3c/
...
> I'll also beef up some of the error-detection that's present in the files ...
**SUCCESS!!** It worked that time! Thank you thank you!
Administrator
I've submitted v2.0.3 to the Plugins area; that version includes the change identified above and some additional error-checking on the imported CSV file.
Zen Follower
I installed the add customer in admin mod on zen cart 1.5.1. When I clicked on the link "Formatting the CSV" in my admin area under customer>add....a page not found opens with the link at the top with the following link prefix ending, add_customers_formatting_csv.html I have look in the admin folder and can't find anywhere add_customers_formatting_csv.html file
My question:
Where would I find this file in my file manager?
How do I get the link to open to the add_customers_formatting_csv.html page?
Diva Boutiques
www.divaboutiques.com
Administrator
divaboutiques, that file is part of the distribution zip-file that came with the plugin; it's in the root directory. Copy that file to the root directory of your store and the link will be resolved.
Zen Follower
lat9:
divaboutiques, that file is part of the distribution zip-file that came with the plugin; it's in the root directory. Copy that file to the root directory of your store and the link will be resolved.
Thank you for the response!
i went ahead and found the add customer from admin mod......the mod I downloaded was admin new customer which didn't have all the csv files.....
and it worked thanks!
Diva Boutiques
www.divaboutiques.com
New Zenner
Hi,
Im running1.5.1 and can not get this to show up in the admin menu? any tricks to it, ive installed plenty of mods before, am I missing something
Administrator
SLY Designs, the only reason that the "Add Customers" link wouldn't show on the Customers tab in your admin is if either (a) you didn't copy /includes/extra_datafiles/add_customers_filenames.php, /includes/functions/extra_functions/init_add_customers.php and /includes/languages/english/extra_definitions/add_customers_name.php into your admin directory or (b) you copied the /YOUR_ADMIN directory contents to your store's root directory without renaming /YOUR_ADMIN to match your admin's "secret name".
The install for the v1.5+ series happens automatically via /YOUR_ADMIN/includes/functions/extra_functions/init_add_customers.php, so those are the only two reasons that I can fathom for the tool not showing up in your admin toolbar.
New Zenner
I have successfully installed your addon to my Zen cart to Add Customers from Admin - I've given it 5 stars too!!
I originally used the bulk upload which worked great and and now add them one by one as I sell on ebay.
I have figured out that it will default to customer Email type (HTML/Text) by reading the setting in Configuration-Customer Details-Customer Default Email Preference
However, it does NOT read the setting Configuration-Customer Details-Show Newsletter Checkbox which I want it to default to Subscribe.
Which php file would I edit so that as I add a customer manually it is defaulted to Subscribe to Newsletter, I always have to change this as I add each customer and it would save a few mouse clicks.
I am a .net developer by trade, just not as familiar with php, but am always happy to give something a try!!
Keep up the great work.
Totally Zenned
rcbitz:
I have successfully installed your addon to my Zen cart to Add Customers from Admin - I've given it 5 stars too!!
I originally used the bulk upload which worked great and and now add them one by one as I sell on ebay.
I have figured out that it will default to customer Email type (HTML/Text) by reading the setting in Configuration-Customer Details-Customer Default Email Preference
However, it does NOT read the setting Configuration-Customer Details-Show Newsletter Checkbox which I want it to default to Subscribe.
Which php file would I edit so that as I add a customer manually it is defaulted to Subscribe to Newsletter, I always have to change this as I add each customer and it would save a few mouse clicks.
I am a .net developer by trade, just not as familiar with php, but am always happy to give something a try!!
Keep up the great work. You want to think about this before you make this change. I'm pretty sure this defaults to no because of spam laws. And you are subscribing on behalf of your customer which is not the same as your customer subscribing for themselves.
My Site - Zen Cart & WordPress integration specialist
I don't answer support questions via PM. Post add-on support questions in the support thread. The question & the answer will benefit others with similar issues.
Administrator
@rcblitz, DivaVocals gave you good advice regarding customers' consent to subscribe to your newsletter.
If you're comfortable "signing up" one or more customers using the bulk upload feature, there is already a provision in the plugin to accomplish that. Just include a 'newsletter' column (see the readme.html and the example_addresses.csv file in the plugin's root directory) in your CSV file and specify the column's value as either 0 or 1 for each bulk-uploaded customer.
New Zenner
Thanks DivaVocals & lat9 for your replies - I understand the consent regarding the newsletter and spam.
I am doing a promotion at a tradeshow where customers fill out a card to subscribe to my newsletter and go into a draw to win a prize, so in that instance I would have their consent.
So aside from the spam issue and just looking at it technically I note that on line 393 of the file add_customers.php
<td class="main"><?php echo zen_draw_pull_down_menu('customers_newsletter', $newsletter_array, (($cInfo->customers_newsletter == '1') ? '1' : '0')); ?></td>
would I change one of those 1's or 0's to default to the other option, I still think it would be nicer to read the setting from Configuration-Customer Settings
more like on line 386 where it uses the default mail format:
echo zen_draw_radio_field('customers_email_format', 'HTML', $email_pref_html) . ' ' . ENTRY_EMAIL_HTML_DISPLAY . ' ' . zen_draw_radio_field('customers_email_format', 'TEXT', $email_pref_text) . ' ' . ENTRY_EMAIL_TEXT_DISPLAY ;
Otherwise I will have a play and see what happens - after making a backup of course!!
Thanks again Peter
Administrator
Peter, here's an updated code fragment (/YOUR_ADMIN/add_customers.php, starting at line#391) that should correct the issue you identified:
<tr>
<td class="main Label"><?php echo ENTRY_NEWSLETTER; ?></td>
<?php
//-bof-v2.0.4-a
$newsletter = ( (empty($cInfo) && ACCOUNT_NEWSLETTER_STATUS == '2') || (isset($cInfo) && $cInfo->customers_newsletter == '1') ) ? '1' : '0';
//-eof-v2.0.4-a
?>
<td class="main"><?php echo zen_draw_pull_down_menu('customers_newsletter', $newsletter_array, /*v2.0.4c*/ $newsletter); ?></td>
</tr>
Just add/change the code highlighted in red. I'll package this up shortly for submission to the plugins area. Thanks for the report!
Tell staff why this post should be reviewed.