Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

ezsimpleshippingtype.php
Go to the documentation of this file.
1 <?php
16 class eZSimpleShippingType extends eZWorkflowEventType
17 {
18 const WORKFLOW_TYPE_STRING = 'ezsimpleshipping';
19
20 public function __construct()
21 {
22 parent::__construct( eZSimpleShippingType::WORKFLOW_TYPE_STRING, ezpI18n::tr( 'kernel/workflow/event', "Simple shipping" ) );
23 $this->setTriggerTypes( array( 'shop' => array( 'confirmorder' => array ( 'before' ) ) ) );
24 }
25
26 function execute( $process, $event )
27 {
28 $ini = eZINI::instance( 'workflow.ini' );
29
30 $cost = $ini->variable( "SimpleShippingWorkflow", "ShippingCost" );
31 $description = $ini->variable( "SimpleShippingWorkflow", "ShippingDescription" );
32
33 $parameters = $process->attribute( 'parameter_list' );
34
35 if ( isset( $parameters['order_id'] ) )
36 {
37 $orderID = $parameters['order_id'];
38
39 $order = eZOrder::fetch( $orderID );
40 $orderItems = $order->attribute( 'order_items' );
41 $addShipping = true;
42 foreach ( $orderItems as $orderItem )
43 {
44 if ( $orderItem->attribute( 'type' ) == 'ezsimpleshipping' )
45 {
46 $addShipping = false;
47 break;
48 }
49 }
50 if ( $addShipping )
51 {
52 $productCollection = $order->attribute( 'productcollection' );
53 $orderCurrency = $productCollection->attribute( 'currency_code' );
54
55 $cost = eZShopFunctions::convertAdditionalPrice( $orderCurrency, $cost );
56
57 $orderItem = new eZOrderItem( array( 'order_id' => $orderID,
58 'description' => $description,
59 'price' => $cost,
60 'type' => 'ezsimpleshipping' )
61 );
62 $orderItem->store();
63 }
64 }
65 return eZWorkflowType::STATUS_ACCEPTED;
66 }
67 }
68
69 eZWorkflowEventType::registerEventType( eZSimpleShippingType::WORKFLOW_TYPE_STRING, "eZSimpleShippingType" );
70
71 ?>
eZOrderItem
eZOrderItem handles custom order items
Definition: ezorderitem.php:27
eZOrder\fetch
static fetch( $id, $asObject=true)
Definition: ezorder.php:177
eZSimpleShippingType
The class eZSimpleShippingType handles adding shipping cost to an order.
Definition: ezsimpleshippingtype.php:17
eZSimpleShippingType\__construct
__construct()
Definition: ezsimpleshippingtype.php:20
eZSimpleShippingType\execute
execute( $process, $event)
Definition: ezsimpleshippingtype.php:26
eZSimpleShippingType\WORKFLOW_TYPE_STRING
const WORKFLOW_TYPE_STRING
Definition: ezsimpleshippingtype.php:18
eZWorkflowEventType
Definition: ezworkfloweventtype.php:18
eZWorkflowEventType\registerEventType
static registerEventType( $typeString, $class_name)
Definition: ezworkfloweventtype.php:40
eZWorkflowType\STATUS_ACCEPTED
const STATUS_ACCEPTED
Definition: ezworkflowtype.php:21
eZWorkflowType\setTriggerTypes
setTriggerTypes( $allowedTypes)
Definition: ezworkflowtype.php:276
ezpI18n\tr
static tr( $context, $source, $comment=null, $arguments=null)
Definition: ezpi18n.php:86
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.