|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
|
|
4
|
|
|
|
|
5
|
|
|
|
|
6
|
|
|
class GiftVoucherProductPage_ProductOrderItem extends Product_OrderItem |
|
|
|
|
|
|
7
|
|
|
{ |
|
8
|
|
|
private static $db = array( |
|
|
|
|
|
|
9
|
|
|
'ValueSet' => 'Currency', |
|
10
|
|
|
'Description' => 'Varchar(40)' |
|
11
|
|
|
); |
|
12
|
|
|
|
|
13
|
|
|
/* standard SS method. |
|
14
|
|
|
* |
|
15
|
|
|
* @var array |
|
16
|
|
|
*/ |
|
17
|
|
|
private static $api_access = array( |
|
|
|
|
|
|
18
|
|
|
'view' => array( |
|
19
|
|
|
'CalculatedTotal', |
|
20
|
|
|
'TableTitle', |
|
21
|
|
|
'TableSubTitleNOHTML', |
|
22
|
|
|
'Name', |
|
23
|
|
|
'TableValue', |
|
24
|
|
|
'Quantity', |
|
25
|
|
|
'BuyableID', |
|
26
|
|
|
'BuyableClassName', |
|
27
|
|
|
'Version', |
|
28
|
|
|
'UnitPrice', |
|
29
|
|
|
'Total', |
|
30
|
|
|
'Order', |
|
31
|
|
|
'InternalItemID', |
|
32
|
|
|
), |
|
33
|
|
|
); |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Standard SS variable. |
|
37
|
|
|
* |
|
38
|
|
|
* @var string |
|
39
|
|
|
*/ |
|
40
|
|
|
private static $singular_name = 'Order for Gift Item'; |
|
|
|
|
|
|
41
|
|
|
public function i18n_singular_name() |
|
|
|
|
|
|
42
|
|
|
{ |
|
43
|
|
|
return $this->Config()->get('singular_name'); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Standard SS variable. |
|
48
|
|
|
* |
|
49
|
|
|
* @var string |
|
50
|
|
|
*/ |
|
51
|
|
|
private static $plural_name = 'Orders for Gift Item'; |
|
|
|
|
|
|
52
|
|
|
public function i18n_plural_name() |
|
|
|
|
|
|
53
|
|
|
{ |
|
54
|
|
|
return $this->Config()->get('plural_name'); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public function onBeforeWrite() |
|
58
|
|
|
{ |
|
59
|
|
|
parent::onBeforeWrite(); |
|
60
|
|
|
$this->CalculatedTotal = $this->ValueSet; |
|
|
|
|
|
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
public function getUnitPrice($recalculate = false) |
|
|
|
|
|
|
64
|
|
|
{ |
|
65
|
|
|
return $this->ValueSet; |
|
|
|
|
|
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
public function getTotal($recalculate = false) |
|
69
|
|
|
{ |
|
70
|
|
|
return $this->ValueSet * $this->Quantity; |
|
|
|
|
|
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
public function getCalculatedTotal() |
|
74
|
|
|
{ |
|
75
|
|
|
return $this->ValueSet * $this->Quantity; |
|
|
|
|
|
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* @param float $total |
|
80
|
|
|
* @return this |
|
|
|
|
|
|
81
|
|
|
*/ |
|
82
|
|
|
public function setCustomCalculatedTotal($total) |
|
83
|
|
|
{ |
|
84
|
|
|
if (!$this->ValueSet) { |
|
|
|
|
|
|
85
|
|
|
$this->ValueSet = $total; |
|
|
|
|
|
|
86
|
|
|
$this->write(); |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
return $this; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* @param string $description |
|
94
|
|
|
* @return this |
|
|
|
|
|
|
95
|
|
|
*/ |
|
96
|
|
|
public function setCustomDescription($description) |
|
97
|
|
|
{ |
|
98
|
|
|
if (! $this->Description) { |
|
|
|
|
|
|
99
|
|
|
$this->Description = $description; |
|
|
|
|
|
|
100
|
|
|
$this->write(); |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
return $this; |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
public function getTableSubTitle() |
|
107
|
|
|
{ |
|
108
|
|
|
$array = array(); |
|
109
|
|
|
if ($this->Description || 1 == 1) { |
|
|
|
|
|
|
110
|
|
|
$array[] = Convert::raw2xml($this->Description); |
|
|
|
|
|
|
111
|
|
|
} |
|
112
|
|
|
$array[] = _t('GIFTVOUCHERPRODUCTPAGE.Value', 'Value: ').$this->UnitPriceAsMoney()->Nice(); |
|
113
|
|
|
return implode('<br />', $array); |
|
114
|
|
|
} |
|
115
|
|
|
} |
|
116
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.