Enhancements to Zen Cart 360 Sales Reporting

I have added an optional feature to Zen Cart 360 Sales Reporting (link) which shows recent direct deposits on the admin dashboard.  Update admin/index_dashboard.php, and at the end of the file, add this block of code:

<div id="colthree" class="col-xs-12 col-sm-6 col-md-4 col-lg-4">
<div class="reportBox">
<div class="header"><?php echo "Recent Direct Deposits"; ?> </div>
<?php
require_once(DIR_WS_CLASSES . 'currencies.php');
$currencies = new currencies();
$orders = $db->Execute( "SELECT * FROM " . TABLE_DIRECT_DEPOSIT . " ORDER BY deposit_date DESC LIMIT 5");
while (!$orders->EOF) {
?>
  <div class="row">
  <span class="left">
    <?php echo substr($orders->fields['name'], 0, 20); ?>
  </span>
  <span class="center">
     <?php echo $currencies->format($orders->fields['amount']); ?>
  </span>
  <span class="left">
     <?php echo $orders->fields['deposit_date']; ?>
  </span>
</div>
<?php
$orders->MoveNext();
}
?>
</div>
</div>

Zen Cart Coupon Single User

Zen Cart Coupon Single User has been upgraded so that you can now restrict a coupon to any email address on a single domain, not just a single email.

So for example, if you want to permit a coupon to only be used by customers with a “@BigClient.com” email address, you would create a coupon code starting with “@BigClient.com”, such as “@BigClient.com_save_ten” or “@BigClient.com-half-off”.

BUG: Always Display State as a Pulldown in Zen Cart 1.5.5

There’s a bug in Zen Cart 1.5.5 that causes the State dropdown not to be correctly populated when you set Configuration->Customer Details->State - Always display as pulldownto true in Admin->Configuration->Customer Details.  It causes your State dropdown menu to look like this:

Zen Cart State dropdown without state set

even though the value of State has been set.

You can see the root cause of this error in the Chrome Javascript debugger.  Right click and select Inspect, then click the Console tab, and you’ll see the traceback for the error.

Traceback in Zen Cart for no state error in 1.5.5

The root cause of the error was that the stText element id was removed from the default template Zen Cart 1.5.5, an attempt to modify that DOM element failed, and stopped JavaScript processing.  The fix was straightforward; just check for this element’s existence before updating it.  You can pull the fix from Github and apply it to your Zen Cart 1.5.5 site, or hire me to do it.

Zen Cart – MailChimp Integration

My Zen Cart – MailChimp integrations have received the following updates:

  • Fixed bug in API integration:
    The original integration had error checking that was based on the 1.3 API, and lo longer work.  So while the success path logic was all correct, the error handling was wrong.
  • Added instructions for changing Zen Cart newsletter page:
    The original Zen Cart integration only handled signup on the account creation page. Now users may subscribe or unsubscribe on the newsletter page (which is linked to on the My Account page as /index.php?main_page=account_newsletters.
  • Removed double opt in:
    At the request of ecommerce companies, MailChimp has changed the default subscribe behavior so that double opt in is no longer required.  Users who prefer the prior behavior can still change it back by modifying the PHP API (includes/functions/extra_functions/mailchimp.php) to set status based on $options[‘status’] rather than just to subscribed.
  • Moved MailChimp error log to /logs folder:
    In the event of an error, the MailChimp.log file was being written to the /cache folder; it is now written to the /logs folder where it is more likely to be noticed (since most logfiles have been migrated there in Zen Cart 1.5+).

You can see the updates in my ZenCart MailChimp and ZenCart Newsletter Discount contributions, and  my MailChimp Integration for Zen Cart GitHub repository.

From Zen Cart to Salesforce – Handling Accounts

Unlike most B2C e-commerce systems, Salesforce makes a distinction between Contacts, which are identified by an email address, and Accounts, which are identified by a name and site.  Contacts belong to an Account, and an Account may have many Contacts.

The way I handled this relationship in the first version of  Zen Cart to Salesforce was simply use the email address as the Account name. This has a significant advantage, since the email address for a shopping cart account is an immutable field.

However, some larger customers have multiple email addresses associated with a single account.   Also, some customers had e-mail address changes over the life of their relationship with me.

For these reasons, I decided to add a “salesforce_account_name”  field to the customers table.  I populate this only in cases where the email address is not sufficient.   I also had to modify the customer export script to export that field rather than the email address in the Account column of the CSV when it was set.

This new way of handling Accounts is reflected in the 360 Sales Reporting modification I did, to get more accurate per-account sales data.

Showing Zen Cart Customer Updates needed by Salesforce

If you’ve installed my Zen Cart to Salesforce Customer Import tool, and done a few exports of customers from your admin, you’d probably like an easy way to see how many updates (if any) are outstanding when you login to your Zen Admin.

I have made a small modification to the admin dashboard (in Zen Cart 1.5.5) to do this, which is described below.  Steps:

a) Add the define BOX_ENTRY_UPDATES_TO_SALESFORCE to admin/includes/languages/english/index.php.

define('BOX_ENTRY_UPDATES_TO_SALESFORCE','New/Updated records for Salesforce');

b) Add the logic to calculate and display the number of new/updated records to admin/index_dashboard.php.

Calculate it below the salemaker query on line 31:

$last_export = $db->Execute("SELECT * FROM " . TABLE_SFDC_CONFIG);
$last_customers_export = $last_export->fields['last_customers_export'];
$salesforce_customers_query = "SELECT count(*) AS count FROM " . 
   TABLE_CUSTOMERS . " c, " . TABLE_ADDRESS_BOOK . " a, " . 
   TABLE_CUSTOMERS_INFO . " ci WHERE a.customers_id = c.customers_id 
   AND a.address_book_id = c.customers_default_address_id AND 
   ci.customers_info_id = c.customers_id AND 
   (ci.customers_info_date_account_created > '" . 
   $last_customers_export . "' OR 
   ci.customers_info_date_account_last_modified > '" . 
   $last_customers_export . "')";
$salesforce = $db->Execute($salesforce_customers_query);

Now display it below the customers count display on line 72:

 
echo '<div class="row"><span class="left">
   <a href="' . zen_href_link(FILENAME_SFDC_EXPORT_CUSTOMERS) . '">' . 
   BOX_ENTRY_UPDATES_TO_SALESFORCE . '</a></span>
   <span class="rigth"> ' . $salesforce->fields['count'] . '</span></div>';

The typo in the class name right is required in Zen Cart 1.5.5; it has been fixed in Zen Cart 1.5.6.

Lifetime Customer Value for Zen Cart customers

When coach Ryan Waggoner asked me about the lifetime value of my average customer, I was embarrassed to say I didn’t know!  So I added Lifetime Customer Value to the Zen Cart Admin->Customers page in this pull request.  The change is now in the 1.5.6 branch, but it can be easily backported to any 1.5.x version of Zen Cart.  It’s a great way to get visibility into the activity of all you customers, and especially your most valuable ones.

Wild Dove Messaging System for Zen Cart

Got this from a client in Hawaii:

Scott,

I continue to be impressed with your use of innovative communication systems, especially those custom designed for customers dealing in bioresources!

While I was doing hours of Zen Cart meditations, your messenger flew into the office.

We were a little offended by the fresh avian “software” downloaded on the desk but I did get the message…

Aloha,
Ed

Wild Dove in Hawaii