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"?
# eZ Publish 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

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

eZ debug

Timing: Jan 31 2025 01:30:45
Script start
Timing: Jan 31 2025 01:30:45
Module start 'layout'
Timing: Jan 31 2025 01:30:45
Module start 'content'
Timing: Jan 31 2025 01:30:46
Module end 'content'
Timing: Jan 31 2025 01:30:46
Script end

Main resources:

Total runtime0.8691 sec
Peak memory usage8,192.0000 KB
Database Queries52

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0051 588.2500151.2266
Module start 'layout' 0.00510.0043 739.4766220.7031
Module start 'content' 0.00940.8589 960.17974,202.2969
Module end 'content' 0.86830.0008 5,162.476619.8438
Script end 0.8691  5,182.3203 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00370.4301160.0002
Check MTime0.00150.1725160.0001
Mysql Total
Database connection0.00070.080210.0007
Mysqli_queries0.788190.6836520.0152
Looping result0.00040.0470500.0000
Template Total0.815493.820.4077
Template load0.00200.233620.0010
Template processing0.813493.588920.4067
Template load and register function0.00170.195710.0017
states
state_id_array0.00270.313710.0027
state_identifier_array0.00120.135420.0006
Override
Cache load0.00170.1949290.0001
Sytem overhead
Fetch class attribute can translate value0.00150.178210.0015
Fetch class attribute name0.00210.240920.0010
XML
Image XML parsing0.00010.013010.0001
class_abstraction
Instantiating content class attribute0.00000.000820.0000
General
dbfile0.00070.0787100.0001
String conversion0.00000.001240.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
8content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
5content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
2content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 19
 Number of unique templates used: 6

Time used to render debug report: 0.0002 secs