shopaccounthandler

About

shopaccounthandler provides for the customization of the registration process

Explanation

It's the component you can create inside an extension to alter the registration process.

Examples

Settings

File, example_com/settings/shopaccount.ini.append

#?ini charset="utf-8"?
[HandlerSettings]
ExtensionRepositories[]=example_com
 
 
[AccountSettings]
Handler=ezcustomized

Handler

File, example_com/shopaccounthandlers/ezcustomizedshopaccounthandler.php

<?php
 
include_once( 'lib/ezxml/classes/ezxml.php' );
 
class eZCustomizedShopAccountHandler
{
    /*!
    */
    function eZCustomizedShopAccountHandler()
    {
 
    }
 
    /*!
     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 )
    {
        $module->redirectTo( '/shop/userregister/' );
    }
 
    /*!
     \return the account information for the given order
    */
    function email( $order )
    {
        $xml = new eZXML();
        $xmlDoc =& $order->attribute( 'data_text_1' );
        if( $xmlDoc != null )
        {
            $dom =& $xml->domTree( $xmlDoc );
            $email =& $dom->elementsByName( "email" );
            return $email[0]->textContent();
        }
        else
            return false;
    }
 
    /*!
     \return the account information for the given order
    */
    function accountName( $order )
    {
        $accountName = "";
        $xml = new eZXML();
        $xmlDoc =& $order->attribute( 'data_text_1' );
        if( $xmlDoc != null )
        {
            $dom =& $xml->domTree( $xmlDoc );
            $firstName = $dom->elementsByName( "first-name" );
            $mi = $dom->elementsByName( "mi" );
 
            if( isset($mi[0]) ){
                $mi_tc = $mi[0]->textContent();
            }else{
                $mi_tc = '';
            }
 
            $lastName = $dom->elementsByName( "last-name" );
            $accountName = $firstName[0]->textContent() . " " . $mi_tc ." " . $lastName[0]->textContent();
        }
 
        return $accountName;
    }
 
