Zen Follower
- Join Date:
- Feb 2017
- Location:
- Tokyo, Japan
- Posts:
- 334
- Plugin Contributions:
- 0
One-Page Checkout [Support Thread]
@lat9
I am looking into your suggestion of class inheritance. First time to do, and I am confused as to where the new and old class are supposed to meet logically.
Firstly, I am not sure whether class override means overriding the whole class, or just a subset of its functions. I assume the latter for now in this example.
Let's say I create new file OnePageCheckoutJP.php and in it have a new class definition to extend your class:
OnePageCheckoutJP extends OnePageChekout
Then I put only the changed functions, with the same names as in the original OnePageCheckout class, into the new file.
Then in class autoloader file config.checkout_one.php I would (well, it would be a new file, but just to illustrate the point) add new definitions for loading (CP-1) and instantiation (CP-74):
autoLoadConfig[0][] = array(
'autoType' => 'class',
'loadFile' => 'OnePageCheckout.php'
);
// new CP-1 loading
autoLoadConfig[1][] = array(
'autoType' => 'class',
'loadFile' => 'OnePageCheckoutJP.php'
);
// new CP-74 instantiation
$autoLoadConfig[74][] = array(
'autoType' => 'classInstantiate',
'className' => 'OnePageCheckoutJP',
'objectName' => 'opc',
'checkInstantiated' => true,
'classSession' => true
);
$autoLoadConfig[75][] = array(
'autoType' => 'classInstantiate',
'className' => 'OnePageCheckout',
'objectName' => 'opc',
'checkInstantiated' => true,
'classSession' => true
);
In this class override, does the "objectName" remain "opc"? I am confused (easily I may add!).
You wrote "then the base OPC class will not be loaded", that seems to imply that actually I need to override the entire class rather than just certain functions within the class?
Any pointers much appreciated.
Zen Cart 1.5.6c modified for Japanese language support. Upgraded incrementally from initial 1.5.5d. Currently planning direct upgrade to 2.1.0