Monday 15 December 2008 3:27:30 am
I want to create a Custome ShopAccount Handler for my Extension, where bank data is saved and can be shown on the customerorder view i created a directory in myextension /ezsimplepayment/shopaccounthandlers there i created a ezcustomshopaccounthandler.php file with follow content
<?
include_once( 'lib/ezxml/classes/ezxml.php' );
class eZCustomShopAccountHandler
{
/*!
*/
function __construct()
{
echo "construct";
}
/*!
Will verify that the user has supplied the correct user information.
Returns true if we have all the information needed about the user.
*/
function verifyAccountInformation()
{
return false;
}
/*!
Redirectes to the user registration page.
*/
function fetchAccountInformation( &$module )
{
echo "account";
$module->redirectTo( '/shop/userregister/' );
}
/*!
\return the account information for the given order
*/
function email( $order )
{
echo "email";
$email = false;
$xmlString = $order->attribute( 'data_text_1' );
if ( $xmlString != null )
{
$dom = new DOMDocument( '1.0', 'utf-8' );
$success = $dom->loadXML( $xmlString );
$emailNode = $dom->getElementsByTagName( 'email' )->item( 0 );
if ( $emailNode )
{
$email = $emailNode->textContent; }
}
return $email;
}
/*!
\return the account information for the given order
*/
function accountName( $order )
{
echo "accountname";
$accountName = '';
$xmlString = $order->attribute( 'data_text_1' );
if ( $xmlString != null )
{
$dom = new DOMDocument( '1.0', 'utf-8' );
$success = $dom->loadXML( $xmlString );
$firstNameNode = $dom->getElementsByTagName( 'first-name' )->item( 0 );
$lastNameNode = $dom->getElementsByTagName( 'last-name' )->item( 0 );
$accountName = $firstNameNode->textContent . ' ' . $lastNameNode->textContent;
}
return $accountName;
}
function accountInformation( $order )
{
echo "HIHO";
$firstName = '';
$lastName = '';
$email = '';
$street1 = '';
$street2 = '';
$zip = '';
$place = '';
$country = '';
$comment = '';
$state = '';
$paymentMethod = 'not filled';
$paymentData = 'not filled';
$dom = new DOMDocument( '1.0', 'utf-8' );
$xmlString = $order->attribute( 'data_text_1' );
if ( $xmlString != null )
{
$dom = new DOMDocument( '1.0', 'utf-8' );
$success = $dom->loadXML( $xmlString );
var_dump($dom);
$firstNameNode = $dom->getElementsByTagName( 'first-name' )->item( 0 );
if ( $firstNameNode )
{
$firstName = $firstNameNode->textContent;
}
$lastNameNode = $dom->getElementsByTagName( 'last-name' )->item( 0 );
if ( $lastNameNode )
{
$lastName = $lastNameNode->textContent;
}
$emailNode = $dom->getElementsByTagName( 'email' )->item( 0 );
if ( $emailNode )
{
$email = $emailNode->textContent;
}
$street1Node = $dom->getElementsByTagName( 'street1' )->item( 0 );
if ( $street1Node )
{
$street1 = $street1Node->textContent;
}
$street2Node = $dom->getElementsByTagName( 'street2' )->item( 0 );
if ( $street2Node )
{
$street2 = $street2Node->textContent;
}
$zipNode = $dom->getElementsByTagName( 'zip' )->item( 0 );
if ( $zipNode )
{
$zip = $zipNode->textContent;
}
$placeNode = $dom->getElementsByTagName( 'place' )->item( 0 );
if ( $placeNode )
{
$place = $placeNode->textContent;
}
$stateNode = $dom->getElementsByTagName( 'state' )->item( 0 );
if ( $stateNode )
{
$state = $stateNode->textContent;
}
$countryNode = $dom->getElementsByTagName( 'country' )->item( 0 );
if ( $countryNode )
{
$country = $countryNode->textContent;
}
$commentNode = $dom->getElementsByTagName( 'comment' )->item( 0 );
if ( $commentNode )
{
$comment = $commentNode->textContent;
}
$paymentMethodNode = $dom->getElementsByTagName( 'paymentdata' )->item( 0 );
if ( $paymentMethodNode )
{
echo "test2";
$paymentMethod = $paymentMethodNode->textContent;
}
$paymentDataNode = $dom->getElementsByTagName( 'paymentdata' )->item( 0 );
if ( $paymentDataNode )
{
echo "hallo";
$paymentData = $paymentDataNode->textContent;
}
}
return array( 'first_name' => $firstName,
'last_name' => $lastName,
'email' => $email,
# 'street1' => $street1,
# 'street2' => $street2,
'street1' => '1234',
'street2' => '56789',
'zip' => $zip,
'place' => $place,
'state' => $state,
'country' => $country,
'comment' => $comment,
'paymentdata' => $paymentdata,
'paymentmethod' => $paymentmethod
);
}
}
?>
The fields in data_text_1 are set , i'm sure
than i created the settings file in /mysimplepayment/settings named shopaccount.ini.append.php
<?php /*
[HandlerSettings]
ExtensionRepositories[]=ezsimplepayment
[AccountSettings]
Handler=ezcustom
*/?>
I also tried the old config style way shopaccount.ini.append
[HandlerSettings]
ExtensionRepositories[]=ezsimplepayment
[AccountSettings]
Handler=ezcustom
than i created the template in ezsimplepayment\design\admin\templates\shop\accounthandlers\html named ez.tpl
<!-- ezSimplePayment -->
Payment{* Name. *}
<div class="block">
<label>{'Name'|i18n( 'design/admin/shop/accounthandlers/html/ez' )}:</label>
{let customer_user=fetch( content, object, hash( object_id, $order.user_id ) )}
<a href={$customer_user.main_node.url_alias|ezurl}>{$order.account_information.first_name} {$order.account_information.last_name}</a>
{/let}
</div>
{* Email. *}
<div class="block">
<label>{'Email'|i18n( 'design/admin/shop/accounthandlers/html/ez' )}:</label>
<a href="mailto:{$order.account_information.email}">{$order.account_information.email}</a>
</div>
{* Address. *}
<div class="block">
<fieldset>
<legend>{'Address'|i18n( 'design/admin/shop/accounthandlers/html/ez' )}</legend>
<table class="list" cellspacing="0">
<tr>
<td>{'Company'|i18n( 'design/admin/shop/accounthandlers/html/ez' )}</td>
<td>{$order.account_information.street1}</td>
</tr>
<tr>
<td>{'Street'|i18n( 'design/admin/shop/accounthandlers/html/ez' )}</td>
<td>{$order.account_information.street2}</td>
</tr>
<tr>
<td>{'Zip code'|i18n( 'design/admin/shop/accounthandlers/html/ez' )}</td>
<td>{$order.account_information.zip}</td>
</tr>
<tr>
<td>{'Place'|i18n( 'design/admin/shop/accounthandlers/html/ez' )}</td>
<td>{$order.account_information.place}</td>
</tr>
<tr>
<td>{'State'|i18n( 'design/admin/shop/accounthandlers/html/ez' )}</td>
<td>{$order.account_information.state}</td>
</tr>
<tr>
<td>{'Country/region'|i18n( 'design/admin/shop/accounthandlers/html/ez' )}</td>
<td>{$order.account_information.country}</td>
</tr>
</table>
</fieldset>
{* Payment. *}
<fieldset>
<legend>{'Payment'|i18n( 'design/admin/shop/accounthandlers/html/ez' )}</legend>
<table class="list" cellspacing="0">
<tr>
<td>{'Payment-Method'|i18n( 'design/admin/shop/accounthandlers/html/ez' )}</td>
<td>{$order.account_information.paymentmethod}</td>
</tr>
<tr>
<td>{'Payment-Data'|i18n( 'design/admin/shop/accounthandlers/html/ez' )}</td>
<td>{$order.account_information.paymentdata}</td>
</tr>
</table>
</fieldset>
</div>
My Template is now Shown in the Admin Interface but now paymentdata and paymentmethod is filled :-( I think the Handler isn't registred there is now echo at the page at all. Did i forgot something?
|