    function accountInformation( $order )
    {
        $xml = new eZXML();
        $xmlDoc =& $order->attribute( 'data_text_1' );
        $dom =& $xml->domTree( $xmlDoc );
 
        $firstName =& $dom->elementsByName( "first-name" );
        $mi =& $dom->elementsByName( "mi" );
        $lastName =& $dom->elementsByName( "last-name" );
 
        $address1 =& $dom->elementsByName( "address1" );
        $address2 =& $dom->elementsByName( "address2" );
 
        $city =& $dom->elementsByName( "city" );
        $state =& $dom->elementsByName( "state" );
        $zip =& $dom->elementsByName( "zip" );
 
        $phone =& $dom->elementsByName( "phone" );
        $email =& $dom->elementsByName( "email" );
 
        $shipping =& $dom->elementsByName( "shipping" );
        $shippingtype =& $dom->elementsByName( "shippingtype" );
 
        $s_firstName =& $dom->elementsByName( "s_first-name" );
        $s_mi =& $dom->elementsByName( "s_mi" );
        $s_lastName =& $dom->elementsByName( "s_last-name" );
 
        $s_address1 =& $dom->elementsByName( "s_address1" );
        $s_address2 =& $dom->elementsByName( "s_address2" );
 
        $s_city =& $dom->elementsByName( "s_city" );
        $s_state =& $dom->elementsByName( "s_state" );
        $s_zip =& $dom->elementsByName( "s_zip" );
 
        $s_phone =& $dom->elementsByName( "s_phone" );
        $s_email =& $dom->elementsByName( "s_email" );
 
        // $country =& $dom->elementsByName( "country" );
        // $comment =& $dom->elementsByName( "comment" );
 
        $firstNameText = "";
        if ( is_object( $firstName[0] ) )
            $firstNameText = $firstName[0]->textContent();
 
        $miText = "";
        if( isset( $mi[0] ) )
        {
        if ( is_object( $mi[0] ) )
            $miText = $mi[0]->textContent();
        }
 
        $lastNameText = "";
        if ( is_object( $lastName[0] ) )
            $lastNameText = $lastName[0]->textContent();
 
        $address1Text = "";
        if ( is_object( $address1[0] ) )
            $address1Text = $address1[0]->textContent();
 
        $address2Text = "";
        if ( is_object( $address2[0] ) )
            $address2Text = $address2[0]->textContent();
 
        $cityText = "";
        if ( is_object( $city[0] ) )
            $cityText = $city[0]->textContent();
 
        $stateText = "";
        if ( is_object( $state[0] ) )
            $stateText = $state[0]->textContent();
 
        $zipText = "";
        if ( is_object( $zip[0] ) )
            $zipText = $zip[0]->textContent();
 
        $phoneText = "";
        if ( is_object( $phone[0] ) )
            $phoneText = $phone[0]->textContent();
 
        $emailText = "";
        if ( is_object( $email[0] ) )
            $emailText = $email[0]->textContent();
 
        $shippingText = "";
        if ( is_object( $shipping[0] ) )
            $shippingText = $shipping[0]->textContent();
 
        $shippingTypeText = "";
        if ( is_object( $shippingtype[0] ) )
            $shippingTypeText = $shippingtype[0]->textContent();
 
        // ezDebug::writeDebug( count($s_firstName), 'eZUser Information'  );
 
        $s_firstNameText = "";
        if ( count($s_firstName) > 0 and is_object( $s_firstName[0] ) )
            $s_firstNameText = $s_firstName[0]->textContent();
 
        $s_miText = "";
        if ( count($s_firstName) > 0 and is_object( $s_mi[0] ) )
            $s_miText = $s_mi[0]->textContent();
 
        $s_lastNameText = "";
        if ( count($s_firstName) > 0 and is_object( $s_lastName[0] ) )
            $s_lastNameText = $s_lastName[0]->textContent();
 
        $s_address1Text = "";
        if ( count($s_firstName) > 0 and is_object( $s_address1[0] ) )
            $s_address1Text = $s_address1[0]->textContent();
 
        $s_address2Text = "";
        if ( count($s_firstName) > 0 and is_object( $s_address2[0] ) )
            $s_address2Text = $s_address2[0]->textContent();
 
        $s_cityText = "";
        if ( count($s_firstName) > 0 and is_object( $s_city[0] ) )
            $s_cityText = $s_city[0]->textContent();
 
        $s_stateText = "";
        if ( count($s_firstName) > 0 and is_object( $s_state[0] ) )
            $s_stateText = $s_state[0]->textContent();
 
        $s_zipText = "";
        if ( count($s_firstName) > 0 and is_object( $s_zip[0] ) )
            $s_zipText = $s_zip[0]->textContent();
 
        $s_phoneText = "";
        if ( count($s_firstName) > 0 and is_object( $s_phone[0] ) )
            $s_phoneText = $s_phone[0]->textContent();
 
        $s_emailText = "";
        if ( count($s_firstName) > 0 and is_object( $s_email[0] ) )
            $s_emailText = $s_email[0]->textContent();
 
        return array( 'first_name' => $firstNameText,
                      'mi' => $miText,
                      'last_name' => $lastNameText,
                      'address1' => $address1Text,
                      'address2' => $address2Text,
                      'city' => $cityText,
                      'state' => $stateText,
                      'zip' => $zipText,
                      'phone' => $phoneText,
                      'email' => $emailText,
                      'shipping' => $shippingText,
                      'shippingtype' => $shippingTypeText,
                      's_first_name' => $s_firstNameText,
                      's_mi' => $s_miText,
                      's_last_name' => $s_lastNameText,
                      's_address1' => $s_address1Text,
                      's_address2' => $s_address2Text,
                      's_city' => $s_cityText,
                      's_state' => $s_stateText,
                      's_zip' => $s_zipText,
                      's_phone' => $s_phoneText,
                      's_email' => $s_emailText );
    }
}
 
?>

Templates

Html Template

File, example_com/design/standard/templates/shop/accounthandlers/html/ez.tpl

{* DO NOT EDIT THIS FILE! Use an override template instead. *}
 <table width="100%" cellspacing="0" cellpadding="0" border="0">
 <tr>
 <td valign="top">
         <b>{"Customer"|i18n("design/standard/shop")}</b>
         </p>
         <p>
         {'Name'|i18n('design/standard/shop')}: {$order.account_information.first_name} {$order.account_information.last_name}<br />
         {'Email'|i18n('design/standard/shop')}: {$order.account_information.email}<br />
 </td>
 <td valign="top" width="300px;">
 {if eq($order.account_information.shipping,1)}
 <b>{"Address"|i18n("design/standard/shop")}</b>
 <table border="0"  cellspacing="0" cellpadding="0">
 <tr><td>{'Address'|i18n('design/standard/shop')}:</td><td>{$order.account_information.address1}</td></tr>
 {if gt(count($order.account_information.address2),0)}
 <tr><td> </td><td>{$order.account_information.address2}</td></tr>
 {/if}
 <tr><td>{'City'|i18n('design/standard/shop')}:</td><td>{$order.account_information.city}</td></tr>
 <tr><td>{'State'|i18n('design/standard/shop')}:</td><td>{$order.account_information.state}</td></tr>
 <tr><td>{'Zip code'|i18n('design/standard/shop')}:</td><td>{$order.account_information.zip}</td></tr>
 <tr><td>{'Phone'|i18n('design/standard/shop')}:</td><td>{$order.account_information.phone}</td></tr>
 <tr><td>{'Shipping'|i18n('design/standard/shop')}:</td><td>
 {switch match=$order.account_information.shippingtype}
 {case match="1"}
     Next Day Service
 {/case}
 {case match="2"}
     2nd Day Service
 {/case}
 {case}
     Standard Shipping
 {/case}
 {/switch}
 </td></tr>
 </table>
       
 {else}
       
 <b>{"Billingaddress"|i18n("design/standard/shop")}</b>
 <table border="0"  cellspacing="0" cellpadding="0">
 <tr><td>{'Address'|i18n('design/standard/shop')}:</td><td>{$order.account_information.address1}</td></tr>
 {if gt(count($order.account_information.address2),0)}
 <tr><td> </td><td>{$order.account_information.address2}</td></tr>
 {/if}
 <tr><td>{'City'|i18n('design/standard/shop')}:</td><td>{$order.account_information.city}</td></tr>
 <tr><td>{'State'|i18n('design/standard/shop')}:</td><td>{$order.account_information.state}</td></tr>
 <tr><td>{'Zip code'|i18n('design/standard/shop')}:</td><td>{$order.account_information.zip}</td></tr>
 <tr><td>{'Phone'|i18n('design/standard/shop')}:</td><td>{$order.account_information.phone}</td></tr>
 <tr><td>{'Shipping'|i18n('design/standard/shop')}:</td><td>
 {switch match=$order.account_information.shippingtype}
 {case match="1"}
     Next Day Service
 {/case}
 {case match="2"}
     2nd Day Service
 {/case}
 {case}
     Standard Shipping
 {/case}
 {/switch}
       
 </td></tr>
 </table>
 <br />
 <b>{"Shippingaddress"|i18n("design/standard/shop")}</b>
 <table border="0"  cellspacing="0" cellpadding="0">
 <tr><td>Name:</td><td>{$order.account_information.s_first_name} {$order.account_information.s_last_name}</td></tr>
 <tr><td>MI:</td><td>{$order.account_information.s_mi}</td></tr>
 <tr><td>{'Address'|i18n('design/standard/shop')}:</td><td>{$order.account_information.s_address1}</td></tr>
 {if gt(count($order.account_information.s_address2),0)}
 <tr><td> </td><td>{$order.account_information.s_address2}</td></tr>
 {/if}
 <tr><td>{'City'|i18n('design/standard/shop')}:</td><td>{$order.account_information.s_city}</td></tr>
 <tr><td>{'State'|i18n('design/standard/shop')}:</td><td>{$order.account_information.s_state}</td></tr>
 <tr><td>{'Zip code'|i18n('design/standard/shop')}:</td><td>{$order.account_information.s_zip}</td></tr>
 <tr><td>{'Phone'|i18n('design/standard/shop')}:</td><td>{$order.account_information.s_phone}</td></tr>
 <tr><td>{'Email'|i18n('design/standard/shop')}:</td><td>{$order.account_information.s_email}</td></tr>
 </table>
       
       
 {/if}
 </td>
 </tr>
 </table>

Text Template

File, example_com/design/standard/templates/shop/accounthandlers/ascii/ez.tpl

Name: {$order.account_information.first_name} {$order.account_information.last_name}
Email: {$order.account_information.email}
MI: {$order.account_information.mi}
 
Address1: {$order.account_information.address1}
 
{if gt(count($order.account_information.address2),0)}
Address2: {$order.account_information.address2}
{/if}
 
City: {$order.account_information.city}
State: {$order.account_information.state}
Zip code: {$order.account_information.zip}
Phone: {$order.account_information.phone}
Shipping: {switch match=$order.account_information.shippingtype}{case match="1"}Next Day Service{/case}{case match="2"}2nd Day Service{/case}{case}Standard Shipping{/case}{/switch}
 
 
{if eq($order.account_information.shipping,0)}
Shipped to:
 
Name: {$order.account_information.s_first_name} {$order.account_information.s_last_name}
MI: {$order.account_information.s_mi}
Address1: {$order.account_information.s_address1}
 
{if gt(count($order.account_information.s_address2),0)}
Address2: {$order.account_information.s_address2}
{/if}
 
City: {$order.account_information.s_city}
State': {$order.account_information.s_state}
Zip code: {$order.account_information.s_zip}
Phone: {$order.account_information.s_phone}
Email: {$order.account_information.s_email}

Html Admin Template

File, example_com/design/admin/templates/shop/accounthandlers/html/ez.tpl

{* 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>{'E-mail'|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>
{if ne($order.account_information.shipping,1)}
<table class="list" cellspacing="0">
<tr>
<td><b>Billingaddress</b></td>
<td><b>Shippingaddress</b></td>
</tr>
<tr>
<td>
{/if}
<table class="list" cellspacing="0">
<tr>
    <td>{'First Name'|i18n( 'design/admin/shop/accounthandlers/html/ez' )}</td>
    <td>{$order.account_information.first_name}</td>
</tr>
<tr>
    <td>MI</td>
    <td>{$order.account_information.mi}</td>
</tr>
<tr>
    <td>{'Last Name'|i18n( 'design/admin/shop/accounthandlers/html/ez' )}</td>
    <td>{$order.account_information.last_name}</td>
</tr>
<tr>
    <td>{'Address 1'|i18n( 'design/admin/shop/accounthandlers/html/ez' )}</td>
    <td>{$order.account_information.address1}</td>
</tr>
<tr>
    <td>{'Address 2'|i18n( 'design/admin/shop/accounthandlers/html/ez' )}</td>
    <td>{$order.account_information.address2}</td>
</tr>
<tr>
    <td>{'City'|i18n( 'design/admin/shop/accounthandlers/html/ez' )}</td>
    <td>{$order.account_information.city}</td>
</tr>
<tr>
    <td>{'State'|i18n( 'design/admin/shop/accounthandlers/html/ez' )}</td>
    <td>{$order.account_information.state}</td>
</tr>
<tr>
    <td>{'Zip Code'|i18n( 'design/admin/shop/accounthandlers/html/ez' )}</td>
    <td>{$order.account_information.zip}</td>
</tr>
<tr>
    <td>{'Phone'|i18n( 'design/admin/shop/accounthandlers/html/ez' )}</td>
    <td>{$order.account_information.phone}</td>
</tr>
<tr>
    <td>{'Shipping Type'|i18n( 'design/admin/shop/accounthandlers/html/ez' )}</td>
    <td>
        {if eq($order.account_information.shippingtype,1)}
            Next Day Service
        {elseif eq($order.account_information.shippingtype,2)}
            2nd Day Service
        {else}Standard Shipping
        {/if}
    </td>
</tr>
</table>
 
{if ne($order.account_information.shipping,1)}
</td>
<td>
<table class="list" cellspacing="0">
<tr>
    <td>{'First Name'|i18n( 'design/admin/shop/accounthandlers/html/ez' )}</td>
    <td>{$order.account_information.s_first_name}</td>
</tr>
<tr>
    <td>MI</td>
    <td>{$order.account_information.s_mi}</td>
</tr>
<tr>
    <td>{'Last Name'|i18n( 'design/admin/shop/accounthandlers/html/ez' )}</td>
    <td>{$order.account_information.s_last_name}</td>
</tr>
<tr>
    <td>{'Address 1'|i18n( 'design/admin/shop/accounthandlers/html/ez' )}</td>
    <td>{$order.account_information.s_address1}</td>
</tr>
<tr>
    <td>{'Address 2'|i18n( 'design/admin/shop/accounthandlers/html/ez' )}</td>
    <td>{$order.account_information.s_address2}</td>
</tr>
<tr>
    <td>{'City'|i18n( 'design/admin/shop/accounthandlers/html/ez' )}</td>
    <td>{$order.account_information.s_city}</td>
</tr>
<tr>
    <td>{'State'|i18n( 'design/admin/shop/accounthandlers/html/ez' )}</td>
    <td>{$order.account_information.s_state}</td>
</tr>
<tr>
    <td>{'Zip Code'|i18n( 'design/admin/shop/accounthandlers/html/ez' )}</td>
    <td>{$order.account_information.s_zip}</td>
</tr>
<tr>
    <td>{'Phone'|i18n( 'design/admin/shop/accounthandlers/html/ez' )}</td>
    <td>{$order.account_information.s_phone}</td>
</tr>
<tr>
    <td>Email</td>
    <td>{$order.account_information.s_email}</td>
</tr>
</table>
</td>
</tr>
</table>
{/if}
</fieldset>
 
</div>

External reference

All text is available under the terms of the GNU Free Documentation License

Powered by eZ publish 3.9.0