Hacking core eCommerce for php7 and c5.6.4
PermalinkFor anyone else doing similar, here is a summary of the code changes I have so far found necessary. Line numbers may not be precise because the cumulative effect of changes can shift them down a bit.
core_commerce/libraries/discount/controller.php [controller.php at line 34, column 50] public function setupAndRun($method=null) // php7, make optional core_commerce/libraries/payment/controller.php [controller.php at line 19, column 50] public function setupAndRun($method=null) // php7, make optional core_commerce/libraries/shipping/controller.php [controller.php at line 25, column 50] public function setupAndRun($method=null) // php7, make optional core_commerce/models/attribute/categories/core_commerce_order.php [core_commerce_order.php at line 15, column 54] public function load($akID, $loadBy = 'akID') // php7, match parameters core_commerce/models/attribute/categories/core_commerce_product.php [core_commerce_product.php at line 55, column 54] public function load($akID, $loadBy = 'akID') // php7, match parameters
So far, that has cured everything in a benign way, except for one really bad parameter mismatch in
core_commerce/models/attribute/types/product_price_adjustment_select/controller.php, CoreCommerceProductAdjustmentSelectAttributeTypeOption::add
The solution to that is a bit more hacky, to suppress the warning. I found and adapted a trick on stack overflow at https://stackoverflow.com/questions/36079651/silence-declaration-sho... . Rather than suppress all warnings, or all declaration warnings, I adapted to catch the specific warning.
if (PHP_MAJOR_VERSION >= 7) { set_error_handler(function ($errno, $errstr) { if(strpos($errstr, 'Declaration of CoreCommerceProductAdjustmentSelectAttributeTypeOption::add') === 0){ return true; } }, E_WARNING); }
For convenience I currently have this code at the bottom of /config/site.php.
The snippet could be adapted to target other specific warnings, though it is always better to resolve the source of the problem.
Anyway, with this in place I now have a dev clone of an eCommerce site running under php7. My own Zone Based Shipping addon, also used on the site, runs happily with php7.
If I find any more changes needed to make eCommerce behave under php7, I will post to this thread.

I am a little confused with the term 'core' as I thought eCommerce was a paid 5.6 addon.
Is there a plan to incorporate eCommerce into the 5.6.4 core?
The package handle is core_commerce, even though its name is eCommerce. It was developed by the 'core team' at Prortland Labs.
AFAIK, there are no moves for integration with the 5.6.4 core.
Thank You
Details are listed at https://www.c5magic.co.uk/add-ons/zone-based-shipping/php7/...