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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.