|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
|
|
4
|
|
|
class ProductVariation_OrderItem extends Product_OrderItem |
|
|
|
|
|
|
5
|
|
|
{ |
|
6
|
|
|
|
|
7
|
|
|
// ProductVariation Access Function |
|
8
|
|
|
public function ProductVariation($current = false) |
|
9
|
|
|
{ |
|
10
|
|
|
return $this->Buyable($current); |
|
11
|
|
|
} |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* @decription: we return the product name here - |
|
15
|
|
|
* leaving the Table Sub Title for the name of the variation |
|
16
|
|
|
* |
|
17
|
|
|
* @return String - title in cart. |
|
18
|
|
|
*/ |
|
19
|
|
|
public function TableTitle() |
|
20
|
|
|
{ |
|
21
|
|
|
return $this->getTableTitle(); |
|
22
|
|
|
} |
|
23
|
|
|
public function getTableTitle() |
|
24
|
|
|
{ |
|
25
|
|
|
$tableTitle = _t("Product.UNKNOWN", "Unknown Product"); |
|
26
|
|
|
if ($variation = $this->ProductVariation()) { |
|
27
|
|
|
if ($product = $variation->Product()) { |
|
28
|
|
|
$tableTitle = $product->Title; |
|
29
|
|
|
} |
|
30
|
|
|
} |
|
31
|
|
|
$extendedTitle = $this->extend('updateTableTitle', $tableTitle); |
|
32
|
|
|
if ($extendedTitle !== null && is_array($extendedTitle) && count($extendedTitle)) { |
|
33
|
|
|
return implode("", $extendedTitle); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
return $tableTitle; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* we return the product variation name here |
|
41
|
|
|
* the Table Title will return the name of the Product. |
|
42
|
|
|
* @return String - sub title in cart. |
|
43
|
|
|
**/ |
|
44
|
|
|
public function TableSubTitle() |
|
45
|
|
|
{ |
|
46
|
|
|
return $this->getTableSubTitle(); |
|
47
|
|
|
} |
|
48
|
|
|
public function getTableSubTitle() |
|
49
|
|
|
{ |
|
50
|
|
|
$tableSubTitle = _t("Product.VARIATIONNOTFOUND", "Variation Not Found"); |
|
51
|
|
|
if ($variation = $this->ProductVariation()) { |
|
52
|
|
|
if ($variation->exists()) { |
|
53
|
|
|
$tableSubTitle = $variation->getTitle(true, true); |
|
|
|
|
|
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
$extendedSubTitle = $this->extend('updateTableSubTitle', $tableSubTitle); |
|
57
|
|
|
if ($extendedSubTitle !== null && is_array($extendedSubTitle) && count($extendedSubTitle)) { |
|
58
|
|
|
return implode("", $extendedSubTitle); |
|
59
|
|
|
} |
|
60
|
|
|
return $tableSubTitle; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* Check if this variation is new - that is, if it has yet to have been written |
|
66
|
|
|
* to the database. |
|
67
|
|
|
* |
|
68
|
|
|
* @return boolean True if this is new. |
|
69
|
|
|
*/ |
|
70
|
|
|
public function isNew() |
|
71
|
|
|
{ |
|
72
|
|
|
/** |
|
73
|
|
|
* This check was a problem for a self-hosted site, and may indicate a |
|
74
|
|
|
* bug in the interpreter on their server, or a bug here |
|
75
|
|
|
* Changing the condition from empty($this->ID) to |
|
76
|
|
|
* !$this->ID && !$this->record['ID'] fixed this. |
|
77
|
|
|
*/ |
|
78
|
|
|
if (empty($this->ID)) { |
|
79
|
|
|
return true; |
|
80
|
|
|
} |
|
81
|
|
|
if (is_numeric($this->ID)) { |
|
82
|
|
|
return false; |
|
83
|
|
|
} |
|
84
|
|
|
return stripos($this->ID, 'new') === 0; |
|
85
|
|
|
} |
|
86
|
|
|
} |
|
87
|
|
|
|
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.