Forums / Developer / Problem with Custom ShopAccountHandler

"Please Note:
  • At the specific request of Ibexa we are changing this projects name to "Exponential" or "Exponential (CMS)" effective as of August, 11th 2025.
  • This project is not associated with the original eZ Publish software or its original developer, eZ Systems or Ibexa".

Problem with Custom ShopAccountHandler

Author Message

florian arbatowski

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}&nbsp;{$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?

florian arbatowski

Tuesday 16 December 2008 1:10:51 am

I changed the shopaccount.ini.append to

#?ini charset="iso-8859-1"?
# Exponential configuration file.
#
# NOTE: It is not recommended to edit this files directly, instead
#       a file in override should be created for setting the
#       values that is required for your site. Either create
#       a file called settings/override/shopaccount.ini.append or
#       settings/override/shopaccount.ini.append.php for more security
#       in non-virtualhost modes (the .php file may already be present
#       and can be used for this purpose).

[HandlerSettings]
# A list of directories to search for shopaccount handlers
#Repositories[]=kernel/classes
# A list of extensions which have shop account handlers
# It's common to create a settings/shopaccount.ini.append file
# in your extension and add the extension name to automatically
# get handlers from the extension when it's turned on.
#ExtensionRepositories[]
ExtensionRepositories[]=ezsimplepayment

# Settings for how user accounts should be handled in the shop/checkout
# default is to use internal user accounts in the system
# simple is for handling account information without user registration
[AccountSettings]
Handler=ezcustom
#Handler=ezuser
#Handler=ezdefault
# Allows for overriding a handler with another
Alias[]
Alias[ezuser]=ezcustom
Alias[ezdefault]=ezcustom

# Settings for how order emails should be handled in the shop/checkout
# default is to send confirmation emails to both customer and admin.
[ConfirmOrderSettings]
Handler=ezdefault
# Allows for overriding a handler with another
Alias[]

 

now it work,

i think i forget to set an alias