Tuesday 03 May 2005 9:32:57 am
Hi another time!
I have modified ezsimpleshipping to decrement an integer (attribute quantity), this is the code but no found could anyone tell me why? Thanks a lot!!
/*! \file ezsimpleshippingtype.php */
/*!
\class eZSimpleShippingType ezsimpleshippingtype.php \brief The class eZSimpleshippingType handles adding shipping cost to an order
*/ include_once( 'kernel/classes/ezorder.php' ); define( 'EZ_WORKFLOW_TYPE_SIMPLESHIPPING_ID', 'ezsimpleshipping' );
class eZSimpleShippingType extends eZWorkflowEventType
{
/*!
Constructor
*/
function eZSimpleShippingType()
{
$this->eZWorkflowEventType( EZ_WORKFLOW_TYPE_SIMPLESHIPPING_ID, ezi18n( 'kernel/workflow/event', "Simple shipping" ) );
$this->setTriggerTypes( array( 'shop' => array( 'confirmorder' => array ( 'before' ) ) ) ); }
function execute( &$process, &$event )
{
$parameters =& $process->attribute( 'parameter_list' ); $http =& eZHTTPTool::instance();
eZDebug::writeNotice( $parameters, "parameters" );
$orderID = $parameters['order_id'];
$order = eZOrder::fetch( $orderID );
if (empty($orderID) || get_class( $order ) != 'ezorder')
{
eZDebug::writeWarning( "Can't proceed without a Order ID.", "Simpleshipping" );
return EZ_WORKFLOW_TYPE_STATUS_FETCH_TEMPLATE_REPEAT;
}
$productCollection = $order->productCollection();
$ordereditems = $productCollection->itemList();
foreach ($ordereditems as $item){
$co = $item->contentObject();
$coVersion =& $co->version( $co->attribute( 'current_version' ) );
$coAttributes =& $coVersion->contentObjectAttributes();
foreach (array_keys($coAttributes) as $key)
{
$coAttribute =& $coAttributes[$key];
$contentClassAttribute =& $coAttribute->contentClassAttribute();
// Each attribute has an attribute called 'name' that identifies it.
if ($contentClassAttribute->attribute("name") == "quantity")
{
$coAttribute->setAttribute("data_int", "50");
$coAttribute->store();
}
}
}
return EZ_WORKFLOW_TYPE_STATUS_ACCEPTED; } eZWorkflowEventType::registerType( EZ_WORKFLOW_TYPE_SIMPLESHIPPING_ID, "ezsimpleshippingtype" ); ?>
|