Email Orders

From Custom Scriptz
Revision as of 02:20, 2 June 2009 by Diego (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Email Orders developed by Diego Vieira
Cannot be resold or freely distributed. This is not a free product.

To get your license key, go to <a href="http://customscriptz.com" target="_blank">http://customscriptz.com</a>

This modification need ionCube loaders installed on your system. If you try to use the files for first time and you receive this kind of message, you will need to ask your hosting company/administrator to install ionCube loaders.


What this does do?
Send email messages separately by manufacturer that have their products bought in the same order.

Example:
Customer buy 10 products from 3 different Manufacturers (often called Designers by Scrapbooking Store Owners). When you use Email Orders, 3 email messages will be sent out with the following contents:

ManufacturerA receive an email message with 3 products and his totals (with discount if any)
ManufacturerB receive an email message with 2 products and his totals (with discount if any)
ManufacturerC receive an email message with 5 products and his totals (with discount if any)
Store Owner receive an email message containing an report with the orders totals sent to this manufacturers.

If any coupon is used, the discount will be restricted only to the products/categories that have restriction to it. If a coupon is used and no restriction is applied, the discount is applied to all products for all emails with his own discount.

This module is aimed to be used at Stores that have their default currency set to USD. In the future it will be added support for different currencies.

Example:
EMAIL ORDER #1083

Order Number: #7335
Date: 2009-05-13 23:53:17

PRODUCTS ORDERED



Product name: Templates
Product model: Templates_01
Product price: $3.50
Product quantity: 1
File 01 of 01



Order Total: $3.50



Note: Same Order, but to another Manufacturer!

EMAIL ORDER #1083

Order Number: #7335
Date: 2009-05-13 23:53:17

PRODUCTS ORDERED



Product name: Template_02
Product model:
Product price: $5.00 (Coupon Applied)
Product quantity: 1
File 01 of 01
File 02 of 02
File 03 of 03
File 04 of 04
File 05 of 05



Order Total: $4.50 (Coupon Code: xxxxxx - Coupon Amount: 10.00%)

Before Installing
This modification needs to replace the file shop-root/admin/manufacturers.php with a modified one, if you have modded this file, do the replacements by hand in the bottom of this file.
The moded file is compatible with <a href="http://www.zen-cart.com" target="_blank">Zen-Cart</a> v1.3.8a and it's located at the directory 'extras' within this zip. If you have not changed the original file and your Zen-Cart version is 1.3.8a, you can safely replace the file 'admin/manufacturers.php' with the modified one. Just upload the 'admin' directory that is inside your 'extras' directory to your shop-root dir. ex. /home/username/public_html/shop or you can merge the 'admin' directory that is inside the 'extras' directory with the 'upload' directory.

Installing Instructions
Upload all files that are inside the folder "upload" to your shop-root directory by using your preferable ftp software.

Go to Customers -> Email Orders (if you have Admin Profiles mod, when you try to access this page you will get a 'Denied' page, so you must go to Tools -> Admin Settings and allow access to this file and try to access it again). Now you will be asked for the license key, go to <a href="http://customsriptz.com" target="_blank">http://customsriptz.com</a> then login into the client area, click on 'View Your Licenses' then 'View & Download' on the right, then you will see a box called 'Your License Key' that should look like this: 'EmailOrders-4a5s84d6asq8q'. Carefull when copying your license key, because if you miss typing the code inside the right box, you will need to reupload the file 'email_orders_license_key.php' or do the manual editing of this file. Now that you have copied the license key, past it into the text field and hit the button Save. If everything is ok, you should see the email orders page asking you to Install it. If not, insert your key manually by doing the steps below or try to reupload the file 'email_orders_license_key.php' overwriting the old one.

Manyally editing license key file if the step above failed:
Open the file 'upload/admin/email_orders_license_key.php' with notepad and past your license key around the quotes $license="Past here your license..."; -> ex. $license="EmailOrders-4a5s84d6asq8q"; (don't remove the quotes or the ;) save and upload this file to your admin folder and replace the older one. Try to access the email orders page now and hit the Install button and follow the instructions.

and.. nothing else, just configure what you want and you are ready to go. Easy isn't?! :D


After Installing
Go to Catalog -> Manufacturers and edit each Manufacturer Email Address. If you don't type the email address for a particular Manufacturer, when you try to send a email order for him/her, you will get a error and the email will not be sent until you type his email address.

   By default the software is set to work in Debug Mode, after you are done testing, you may want to change it to live mode, to do this go to Configuration -> Email Orders -> Debug Mode and set this to False. While debug mode is On, you will see a report at your screen like how the email message would be sent, but no emails will be send until you set debug mode to False.


Upgrading Instructions
Do a full backup of your database and files before continue. We are not responsible for any loss of data.

Upload all the files that are inside the folder "upload" to your shop-root directory by using your preferable ftp software, overwriting the old files.
Go to Customers -> Email Orders -> press the button 'Update'.

Settings Available

All the setings below can be found at: Configuration -> Email Orders

   Cron Admin ID - For the first time you install Email Orders, this will be set to the admin ID that installed the software, but if you delete that admin, you must change this ID for your current admin ID. You can see your admin ID going to Tools -> Admin Settings and click the green (E) and look at the right panel, you will see a number before your login name, this is your admin ID. (this is not necessary until AutoSend feature is ready)

Debug Mode - If this is set to True, you will see the email that would be sent out, but not sent any email until this is change to True.

Include Gift Certificate - Changing this to false, will cause the software to not include GIFT certificates. Default = True (True meaning include gift certificates).

Maximum Emails per Batch - When you use AutoSend feature, this will determine how many emails you can sent per batch, so if you set your cron job to run every hour it will send this amount of emails or if you set your cron job to run each 30 minutes, this value will be 2x per hour, so carefull when changing this value. Default = 25.

Send $0 Email Orders - Changing this to false, will cause the software to not send email out if the Order Total is $0. (ex. after a coupon of 100% is applied towards the entire order, the order total will be $0). Default = True.

Show Customer Details - This is to show the customer details within email messages, but I highly recommend leave this setting Off because of Privacy Policy. I'm not responsible for the bad use of this feature. Default = False.

Show $0 Products - This will show the products with price of $0.00 (normally Free products) to be displayed at the send form and used with AutoSend feature. Default = False.

Email Orders Page - Send Old feature - You can resend products that have been sent already, when you access the Email Orders page, you will see a 'Send Old' button at the top of the page (allright, I'll move that button to the statistics panel :p). So you click the Send Old and do a search for the period that you want and send the products again as you do normally. Note: Products that have been sent will not disappear for this list, instead the column 'Sent Times' will increase by 1 each time you send the order. If you want to send new emails, just click the Send New button.

Additional Settings
Catalog -> Manufacturer -> Manufacturer New/Edit Page

Manufacturers Email - This is necessary if you want to send email to this manufacturer.

Receive Email Orders - Check this if you want this manufacturer to receive email orders, otherwise his/her products will not be available for you to send to him/her until you check this.

How to Use
When you are ready, go to Customers -> Email Orders.

In this page you will see a list of Products with their respective Manufacturers. Check the products (99% of the time you will leave the products checked - but you can un/check all the boxes at the top of the column with the boxes) that you want your manufacturers to receive the email for it and press the button "Send". If everything nothing goes wrong, your manufacturers should receive a email right way with his bought products. Now you are done sending and the next batch/page (if there are remaining products) will be displayed and you press the button "Send" to start again. If failed to send the email out (manufacturer with no email address for example) the products will be displayed again until you you correct the email address at the Manufacturers page. Next version you will be able to configure a scheduled task to do the job for you.

AutoSend
In Development

Note
- This tool send a email for each order for each manufacturer that has products in the order. Ex. Order #1234 -> 3 Manufacturers envolved, 3 email messages will be sent out, Order #1235 -> The same 3 Manufacturers, 3 email will sent out for that and this particular order, total = 6 messages. Before complaining that the tool is not working, check your email settings at My Store -> E-Mail Options or ask your host to increase the limit of email messages that you can send per hour. Maybe you have reach this limit.

Troubleshooting
Q: One product does not appear on the list for me to send, why?
A: Check if this a product have a manufacturer set up on the Products Page. This is a free product and your configuration is set to 'False' to not send products with price of $0.

Manually Editing

   File: shop-root/admin/manufacturers.php
FIND:
$manufacturers_name = zen_db_prepare_input($_POST['manufacturers_name']);

AFTER THAT LINE ADD:
$manufacturers_email = zen_db_prepare_input($_POST['manufacturers_email']);
$manufacturers_receive_orders = zen_db_prepare_input($_POST['manufacturers_receive_orders']);


FIND:
$sql_data_array = array('manufacturers_name' => $manufacturers_name);

REPLACE WITH:
$sql_data_array = array('manufacturers_name' => $manufacturers_name, 'manufacturers_email' => $manufacturers_email, 'manufacturers_receive_orders' => $manufacturers_receive_orders);

FIND:
$manufacturers_query_raw = "select manufacturers_id, manufacturers_name, manufacturers_image, date_added, last_modified from " . TABLE_MANUFACTURERS . " order by manufacturers_name";

REPLACE WITH:
$manufacturers_query_raw = "select manufacturers_id, manufacturers_name, manufacturers_email, manufacturers_receive_orders, manufacturers_image, date_added, last_modified from " . TABLE_MANUFACTURERS . " order by manufacturers_name";

FIND:
$contents[] = array('text' => '<br>' . TEXT_MANUFACTURERS_NAME . '<br>' . zen_draw_input_field('manufacturers_name', , zen_set_field_length(TABLE_MANUFACTURERS, 'manufacturers_name')));

AFTER THAT LINE ADD:
$contents[] = array('text' => '<br>' . TEXT_MANUFACTURERS_EMAIL . '<br>' . zen_draw_input_field('manufacturers_email', , 100));
$contents[] = array('text' => '<br>' . TEXT_MANUFACTURERS_RECEIVE_ORDERS . '<br>' . zen_draw_checkbox_field('manufacturers_receive_orders', '1', 'checked'));


FIND:
case 'edit':

AFTER THAT LINE ADD:
$check = ;
if($mInfo->manufacturers_receive_orders) $check = 'checked';


FIND:
$contents[] = array('text' => '<br />' . TEXT_MANUFACTURERS_NAME . '<br>' . zen_draw_input_field('manufacturers_name', $mInfo->manufacturers_name, zen_set_field_length(TABLE_MANUFACTURERS, 'manufacturers_name')));

AFTER THAT LINE ADD:
$contents[] = array('text' => '<br />' . TEXT_MANUFACTURERS_EMAIL . '<br>' . zen_draw_input_field('manufacturers_email', $mInfo->manufacturers_email, 100));
$contents[] = array('text' => '<br />' . TEXT_MANUFACTURERS_RECEIVE_ORDERS . '<br>' . zen_draw_checkbox_field('manufacturers_receive_orders', '1', $check));


   FIND:
$contents[] = array('text' => '<br>' . zen_info_image($mInfo->manufacturers_image, $mInfo->manufacturers_name));

AFTER THAT LINE ADD:
$contents[] = array('text' => '<br>' . $mInfo->manufacturers_email);

SAVE, CLOSE AND UPLOAD TO YOUR shop-root/admin DIR



Change Log

v1.0
1. Initial Release

v2.0
1. A lot of improvimentst to the SQL queries
2. Deleted file email_orders_edit_designers.php and move the field Email to Manufacturers Page
3. Patched manufacturers.php file to include Email field. Zen-Cart v1.3.8a.
4. Created README file with Upgrade/Installation Instructions, Settings and How to Use. Included manually edits for file manufacturers.php.
5. Added Spam disclaimer and copyright notice to the bottom of the emails sent. (in the next version, members will be able to buy the version withow the copyright notice)
x. Many, many improvements to the performance and minor bug fixes.

v3.0
1. AutoSend under test (not fully working)
2. Added setting 'Cron Admin ID' for future AutoSend feature
3. Added setting 'Maximum Emails per Batch' for future AutoSend feature
4. Added setting 'Show $0 Products'
5. Reports are now sent to the Store Owner with the send result for both Manual Send and AutoSend.
6. Install/Update feature withow manually doing SQL updates.
7. Set if a manufacturer can receive email or not for his/her products.
8. Resend products that are previosly sent.
x. Fixed minor bugs

v3.1
1. Manufacturers can now be set to receive or not email orders.
3. Moved all Email Orders Settings to it's own configuration Group to Configuration -> Email Orders
4. Added setting 'Include Gift Certificate'
5. Added setting 'Send $0 Email Orders'
6. Added setting 'Send $0 orders'
7. Emails are now sent using HTML and Plain TEXT
x. Minor improvements

Next Version

- Set a scheduled task (cron job) to send the emails out (AutoSend feature)
- Allow selection of what to show at the email message such as, Customer name, Order number, etc
- Statistics panel with: How many email orders has been sent, Manufacturers total, grand total.. (suggestions are welcome)
- Begin test with other currencies