Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

ezorderitem.php
Go to the documentation of this file.
1 <?php
26 class eZOrderItem extends eZPersistentObject
27 {
28 public $VATValue;
29 public $Price;
30 static function definition()
31 {
32 return array( "fields" => array( 'id' => array( 'name' => 'ID',
33 'datatype' => 'integer',
34 'default' => 0,
35 'required' => true ),
36 'order_id' => array( 'name' => 'OrderID',
37 'datatype' => 'integer',
38 'default' => 0,
39 'required' => true,
40 'foreign_class' => 'eZOrder',
41 'foreign_attribute' => 'id',
42 'multiplicity' => '1..*' ),
43 'description' => array( 'name' => 'Description',
44 'datatype' => 'string',
45 'default' => '',
46 'required' => true ),
47 'price' => array( 'name' => 'Price',
48 'datatype' => 'float',
49 'default' => 0,
50 'required' => true ),
51 'vat_value' => array( 'name' => 'VATValue',
52 'datatype' => 'float',
53 'default' => 0,
54 'required' => true ),
55 'is_vat_inc' => array( 'name' => 'IsVATIncluded',
56 'datatype' => 'integer',
57 'default' => 0,
58 'required' => true ),
59 'type' => array( 'name' => 'Type',
60 'datatype' => 'string',
61 'required' => false ) ),
62 'keys' => array( 'id' ),
63 'function_attributes' => array( 'vat_value' => 'vatValue',
64 'price_inc_vat' => 'priceIncVat',
65 'price_ex_vat' => 'priceExVAT' ),
66 'increment_key' => 'id',
67 'class_name' => 'eZOrderItem',
68 'name' => 'ezorder_item' );
69 }
70
71 static function fetchList( $orderID, $asObject = true )
72 {
73 return eZPersistentObject::fetchObjectList( eZOrderItem::definition(),
74 null,
75 array( "order_id" => $orderID ),
76 null,
77 null,
78 $asObject );
79 }
80
81 static function fetchListByType( $orderID, $itemType, $asObject = true )
82 {
83 return eZPersistentObject::fetchObjectList( eZOrderItem::definition(),
84 null,
85 array( 'order_id' => $orderID, 'type' => $itemType ),
86 null,
87 null,
88 $asObject );
89
90 }
91
92 function vatValue()
93 {
94 return $this->VATValue;
95 }
96
97 function priceIncVAT()
98 {
99 if ( $this->attribute( 'is_vat_inc' ) == 1 )
100 {
101 return $this->Price;
102 }
103 else
104 {
105 $incVATPrice = $this->Price * ( $this->vatValue() + 100 ) / 100;
106 return $incVATPrice;
107 }
108
109 }
110
111 function priceExVAT()
112 {
113 if ( $this->attribute( 'is_vat_inc' ) == 1 )
114 {
115 return $this->Price / ( $this->vatValue() + 100 ) * 100;
116 }
117
118 return $this->Price;
119 }
120
127 function cleanup()
128 {
129 $db = eZDB::instance();
130 $db->query( "DELETE FROM ezorder_item" );
131 }
132 }
133
134 ?>
eZDB\instance
static instance( $databaseImplementation=false, $databaseParameters=false, $forceNewInstance=false)
Definition: ezdb.php:117
eZOrderItem
eZOrderItem handles custom order items
Definition: ezorderitem.php:27
eZOrderItem\cleanup
cleanup()
Definition: ezorderitem.php:127
eZOrderItem\fetchList
static fetchList( $orderID, $asObject=true)
Definition: ezorderitem.php:71
eZOrderItem\priceIncVAT
priceIncVAT()
Definition: ezorderitem.php:97
eZOrderItem\priceExVAT
priceExVAT()
Definition: ezorderitem.php:111
eZOrderItem\vatValue
vatValue()
Definition: ezorderitem.php:92
eZOrderItem\$VATValue
$VATValue
Definition: ezorderitem.php:28
eZOrderItem\fetchListByType
static fetchListByType( $orderID, $itemType, $asObject=true)
Definition: ezorderitem.php:81
eZOrderItem\definition
static definition()
Definition: ezorderitem.php:30
eZOrderItem\$Price
$Price
Definition: ezorderitem.php:29
eZPersistentObject
Definition: ezpersistentobject.php:33
eZPersistentObject\attribute
attribute( $attr, $noFunction=false)
Definition: ezpersistentobject.php:1329
eZPersistentObject\fetchObjectList
static fetchObjectList( $def, $field_filters=null, $conds=null, $sorts=null, $limit=null, $asObject=true, $grouping=false, $custom_fields=null, $custom_tables=null, $custom_conds=null)
Definition: ezpersistentobject.php:806
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.