This was the bugfix that needed to be applied - Re: 157: plugins watching shared notifiers may not all trigger properly , I should have paid more attention to that thread.
This was the bugfix that needed to be applied - Re: 157: plugins watching shared notifiers may not all trigger properly , I should have paid more attention to that thread.
Last edited by simon1066; 28 Sep 2020 at 05:18 PM. Reason: 'SNAP'
Simon
Hello,
I am finally finding time to work further on trying to add support for Japanese (some issues with zones, as well as adding language and hiragana fields) to OPC.
I have had to disable OPC because while it worked beautifully for guest checkout and registrations, it gave an error when trying to add addresses, since my shop's user creation and address book registration/changing code has been modified to support the needs of users here in Japan (selecting a language for the address, so that users can register an address in either English or Japanese, and then fields for hiragana name/surname as appropriate, plus multilanguage zone and country support).
I am working now using the code of OPC 2.3.4.
I suspect most of my work will be limited to editing files in includes/modules/pages/checkout_one/, with no changes needed in modules/pages/create_account/ unless I want to change the default population of an account.
I understand I will need to change the function "saveAddressValues" in the file jquery.checkout_one.js. This seems fairly simple.
However, in the file jquery.checkout_one_addr.js there is mention of an array "z2c" in function "updateCountryZone", but I cannot find this anywhere.
Apparently it is supposed to be supplied by jscript_main.php, but there is no mention of it there. I definitely need to edit the creation of this array. Can anyone point out where I may find it?
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
Sorry, meant to write "c2z", not "z2c". Still, cannot find the array anywhere.
Apart from the page files above, most of the work will be in includes/classes/OnePageCheckout.php to add Japanese address requirements (language choice for address, hiragana support in new name fields, and multilanguage country and zone support). In standard Zen Cart this is done in the PHP and the JavaScript files (for real-time zone updates when country or language selection changes, so one more level added: address language change also changes display of country and zones).
Plus then adding new fields to the various template files, just like in standard Zen Cart.
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
@gernot, that c2z (country-to-zone) lookup table is generated by the OnePageCheckout class' getCountriesZonesJavascript method (as called by /includes/modules/pages/checkout_one/jscript_main.php) when state dropdowns are enabled for a site.
I'll suggest, if you're planning on "tinkering" with OPC's innards (i.e. /includes/classes/OnePageCheckout.php) that you create a Japanese version that uses class-inheritance so that you override only what's needed. That will save you a 'world-of-hurts' if/when that class is updated in the future.
That class is loaded at CP-0 and instantiated into the session at CP-75 by its auto_loader. If your class-override was loaded at CP-1 (so that it can extend OnePageCheckout) and instantiated into the session at CP-74, then the base OPC class will not be loaded, since it checks for instantiation prior to its load.
@lat9
Many thanks for the pointer, I saw the function in the class file, not sure why search for c2z in Windows did not show me that file. I know I need to modify many of the functions in the class, and was only too aware of the world of hurts you speak of (and which I have at each Zen Cart upgrade too).
I will play with the auto_loader method, although I need to first figure out class inheritance, and the implementation of loading and instantiation. All good basic study for further work on Zen Cart!
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
@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:
Then I put only the changed functions, with the same names as in the original OnePageCheckout class, into the new file.Code:OnePageCheckoutJP extends OnePageChekout
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):
In this class override, does the "objectName" remain "opc"? I am confused (easily I may add!).Code: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 );
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
@gernot, you're on the right track!
First, in the new auto_loader, you'll instantiate your class-override as the 'opc' session value. Since that will occur at CP-74, the instantiation of the base OPC at CP-75 won't occur, since the auto-loader won't overwrite that class if it's already there.
For the class-inheritance, you're correct ... you'll only provide the methods in your class that are being overridden, with the same names and inputs as the 'base' OPC methods. You might take a peek at my Database I/O Manager as its /admin/includes/classes/dbio/DbIo*Handler.php classes use class-inheritance to provide handler-specific actions while using common/base functions within the DbIoHandler.php class.