An update regarding the ongoing work to drag Super Orders into the modern age and allow compatibility with Zen Cart 2.2.0
One major step forward with the latest version is that it's now an encapsulated plugin.
Popup windows have been retired and it now uses modal popups.
Pages have been updated to use Zen Cart's modern Bootstrap styling.
Does anyone have any objections if I identify this update as version 6.0.0?
The version numbers in the files are all over the place. I think v5.0.0 is the highest I've seen listed in the files, but as this is such a major rewrite I'd prefer not to just make it 5.1.0
I'll do a PR once I've finished testing and I'm sure I don't need to add any more.
So far there are new notifiers in invoice.php, packingslip.php, and orders.php
> Does anyone have any objections if I identify this update as version 6.0.0?
Please do so. This is very much in line with the kind of Semantic versioning that we're trying to use in the product.
And thanks for your hard work on Super Orders.
That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.
Hi @lat9 and @swguy,
While testing recent Super Orders updates, I’ve encountered a fatal error during batch printing of invoices or packing slips and would appreciate some guidance.
Issue Summary
When batch-printing multiple invoices or packing slips, a fatal error occurs once the second order is processed:
Root CauseCode:PHP Fatal error: Cannot declare class currencies, because the name is already in use in /includes/classes/currencies.php on line 18
Batch printing loops through multiple order IDs and repeatedly requires the same invoice/packing slip file:
Both invoice.php and packingslip.php contain:Code:foreach ($batch_order_numbers as $_order_number) { $_GET['oID'] = $_order_number; require $target_file; // invoice.php or packingslip.php }
On the first iteration, application_top.php loads normally and includes the currencies class.Code:require('includes/application_top.php'); ... $currencies = new currencies();
On subsequent iterations, require causes application_top.php to execute again, attempting to
re-declare the currencies class and resulting in the fatal error.
Proposed Solutions
Solution 1: Notifier-Based Approach (Observer Pattern)
In invoice.php and packingslip.php:
Observer example:Code:require('includes/application_top.php'); $currencies_already_initialized = false; $zco_notifier->notify( 'NOTIFY_ADMIN_INVOICE_CURRENCIES_INIT', $currencies_already_initialized ); if ( !$currencies_already_initialized && (!isset($currencies) || !is_object($currencies)) ) { $currencies = new currencies(); }
Solution 2: Explicit require_once for currencies ClassCode:$zco_notifier->attach( $this, 'NOTIFY_ADMIN_INVOICE_CURRENCIES_INIT', function (&$currencies_already_initialized) { global $currencies; if (isset($currencies) && is_object($currencies)) { $currencies_already_initialized = true; } } );
QuestionCode:require('includes/application_top.php'); require_once(DIR_WS_CLASSES . 'currencies.php'); $currencies = new currencies();
From a core-development perspective, which approach would be preferred for addressing this
batch printing issue: a notifier-based solution aligned with Zen Cart’s observer pattern, or a
simpler require_once safeguard?
Thanks for your guidance.
There was an error in this section
It would probably need to be more likeCode:require('includes/application_top.php'); require_once(DIR_WS_CLASSES . 'currencies.php'); $currencies = new currencies();
Code:require('includes/application_top.php'); // Ensure currencies class is available (use require_once to prevent redeclaration) require_once(DIR_WS_CLASSES . 'currencies.php'); // $currencies = new currencies();
Having reviewed this further, would it be workable to attach an observer to NOTIFIER_CURRENCIES_CONSTRUCT_END that treats the first currencies instance as canonical, and on subsequent instantiations copies state from the original instance so repeated new currencies() calls are effectively idempotent.
Where does the update stand? I have customers who still use Super Batch Print. Thanks!
That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.
Any updates on this plugin?
That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.