Zen Cart v1.5.4 Released!

 plugins, v1.5.4, zen-cart  Comments Off on Zen Cart v1.5.4 Released!
Jan 012015
 

Zen Cart v1.5.4 was released yesterday, primarily containing bugfixes and performance improvements over and above Zen Cart v1.5.3; this version (like v1.5.0) is PCI-compliant.

One change of note is the addition of an admin function: zen_record_admin_activity.  This function is now widely used within the various Zen Cart admin modules, especially in the (ever popular) /YOUR_ADMIN/orders.php.  I’ve developed a backward-compatibility script that any Zen Cart plugin author can use; this script enables authors to upgrade their admin-level core-file overwrites to use the Zen Cart v1.5.4 version without the need for Zen Cart version-specific instructions in their installations.  This script (two files) is posted here on the Zen Cart forums.

At this time, all of my Zen Cart plugins (both free and commerical) have either been updated or verified to operate with Zen Cart v1.5.4!

Overriding Zen Cart Database Settings

 hints, php, troubleshoot, zen-cart  Comments Off on Overriding Zen Cart Database Settings
Mar 102014
 

I’ve had occasion to troubleshoot an issue for a client where it’s necessary to make a database configuration change.  Since I don’t like receiving credentials that I don’t need, I create an override file containing the database settings I’m interested in and apply them only if it’s me that’s accessing the site.

Let’s say, for example, that a client is having issues when CSS Buttons are enabled, i.e. Configuration->Layout Settings->CSS Buttons is set to Yes.  They’ve since set their site back to use the image-based buttons.

I’ll create the file /includes/extra_configures/enable_css_buttons.php that contains

if ($_SERVER['REMOTE_ADDR'] == 'my.ipa.ddr.ess') {
  define ('IMAGE_USE_CSS_BUTTONS', 'Yes');
}

Since the files in the /includes/extra_configures folder are loaded prior to the database initialization, that constant overrides the setting present in the database.  This will allow me — and only me — to see how the site looks with the CSS buttons enabled and perform my analysis without requiring access to the client’s Zen Cart admin!

Another Template-Override Method

 hints, php, plugins, zen-cart  Comments Off on Another Template-Override Method
Jan 272014
 

When you’re developing a plugin that needs to make major modifications to an existing Zen Cart template file, it can be difficult and/or cumbersome to add the required conditional statements and keep your code readable.  Zen Cart has a built-in mechanism to help!

The file /includes/templates/{current template}/common/main_template_vars.php (loaded by your store’s /index.php) sets the name of the file to be loaded to provide the formatting for the current page (page_name).  That file is either

  1. /includes/modules/pages/page_name/main_template_vars.php, if that file exists.
  2. /includes/templates/{current template}/templates/tpl_page_name_default.php, otherwise.

For example, to create a template override for a major change to the formatting of the account_history_info page for a plugin I’ve got in the works, I created the file /includes/modules/pages/account_history_info/main_template_vars.php and programmed that file to contain:

$tpl_page_body = ($is_multiship_order) ? '/tpl_account_history_info_multiship.php' : '/tpl_account_history_info_default.php';
require($template->get_template_dir($tpl_page_body,DIR_WS_TEMPLATE, $current_page_base,'templates'). $tpl_page_body);

That code will load the either my customized template or the built-in, default formatting template, depending on whether or not the order currently being displayed contains multiple ship-to addresses. Now, I can fully separate the formatting required to support the multiple ship-to addresses!

Watch the Zen Cart forums for the availability announcement for the Multiple Ship-To Addresses plugin!