@@ -16,220 +16,220 @@ |
||
16 | 16 | class Prices_List_Table extends EE_Admin_List_Table |
17 | 17 | { |
18 | 18 | |
19 | - private $_PRT; |
|
20 | - |
|
21 | - /** |
|
22 | - * Array of price types. |
|
23 | - * |
|
24 | - * @var EE_Price_Type[] |
|
25 | - */ |
|
26 | - protected $_price_types = array(); |
|
27 | - |
|
28 | - public function __construct($admin_page) |
|
29 | - { |
|
30 | - parent::__construct($admin_page); |
|
31 | - require_once(EE_MODELS . 'EEM_Price_Type.model.php'); |
|
32 | - $this->_PRT = EEM_Price_Type::instance(); |
|
33 | - $this->_price_types = $this->_PRT->get_all_deleted_and_undeleted(); |
|
34 | - } |
|
35 | - |
|
36 | - |
|
37 | - protected function _setup_data() |
|
38 | - { |
|
39 | - $trashed = $this->_admin_page->get_view() == 'trashed' ? true : false; |
|
40 | - $this->_data = $this->_admin_page->get_prices_overview_data($this->_per_page, false, $trashed); |
|
41 | - $this->_all_data_count = $this->_admin_page->get_prices_overview_data($this->_per_page, true, false); |
|
42 | - $this->_trashed_count = $this->_admin_page->get_prices_overview_data($this->_per_page, true, true); |
|
43 | - } |
|
44 | - |
|
45 | - |
|
46 | - protected function _set_properties() |
|
47 | - { |
|
48 | - $this->_wp_list_args = array( |
|
49 | - 'singular' => __('price', 'event_espresso'), |
|
50 | - 'plural' => __('prices', 'event_espresso'), |
|
51 | - 'ajax' => true, |
|
52 | - 'screen' => $this->_admin_page->get_current_screen()->id, |
|
53 | - ); |
|
54 | - |
|
55 | - $this->_columns = array( |
|
56 | - 'cb' => '<input type="checkbox" />', // Render a checkbox instead of text |
|
57 | - 'name' => __('Name', 'event_espresso'), |
|
58 | - 'type' => __('Price Type', 'event_espresso'), |
|
59 | - 'description' => __('Description', 'event_espresso'), |
|
60 | - 'amount' => __('Amount', 'event_espresso'), |
|
61 | - ); |
|
62 | - |
|
63 | - $this->_sortable_columns = array( |
|
64 | - // true means its already sorted |
|
65 | - 'name' => array('name' => false), |
|
66 | - 'type' => array('type' => false), |
|
67 | - 'amount' => array('amount' => false), |
|
68 | - ); |
|
69 | - |
|
70 | - $this->_hidden_columns = array(); |
|
71 | - |
|
72 | - $this->_ajax_sorting_callback = 'update_prices_order'; |
|
73 | - } |
|
74 | - |
|
75 | - |
|
76 | - protected function _get_table_filters() |
|
77 | - { |
|
78 | - } |
|
79 | - |
|
80 | - |
|
81 | - protected function _add_view_counts() |
|
82 | - { |
|
83 | - $this->_views['all']['count'] = $this->_all_data_count; |
|
84 | - if (EE_Registry::instance()->CAP->current_user_can('ee_delete_default_prices', 'pricing_trash_price')) { |
|
85 | - $this->_views['trashed']['count'] = $this->_trashed_count; |
|
86 | - } |
|
87 | - } |
|
88 | - |
|
89 | - |
|
90 | - /** |
|
91 | - * overriding parent method so that we can make sure the row isn't sortable for certain items |
|
92 | - * |
|
93 | - * @param object $item the current item |
|
94 | - * @return string |
|
95 | - */ |
|
96 | - protected function _get_row_class($item) |
|
97 | - { |
|
98 | - static $row_class = ''; |
|
99 | - $row_class = ($row_class == '' ? 'alternate' : ''); |
|
100 | - |
|
101 | - $new_row = $row_class; |
|
102 | - |
|
103 | - if ($item->type_obj()->base_type() !== 1 && $item->type_obj()->base_type() !== 4) { |
|
104 | - $new_row .= ' rowsortable'; |
|
105 | - } |
|
106 | - |
|
107 | - return ' class="' . $new_row . '"'; |
|
108 | - } |
|
109 | - |
|
110 | - |
|
111 | - public function column_cb($item) |
|
112 | - { |
|
113 | - if ($item->type_obj()->base_type() !== 1) { |
|
114 | - return sprintf( |
|
115 | - '<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', |
|
116 | - $item->ID() |
|
117 | - ); |
|
118 | - } |
|
119 | - return ''; |
|
120 | - } |
|
121 | - |
|
122 | - |
|
123 | - public function column_name($item) |
|
124 | - { |
|
125 | - |
|
126 | - // Build row actions |
|
127 | - $actions = array(); |
|
128 | - // edit price link |
|
129 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
130 | - 'ee_edit_default_price', |
|
131 | - 'pricing_edit_price', |
|
132 | - $item->ID() |
|
133 | - )) { |
|
134 | - $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
135 | - 'action' => 'edit_price', |
|
136 | - 'id' => $item->ID(), |
|
137 | - ), PRICING_ADMIN_URL); |
|
138 | - $actions['edit'] = '<a href="' . $edit_lnk_url . '" title="' |
|
139 | - . esc_attr__('Edit Price', 'event_espresso') . '">' |
|
140 | - . __('Edit', 'event_espresso') . '</a>'; |
|
141 | - } |
|
142 | - |
|
143 | - $name_link = EE_Registry::instance()->CAP->current_user_can( |
|
144 | - 'ee_edit_default_price', |
|
145 | - 'edit_price', |
|
146 | - $item->ID() |
|
147 | - ) |
|
148 | - ? '<a href="' . $edit_lnk_url . '" title="' |
|
149 | - . esc_attr__('Edit Price', 'event_espresso') . '">' |
|
150 | - . stripslashes($item->name()) . '</a>' |
|
151 | - : $item->name(); |
|
152 | - |
|
153 | - if ($item->type_obj()->base_type() !== 1) { |
|
154 | - if ($this->_view == 'all') { |
|
155 | - // trash price link |
|
156 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
157 | - 'ee_delete_default_price', |
|
158 | - 'pricing_trash_price', |
|
159 | - $item->ID() |
|
160 | - )) { |
|
161 | - $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
162 | - 'action' => 'trash_price', |
|
163 | - 'id' => $item->ID(), |
|
164 | - 'noheader' => true, |
|
165 | - ), PRICING_ADMIN_URL); |
|
166 | - $actions['trash'] = '<a href="' . $trash_lnk_url . '" title="' |
|
167 | - . esc_attr__('Move Price to Trash', 'event_espresso') . '">' |
|
168 | - . __('Move to Trash', 'event_espresso') . '</a>'; |
|
169 | - } |
|
170 | - } else { |
|
171 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
172 | - 'ee_delete_default_price', |
|
173 | - 'pricing_restore_price', |
|
174 | - $item->ID() |
|
175 | - )) { |
|
176 | - // restore price link |
|
177 | - $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
178 | - 'action' => 'restore_price', |
|
179 | - 'id' => $item->ID(), |
|
180 | - 'noheader' => true, |
|
181 | - ), PRICING_ADMIN_URL); |
|
182 | - $actions['restore'] = '<a href="' . $restore_lnk_url . '" title="' |
|
183 | - . esc_attr__('Restore Price', 'event_espresso') . '">' |
|
184 | - . __('Restore', 'event_espresso') . '</a>'; |
|
185 | - } |
|
186 | - |
|
187 | - // delete price link |
|
188 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
189 | - 'ee_delete_default_price', |
|
190 | - 'pricing_delete_price', |
|
191 | - $item->ID() |
|
192 | - )) { |
|
193 | - $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
194 | - 'action' => 'delete_price', |
|
195 | - 'id' => $item->ID(), |
|
196 | - 'noheader' => true, |
|
197 | - ), PRICING_ADMIN_URL); |
|
198 | - $actions['delete'] = '<a href="' . $delete_lnk_url . '" title="' |
|
199 | - . esc_attr__('Delete Price Permanently', 'event_espresso') . '">' |
|
200 | - . __('Delete Permanently', 'event_espresso') . '</a>'; |
|
201 | - } |
|
202 | - } |
|
203 | - } |
|
204 | - |
|
205 | - // Return the name contents |
|
206 | - return sprintf( |
|
207 | - '%1$s <span style="color:silver">(id:%2$s)</span>%3$s', |
|
208 | - $name_link, |
|
209 | - $item->ID(), |
|
210 | - $this->row_actions($actions) |
|
211 | - ); |
|
212 | - } |
|
213 | - |
|
214 | - |
|
215 | - public function column_type($item) |
|
216 | - { |
|
217 | - return $this->_price_types[ $item->type() ]->name(); |
|
218 | - } |
|
219 | - |
|
220 | - |
|
221 | - public function column_description($item) |
|
222 | - { |
|
223 | - return stripslashes($item->desc()); |
|
224 | - } |
|
225 | - |
|
226 | - |
|
227 | - public function column_amount($item) |
|
228 | - { |
|
229 | - if ($this->_price_types[ $item->type() ]->is_percent()) { |
|
230 | - return '<div class="pad-amnt-rght">' . number_format($item->amount(), 1) . '%</div>'; |
|
231 | - } else { |
|
232 | - return '<div class="pad-amnt-rght">' . EEH_Template::format_currency($item->amount()) . '</div>'; |
|
233 | - } |
|
234 | - } |
|
19 | + private $_PRT; |
|
20 | + |
|
21 | + /** |
|
22 | + * Array of price types. |
|
23 | + * |
|
24 | + * @var EE_Price_Type[] |
|
25 | + */ |
|
26 | + protected $_price_types = array(); |
|
27 | + |
|
28 | + public function __construct($admin_page) |
|
29 | + { |
|
30 | + parent::__construct($admin_page); |
|
31 | + require_once(EE_MODELS . 'EEM_Price_Type.model.php'); |
|
32 | + $this->_PRT = EEM_Price_Type::instance(); |
|
33 | + $this->_price_types = $this->_PRT->get_all_deleted_and_undeleted(); |
|
34 | + } |
|
35 | + |
|
36 | + |
|
37 | + protected function _setup_data() |
|
38 | + { |
|
39 | + $trashed = $this->_admin_page->get_view() == 'trashed' ? true : false; |
|
40 | + $this->_data = $this->_admin_page->get_prices_overview_data($this->_per_page, false, $trashed); |
|
41 | + $this->_all_data_count = $this->_admin_page->get_prices_overview_data($this->_per_page, true, false); |
|
42 | + $this->_trashed_count = $this->_admin_page->get_prices_overview_data($this->_per_page, true, true); |
|
43 | + } |
|
44 | + |
|
45 | + |
|
46 | + protected function _set_properties() |
|
47 | + { |
|
48 | + $this->_wp_list_args = array( |
|
49 | + 'singular' => __('price', 'event_espresso'), |
|
50 | + 'plural' => __('prices', 'event_espresso'), |
|
51 | + 'ajax' => true, |
|
52 | + 'screen' => $this->_admin_page->get_current_screen()->id, |
|
53 | + ); |
|
54 | + |
|
55 | + $this->_columns = array( |
|
56 | + 'cb' => '<input type="checkbox" />', // Render a checkbox instead of text |
|
57 | + 'name' => __('Name', 'event_espresso'), |
|
58 | + 'type' => __('Price Type', 'event_espresso'), |
|
59 | + 'description' => __('Description', 'event_espresso'), |
|
60 | + 'amount' => __('Amount', 'event_espresso'), |
|
61 | + ); |
|
62 | + |
|
63 | + $this->_sortable_columns = array( |
|
64 | + // true means its already sorted |
|
65 | + 'name' => array('name' => false), |
|
66 | + 'type' => array('type' => false), |
|
67 | + 'amount' => array('amount' => false), |
|
68 | + ); |
|
69 | + |
|
70 | + $this->_hidden_columns = array(); |
|
71 | + |
|
72 | + $this->_ajax_sorting_callback = 'update_prices_order'; |
|
73 | + } |
|
74 | + |
|
75 | + |
|
76 | + protected function _get_table_filters() |
|
77 | + { |
|
78 | + } |
|
79 | + |
|
80 | + |
|
81 | + protected function _add_view_counts() |
|
82 | + { |
|
83 | + $this->_views['all']['count'] = $this->_all_data_count; |
|
84 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_default_prices', 'pricing_trash_price')) { |
|
85 | + $this->_views['trashed']['count'] = $this->_trashed_count; |
|
86 | + } |
|
87 | + } |
|
88 | + |
|
89 | + |
|
90 | + /** |
|
91 | + * overriding parent method so that we can make sure the row isn't sortable for certain items |
|
92 | + * |
|
93 | + * @param object $item the current item |
|
94 | + * @return string |
|
95 | + */ |
|
96 | + protected function _get_row_class($item) |
|
97 | + { |
|
98 | + static $row_class = ''; |
|
99 | + $row_class = ($row_class == '' ? 'alternate' : ''); |
|
100 | + |
|
101 | + $new_row = $row_class; |
|
102 | + |
|
103 | + if ($item->type_obj()->base_type() !== 1 && $item->type_obj()->base_type() !== 4) { |
|
104 | + $new_row .= ' rowsortable'; |
|
105 | + } |
|
106 | + |
|
107 | + return ' class="' . $new_row . '"'; |
|
108 | + } |
|
109 | + |
|
110 | + |
|
111 | + public function column_cb($item) |
|
112 | + { |
|
113 | + if ($item->type_obj()->base_type() !== 1) { |
|
114 | + return sprintf( |
|
115 | + '<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', |
|
116 | + $item->ID() |
|
117 | + ); |
|
118 | + } |
|
119 | + return ''; |
|
120 | + } |
|
121 | + |
|
122 | + |
|
123 | + public function column_name($item) |
|
124 | + { |
|
125 | + |
|
126 | + // Build row actions |
|
127 | + $actions = array(); |
|
128 | + // edit price link |
|
129 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
130 | + 'ee_edit_default_price', |
|
131 | + 'pricing_edit_price', |
|
132 | + $item->ID() |
|
133 | + )) { |
|
134 | + $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
135 | + 'action' => 'edit_price', |
|
136 | + 'id' => $item->ID(), |
|
137 | + ), PRICING_ADMIN_URL); |
|
138 | + $actions['edit'] = '<a href="' . $edit_lnk_url . '" title="' |
|
139 | + . esc_attr__('Edit Price', 'event_espresso') . '">' |
|
140 | + . __('Edit', 'event_espresso') . '</a>'; |
|
141 | + } |
|
142 | + |
|
143 | + $name_link = EE_Registry::instance()->CAP->current_user_can( |
|
144 | + 'ee_edit_default_price', |
|
145 | + 'edit_price', |
|
146 | + $item->ID() |
|
147 | + ) |
|
148 | + ? '<a href="' . $edit_lnk_url . '" title="' |
|
149 | + . esc_attr__('Edit Price', 'event_espresso') . '">' |
|
150 | + . stripslashes($item->name()) . '</a>' |
|
151 | + : $item->name(); |
|
152 | + |
|
153 | + if ($item->type_obj()->base_type() !== 1) { |
|
154 | + if ($this->_view == 'all') { |
|
155 | + // trash price link |
|
156 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
157 | + 'ee_delete_default_price', |
|
158 | + 'pricing_trash_price', |
|
159 | + $item->ID() |
|
160 | + )) { |
|
161 | + $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
162 | + 'action' => 'trash_price', |
|
163 | + 'id' => $item->ID(), |
|
164 | + 'noheader' => true, |
|
165 | + ), PRICING_ADMIN_URL); |
|
166 | + $actions['trash'] = '<a href="' . $trash_lnk_url . '" title="' |
|
167 | + . esc_attr__('Move Price to Trash', 'event_espresso') . '">' |
|
168 | + . __('Move to Trash', 'event_espresso') . '</a>'; |
|
169 | + } |
|
170 | + } else { |
|
171 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
172 | + 'ee_delete_default_price', |
|
173 | + 'pricing_restore_price', |
|
174 | + $item->ID() |
|
175 | + )) { |
|
176 | + // restore price link |
|
177 | + $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
178 | + 'action' => 'restore_price', |
|
179 | + 'id' => $item->ID(), |
|
180 | + 'noheader' => true, |
|
181 | + ), PRICING_ADMIN_URL); |
|
182 | + $actions['restore'] = '<a href="' . $restore_lnk_url . '" title="' |
|
183 | + . esc_attr__('Restore Price', 'event_espresso') . '">' |
|
184 | + . __('Restore', 'event_espresso') . '</a>'; |
|
185 | + } |
|
186 | + |
|
187 | + // delete price link |
|
188 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
189 | + 'ee_delete_default_price', |
|
190 | + 'pricing_delete_price', |
|
191 | + $item->ID() |
|
192 | + )) { |
|
193 | + $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
194 | + 'action' => 'delete_price', |
|
195 | + 'id' => $item->ID(), |
|
196 | + 'noheader' => true, |
|
197 | + ), PRICING_ADMIN_URL); |
|
198 | + $actions['delete'] = '<a href="' . $delete_lnk_url . '" title="' |
|
199 | + . esc_attr__('Delete Price Permanently', 'event_espresso') . '">' |
|
200 | + . __('Delete Permanently', 'event_espresso') . '</a>'; |
|
201 | + } |
|
202 | + } |
|
203 | + } |
|
204 | + |
|
205 | + // Return the name contents |
|
206 | + return sprintf( |
|
207 | + '%1$s <span style="color:silver">(id:%2$s)</span>%3$s', |
|
208 | + $name_link, |
|
209 | + $item->ID(), |
|
210 | + $this->row_actions($actions) |
|
211 | + ); |
|
212 | + } |
|
213 | + |
|
214 | + |
|
215 | + public function column_type($item) |
|
216 | + { |
|
217 | + return $this->_price_types[ $item->type() ]->name(); |
|
218 | + } |
|
219 | + |
|
220 | + |
|
221 | + public function column_description($item) |
|
222 | + { |
|
223 | + return stripslashes($item->desc()); |
|
224 | + } |
|
225 | + |
|
226 | + |
|
227 | + public function column_amount($item) |
|
228 | + { |
|
229 | + if ($this->_price_types[ $item->type() ]->is_percent()) { |
|
230 | + return '<div class="pad-amnt-rght">' . number_format($item->amount(), 1) . '%</div>'; |
|
231 | + } else { |
|
232 | + return '<div class="pad-amnt-rght">' . EEH_Template::format_currency($item->amount()) . '</div>'; |
|
233 | + } |
|
234 | + } |
|
235 | 235 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | public function __construct($admin_page) |
29 | 29 | { |
30 | 30 | parent::__construct($admin_page); |
31 | - require_once(EE_MODELS . 'EEM_Price_Type.model.php'); |
|
31 | + require_once(EE_MODELS.'EEM_Price_Type.model.php'); |
|
32 | 32 | $this->_PRT = EEM_Price_Type::instance(); |
33 | 33 | $this->_price_types = $this->_PRT->get_all_deleted_and_undeleted(); |
34 | 34 | } |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | $new_row .= ' rowsortable'; |
105 | 105 | } |
106 | 106 | |
107 | - return ' class="' . $new_row . '"'; |
|
107 | + return ' class="'.$new_row.'"'; |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | |
@@ -135,9 +135,9 @@ discard block |
||
135 | 135 | 'action' => 'edit_price', |
136 | 136 | 'id' => $item->ID(), |
137 | 137 | ), PRICING_ADMIN_URL); |
138 | - $actions['edit'] = '<a href="' . $edit_lnk_url . '" title="' |
|
139 | - . esc_attr__('Edit Price', 'event_espresso') . '">' |
|
140 | - . __('Edit', 'event_espresso') . '</a>'; |
|
138 | + $actions['edit'] = '<a href="'.$edit_lnk_url.'" title="' |
|
139 | + . esc_attr__('Edit Price', 'event_espresso').'">' |
|
140 | + . __('Edit', 'event_espresso').'</a>'; |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | $name_link = EE_Registry::instance()->CAP->current_user_can( |
@@ -145,9 +145,9 @@ discard block |
||
145 | 145 | 'edit_price', |
146 | 146 | $item->ID() |
147 | 147 | ) |
148 | - ? '<a href="' . $edit_lnk_url . '" title="' |
|
149 | - . esc_attr__('Edit Price', 'event_espresso') . '">' |
|
150 | - . stripslashes($item->name()) . '</a>' |
|
148 | + ? '<a href="'.$edit_lnk_url.'" title="' |
|
149 | + . esc_attr__('Edit Price', 'event_espresso').'">' |
|
150 | + . stripslashes($item->name()).'</a>' |
|
151 | 151 | : $item->name(); |
152 | 152 | |
153 | 153 | if ($item->type_obj()->base_type() !== 1) { |
@@ -163,9 +163,9 @@ discard block |
||
163 | 163 | 'id' => $item->ID(), |
164 | 164 | 'noheader' => true, |
165 | 165 | ), PRICING_ADMIN_URL); |
166 | - $actions['trash'] = '<a href="' . $trash_lnk_url . '" title="' |
|
167 | - . esc_attr__('Move Price to Trash', 'event_espresso') . '">' |
|
168 | - . __('Move to Trash', 'event_espresso') . '</a>'; |
|
166 | + $actions['trash'] = '<a href="'.$trash_lnk_url.'" title="' |
|
167 | + . esc_attr__('Move Price to Trash', 'event_espresso').'">' |
|
168 | + . __('Move to Trash', 'event_espresso').'</a>'; |
|
169 | 169 | } |
170 | 170 | } else { |
171 | 171 | if (EE_Registry::instance()->CAP->current_user_can( |
@@ -179,9 +179,9 @@ discard block |
||
179 | 179 | 'id' => $item->ID(), |
180 | 180 | 'noheader' => true, |
181 | 181 | ), PRICING_ADMIN_URL); |
182 | - $actions['restore'] = '<a href="' . $restore_lnk_url . '" title="' |
|
183 | - . esc_attr__('Restore Price', 'event_espresso') . '">' |
|
184 | - . __('Restore', 'event_espresso') . '</a>'; |
|
182 | + $actions['restore'] = '<a href="'.$restore_lnk_url.'" title="' |
|
183 | + . esc_attr__('Restore Price', 'event_espresso').'">' |
|
184 | + . __('Restore', 'event_espresso').'</a>'; |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | // delete price link |
@@ -195,9 +195,9 @@ discard block |
||
195 | 195 | 'id' => $item->ID(), |
196 | 196 | 'noheader' => true, |
197 | 197 | ), PRICING_ADMIN_URL); |
198 | - $actions['delete'] = '<a href="' . $delete_lnk_url . '" title="' |
|
199 | - . esc_attr__('Delete Price Permanently', 'event_espresso') . '">' |
|
200 | - . __('Delete Permanently', 'event_espresso') . '</a>'; |
|
198 | + $actions['delete'] = '<a href="'.$delete_lnk_url.'" title="' |
|
199 | + . esc_attr__('Delete Price Permanently', 'event_espresso').'">' |
|
200 | + . __('Delete Permanently', 'event_espresso').'</a>'; |
|
201 | 201 | } |
202 | 202 | } |
203 | 203 | } |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | |
215 | 215 | public function column_type($item) |
216 | 216 | { |
217 | - return $this->_price_types[ $item->type() ]->name(); |
|
217 | + return $this->_price_types[$item->type()]->name(); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | |
@@ -226,10 +226,10 @@ discard block |
||
226 | 226 | |
227 | 227 | public function column_amount($item) |
228 | 228 | { |
229 | - if ($this->_price_types[ $item->type() ]->is_percent()) { |
|
230 | - return '<div class="pad-amnt-rght">' . number_format($item->amount(), 1) . '%</div>'; |
|
229 | + if ($this->_price_types[$item->type()]->is_percent()) { |
|
230 | + return '<div class="pad-amnt-rght">'.number_format($item->amount(), 1).'%</div>'; |
|
231 | 231 | } else { |
232 | - return '<div class="pad-amnt-rght">' . EEH_Template::format_currency($item->amount()) . '</div>'; |
|
232 | + return '<div class="pad-amnt-rght">'.EEH_Template::format_currency($item->amount()).'</div>'; |
|
233 | 233 | } |
234 | 234 | } |
235 | 235 | } |
@@ -10,138 +10,138 @@ |
||
10 | 10 | class EE_Taxes extends EE_Base |
11 | 11 | { |
12 | 12 | |
13 | - /** |
|
14 | - * This is used for when EE_Taxes is used statically by the admin |
|
15 | - * |
|
16 | - * @var array |
|
17 | - */ |
|
18 | - private static $_subtotal = array(); |
|
13 | + /** |
|
14 | + * This is used for when EE_Taxes is used statically by the admin |
|
15 | + * |
|
16 | + * @var array |
|
17 | + */ |
|
18 | + private static $_subtotal = array(); |
|
19 | 19 | |
20 | - /** |
|
21 | - * This holds an array of EE_Price objects that are of PRT_ID == 4 (tax price types) |
|
22 | - * |
|
23 | - * @var EE_Price[] |
|
24 | - */ |
|
25 | - private static $_default_taxes = array(); |
|
20 | + /** |
|
21 | + * This holds an array of EE_Price objects that are of PRT_ID == 4 (tax price types) |
|
22 | + * |
|
23 | + * @var EE_Price[] |
|
24 | + */ |
|
25 | + private static $_default_taxes = array(); |
|
26 | 26 | |
27 | 27 | |
28 | - /** |
|
29 | - * This method simply calculates the total taxes for a given ticket (by pulling the prices attached to the ticket |
|
30 | - * and applying default taxes to it). Note: this is just an intermediary helper method added to facilitate quick |
|
31 | - * calc of taxes for tickets listed in the event editor. |
|
32 | - * |
|
33 | - * @param EE_Ticket $ticket incoming EE_Ticket |
|
34 | - * @return float total taxes to apply to ticket. |
|
35 | - * @throws \EE_Error |
|
36 | - */ |
|
37 | - public static function get_total_taxes_for_admin(EE_Ticket $ticket) |
|
38 | - { |
|
39 | - $tax = 0; |
|
40 | - $total_tax = 0; |
|
41 | - // This first checks to see if the given ticket is taxable. |
|
42 | - if (! $ticket->get('TKT_taxable')) { |
|
43 | - return $tax; |
|
44 | - } |
|
45 | - // get subtotal (notice we're only retrieving a subtotal if there isn't one given) |
|
46 | - $subtotal = self::get_subtotal_for_admin($ticket); |
|
47 | - // get taxes |
|
48 | - $taxes = self::get_taxes_for_admin(); |
|
49 | - // apply taxes to subtotal |
|
50 | - foreach ($taxes as $tax) { |
|
51 | - // assuming taxes are not cumulative |
|
52 | - $total_tax += $subtotal * $tax->get('PRC_amount') / 100; |
|
53 | - } |
|
54 | - return $total_tax; |
|
55 | - } |
|
28 | + /** |
|
29 | + * This method simply calculates the total taxes for a given ticket (by pulling the prices attached to the ticket |
|
30 | + * and applying default taxes to it). Note: this is just an intermediary helper method added to facilitate quick |
|
31 | + * calc of taxes for tickets listed in the event editor. |
|
32 | + * |
|
33 | + * @param EE_Ticket $ticket incoming EE_Ticket |
|
34 | + * @return float total taxes to apply to ticket. |
|
35 | + * @throws \EE_Error |
|
36 | + */ |
|
37 | + public static function get_total_taxes_for_admin(EE_Ticket $ticket) |
|
38 | + { |
|
39 | + $tax = 0; |
|
40 | + $total_tax = 0; |
|
41 | + // This first checks to see if the given ticket is taxable. |
|
42 | + if (! $ticket->get('TKT_taxable')) { |
|
43 | + return $tax; |
|
44 | + } |
|
45 | + // get subtotal (notice we're only retrieving a subtotal if there isn't one given) |
|
46 | + $subtotal = self::get_subtotal_for_admin($ticket); |
|
47 | + // get taxes |
|
48 | + $taxes = self::get_taxes_for_admin(); |
|
49 | + // apply taxes to subtotal |
|
50 | + foreach ($taxes as $tax) { |
|
51 | + // assuming taxes are not cumulative |
|
52 | + $total_tax += $subtotal * $tax->get('PRC_amount') / 100; |
|
53 | + } |
|
54 | + return $total_tax; |
|
55 | + } |
|
56 | 56 | |
57 | 57 | |
58 | - /** |
|
59 | - * Gets the total percentage of tax that should be applied to taxable line items |
|
60 | - * |
|
61 | - * @return float the percentage of tax that should be added to taxable items |
|
62 | - * @throws \EE_Error |
|
63 | - * eg 20 for %20 tax (NOT 0.20, which |
|
64 | - */ |
|
65 | - public static function get_total_taxes_percentage() |
|
66 | - { |
|
67 | - $total_tax_percent = 0; |
|
68 | - foreach (self::get_taxes_for_admin() as $tax_price) { |
|
69 | - $total_tax_percent += $tax_price->get('PRC_amount'); |
|
70 | - } |
|
71 | - return $total_tax_percent; |
|
72 | - } |
|
58 | + /** |
|
59 | + * Gets the total percentage of tax that should be applied to taxable line items |
|
60 | + * |
|
61 | + * @return float the percentage of tax that should be added to taxable items |
|
62 | + * @throws \EE_Error |
|
63 | + * eg 20 for %20 tax (NOT 0.20, which |
|
64 | + */ |
|
65 | + public static function get_total_taxes_percentage() |
|
66 | + { |
|
67 | + $total_tax_percent = 0; |
|
68 | + foreach (self::get_taxes_for_admin() as $tax_price) { |
|
69 | + $total_tax_percent += $tax_price->get('PRC_amount'); |
|
70 | + } |
|
71 | + return $total_tax_percent; |
|
72 | + } |
|
73 | 73 | |
74 | 74 | |
75 | - /** |
|
76 | - * @param EE_Ticket $ticket |
|
77 | - * @return float |
|
78 | - * @throws \EE_Error |
|
79 | - */ |
|
80 | - public static function get_subtotal_for_admin(EE_Ticket $ticket) |
|
81 | - { |
|
82 | - $TKT_ID = $ticket->ID(); |
|
83 | - return isset(self::$_subtotal[ $TKT_ID ]) |
|
84 | - ? self::$_subtotal[ $TKT_ID ] |
|
85 | - : self::_get_subtotal_for_admin($ticket); |
|
86 | - } |
|
75 | + /** |
|
76 | + * @param EE_Ticket $ticket |
|
77 | + * @return float |
|
78 | + * @throws \EE_Error |
|
79 | + */ |
|
80 | + public static function get_subtotal_for_admin(EE_Ticket $ticket) |
|
81 | + { |
|
82 | + $TKT_ID = $ticket->ID(); |
|
83 | + return isset(self::$_subtotal[ $TKT_ID ]) |
|
84 | + ? self::$_subtotal[ $TKT_ID ] |
|
85 | + : self::_get_subtotal_for_admin($ticket); |
|
86 | + } |
|
87 | 87 | |
88 | 88 | |
89 | - /** |
|
90 | - * simply take an incoming ticket and calculate the subtotal for the ticket |
|
91 | - * |
|
92 | - * @param EE_Ticket $ticket |
|
93 | - * @return float subtotal calculated from all EE_Price[] on Ticket. |
|
94 | - * @throws \EE_Error |
|
95 | - */ |
|
96 | - private static function _get_subtotal_for_admin(EE_Ticket $ticket) |
|
97 | - { |
|
98 | - $subtotal = 0; |
|
99 | - // get all prices |
|
100 | - $prices = $ticket->get_many_related( |
|
101 | - 'Price', |
|
102 | - array( |
|
103 | - 'default_where_conditions' => 'none', |
|
104 | - 'order_by' => array('PRC_order' => 'ASC'), |
|
105 | - ) |
|
106 | - ); |
|
107 | - // let's loop through them (base price is always the first item) |
|
108 | - foreach ($prices as $price) { |
|
109 | - if ($price instanceof EE_Price) { |
|
110 | - $price_type = $price->type_obj(); |
|
111 | - if ($price_type instanceof EE_Price_Type) { |
|
112 | - switch ($price->type_obj()->base_type()) { |
|
113 | - case 1: // base price |
|
114 | - case 3: // surcharges |
|
115 | - $subtotal += $price->is_percent() ? $subtotal * $price->get('PRC_amount') / 100 |
|
116 | - : $price->get('PRC_amount'); |
|
117 | - break; |
|
118 | - case 2: // discounts |
|
119 | - $subtotal -= $price->is_percent() ? $subtotal * $price->get('PRC_amount') / 100 |
|
120 | - : $price->get('PRC_amount'); |
|
121 | - break; |
|
122 | - } |
|
123 | - } |
|
124 | - } |
|
125 | - } |
|
126 | - $TKT_ID = $ticket->ID(); |
|
127 | - self::$_subtotal = array($TKT_ID => $subtotal); |
|
128 | - return $subtotal; |
|
129 | - } |
|
89 | + /** |
|
90 | + * simply take an incoming ticket and calculate the subtotal for the ticket |
|
91 | + * |
|
92 | + * @param EE_Ticket $ticket |
|
93 | + * @return float subtotal calculated from all EE_Price[] on Ticket. |
|
94 | + * @throws \EE_Error |
|
95 | + */ |
|
96 | + private static function _get_subtotal_for_admin(EE_Ticket $ticket) |
|
97 | + { |
|
98 | + $subtotal = 0; |
|
99 | + // get all prices |
|
100 | + $prices = $ticket->get_many_related( |
|
101 | + 'Price', |
|
102 | + array( |
|
103 | + 'default_where_conditions' => 'none', |
|
104 | + 'order_by' => array('PRC_order' => 'ASC'), |
|
105 | + ) |
|
106 | + ); |
|
107 | + // let's loop through them (base price is always the first item) |
|
108 | + foreach ($prices as $price) { |
|
109 | + if ($price instanceof EE_Price) { |
|
110 | + $price_type = $price->type_obj(); |
|
111 | + if ($price_type instanceof EE_Price_Type) { |
|
112 | + switch ($price->type_obj()->base_type()) { |
|
113 | + case 1: // base price |
|
114 | + case 3: // surcharges |
|
115 | + $subtotal += $price->is_percent() ? $subtotal * $price->get('PRC_amount') / 100 |
|
116 | + : $price->get('PRC_amount'); |
|
117 | + break; |
|
118 | + case 2: // discounts |
|
119 | + $subtotal -= $price->is_percent() ? $subtotal * $price->get('PRC_amount') / 100 |
|
120 | + : $price->get('PRC_amount'); |
|
121 | + break; |
|
122 | + } |
|
123 | + } |
|
124 | + } |
|
125 | + } |
|
126 | + $TKT_ID = $ticket->ID(); |
|
127 | + self::$_subtotal = array($TKT_ID => $subtotal); |
|
128 | + return $subtotal; |
|
129 | + } |
|
130 | 130 | |
131 | 131 | |
132 | - /** |
|
133 | - * get all default prices that are a Tax price type (PRT_ID = 4) and return |
|
134 | - * |
|
135 | - * @return EE_Price[] EE_Price objects that have PRT_ID == 4 |
|
136 | - * @throws \EE_Error |
|
137 | - */ |
|
138 | - public static function get_taxes_for_admin() |
|
139 | - { |
|
140 | - if (empty(self::$_default_taxes)) { |
|
141 | - self::$_default_taxes = EE_Registry::instance()->load_model('Price')->get_all( |
|
142 | - array(array('Price_Type.PBT_ID' => 4)) |
|
143 | - ); |
|
144 | - } |
|
145 | - return self::$_default_taxes; |
|
146 | - } |
|
132 | + /** |
|
133 | + * get all default prices that are a Tax price type (PRT_ID = 4) and return |
|
134 | + * |
|
135 | + * @return EE_Price[] EE_Price objects that have PRT_ID == 4 |
|
136 | + * @throws \EE_Error |
|
137 | + */ |
|
138 | + public static function get_taxes_for_admin() |
|
139 | + { |
|
140 | + if (empty(self::$_default_taxes)) { |
|
141 | + self::$_default_taxes = EE_Registry::instance()->load_model('Price')->get_all( |
|
142 | + array(array('Price_Type.PBT_ID' => 4)) |
|
143 | + ); |
|
144 | + } |
|
145 | + return self::$_default_taxes; |
|
146 | + } |
|
147 | 147 | } |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | $tax = 0; |
40 | 40 | $total_tax = 0; |
41 | 41 | // This first checks to see if the given ticket is taxable. |
42 | - if (! $ticket->get('TKT_taxable')) { |
|
42 | + if ( ! $ticket->get('TKT_taxable')) { |
|
43 | 43 | return $tax; |
44 | 44 | } |
45 | 45 | // get subtotal (notice we're only retrieving a subtotal if there isn't one given) |
@@ -80,8 +80,8 @@ discard block |
||
80 | 80 | public static function get_subtotal_for_admin(EE_Ticket $ticket) |
81 | 81 | { |
82 | 82 | $TKT_ID = $ticket->ID(); |
83 | - return isset(self::$_subtotal[ $TKT_ID ]) |
|
84 | - ? self::$_subtotal[ $TKT_ID ] |
|
83 | + return isset(self::$_subtotal[$TKT_ID]) |
|
84 | + ? self::$_subtotal[$TKT_ID] |
|
85 | 85 | : self::_get_subtotal_for_admin($ticket); |
86 | 86 | } |
87 | 87 |
@@ -13,173 +13,173 @@ |
||
13 | 13 | class EE_Message_Template extends EE_Base_Class |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * @param array $props_n_values |
|
18 | - * @param string $timezone |
|
19 | - * @return EE_Message_Template|mixed |
|
20 | - */ |
|
21 | - public static function new_instance($props_n_values = array(), $timezone = '') |
|
22 | - { |
|
23 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone); |
|
24 | - return $has_object ? $has_object : new self($props_n_values, false, $timezone); |
|
25 | - } |
|
26 | - |
|
27 | - |
|
28 | - /** |
|
29 | - * @param array $props_n_values |
|
30 | - * @param string $timezone |
|
31 | - * @return EE_Message_Template |
|
32 | - */ |
|
33 | - public static function new_instance_from_db($props_n_values = array(), $timezone = '') |
|
34 | - { |
|
35 | - return new self($props_n_values, true, $timezone); |
|
36 | - } |
|
37 | - |
|
38 | - |
|
39 | - /** |
|
40 | - * @param bool $GRP_ID |
|
41 | - * @throws EE_Error |
|
42 | - */ |
|
43 | - public function set_group_template_id($GRP_ID = false) |
|
44 | - { |
|
45 | - if (! $GRP_ID) { |
|
46 | - throw new EE_Error(__('Missing required value for the message template group id', 'event_espresso')); |
|
47 | - } |
|
48 | - $this->set('GRP_ID', $GRP_ID); |
|
49 | - } |
|
50 | - |
|
51 | - |
|
52 | - /** |
|
53 | - * get Group ID |
|
54 | - * |
|
55 | - * @access public |
|
56 | - * @return int |
|
57 | - */ |
|
58 | - public function GRP_ID() |
|
59 | - { |
|
60 | - return $this->get('GRP_ID'); |
|
61 | - } |
|
62 | - |
|
63 | - |
|
64 | - /** |
|
65 | - * get User ID |
|
66 | - * |
|
67 | - * @access public |
|
68 | - * @return int |
|
69 | - */ |
|
70 | - public function user() |
|
71 | - { |
|
72 | - return $this->get_first_related('Message_Template_Group')->get('MTP_user_id'); |
|
73 | - } |
|
74 | - |
|
75 | - |
|
76 | - /** |
|
77 | - * get Message Messenger |
|
78 | - * |
|
79 | - * @access public |
|
80 | - * @return string |
|
81 | - */ |
|
82 | - public function messenger() |
|
83 | - { |
|
84 | - return $this->get_first_related('Message_Template_Group')->messenger(); |
|
85 | - } |
|
86 | - |
|
87 | - |
|
88 | - /** |
|
89 | - * get Message Messenger OBJECT |
|
90 | - * |
|
91 | - * @access public |
|
92 | - * @return object Messenger Object for the given messenger |
|
93 | - */ |
|
94 | - public function messenger_obj() |
|
95 | - { |
|
96 | - return $this->get_first_related('Message_Template_Group')->messenger_obj(); |
|
97 | - } |
|
98 | - |
|
99 | - |
|
100 | - /** |
|
101 | - * get Message Type |
|
102 | - * |
|
103 | - * @access public |
|
104 | - * @return string |
|
105 | - */ |
|
106 | - public function message_type() |
|
107 | - { |
|
108 | - return $this->get_first_related('Message_Template_Group')->message_type(); |
|
109 | - } |
|
110 | - |
|
111 | - |
|
112 | - /** |
|
113 | - * get Message type OBJECT |
|
114 | - * |
|
115 | - * @access public |
|
116 | - * @return object Message Type object for the given message type |
|
117 | - */ |
|
118 | - public function message_type_obj() |
|
119 | - { |
|
120 | - return $this->get_first_related('Message_Template_Group')->message_type_obj(); |
|
121 | - } |
|
122 | - |
|
123 | - |
|
124 | - /** |
|
125 | - * This returns the set context array configured in the message type object |
|
126 | - * |
|
127 | - * @access public |
|
128 | - * @return array array of contexts and their configuration. |
|
129 | - */ |
|
130 | - public function contexts_config() |
|
131 | - { |
|
132 | - return $this->get_first_related('Message_Template_Group')->contexts_config(); |
|
133 | - } |
|
134 | - |
|
135 | - |
|
136 | - /** |
|
137 | - * This returns the context_label for contexts as set in the message type object |
|
138 | - * |
|
139 | - * @access public |
|
140 | - * @return string label for "context" |
|
141 | - */ |
|
142 | - public function context_label() |
|
143 | - { |
|
144 | - return $this->get_first_related('Message_Template_Group')->context_label(); |
|
145 | - } |
|
146 | - |
|
147 | - |
|
148 | - /** |
|
149 | - * this returns if the template group this template belongs to is global |
|
150 | - * |
|
151 | - * @return boolean true if it is, false if it isn't |
|
152 | - */ |
|
153 | - public function is_global() |
|
154 | - { |
|
155 | - return $this->get_first_related('Message_Template_Group')->is_global(); |
|
156 | - } |
|
157 | - |
|
158 | - |
|
159 | - /** |
|
160 | - * this returns if the template group this template belongs to is active (i.e. turned "on" or not) |
|
161 | - * |
|
162 | - * @return boolean true if it is, false if it isn't |
|
163 | - */ |
|
164 | - public function is_active() |
|
165 | - { |
|
166 | - return $this->get_first_related('Message_Template_Group')->is_active(); |
|
167 | - } |
|
168 | - |
|
169 | - |
|
170 | - /** |
|
171 | - * This will return an array of shortcodes => labels from the messenger and message_type objects associated with |
|
172 | - * this template. |
|
173 | - * |
|
174 | - * @access public |
|
175 | - * @param string $context what context we're going to return shortcodes for |
|
176 | - * @param array $fields what fields we're returning valid shortcodes for. If empty then we assume all fields are |
|
177 | - * to be merged and returned. |
|
178 | - * @return mixed (array|bool) an array of shortcodes in the format array( '[shortcode] => 'label') OR FALSE if no |
|
179 | - * shortcodes found. |
|
180 | - */ |
|
181 | - public function get_shortcodes($context, $fields = array()) |
|
182 | - { |
|
183 | - return $this->get_first_related('Message_Template_Group')->get_shortcodes($context, $fields); |
|
184 | - } |
|
16 | + /** |
|
17 | + * @param array $props_n_values |
|
18 | + * @param string $timezone |
|
19 | + * @return EE_Message_Template|mixed |
|
20 | + */ |
|
21 | + public static function new_instance($props_n_values = array(), $timezone = '') |
|
22 | + { |
|
23 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone); |
|
24 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone); |
|
25 | + } |
|
26 | + |
|
27 | + |
|
28 | + /** |
|
29 | + * @param array $props_n_values |
|
30 | + * @param string $timezone |
|
31 | + * @return EE_Message_Template |
|
32 | + */ |
|
33 | + public static function new_instance_from_db($props_n_values = array(), $timezone = '') |
|
34 | + { |
|
35 | + return new self($props_n_values, true, $timezone); |
|
36 | + } |
|
37 | + |
|
38 | + |
|
39 | + /** |
|
40 | + * @param bool $GRP_ID |
|
41 | + * @throws EE_Error |
|
42 | + */ |
|
43 | + public function set_group_template_id($GRP_ID = false) |
|
44 | + { |
|
45 | + if (! $GRP_ID) { |
|
46 | + throw new EE_Error(__('Missing required value for the message template group id', 'event_espresso')); |
|
47 | + } |
|
48 | + $this->set('GRP_ID', $GRP_ID); |
|
49 | + } |
|
50 | + |
|
51 | + |
|
52 | + /** |
|
53 | + * get Group ID |
|
54 | + * |
|
55 | + * @access public |
|
56 | + * @return int |
|
57 | + */ |
|
58 | + public function GRP_ID() |
|
59 | + { |
|
60 | + return $this->get('GRP_ID'); |
|
61 | + } |
|
62 | + |
|
63 | + |
|
64 | + /** |
|
65 | + * get User ID |
|
66 | + * |
|
67 | + * @access public |
|
68 | + * @return int |
|
69 | + */ |
|
70 | + public function user() |
|
71 | + { |
|
72 | + return $this->get_first_related('Message_Template_Group')->get('MTP_user_id'); |
|
73 | + } |
|
74 | + |
|
75 | + |
|
76 | + /** |
|
77 | + * get Message Messenger |
|
78 | + * |
|
79 | + * @access public |
|
80 | + * @return string |
|
81 | + */ |
|
82 | + public function messenger() |
|
83 | + { |
|
84 | + return $this->get_first_related('Message_Template_Group')->messenger(); |
|
85 | + } |
|
86 | + |
|
87 | + |
|
88 | + /** |
|
89 | + * get Message Messenger OBJECT |
|
90 | + * |
|
91 | + * @access public |
|
92 | + * @return object Messenger Object for the given messenger |
|
93 | + */ |
|
94 | + public function messenger_obj() |
|
95 | + { |
|
96 | + return $this->get_first_related('Message_Template_Group')->messenger_obj(); |
|
97 | + } |
|
98 | + |
|
99 | + |
|
100 | + /** |
|
101 | + * get Message Type |
|
102 | + * |
|
103 | + * @access public |
|
104 | + * @return string |
|
105 | + */ |
|
106 | + public function message_type() |
|
107 | + { |
|
108 | + return $this->get_first_related('Message_Template_Group')->message_type(); |
|
109 | + } |
|
110 | + |
|
111 | + |
|
112 | + /** |
|
113 | + * get Message type OBJECT |
|
114 | + * |
|
115 | + * @access public |
|
116 | + * @return object Message Type object for the given message type |
|
117 | + */ |
|
118 | + public function message_type_obj() |
|
119 | + { |
|
120 | + return $this->get_first_related('Message_Template_Group')->message_type_obj(); |
|
121 | + } |
|
122 | + |
|
123 | + |
|
124 | + /** |
|
125 | + * This returns the set context array configured in the message type object |
|
126 | + * |
|
127 | + * @access public |
|
128 | + * @return array array of contexts and their configuration. |
|
129 | + */ |
|
130 | + public function contexts_config() |
|
131 | + { |
|
132 | + return $this->get_first_related('Message_Template_Group')->contexts_config(); |
|
133 | + } |
|
134 | + |
|
135 | + |
|
136 | + /** |
|
137 | + * This returns the context_label for contexts as set in the message type object |
|
138 | + * |
|
139 | + * @access public |
|
140 | + * @return string label for "context" |
|
141 | + */ |
|
142 | + public function context_label() |
|
143 | + { |
|
144 | + return $this->get_first_related('Message_Template_Group')->context_label(); |
|
145 | + } |
|
146 | + |
|
147 | + |
|
148 | + /** |
|
149 | + * this returns if the template group this template belongs to is global |
|
150 | + * |
|
151 | + * @return boolean true if it is, false if it isn't |
|
152 | + */ |
|
153 | + public function is_global() |
|
154 | + { |
|
155 | + return $this->get_first_related('Message_Template_Group')->is_global(); |
|
156 | + } |
|
157 | + |
|
158 | + |
|
159 | + /** |
|
160 | + * this returns if the template group this template belongs to is active (i.e. turned "on" or not) |
|
161 | + * |
|
162 | + * @return boolean true if it is, false if it isn't |
|
163 | + */ |
|
164 | + public function is_active() |
|
165 | + { |
|
166 | + return $this->get_first_related('Message_Template_Group')->is_active(); |
|
167 | + } |
|
168 | + |
|
169 | + |
|
170 | + /** |
|
171 | + * This will return an array of shortcodes => labels from the messenger and message_type objects associated with |
|
172 | + * this template. |
|
173 | + * |
|
174 | + * @access public |
|
175 | + * @param string $context what context we're going to return shortcodes for |
|
176 | + * @param array $fields what fields we're returning valid shortcodes for. If empty then we assume all fields are |
|
177 | + * to be merged and returned. |
|
178 | + * @return mixed (array|bool) an array of shortcodes in the format array( '[shortcode] => 'label') OR FALSE if no |
|
179 | + * shortcodes found. |
|
180 | + */ |
|
181 | + public function get_shortcodes($context, $fields = array()) |
|
182 | + { |
|
183 | + return $this->get_first_related('Message_Template_Group')->get_shortcodes($context, $fields); |
|
184 | + } |
|
185 | 185 | } |
@@ -42,7 +42,7 @@ |
||
42 | 42 | */ |
43 | 43 | public function set_group_template_id($GRP_ID = false) |
44 | 44 | { |
45 | - if (! $GRP_ID) { |
|
45 | + if ( ! $GRP_ID) { |
|
46 | 46 | throw new EE_Error(__('Missing required value for the message template group id', 'event_espresso')); |
47 | 47 | } |
48 | 48 | $this->set('GRP_ID', $GRP_ID); |
@@ -11,25 +11,25 @@ |
||
11 | 11 | class EE_Ticket_Price extends EE_Base_Class |
12 | 12 | { |
13 | 13 | |
14 | - /** |
|
15 | - * @param array $props_n_values |
|
16 | - * @param string $timezone |
|
17 | - * @return EE_Ticket_Price|mixed |
|
18 | - */ |
|
19 | - public static function new_instance($props_n_values = array(), $timezone = '', $date_formats = array()) |
|
20 | - { |
|
21 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
22 | - return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
23 | - } |
|
14 | + /** |
|
15 | + * @param array $props_n_values |
|
16 | + * @param string $timezone |
|
17 | + * @return EE_Ticket_Price|mixed |
|
18 | + */ |
|
19 | + public static function new_instance($props_n_values = array(), $timezone = '', $date_formats = array()) |
|
20 | + { |
|
21 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
22 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
23 | + } |
|
24 | 24 | |
25 | 25 | |
26 | - /** |
|
27 | - * @param array $props_n_values |
|
28 | - * @param string $timezone |
|
29 | - * @return EE_Ticket_Price |
|
30 | - */ |
|
31 | - public static function new_instance_from_db($props_n_values = array(), $timezone = '') |
|
32 | - { |
|
33 | - return new self($props_n_values, true, $timezone); |
|
34 | - } |
|
26 | + /** |
|
27 | + * @param array $props_n_values |
|
28 | + * @param string $timezone |
|
29 | + * @return EE_Ticket_Price |
|
30 | + */ |
|
31 | + public static function new_instance_from_db($props_n_values = array(), $timezone = '') |
|
32 | + { |
|
33 | + return new self($props_n_values, true, $timezone); |
|
34 | + } |
|
35 | 35 | } |
@@ -12,25 +12,25 @@ |
||
12 | 12 | class EE_Ticket_Template extends EE_Base_Class |
13 | 13 | { |
14 | 14 | |
15 | - /** |
|
16 | - * @param array $props_n_values |
|
17 | - * @param string $timezone |
|
18 | - * @return EE_Ticket_Template|mixed |
|
19 | - */ |
|
20 | - public static function new_instance($props_n_values = array(), $timezone = '') |
|
21 | - { |
|
22 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone); |
|
23 | - return $has_object ? $has_object : new self($props_n_values, false, $timezone); |
|
24 | - } |
|
15 | + /** |
|
16 | + * @param array $props_n_values |
|
17 | + * @param string $timezone |
|
18 | + * @return EE_Ticket_Template|mixed |
|
19 | + */ |
|
20 | + public static function new_instance($props_n_values = array(), $timezone = '') |
|
21 | + { |
|
22 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone); |
|
23 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone); |
|
24 | + } |
|
25 | 25 | |
26 | 26 | |
27 | - /** |
|
28 | - * @param array $props_n_values |
|
29 | - * @param string $timezone |
|
30 | - * @return EE_Ticket_Template |
|
31 | - */ |
|
32 | - public static function new_instance_from_db($props_n_values = array(), $timezone = '') |
|
33 | - { |
|
34 | - return new self($props_n_values, true, $timezone); |
|
35 | - } |
|
27 | + /** |
|
28 | + * @param array $props_n_values |
|
29 | + * @param string $timezone |
|
30 | + * @return EE_Ticket_Template |
|
31 | + */ |
|
32 | + public static function new_instance_from_db($props_n_values = array(), $timezone = '') |
|
33 | + { |
|
34 | + return new self($props_n_values, true, $timezone); |
|
35 | + } |
|
36 | 36 | } |
@@ -10,23 +10,23 @@ |
||
10 | 10 | class EE_Term_Relationship extends EE_Base_Class |
11 | 11 | { |
12 | 12 | |
13 | - /** |
|
14 | - * @param array $props_n_values |
|
15 | - * @return EE_Term_Relationship |
|
16 | - */ |
|
17 | - public static function new_instance($props_n_values = array()) |
|
18 | - { |
|
19 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
20 | - return $has_object ? $has_object : new self($props_n_values); |
|
21 | - } |
|
13 | + /** |
|
14 | + * @param array $props_n_values |
|
15 | + * @return EE_Term_Relationship |
|
16 | + */ |
|
17 | + public static function new_instance($props_n_values = array()) |
|
18 | + { |
|
19 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
20 | + return $has_object ? $has_object : new self($props_n_values); |
|
21 | + } |
|
22 | 22 | |
23 | 23 | |
24 | - /** |
|
25 | - * @param array $props_n_values |
|
26 | - * @return EE_Term_Relationship |
|
27 | - */ |
|
28 | - public static function new_instance_from_db($props_n_values = array()) |
|
29 | - { |
|
30 | - return new self($props_n_values, true); |
|
31 | - } |
|
24 | + /** |
|
25 | + * @param array $props_n_values |
|
26 | + * @return EE_Term_Relationship |
|
27 | + */ |
|
28 | + public static function new_instance_from_db($props_n_values = array()) |
|
29 | + { |
|
30 | + return new self($props_n_values, true); |
|
31 | + } |
|
32 | 32 | } |
@@ -10,123 +10,123 @@ |
||
10 | 10 | class EE_Country extends EE_Base_Class |
11 | 11 | { |
12 | 12 | |
13 | - /** |
|
14 | - * @param array $props_n_values |
|
15 | - * @return EE_Country|mixed |
|
16 | - */ |
|
17 | - public static function new_instance($props_n_values = array()) |
|
18 | - { |
|
19 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
20 | - return $has_object ? $has_object : new self($props_n_values); |
|
21 | - } |
|
22 | - |
|
23 | - |
|
24 | - /** |
|
25 | - * @param array $props_n_values |
|
26 | - * @return EE_Country |
|
27 | - */ |
|
28 | - public static function new_instance_from_db($props_n_values = array()) |
|
29 | - { |
|
30 | - return new self($props_n_values, true); |
|
31 | - } |
|
32 | - |
|
33 | - |
|
34 | - /** |
|
35 | - * Gets the country name |
|
36 | - * |
|
37 | - * @return string |
|
38 | - */ |
|
39 | - public function name() |
|
40 | - { |
|
41 | - return $this->get('CNT_name'); |
|
42 | - } |
|
43 | - |
|
44 | - |
|
45 | - /** |
|
46 | - * gets the country's currency code |
|
47 | - * |
|
48 | - * @return string |
|
49 | - */ |
|
50 | - public function currency_code() |
|
51 | - { |
|
52 | - return $this->get('CNT_cur_code'); |
|
53 | - } |
|
54 | - |
|
55 | - |
|
56 | - /** |
|
57 | - * gets the country's currency sign/symbol |
|
58 | - * |
|
59 | - * @return string |
|
60 | - */ |
|
61 | - public function currency_sign() |
|
62 | - { |
|
63 | - $CNT_cur_sign = $this->get('CNT_cur_sign'); |
|
64 | - return $CNT_cur_sign ? $CNT_cur_sign : ''; |
|
65 | - } |
|
66 | - |
|
67 | - |
|
68 | - /** |
|
69 | - * Currency name singular |
|
70 | - * |
|
71 | - * @return string |
|
72 | - */ |
|
73 | - public function currency_name_single() |
|
74 | - { |
|
75 | - return $this->get('CNT_cur_single'); |
|
76 | - } |
|
77 | - |
|
78 | - |
|
79 | - /** |
|
80 | - * Currency name plural |
|
81 | - * |
|
82 | - * @return string |
|
83 | - */ |
|
84 | - public function currency_name_plural() |
|
85 | - { |
|
86 | - return $this->get('CNT_cur_plural'); |
|
87 | - } |
|
88 | - |
|
89 | - |
|
90 | - /** |
|
91 | - * currency_sign_before - ie: $TRUE or FALSE$ |
|
92 | - * |
|
93 | - * @return boolean |
|
94 | - */ |
|
95 | - public function currency_sign_before() |
|
96 | - { |
|
97 | - return $this->get('CNT_cur_sign_b4'); |
|
98 | - } |
|
99 | - |
|
100 | - |
|
101 | - /** |
|
102 | - * currency_decimal_places : 2 = 0.00 3 = 0.000 |
|
103 | - * |
|
104 | - * @return integer |
|
105 | - */ |
|
106 | - public function currency_decimal_places() |
|
107 | - { |
|
108 | - return $this->get('CNT_cur_dec_plc'); |
|
109 | - } |
|
110 | - |
|
111 | - |
|
112 | - /** |
|
113 | - * currency_decimal_mark : (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
114 | - * |
|
115 | - * @return string |
|
116 | - */ |
|
117 | - public function currency_decimal_mark() |
|
118 | - { |
|
119 | - return $this->get('CNT_cur_dec_mrk'); |
|
120 | - } |
|
121 | - |
|
122 | - |
|
123 | - /** |
|
124 | - * currency thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
125 | - * |
|
126 | - * @return string |
|
127 | - */ |
|
128 | - public function currency_thousands_separator() |
|
129 | - { |
|
130 | - return $this->get('CNT_cur_thsnds'); |
|
131 | - } |
|
13 | + /** |
|
14 | + * @param array $props_n_values |
|
15 | + * @return EE_Country|mixed |
|
16 | + */ |
|
17 | + public static function new_instance($props_n_values = array()) |
|
18 | + { |
|
19 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
20 | + return $has_object ? $has_object : new self($props_n_values); |
|
21 | + } |
|
22 | + |
|
23 | + |
|
24 | + /** |
|
25 | + * @param array $props_n_values |
|
26 | + * @return EE_Country |
|
27 | + */ |
|
28 | + public static function new_instance_from_db($props_n_values = array()) |
|
29 | + { |
|
30 | + return new self($props_n_values, true); |
|
31 | + } |
|
32 | + |
|
33 | + |
|
34 | + /** |
|
35 | + * Gets the country name |
|
36 | + * |
|
37 | + * @return string |
|
38 | + */ |
|
39 | + public function name() |
|
40 | + { |
|
41 | + return $this->get('CNT_name'); |
|
42 | + } |
|
43 | + |
|
44 | + |
|
45 | + /** |
|
46 | + * gets the country's currency code |
|
47 | + * |
|
48 | + * @return string |
|
49 | + */ |
|
50 | + public function currency_code() |
|
51 | + { |
|
52 | + return $this->get('CNT_cur_code'); |
|
53 | + } |
|
54 | + |
|
55 | + |
|
56 | + /** |
|
57 | + * gets the country's currency sign/symbol |
|
58 | + * |
|
59 | + * @return string |
|
60 | + */ |
|
61 | + public function currency_sign() |
|
62 | + { |
|
63 | + $CNT_cur_sign = $this->get('CNT_cur_sign'); |
|
64 | + return $CNT_cur_sign ? $CNT_cur_sign : ''; |
|
65 | + } |
|
66 | + |
|
67 | + |
|
68 | + /** |
|
69 | + * Currency name singular |
|
70 | + * |
|
71 | + * @return string |
|
72 | + */ |
|
73 | + public function currency_name_single() |
|
74 | + { |
|
75 | + return $this->get('CNT_cur_single'); |
|
76 | + } |
|
77 | + |
|
78 | + |
|
79 | + /** |
|
80 | + * Currency name plural |
|
81 | + * |
|
82 | + * @return string |
|
83 | + */ |
|
84 | + public function currency_name_plural() |
|
85 | + { |
|
86 | + return $this->get('CNT_cur_plural'); |
|
87 | + } |
|
88 | + |
|
89 | + |
|
90 | + /** |
|
91 | + * currency_sign_before - ie: $TRUE or FALSE$ |
|
92 | + * |
|
93 | + * @return boolean |
|
94 | + */ |
|
95 | + public function currency_sign_before() |
|
96 | + { |
|
97 | + return $this->get('CNT_cur_sign_b4'); |
|
98 | + } |
|
99 | + |
|
100 | + |
|
101 | + /** |
|
102 | + * currency_decimal_places : 2 = 0.00 3 = 0.000 |
|
103 | + * |
|
104 | + * @return integer |
|
105 | + */ |
|
106 | + public function currency_decimal_places() |
|
107 | + { |
|
108 | + return $this->get('CNT_cur_dec_plc'); |
|
109 | + } |
|
110 | + |
|
111 | + |
|
112 | + /** |
|
113 | + * currency_decimal_mark : (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
114 | + * |
|
115 | + * @return string |
|
116 | + */ |
|
117 | + public function currency_decimal_mark() |
|
118 | + { |
|
119 | + return $this->get('CNT_cur_dec_mrk'); |
|
120 | + } |
|
121 | + |
|
122 | + |
|
123 | + /** |
|
124 | + * currency thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
125 | + * |
|
126 | + * @return string |
|
127 | + */ |
|
128 | + public function currency_thousands_separator() |
|
129 | + { |
|
130 | + return $this->get('CNT_cur_thsnds'); |
|
131 | + } |
|
132 | 132 | } |
@@ -12,25 +12,25 @@ |
||
12 | 12 | class EE_Extra_Join extends EE_Base_Class |
13 | 13 | { |
14 | 14 | |
15 | - /** |
|
16 | - * @param array $props_n_values |
|
17 | - * @param null $timezone |
|
18 | - * @return EE_Extra_Join|mixed |
|
19 | - */ |
|
20 | - public static function new_instance($props_n_values = array(), $timezone = null) |
|
21 | - { |
|
22 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone); |
|
23 | - return $has_object ? $has_object : new self($props_n_values, false, $timezone); |
|
24 | - } |
|
15 | + /** |
|
16 | + * @param array $props_n_values |
|
17 | + * @param null $timezone |
|
18 | + * @return EE_Extra_Join|mixed |
|
19 | + */ |
|
20 | + public static function new_instance($props_n_values = array(), $timezone = null) |
|
21 | + { |
|
22 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone); |
|
23 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone); |
|
24 | + } |
|
25 | 25 | |
26 | 26 | |
27 | - /** |
|
28 | - * @param array $props_n_values |
|
29 | - * @param null $timezone |
|
30 | - * @return EE_Extra_Join |
|
31 | - */ |
|
32 | - public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
33 | - { |
|
34 | - return new self($props_n_values, true, $timezone); |
|
35 | - } |
|
27 | + /** |
|
28 | + * @param array $props_n_values |
|
29 | + * @param null $timezone |
|
30 | + * @return EE_Extra_Join |
|
31 | + */ |
|
32 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
33 | + { |
|
34 | + return new self($props_n_values, true, $timezone); |
|
35 | + } |
|
36 | 36 | } |
@@ -10,163 +10,163 @@ |
||
10 | 10 | class EE_Price_Type extends EE_Soft_Delete_Base_Class |
11 | 11 | { |
12 | 12 | |
13 | - /** |
|
14 | - * @param array $props_n_values |
|
15 | - * @return EE_Price_Type |
|
16 | - */ |
|
17 | - public static function new_instance($props_n_values = array()) |
|
18 | - { |
|
19 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
20 | - return $has_object ? $has_object : new self($props_n_values); |
|
21 | - } |
|
22 | - |
|
23 | - |
|
24 | - /** |
|
25 | - * @param array $props_n_values |
|
26 | - * @return EE_Price_Type |
|
27 | - */ |
|
28 | - public static function new_instance_from_db($props_n_values = array()) |
|
29 | - { |
|
30 | - return new self($props_n_values, true); |
|
31 | - } |
|
32 | - |
|
33 | - |
|
34 | - /** |
|
35 | - * Set Price Type Name |
|
36 | - * |
|
37 | - * @access public |
|
38 | - * @param string $PRT_name |
|
39 | - */ |
|
40 | - public function set_name($PRT_name = '') |
|
41 | - { |
|
42 | - $this->set('PRT_name', $PRT_name); |
|
43 | - } |
|
44 | - |
|
45 | - |
|
46 | - /** |
|
47 | - * Set Price Type a percent |
|
48 | - * |
|
49 | - * @access public |
|
50 | - * @param bool $PRT_is_percent |
|
51 | - */ |
|
52 | - public function set_is_percent($PRT_is_percent = false) |
|
53 | - { |
|
54 | - $this->set('PRT_is_percent', $PRT_is_percent); |
|
55 | - } |
|
56 | - |
|
57 | - |
|
58 | - /** |
|
59 | - * Set Price Type order |
|
60 | - * |
|
61 | - * @access public |
|
62 | - * @param int $PRT_order |
|
63 | - */ |
|
64 | - public function set_order($PRT_order = 0) |
|
65 | - { |
|
66 | - $this->set('PRT_order', $PRT_order); |
|
67 | - } |
|
68 | - |
|
69 | - |
|
70 | - /** |
|
71 | - * |
|
72 | - */ |
|
73 | - public function move_to_trash() |
|
74 | - { |
|
75 | - $this->set('PRT_deleted', true); |
|
76 | - } |
|
77 | - |
|
78 | - |
|
79 | - /** |
|
80 | - * |
|
81 | - */ |
|
82 | - public function restore_from_trash() |
|
83 | - { |
|
84 | - $this->set('PRT_deleted', false); |
|
85 | - } |
|
86 | - |
|
87 | - |
|
88 | - /** |
|
89 | - * get Price Type Name |
|
90 | - * |
|
91 | - * @access public |
|
92 | - */ |
|
93 | - public function name() |
|
94 | - { |
|
95 | - return $this->get('PRT_name'); |
|
96 | - } |
|
97 | - |
|
98 | - |
|
99 | - /** |
|
100 | - * get is Price Type a discount? |
|
101 | - * |
|
102 | - * @access public |
|
103 | - */ |
|
104 | - public function base_type() |
|
105 | - { |
|
106 | - return $this->get('PBT_ID'); |
|
107 | - } |
|
108 | - |
|
109 | - |
|
110 | - /** |
|
111 | - * @return mixed |
|
112 | - */ |
|
113 | - public function base_type_name() |
|
114 | - { |
|
115 | - return $this->get_pretty('PBT_ID'); |
|
116 | - } |
|
117 | - |
|
118 | - |
|
119 | - /** |
|
120 | - * get is Price Type a percent? |
|
121 | - * |
|
122 | - * @access public |
|
123 | - */ |
|
124 | - public function is_percent() |
|
125 | - { |
|
126 | - return $this->get('PRT_is_percent'); |
|
127 | - } |
|
128 | - |
|
129 | - |
|
130 | - /** |
|
131 | - * @return bool |
|
132 | - */ |
|
133 | - public function is_discount() |
|
134 | - { |
|
135 | - return $this->get('PBT_ID') == 2 ? true : false; |
|
136 | - } |
|
137 | - |
|
138 | - |
|
139 | - /** |
|
140 | - * get the author of the price type. |
|
141 | - * |
|
142 | - * @since 4.5.0 |
|
143 | - * |
|
144 | - * @return int |
|
145 | - */ |
|
146 | - public function wp_user() |
|
147 | - { |
|
148 | - return $this->get('PRT_wp_user'); |
|
149 | - } |
|
150 | - |
|
151 | - |
|
152 | - /** |
|
153 | - * get Price Type order |
|
154 | - * |
|
155 | - * @access public |
|
156 | - */ |
|
157 | - public function order() |
|
158 | - { |
|
159 | - return $this->get('PRT_order'); |
|
160 | - } |
|
161 | - |
|
162 | - |
|
163 | - /** |
|
164 | - * get is Price Type deleted ? |
|
165 | - * |
|
166 | - * @access public |
|
167 | - */ |
|
168 | - public function deleted() |
|
169 | - { |
|
170 | - return $this->get('PRT_deleted'); |
|
171 | - } |
|
13 | + /** |
|
14 | + * @param array $props_n_values |
|
15 | + * @return EE_Price_Type |
|
16 | + */ |
|
17 | + public static function new_instance($props_n_values = array()) |
|
18 | + { |
|
19 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
20 | + return $has_object ? $has_object : new self($props_n_values); |
|
21 | + } |
|
22 | + |
|
23 | + |
|
24 | + /** |
|
25 | + * @param array $props_n_values |
|
26 | + * @return EE_Price_Type |
|
27 | + */ |
|
28 | + public static function new_instance_from_db($props_n_values = array()) |
|
29 | + { |
|
30 | + return new self($props_n_values, true); |
|
31 | + } |
|
32 | + |
|
33 | + |
|
34 | + /** |
|
35 | + * Set Price Type Name |
|
36 | + * |
|
37 | + * @access public |
|
38 | + * @param string $PRT_name |
|
39 | + */ |
|
40 | + public function set_name($PRT_name = '') |
|
41 | + { |
|
42 | + $this->set('PRT_name', $PRT_name); |
|
43 | + } |
|
44 | + |
|
45 | + |
|
46 | + /** |
|
47 | + * Set Price Type a percent |
|
48 | + * |
|
49 | + * @access public |
|
50 | + * @param bool $PRT_is_percent |
|
51 | + */ |
|
52 | + public function set_is_percent($PRT_is_percent = false) |
|
53 | + { |
|
54 | + $this->set('PRT_is_percent', $PRT_is_percent); |
|
55 | + } |
|
56 | + |
|
57 | + |
|
58 | + /** |
|
59 | + * Set Price Type order |
|
60 | + * |
|
61 | + * @access public |
|
62 | + * @param int $PRT_order |
|
63 | + */ |
|
64 | + public function set_order($PRT_order = 0) |
|
65 | + { |
|
66 | + $this->set('PRT_order', $PRT_order); |
|
67 | + } |
|
68 | + |
|
69 | + |
|
70 | + /** |
|
71 | + * |
|
72 | + */ |
|
73 | + public function move_to_trash() |
|
74 | + { |
|
75 | + $this->set('PRT_deleted', true); |
|
76 | + } |
|
77 | + |
|
78 | + |
|
79 | + /** |
|
80 | + * |
|
81 | + */ |
|
82 | + public function restore_from_trash() |
|
83 | + { |
|
84 | + $this->set('PRT_deleted', false); |
|
85 | + } |
|
86 | + |
|
87 | + |
|
88 | + /** |
|
89 | + * get Price Type Name |
|
90 | + * |
|
91 | + * @access public |
|
92 | + */ |
|
93 | + public function name() |
|
94 | + { |
|
95 | + return $this->get('PRT_name'); |
|
96 | + } |
|
97 | + |
|
98 | + |
|
99 | + /** |
|
100 | + * get is Price Type a discount? |
|
101 | + * |
|
102 | + * @access public |
|
103 | + */ |
|
104 | + public function base_type() |
|
105 | + { |
|
106 | + return $this->get('PBT_ID'); |
|
107 | + } |
|
108 | + |
|
109 | + |
|
110 | + /** |
|
111 | + * @return mixed |
|
112 | + */ |
|
113 | + public function base_type_name() |
|
114 | + { |
|
115 | + return $this->get_pretty('PBT_ID'); |
|
116 | + } |
|
117 | + |
|
118 | + |
|
119 | + /** |
|
120 | + * get is Price Type a percent? |
|
121 | + * |
|
122 | + * @access public |
|
123 | + */ |
|
124 | + public function is_percent() |
|
125 | + { |
|
126 | + return $this->get('PRT_is_percent'); |
|
127 | + } |
|
128 | + |
|
129 | + |
|
130 | + /** |
|
131 | + * @return bool |
|
132 | + */ |
|
133 | + public function is_discount() |
|
134 | + { |
|
135 | + return $this->get('PBT_ID') == 2 ? true : false; |
|
136 | + } |
|
137 | + |
|
138 | + |
|
139 | + /** |
|
140 | + * get the author of the price type. |
|
141 | + * |
|
142 | + * @since 4.5.0 |
|
143 | + * |
|
144 | + * @return int |
|
145 | + */ |
|
146 | + public function wp_user() |
|
147 | + { |
|
148 | + return $this->get('PRT_wp_user'); |
|
149 | + } |
|
150 | + |
|
151 | + |
|
152 | + /** |
|
153 | + * get Price Type order |
|
154 | + * |
|
155 | + * @access public |
|
156 | + */ |
|
157 | + public function order() |
|
158 | + { |
|
159 | + return $this->get('PRT_order'); |
|
160 | + } |
|
161 | + |
|
162 | + |
|
163 | + /** |
|
164 | + * get is Price Type deleted ? |
|
165 | + * |
|
166 | + * @access public |
|
167 | + */ |
|
168 | + public function deleted() |
|
169 | + { |
|
170 | + return $this->get('PRT_deleted'); |
|
171 | + } |
|
172 | 172 | } |