The above may be moot, as I have been thinking about the processing sequence while studying the various files. There is no reason for orderTagBuilder.php to be autoloaded on every page. It only needs to be active when the order class is active. If it would be discarded and rebuilt on a fresh page load with autoload, it would actually be bad to autoload.
What I am thinking is to have an autoloaded observer that looks for the order class to be instantiated, and load and instantiate orderTagBuilder at that time (only). If the order class/object persists until the end of checkout, would orderTagBuilder also persist when instantiated in the same way?
config.orderTagBuilderLoader.php:
PHP Code:
<?php
/*
* //@package autoloaders (In includes/auto_loaders)
* @copyright Copyright 2017 Glenn J. Herbert (gjh42)
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: config.orderTagBuilderLoader.php 2017-04-04 gjh42 $
*/
$autoLoadConfig[10][] = array('autoType'=>'class',
'loadFile'=>'observers/orderTagBuilderLoader.php');
$autoLoadConfig[160][] = array('autoType'=>'classInstantiate',
'className'=>'orderTagBuilderLoader',
'objectName'=>'orderTagBuilderLoader');//160 to be ready when order is instantiated?
//eof
orderTagBuilderLoader.php:
PHP Code:
<?php
/**
* File loads & instantiates the car & tent tag building code for confirmation e-mail
*
* //@package classes
* @copyright Copyright 2017 Glenn J. Herbert (gjh42)
* @copyright Copyright 2003-2007 Zen Cart Development Team
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: orderTagBuilderLoader.php 2017-04-04 gjh42 $
*/
class orderTagBuilderLoader extends base {
function __construct() {
//$this->attach($this, array('NOTIFY_CHECKOUT_PROCESS_BEFORE_ORDER_TOTALS_PRE_CONFIRMATION_CHECK'));
global $zco_notifier;//alternate version of constructor
$zco_notifier->attach($this, array('NOTIFY_CHECKOUT_PROCESS_BEFORE_ORDER_TOTALS_PRE_CONFIRMATION_CHECK'));//from /includes/modules/checkout_process.php
}
function update(&$class, $eventID) {
require(DIR_WS_CLASSES . 'observers/orderTagBuilder.php');
$orderTagBuilder = new orderTagBuilder;
}
}
//eof
/includes/modules/checkout_process.php, lines 55-66:
PHP Code:
require(DIR_WS_CLASSES . 'order.php');
$order = new order;
// prevent 0-entry orders from being generated/spoofed
if (sizeof($order->products) < 1) {
zen_redirect(zen_href_link(FILENAME_SHOPPING_CART));
}
require(DIR_WS_CLASSES . 'order_total.php');
$order_total_modules = new order_total;
$zco_notifier->notify('NOTIFY_CHECKOUT_PROCESS_BEFORE_ORDER_TOTALS_PRE_CONFIRMATION_CHECK');
Bookmarks