Forums / Developer / Userregister add Field to Checkout

Userregister add Field to Checkout

Author Message

Wenzel Wondra

Wednesday 25 March 2009 5:58:33 am

Hello @all,

I need to add a custom field to the user in the check out process - eZP 4.1.0.
Therefore I modified the ezwebin shop templates and copied /kernel/classes/shopaccounthandler.php to /extension/ezwebin/shopaccounthandlers/ezgkashopaccounthandler.php

Now I created /extension/ezwebin/settings/shopaccount.ini.append.php:

<?php /*
[HandlerSettings]
ExtensionRepositories[]=ezwebin
 
[AccountSettings]
Handler=ezgka
*/ ?>

So far so good, the new ShopAccountHandler gets executed. :)

But now I am really totally stuck - sorry - eZ rookie :(
How does the overriding of /kernel/shop/userregister.php work?

Any help would be really appreciated!

Thank you very much,
wewo

André R.

Wednesday 25 March 2009 7:09:30 am

Not related, but you should create your own extension and place your modifications in there instead of modifying ezwebin, will make it easier to upgrade later on.

On the issue, you can fork the view and place it in your extension (see shop/module.php for how userregister is setup as a view for the shop module), then use url translator (in setup tab in admin) to redirect (internally) from shop/userregister to yourmodule/shopuserregister. And just override the template and make your modified version of the view just use the same template.

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Wenzel Wondra

Wednesday 25 March 2009 2:45:33 pm

André, thank your very much for the quick answer!
OMG I have so much to learn about eZ :)

Following your advice, I startet a new module "gka" (what was my plan after finishing that task).

/extension/gka/
- ezinfo.php
- modules/
- - shopuserregister/
- - - module.php
- - - shopuserregister.php
- settings/
- - module.ini.append.php
- - site.ini.append.php

module.ini.append.php

<?php /* 
[ModuleSettings]
ExtensionRepositories[]=gka
ModuleList[]=shopuserregister
*/ ?>

site.ini.append.php

<?php /* #?ini charset="utf-8"? 
[ExtensionSettings] 
ActiveExtensions[] 
ActiveExtensions[]=gka 

[RoleSettings] 
PolicyOmitList[]=shopuserregister
*/ ?>

module.php

<?php
$Module = array( "name" => "GKAShop",
                 "variable_params" => true );

$ViewList = array();

$ViewList["shopuserregister"] = array(
    "functions" => array( 'buy' ),
    "script" => "shopuserregister.php",
    'ui_context' => 'edit',
    "default_navigation_part" => 'ezshopnavigationpart',
    'single_post_actions' => array( 'StoreButton' => 'Store',
                                    'CancelButton' => 'Cancel'
                                    )
    );

$FunctionList = array();
$FunctionList['buy'] = array( );
?>

shopuserregister.php is currently just a copy of the original userregister.php plus my new variable from the template.

Finally I added an url translator "user/userregister" -> "shopuserregister/shopuserregister" (gka/shopuserregister) did not work.

<b>And my new variable finally is in $order.data_text_1 :)</b>

Thank you so much - you made my day!
Wewo

André R.

Thursday 26 March 2009 2:59:10 am

Note:

[ExtensionSettings] 
ActiveExtensions[] 
ActiveExtensions[]=gka 

Should not be in the extension, only in settings/override/site.ini*, I guess you already have it there as the extension would not work without it ;)

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

eZ debug

Timing: Jan 31 2025 01:36:13
Script start
Timing: Jan 31 2025 01:36:13
Module start 'content'
Timing: Jan 31 2025 01:36:13
Module end 'content'
Timing: Jan 31 2025 01:36:13
Script end

Main resources:

Total runtime0.0291 sec
Peak memory usage6,144.0000 KB
Database Queries4

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0073 587.9531370.2891
Module start 'content' 0.00730.0123 958.24221,005.6563
Module end 'content' 0.01960.0094 1,963.898474.7031
Script end 0.0290  2,038.6016 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00258.7224120.0002
Check MTime0.00103.6034120.0001
Mysql Total
Database connection0.00082.784510.0008
Mysqli_queries0.003913.353740.0010
Looping result0.00000.041820.0000
Template Total0.009031.010.0090
Template load0.00082.884510.0008
Template processing0.008228.050910.0082
Override
Cache load0.00062.045110.0006
General
dbfile0.004314.7734100.0004
String conversion0.00000.018030.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs