Tuesday 14 February 2006 6:39:21 am
Hi! I started creating a new Workflow Event as mentioned in the documentation on page http://ez.no/products/ez_publish_open_source_enterprise_cms/documentation/development/extensions/workflow_events/creating_a_new_event
My goal is to write an advanced shipping workflow with more shipping-rules(like "free shipping for orders over 20 euros" etc).
For the start i simply copied the contents of the ezsimpleshippingtype.php into my newly ezadvancedshippingtype.php (which i created like suggested by the documentation i mentioned above). then i only changed the ezsimpleshipping-references to my ezadvancedshipping and included the "kernel/classes/ezworkflowtype.php" and the code now ooks like this:
<?php
//
// Definition of eZAdvancedShippingType class
//
// Created on: <09-äÅË-2002 14:42:23 sp>
//
// This file may be distributed and/or modified under the terms of the
// "GNU General Public License" version 2 as published by the Free
// Software Foundation and appearing in the file LICENSE included in
// the packaging of this file.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
// THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE.
//
// The "GNU General Public License" (GPL) is available at
// http://www.gnu.org/copyleft/gpl.html.
//
//
/*! \file ezadvancedshippingtype.php
*/
/*!
\class eZAdvancedShippingType ezadvancedshippingtype.php
\brief The class eZAdvancedshippingType handles adding shipping cost to an order plus the abillity to set an freeshipping border and an advanced shipping-calculation(depending on the shipping cost of each item)
*/
include_once( 'kernel/classes/ezorder.php' );
include_once('kernel/classes/ezworkflowtype.php');
define( 'EZ_WORKFLOW_TYPE_ADVANCEDSHIPPING_ID', 'ezadvancedshipping' );
class eZAdvancedShippingType extends eZWorkflowEventType
{
/*!
Constructor
*/
function eZAdvancedShippingType()
{
$this->eZWorkflowEventType( EZ_WORKFLOW_TYPE_ADVANCEDSHIPPING_ID, ezi18n( 'kernel/workflow/event', "AdvancedShipping" ) );
$this->setTriggerTypes( array( 'shop' => array( 'confirmorder' => array ( 'before' ) ) ) );
}
function execute( &$process, &$event )
{
$ini =& eZINI::instance( 'workflow.ini' );
$cost = $ini->variable( "SimpleShippingWorkflow", "ShippingCost" );
$description = $ini->variable( "SimpleShippingWorkflow", "ShippingDescription" );
$parameters = $process->attribute( 'parameter_list' );
$orderID = $parameters['order_id'];
$order = eZOrder::fetch( $orderID );
$orderItems = $order->attribute( 'order_items' );
$addShipping = true;
foreach ( array_keys( $orderItems ) as $key )
{
$orderItem =& $orderItems[$key];
if ( $orderItem->attribute( 'description' ) == $description )
{
$addShipping = false;
break;
}
}
if ( $addShipping )
{
$orderItem = new eZOrderItem( array( 'order_id' => $orderID,
'description' => $description,
'price' => $cost,
'vat_is_included' => true,
'vat_type_id' => 1 )
);
$orderItem->store();
}
return EZ_WORKFLOW_TYPE_STATUS_ACCEPTED;
}
}
eZWorkflowEventType::registerType( EZ_WORKFLOW_TYPE_ADVANCEDSHIPPING_ID, "advancedshippingtype" );
?>
unfortunalty evertime i create a new workflow, select the new event an want to add the new event i become this error:
<i>
Fatal error: Call to a member function on a non-object in /www/sujls136/htdocs/lvstein/kernel/workflow/edit.php on line 329 Fatal error: eZ publish did not finish its request
The execution of eZ publish was abruptly ended, the debug output is present below. </i>
I dont understand the problem, because i simply took prebuild ezsimpleshippingtype.php and customized it only a bit.
I looked at other extensions (the shopsender-extension for example) and they're build analogical.
Anyone who can solve my problem???
Many thanks Achim Bleidiessel
|