[ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // Definition of eZSimpleShippingType class 4 // 5 // Created on: <09-äÅË-2002 14:42:23 sp> 6 // 7 // SOFTWARE NAME: eZ publish 8 // SOFTWARE RELEASE: 3.9.0 9 // BUILD VERSION: 17785 10 // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS 11 // SOFTWARE LICENSE: GNU General Public License v2.0 12 // NOTICE: > 13 // This program is free software; you can redistribute it and/or 14 // modify it under the terms of version 2.0 of the GNU General 15 // Public License as published by the Free Software Foundation. 16 // 17 // This program is distributed in the hope that it will be useful, 18 // but WITHOUT ANY WARRANTY; without even the implied warranty of 19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 // GNU General Public License for more details. 21 // 22 // You should have received a copy of version 2.0 of the GNU General 23 // Public License along with this program; if not, write to the Free 24 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 25 // MA 02110-1301, USA. 26 // 27 // 28 29 /*! \file ezsimpleshippingtype.php 30 */ 31 32 /*! 33 \class eZSimpleShippingType ezsimpleshippingtype.php 34 \brief The class eZSimpleshippingType handles adding shipping cost to an order 35 36 */ 37 include_once ( 'kernel/classes/ezorder.php' ); 38 39 40 define( 'EZ_WORKFLOW_TYPE_SIMPLESHIPPING_ID', 'ezsimpleshipping' ); 41 42 class eZSimpleShippingType extends eZWorkflowEventType 43 { 44 /*! 45 Constructor 46 */ 47 function eZSimpleShippingType() 48 { 49 $this->eZWorkflowEventType( EZ_WORKFLOW_TYPE_SIMPLESHIPPING_ID, ezi18n( 'kernel/workflow/event', "Simple shipping" ) ); 50 $this->setTriggerTypes( array( 'shop' => array( 'confirmorder' => array ( 'before' ) ) ) ); 51 } 52 53 function execute( &$process, &$event ) 54 { 55 $ini =& eZINI::instance( 'workflow.ini' ); 56 57 $cost = $ini->variable( "SimpleShippingWorkflow", "ShippingCost" ); 58 $description = $ini->variable( "SimpleShippingWorkflow", "ShippingDescription" ); 59 60 $parameters = $process->attribute( 'parameter_list' ); 61 62 if ( isset( $parameters['order_id'] ) ) 63 { 64 $orderID = $parameters['order_id']; 65 66 $order = eZOrder::fetch( $orderID ); 67 $orderItems = $order->attribute( 'order_items' ); 68 $addShipping = true; 69 foreach ( array_keys( $orderItems ) as $key ) 70 { 71 $orderItem =& $orderItems[$key]; 72 if ( $orderItem->attribute( 'type' ) == 'ezsimpleshipping' ) 73 { 74 $addShipping = false; 75 break; 76 } 77 } 78 if ( $addShipping ) 79 { 80 $productCollection =& $order->attribute( 'productcollection' ); 81 $orderCurrency =& $productCollection->attribute( 'currency_code' ); 82 83 include_once ( 'kernel/shop/classes/ezshopfunctions.php' ); 84 $cost = eZShopFunctions::convertAdditionalPrice( $orderCurrency, $cost ); 85 86 $orderItem = new eZOrderItem( array( 'order_id' => $orderID, 87 'description' => $description, 88 'price' => $cost, 89 'type' => 'ezsimpleshipping' ) 90 ); 91 $orderItem->store(); 92 } 93 } 94 return EZ_WORKFLOW_TYPE_STATUS_ACCEPTED; 95 } 96 } 97 98 eZWorkflowEventType::registerType( EZ_WORKFLOW_TYPE_SIMPLESHIPPING_ID, "ezsimpleshippingtype" ); 99 100 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Feb 24 10:30:04 2007 | par Balluche grâce à PHPXref 0.7 |