@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | use EventEspresso\core\exceptions\InvalidEntityException; |
5 | 5 | |
6 | 6 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
7 | - exit('No direct script access allowed'); |
|
7 | + exit('No direct script access allowed'); |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | |
@@ -22,40 +22,40 @@ discard block |
||
22 | 22 | |
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * setCollectionInterface |
|
27 | - * |
|
28 | - * @access protected |
|
29 | - * @param string $collection_interface |
|
30 | - */ |
|
31 | - protected function setCollectionInterface($collection_interface ) |
|
32 | - { |
|
33 | - $this->collection_interface = ''; |
|
34 | - } |
|
25 | + /** |
|
26 | + * setCollectionInterface |
|
27 | + * |
|
28 | + * @access protected |
|
29 | + * @param string $collection_interface |
|
30 | + */ |
|
31 | + protected function setCollectionInterface($collection_interface ) |
|
32 | + { |
|
33 | + $this->collection_interface = ''; |
|
34 | + } |
|
35 | 35 | |
36 | 36 | |
37 | 37 | |
38 | - /** |
|
39 | - * add |
|
40 | - * attaches an object to the Collection |
|
41 | - * and sets any supplied data associated with the current iterator entry |
|
42 | - * by calling EE_Object_Collection::set_identifier() |
|
43 | - * |
|
44 | - * @access public |
|
45 | - * @param mixed $object |
|
46 | - * @param mixed $identifier |
|
47 | - * @return bool |
|
48 | - * @throws InvalidEntityException |
|
49 | - */ |
|
50 | - public function add($object, $identifier = null) |
|
51 | - { |
|
52 | - if (! is_object($object)) { |
|
53 | - throw new InvalidEntityException($object, 'object'); |
|
54 | - } |
|
55 | - $this->attach($object); |
|
56 | - $this->setIdentifier($object, $identifier); |
|
57 | - return $this->contains($object); |
|
58 | - } |
|
38 | + /** |
|
39 | + * add |
|
40 | + * attaches an object to the Collection |
|
41 | + * and sets any supplied data associated with the current iterator entry |
|
42 | + * by calling EE_Object_Collection::set_identifier() |
|
43 | + * |
|
44 | + * @access public |
|
45 | + * @param mixed $object |
|
46 | + * @param mixed $identifier |
|
47 | + * @return bool |
|
48 | + * @throws InvalidEntityException |
|
49 | + */ |
|
50 | + public function add($object, $identifier = null) |
|
51 | + { |
|
52 | + if (! is_object($object)) { |
|
53 | + throw new InvalidEntityException($object, 'object'); |
|
54 | + } |
|
55 | + $this->attach($object); |
|
56 | + $this->setIdentifier($object, $identifier); |
|
57 | + return $this->contains($object); |
|
58 | + } |
|
59 | 59 | |
60 | 60 | |
61 | 61 |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * @access protected |
29 | 29 | * @param string $collection_interface |
30 | 30 | */ |
31 | - protected function setCollectionInterface($collection_interface ) |
|
31 | + protected function setCollectionInterface($collection_interface) |
|
32 | 32 | { |
33 | 33 | $this->collection_interface = ''; |
34 | 34 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public function add($object, $identifier = null) |
51 | 51 | { |
52 | - if (! is_object($object)) { |
|
52 | + if ( ! is_object($object)) { |
|
53 | 53 | throw new InvalidEntityException($object, 'object'); |
54 | 54 | } |
55 | 55 | $this->attach($object); |
@@ -33,210 +33,210 @@ |
||
33 | 33 | class ShortcodesManager |
34 | 34 | { |
35 | 35 | |
36 | - /** |
|
37 | - * @var LegacyShortcodesManager $legacy_shortcodes_manager |
|
38 | - */ |
|
39 | - private $legacy_shortcodes_manager; |
|
40 | - |
|
41 | - /** |
|
42 | - * @var ShortcodeInterface[] $shortcodes |
|
43 | - */ |
|
44 | - private $shortcodes; |
|
45 | - |
|
46 | - |
|
47 | - |
|
48 | - /** |
|
49 | - * ShortcodesManager constructor |
|
50 | - * |
|
51 | - * @param LegacyShortcodesManager $legacy_shortcodes_manager |
|
52 | - */ |
|
53 | - public function __construct(LegacyShortcodesManager $legacy_shortcodes_manager) { |
|
54 | - $this->legacy_shortcodes_manager = $legacy_shortcodes_manager; |
|
55 | - // assemble a list of installed and active shortcodes |
|
56 | - add_action( |
|
57 | - 'AHEE__EE_System__register_shortcodes_modules_and_widgets', |
|
58 | - array($this, 'registerShortcodes'), |
|
59 | - 999 |
|
60 | - ); |
|
61 | - // call add_shortcode() for all installed shortcodes |
|
62 | - add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'addShortcodes')); |
|
63 | - // check content for shortcodes, the old way, and the more efficient new way |
|
64 | - add_action('parse_query', array($this->legacy_shortcodes_manager, 'initializeShortcodes'), 5); |
|
65 | - add_action('get_header', array($this, 'getHeader')); |
|
66 | - } |
|
67 | - |
|
68 | - |
|
69 | - |
|
70 | - /** |
|
71 | - * @return CollectionInterface|ShortcodeInterface[] |
|
72 | - * @throws InvalidIdentifierException |
|
73 | - * @throws InvalidInterfaceException |
|
74 | - * @throws InvalidFilePathException |
|
75 | - * @throws InvalidEntityException |
|
76 | - * @throws InvalidDataTypeException |
|
77 | - * @throws InvalidClassException |
|
78 | - */ |
|
79 | - public function getShortcodes() |
|
80 | - { |
|
81 | - if ( ! $this->shortcodes instanceof CollectionInterface) { |
|
82 | - $this->shortcodes = $this->loadShortcodesCollection(); |
|
83 | - } |
|
84 | - return $this->shortcodes; |
|
85 | - } |
|
86 | - |
|
87 | - |
|
88 | - |
|
89 | - /** |
|
90 | - * @return CollectionInterface|ShortcodeInterface[] |
|
91 | - * @throws InvalidIdentifierException |
|
92 | - * @throws InvalidInterfaceException |
|
93 | - * @throws InvalidFilePathException |
|
94 | - * @throws InvalidEntityException |
|
95 | - * @throws InvalidDataTypeException |
|
96 | - * @throws InvalidClassException |
|
97 | - */ |
|
98 | - protected function loadShortcodesCollection() |
|
99 | - { |
|
100 | - $loader = new CollectionLoader( |
|
101 | - new CollectionDetails( |
|
102 | - // collection name |
|
103 | - 'shortcodes', |
|
104 | - // collection interface |
|
105 | - 'EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
106 | - // FQCNs for classes to add (all classes within that namespace will be loaded) |
|
107 | - array('EventEspresso\core\domain\entities\shortcodes'), |
|
108 | - // filepaths to classes to add |
|
109 | - array(), |
|
110 | - // filemask to use if parsing folder for files to add |
|
111 | - '', |
|
112 | - // what to use as identifier for collection entities |
|
113 | - // using CLASS NAME prevents duplicates (works like a singleton) |
|
114 | - CollectionDetails::ID_CLASS_NAME |
|
115 | - ) |
|
116 | - ); |
|
117 | - return $loader->getCollection(); |
|
118 | - } |
|
119 | - |
|
120 | - |
|
121 | - |
|
122 | - /** |
|
123 | - * @return void |
|
124 | - * @throws DomainException |
|
125 | - * @throws InvalidInterfaceException |
|
126 | - * @throws InvalidIdentifierException |
|
127 | - * @throws InvalidFilePathException |
|
128 | - * @throws InvalidEntityException |
|
129 | - * @throws InvalidDataTypeException |
|
130 | - * @throws InvalidClassException |
|
131 | - */ |
|
132 | - public function registerShortcodes() |
|
133 | - { |
|
134 | - try { |
|
135 | - $this->shortcodes = apply_filters( |
|
136 | - 'FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection', |
|
137 | - $this->getShortcodes() |
|
138 | - ); |
|
139 | - if (! $this->shortcodes instanceof CollectionInterface) { |
|
140 | - throw new InvalidEntityException( |
|
141 | - $this->shortcodes, |
|
142 | - 'CollectionInterface', |
|
143 | - sprintf( |
|
144 | - esc_html__( |
|
145 | - 'The "FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection" filter must return a Collection of EspressoShortcode objects. "%1$s" was received instead.', |
|
146 | - 'event_espresso' |
|
147 | - ), |
|
148 | - is_object($this->shortcodes) ? get_class($this->shortcodes) : gettype($this->shortcodes) |
|
149 | - ) |
|
150 | - ); |
|
151 | - } |
|
152 | - $this->legacy_shortcodes_manager->registerShortcodes(); |
|
153 | - } catch (Exception $exception) { |
|
154 | - new ExceptionStackTraceDisplay($exception); |
|
155 | - } |
|
156 | - } |
|
157 | - |
|
158 | - |
|
159 | - |
|
160 | - /** |
|
161 | - * @return void |
|
162 | - */ |
|
163 | - public function addShortcodes() |
|
164 | - { |
|
165 | - try { |
|
166 | - // cycle thru shortcode folders |
|
167 | - foreach ($this->shortcodes as $shortcode) { |
|
168 | - /** @var ShortcodeInterface $shortcode */ |
|
169 | - if ( $shortcode instanceof EnqueueAssetsInterface) { |
|
170 | - add_action('wp_enqueue_scripts', array($shortcode, 'registerScriptsAndStylesheets'), 10); |
|
171 | - add_action('wp_enqueue_scripts', array($shortcode, 'enqueueStylesheets'), 11); |
|
172 | - } |
|
173 | - // add_shortcode() if it has not already been added |
|
174 | - if ( ! shortcode_exists($shortcode->getTag())) { |
|
175 | - add_shortcode($shortcode->getTag(), array($shortcode, 'processShortcodeCallback')); |
|
176 | - } |
|
177 | - } |
|
178 | - $this->legacy_shortcodes_manager->addShortcodes(); |
|
179 | - } catch (Exception $exception) { |
|
180 | - new ExceptionStackTraceDisplay($exception); |
|
181 | - } |
|
182 | - } |
|
183 | - |
|
184 | - |
|
185 | - |
|
186 | - /** |
|
187 | - * callback for the WP "get_header" hook point |
|
188 | - * checks posts for EE shortcodes, and initializes them, |
|
189 | - * then toggles filter switch that loads core default assets |
|
190 | - * |
|
191 | - * @return void |
|
192 | - */ |
|
193 | - public function getHeader() |
|
194 | - { |
|
195 | - global $wp_query; |
|
196 | - if (empty($wp_query->posts)) { |
|
197 | - return; |
|
198 | - } |
|
199 | - $load_assets = false; |
|
200 | - // array of posts displayed in current request |
|
201 | - $posts = is_array($wp_query->posts) ? $wp_query->posts : array($wp_query->posts); |
|
202 | - foreach ($posts as $post) { |
|
203 | - // now check post content and excerpt for EE shortcodes |
|
204 | - $load_assets = $this->parseContentForShortcodes($post->post_content) |
|
205 | - ? true |
|
206 | - : $load_assets; |
|
207 | - } |
|
208 | - if ($load_assets) { |
|
209 | - $this->legacy_shortcodes_manager->registry()->REQ->set_espresso_page(true); |
|
210 | - add_filter('FHEE_load_css', '__return_true'); |
|
211 | - add_filter('FHEE_load_js', '__return_true'); |
|
212 | - } |
|
213 | - } |
|
214 | - |
|
215 | - |
|
216 | - |
|
217 | - /** |
|
218 | - * checks supplied content against list of shortcodes, |
|
219 | - * then initializes any found shortcodes, and returns true. |
|
220 | - * returns false if no shortcodes found. |
|
221 | - * |
|
222 | - * @param string $content |
|
223 | - * @return bool |
|
224 | - */ |
|
225 | - public function parseContentForShortcodes($content) |
|
226 | - { |
|
227 | - $has_shortcode = false; |
|
228 | - if(empty($this->shortcodes)){ |
|
229 | - return $has_shortcode; |
|
230 | - } |
|
231 | - foreach ($this->shortcodes as $shortcode) { |
|
232 | - /** @var ShortcodeInterface $shortcode */ |
|
233 | - if (has_shortcode($content, $shortcode->getTag())) { |
|
234 | - $shortcode->initializeShortcode(); |
|
235 | - $has_shortcode = true; |
|
236 | - } |
|
237 | - } |
|
238 | - return $has_shortcode; |
|
239 | - } |
|
36 | + /** |
|
37 | + * @var LegacyShortcodesManager $legacy_shortcodes_manager |
|
38 | + */ |
|
39 | + private $legacy_shortcodes_manager; |
|
40 | + |
|
41 | + /** |
|
42 | + * @var ShortcodeInterface[] $shortcodes |
|
43 | + */ |
|
44 | + private $shortcodes; |
|
45 | + |
|
46 | + |
|
47 | + |
|
48 | + /** |
|
49 | + * ShortcodesManager constructor |
|
50 | + * |
|
51 | + * @param LegacyShortcodesManager $legacy_shortcodes_manager |
|
52 | + */ |
|
53 | + public function __construct(LegacyShortcodesManager $legacy_shortcodes_manager) { |
|
54 | + $this->legacy_shortcodes_manager = $legacy_shortcodes_manager; |
|
55 | + // assemble a list of installed and active shortcodes |
|
56 | + add_action( |
|
57 | + 'AHEE__EE_System__register_shortcodes_modules_and_widgets', |
|
58 | + array($this, 'registerShortcodes'), |
|
59 | + 999 |
|
60 | + ); |
|
61 | + // call add_shortcode() for all installed shortcodes |
|
62 | + add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'addShortcodes')); |
|
63 | + // check content for shortcodes, the old way, and the more efficient new way |
|
64 | + add_action('parse_query', array($this->legacy_shortcodes_manager, 'initializeShortcodes'), 5); |
|
65 | + add_action('get_header', array($this, 'getHeader')); |
|
66 | + } |
|
67 | + |
|
68 | + |
|
69 | + |
|
70 | + /** |
|
71 | + * @return CollectionInterface|ShortcodeInterface[] |
|
72 | + * @throws InvalidIdentifierException |
|
73 | + * @throws InvalidInterfaceException |
|
74 | + * @throws InvalidFilePathException |
|
75 | + * @throws InvalidEntityException |
|
76 | + * @throws InvalidDataTypeException |
|
77 | + * @throws InvalidClassException |
|
78 | + */ |
|
79 | + public function getShortcodes() |
|
80 | + { |
|
81 | + if ( ! $this->shortcodes instanceof CollectionInterface) { |
|
82 | + $this->shortcodes = $this->loadShortcodesCollection(); |
|
83 | + } |
|
84 | + return $this->shortcodes; |
|
85 | + } |
|
86 | + |
|
87 | + |
|
88 | + |
|
89 | + /** |
|
90 | + * @return CollectionInterface|ShortcodeInterface[] |
|
91 | + * @throws InvalidIdentifierException |
|
92 | + * @throws InvalidInterfaceException |
|
93 | + * @throws InvalidFilePathException |
|
94 | + * @throws InvalidEntityException |
|
95 | + * @throws InvalidDataTypeException |
|
96 | + * @throws InvalidClassException |
|
97 | + */ |
|
98 | + protected function loadShortcodesCollection() |
|
99 | + { |
|
100 | + $loader = new CollectionLoader( |
|
101 | + new CollectionDetails( |
|
102 | + // collection name |
|
103 | + 'shortcodes', |
|
104 | + // collection interface |
|
105 | + 'EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
106 | + // FQCNs for classes to add (all classes within that namespace will be loaded) |
|
107 | + array('EventEspresso\core\domain\entities\shortcodes'), |
|
108 | + // filepaths to classes to add |
|
109 | + array(), |
|
110 | + // filemask to use if parsing folder for files to add |
|
111 | + '', |
|
112 | + // what to use as identifier for collection entities |
|
113 | + // using CLASS NAME prevents duplicates (works like a singleton) |
|
114 | + CollectionDetails::ID_CLASS_NAME |
|
115 | + ) |
|
116 | + ); |
|
117 | + return $loader->getCollection(); |
|
118 | + } |
|
119 | + |
|
120 | + |
|
121 | + |
|
122 | + /** |
|
123 | + * @return void |
|
124 | + * @throws DomainException |
|
125 | + * @throws InvalidInterfaceException |
|
126 | + * @throws InvalidIdentifierException |
|
127 | + * @throws InvalidFilePathException |
|
128 | + * @throws InvalidEntityException |
|
129 | + * @throws InvalidDataTypeException |
|
130 | + * @throws InvalidClassException |
|
131 | + */ |
|
132 | + public function registerShortcodes() |
|
133 | + { |
|
134 | + try { |
|
135 | + $this->shortcodes = apply_filters( |
|
136 | + 'FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection', |
|
137 | + $this->getShortcodes() |
|
138 | + ); |
|
139 | + if (! $this->shortcodes instanceof CollectionInterface) { |
|
140 | + throw new InvalidEntityException( |
|
141 | + $this->shortcodes, |
|
142 | + 'CollectionInterface', |
|
143 | + sprintf( |
|
144 | + esc_html__( |
|
145 | + 'The "FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection" filter must return a Collection of EspressoShortcode objects. "%1$s" was received instead.', |
|
146 | + 'event_espresso' |
|
147 | + ), |
|
148 | + is_object($this->shortcodes) ? get_class($this->shortcodes) : gettype($this->shortcodes) |
|
149 | + ) |
|
150 | + ); |
|
151 | + } |
|
152 | + $this->legacy_shortcodes_manager->registerShortcodes(); |
|
153 | + } catch (Exception $exception) { |
|
154 | + new ExceptionStackTraceDisplay($exception); |
|
155 | + } |
|
156 | + } |
|
157 | + |
|
158 | + |
|
159 | + |
|
160 | + /** |
|
161 | + * @return void |
|
162 | + */ |
|
163 | + public function addShortcodes() |
|
164 | + { |
|
165 | + try { |
|
166 | + // cycle thru shortcode folders |
|
167 | + foreach ($this->shortcodes as $shortcode) { |
|
168 | + /** @var ShortcodeInterface $shortcode */ |
|
169 | + if ( $shortcode instanceof EnqueueAssetsInterface) { |
|
170 | + add_action('wp_enqueue_scripts', array($shortcode, 'registerScriptsAndStylesheets'), 10); |
|
171 | + add_action('wp_enqueue_scripts', array($shortcode, 'enqueueStylesheets'), 11); |
|
172 | + } |
|
173 | + // add_shortcode() if it has not already been added |
|
174 | + if ( ! shortcode_exists($shortcode->getTag())) { |
|
175 | + add_shortcode($shortcode->getTag(), array($shortcode, 'processShortcodeCallback')); |
|
176 | + } |
|
177 | + } |
|
178 | + $this->legacy_shortcodes_manager->addShortcodes(); |
|
179 | + } catch (Exception $exception) { |
|
180 | + new ExceptionStackTraceDisplay($exception); |
|
181 | + } |
|
182 | + } |
|
183 | + |
|
184 | + |
|
185 | + |
|
186 | + /** |
|
187 | + * callback for the WP "get_header" hook point |
|
188 | + * checks posts for EE shortcodes, and initializes them, |
|
189 | + * then toggles filter switch that loads core default assets |
|
190 | + * |
|
191 | + * @return void |
|
192 | + */ |
|
193 | + public function getHeader() |
|
194 | + { |
|
195 | + global $wp_query; |
|
196 | + if (empty($wp_query->posts)) { |
|
197 | + return; |
|
198 | + } |
|
199 | + $load_assets = false; |
|
200 | + // array of posts displayed in current request |
|
201 | + $posts = is_array($wp_query->posts) ? $wp_query->posts : array($wp_query->posts); |
|
202 | + foreach ($posts as $post) { |
|
203 | + // now check post content and excerpt for EE shortcodes |
|
204 | + $load_assets = $this->parseContentForShortcodes($post->post_content) |
|
205 | + ? true |
|
206 | + : $load_assets; |
|
207 | + } |
|
208 | + if ($load_assets) { |
|
209 | + $this->legacy_shortcodes_manager->registry()->REQ->set_espresso_page(true); |
|
210 | + add_filter('FHEE_load_css', '__return_true'); |
|
211 | + add_filter('FHEE_load_js', '__return_true'); |
|
212 | + } |
|
213 | + } |
|
214 | + |
|
215 | + |
|
216 | + |
|
217 | + /** |
|
218 | + * checks supplied content against list of shortcodes, |
|
219 | + * then initializes any found shortcodes, and returns true. |
|
220 | + * returns false if no shortcodes found. |
|
221 | + * |
|
222 | + * @param string $content |
|
223 | + * @return bool |
|
224 | + */ |
|
225 | + public function parseContentForShortcodes($content) |
|
226 | + { |
|
227 | + $has_shortcode = false; |
|
228 | + if(empty($this->shortcodes)){ |
|
229 | + return $has_shortcode; |
|
230 | + } |
|
231 | + foreach ($this->shortcodes as $shortcode) { |
|
232 | + /** @var ShortcodeInterface $shortcode */ |
|
233 | + if (has_shortcode($content, $shortcode->getTag())) { |
|
234 | + $shortcode->initializeShortcode(); |
|
235 | + $has_shortcode = true; |
|
236 | + } |
|
237 | + } |
|
238 | + return $has_shortcode; |
|
239 | + } |
|
240 | 240 | |
241 | 241 | } |
242 | 242 | // End of file ShortcodesManager.php |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | 'FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection', |
137 | 137 | $this->getShortcodes() |
138 | 138 | ); |
139 | - if (! $this->shortcodes instanceof CollectionInterface) { |
|
139 | + if ( ! $this->shortcodes instanceof CollectionInterface) { |
|
140 | 140 | throw new InvalidEntityException( |
141 | 141 | $this->shortcodes, |
142 | 142 | 'CollectionInterface', |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | // cycle thru shortcode folders |
167 | 167 | foreach ($this->shortcodes as $shortcode) { |
168 | 168 | /** @var ShortcodeInterface $shortcode */ |
169 | - if ( $shortcode instanceof EnqueueAssetsInterface) { |
|
169 | + if ($shortcode instanceof EnqueueAssetsInterface) { |
|
170 | 170 | add_action('wp_enqueue_scripts', array($shortcode, 'registerScriptsAndStylesheets'), 10); |
171 | 171 | add_action('wp_enqueue_scripts', array($shortcode, 'enqueueStylesheets'), 11); |
172 | 172 | } |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | public function parseContentForShortcodes($content) |
226 | 226 | { |
227 | 227 | $has_shortcode = false; |
228 | - if(empty($this->shortcodes)){ |
|
228 | + if (empty($this->shortcodes)) { |
|
229 | 229 | return $has_shortcode; |
230 | 230 | } |
231 | 231 | foreach ($this->shortcodes as $shortcode) { |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
4 | - exit('NO direct script access allowed'); |
|
4 | + exit('NO direct script access allowed'); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | /** |
@@ -36,82 +36,82 @@ discard block |
||
36 | 36 | { |
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * _init_props |
|
41 | - * |
|
42 | - * @access protected |
|
43 | - * @return void |
|
44 | - */ |
|
45 | - protected function _init_props() |
|
46 | - { |
|
47 | - $this->label = __('Attendee Shortcodes', 'event_espresso'); |
|
48 | - $this->description = __('All shortcodes specific to attendee related data', 'event_espresso'); |
|
49 | - $this->_shortcodes = array( |
|
50 | - '[QUESTION]' => __('Will parse to a question.', 'event_espresso'), |
|
51 | - '[ANSWER]' => __('Will parse to the answer for a question', 'event_espresso') |
|
52 | - ); |
|
53 | - } |
|
39 | + /** |
|
40 | + * _init_props |
|
41 | + * |
|
42 | + * @access protected |
|
43 | + * @return void |
|
44 | + */ |
|
45 | + protected function _init_props() |
|
46 | + { |
|
47 | + $this->label = __('Attendee Shortcodes', 'event_espresso'); |
|
48 | + $this->description = __('All shortcodes specific to attendee related data', 'event_espresso'); |
|
49 | + $this->_shortcodes = array( |
|
50 | + '[QUESTION]' => __('Will parse to a question.', 'event_espresso'), |
|
51 | + '[ANSWER]' => __('Will parse to the answer for a question', 'event_espresso') |
|
52 | + ); |
|
53 | + } |
|
54 | 54 | |
55 | 55 | |
56 | - /** |
|
57 | - * This method will give parsing instructions for each shortcode defined in the _shortcodes array. Child methods |
|
58 | - * will have to take care of handling. |
|
59 | - * |
|
60 | - * @access protected |
|
61 | - * |
|
62 | - * @param string $shortcode the shortcode to be parsed. |
|
63 | - * |
|
64 | - * @return string parsed shortcode |
|
65 | - */ |
|
66 | - protected function _parser($shortcode) |
|
67 | - { |
|
56 | + /** |
|
57 | + * This method will give parsing instructions for each shortcode defined in the _shortcodes array. Child methods |
|
58 | + * will have to take care of handling. |
|
59 | + * |
|
60 | + * @access protected |
|
61 | + * |
|
62 | + * @param string $shortcode the shortcode to be parsed. |
|
63 | + * |
|
64 | + * @return string parsed shortcode |
|
65 | + */ |
|
66 | + protected function _parser($shortcode) |
|
67 | + { |
|
68 | 68 | |
69 | - if ( ! $this->_data instanceof EE_Answer || ! isset($this->_extra_data['data']) || ! $this->_extra_data['data'] instanceof EE_Messages_Addressee) { |
|
70 | - return ''; |
|
71 | - } |
|
69 | + if ( ! $this->_data instanceof EE_Answer || ! isset($this->_extra_data['data']) || ! $this->_extra_data['data'] instanceof EE_Messages_Addressee) { |
|
70 | + return ''; |
|
71 | + } |
|
72 | 72 | |
73 | - switch ($shortcode) { |
|
73 | + switch ($shortcode) { |
|
74 | 74 | |
75 | - case '[QUESTION]' : |
|
76 | - $question = isset($this->_extra_data['data']->questions[$this->_data->ID()]) ? $this->_extra_data['data']->questions[$this->_data->ID()] : $this->_data->question(); |
|
77 | - if ( ! $question instanceof EE_Question) { |
|
78 | - return ''; //get out because we can't figure out what the question is. |
|
79 | - } |
|
75 | + case '[QUESTION]' : |
|
76 | + $question = isset($this->_extra_data['data']->questions[$this->_data->ID()]) ? $this->_extra_data['data']->questions[$this->_data->ID()] : $this->_data->question(); |
|
77 | + if ( ! $question instanceof EE_Question) { |
|
78 | + return ''; //get out because we can't figure out what the question is. |
|
79 | + } |
|
80 | 80 | |
81 | - return $question->get('QST_display_text'); |
|
82 | - break; |
|
81 | + return $question->get('QST_display_text'); |
|
82 | + break; |
|
83 | 83 | |
84 | - case '[ANSWER]' : |
|
85 | - //need to get the question to determine the type of question (some questions require translation of the answer). |
|
86 | - $question = isset($this->_extra_data['data']->questions[$this->_data->ID()]) ? $this->_extra_data['data']->questions[$this->_data->ID()] : $this->_data->question(); |
|
87 | - if ( ! $question instanceof EE_Question) { |
|
88 | - return ''; //get out cause we can't figure out what the question type is! |
|
89 | - } |
|
84 | + case '[ANSWER]' : |
|
85 | + //need to get the question to determine the type of question (some questions require translation of the answer). |
|
86 | + $question = isset($this->_extra_data['data']->questions[$this->_data->ID()]) ? $this->_extra_data['data']->questions[$this->_data->ID()] : $this->_data->question(); |
|
87 | + if ( ! $question instanceof EE_Question) { |
|
88 | + return ''; //get out cause we can't figure out what the question type is! |
|
89 | + } |
|
90 | 90 | |
91 | - //what we show for the answer depends on the question type! |
|
92 | - switch ($question->get('QST_type')) { |
|
91 | + //what we show for the answer depends on the question type! |
|
92 | + switch ($question->get('QST_type')) { |
|
93 | 93 | |
94 | - case 'STATE' : |
|
95 | - $state = EEM_State::instance()->get_one_by_ID($this->_data->get('ANS_value')); |
|
96 | - $answer = $state instanceof EE_State ? $state->name() : ''; |
|
97 | - break; |
|
94 | + case 'STATE' : |
|
95 | + $state = EEM_State::instance()->get_one_by_ID($this->_data->get('ANS_value')); |
|
96 | + $answer = $state instanceof EE_State ? $state->name() : ''; |
|
97 | + break; |
|
98 | 98 | |
99 | - case 'COUNTRY' : |
|
100 | - $country = EEM_Country::instance()->get_one_by_ID($this->_data->get('ANS_value')); |
|
101 | - $answer = $country instanceof EE_Country ? $country->name() : ''; |
|
102 | - break; |
|
99 | + case 'COUNTRY' : |
|
100 | + $country = EEM_Country::instance()->get_one_by_ID($this->_data->get('ANS_value')); |
|
101 | + $answer = $country instanceof EE_Country ? $country->name() : ''; |
|
102 | + break; |
|
103 | 103 | |
104 | - default : |
|
105 | - $answer = $this->_data->get_pretty('ANS_value', 'no_wpautop'); |
|
106 | - break; |
|
107 | - } |
|
104 | + default : |
|
105 | + $answer = $this->_data->get_pretty('ANS_value', 'no_wpautop'); |
|
106 | + break; |
|
107 | + } |
|
108 | 108 | |
109 | - return $answer; |
|
110 | - break; |
|
109 | + return $answer; |
|
110 | + break; |
|
111 | 111 | |
112 | - } |
|
112 | + } |
|
113 | 113 | |
114 | - return ''; |
|
115 | - } |
|
114 | + return ''; |
|
115 | + } |
|
116 | 116 | |
117 | 117 | } //end EE_Question_Shortcodes class |
@@ -43,7 +43,7 @@ |
||
43 | 43 | <div class="padding"> |
44 | 44 | <h4 class="espresso-header"><span class="dashicons dashicons-post-trash ee-icon-size-22"></span><?php esc_html_e('Permanently Delete ALL Event Espresso Data', 'event_espresso');?></h4> |
45 | 45 | <p><?php esc_html_e(' This will delete data for Event Espresso 4, and all currently active add-ons. Event Espresso will then be deactivated. You may need to manually deactivate each add-on individually.', |
46 | - 'event_espresso');?></p> |
|
46 | + 'event_espresso');?></p> |
|
47 | 47 | <p><?php esc_html_e('If you know for certain that you will no longer be using Event Espresso and you wish to remove ALL traces of the plugin from your system, then perform the following steps.', 'event_espresso');?></p> |
48 | 48 | <p class="important-notice"><?php printf( esc_html__('Please note: %sThis is permanent and can NOT be undone.%s', 'event_espresso'), '<em>', '</em>' ); ?><br/></p> |
49 | 49 | <ol> |
@@ -7,13 +7,13 @@ discard block |
||
7 | 7 | /** @var string $delete_db_url */ |
8 | 8 | ?> |
9 | 9 | <h2> |
10 | - <?php esc_html_e( 'Reset/Delete Data for Event Espresso', 'event_espresso' );?> |
|
10 | + <?php esc_html_e('Reset/Delete Data for Event Espresso', 'event_espresso'); ?> |
|
11 | 11 | </h2> |
12 | 12 | <br /> |
13 | 13 | |
14 | 14 | <div class="padding"> |
15 | - <h4 class="espresso-header"><span class="dashicons dashicons-update ee-icon-size-22"></span><?php esc_html_e('Reset Ticket and Datetime Reserved Counts', 'event_espresso');?></h4> |
|
16 | - <p><?php esc_html_e('Use this to reset the counts for ticket and datetime reservations.', 'event_espresso');?></p> |
|
15 | + <h4 class="espresso-header"><span class="dashicons dashicons-update ee-icon-size-22"></span><?php esc_html_e('Reset Ticket and Datetime Reserved Counts', 'event_espresso'); ?></h4> |
|
16 | + <p><?php esc_html_e('Use this to reset the counts for ticket and datetime reservations.', 'event_espresso'); ?></p> |
|
17 | 17 | <div class="float-right"><?php echo $reset_reservations_button; ?></div> |
18 | 18 | <div class="clear"></div> |
19 | 19 | </div> |
@@ -22,8 +22,8 @@ discard block |
||
22 | 22 | |
23 | 23 | <!-- reset DB url is here. Just need to make it look pretty and unhide it--> |
24 | 24 | <div class="padding"> |
25 | - <h4 class="espresso-header"><span class="dashicons dashicons-update ee-icon-size-22"></span><?php esc_html_e('Reset Event Espresso Capabilities', 'event_espresso');?></h4> |
|
26 | - <p><?php esc_html_e('Use this to reset the capabilities on WP roles to the defaults as defined via EE_Capabilities. Note this reset does not REMOVE any existing capabilities, it just ensures that all the defaults are ADDED to the roles.', 'event_espresso');?></p> |
|
25 | + <h4 class="espresso-header"><span class="dashicons dashicons-update ee-icon-size-22"></span><?php esc_html_e('Reset Event Espresso Capabilities', 'event_espresso'); ?></h4> |
|
26 | + <p><?php esc_html_e('Use this to reset the capabilities on WP roles to the defaults as defined via EE_Capabilities. Note this reset does not REMOVE any existing capabilities, it just ensures that all the defaults are ADDED to the roles.', 'event_espresso'); ?></p> |
|
27 | 27 | <div class="float-right"><?php echo $reset_capabilities_button; ?></div> |
28 | 28 | <div class="clear"></div> |
29 | 29 | </div> |
@@ -31,27 +31,27 @@ discard block |
||
31 | 31 | <br /> |
32 | 32 | |
33 | 33 | <div class="padding"> |
34 | - <h4 class="espresso-header"><span class="dashicons dashicons-update ee-icon-size-22"></span><?php esc_html_e('Reset Event Espresso Data', 'event_espresso');?></h4> |
|
35 | - <p><?php esc_html_e(' This will reset data for Event Espresso 4, and for all active add-ons. Inactive add-ons will not be affected.', 'event_espresso');?></p> |
|
36 | - <p><?php esc_html_e('Your Event Espresso data will return to its default settings. The rest of your website will be unaffected.', 'event_espresso');?></p> |
|
37 | - <div class="float-right"><a class="button button-primary" href="<?php echo $reset_db_url;?>"><?php esc_html_e('Reset Event Espresso Tables', 'event_espresso');?></a></div> |
|
34 | + <h4 class="espresso-header"><span class="dashicons dashicons-update ee-icon-size-22"></span><?php esc_html_e('Reset Event Espresso Data', 'event_espresso'); ?></h4> |
|
35 | + <p><?php esc_html_e(' This will reset data for Event Espresso 4, and for all active add-ons. Inactive add-ons will not be affected.', 'event_espresso'); ?></p> |
|
36 | + <p><?php esc_html_e('Your Event Espresso data will return to its default settings. The rest of your website will be unaffected.', 'event_espresso'); ?></p> |
|
37 | + <div class="float-right"><a class="button button-primary" href="<?php echo $reset_db_url; ?>"><?php esc_html_e('Reset Event Espresso Tables', 'event_espresso'); ?></a></div> |
|
38 | 38 | <div class="clear"></div> |
39 | 39 | </div> |
40 | 40 | <br /> |
41 | 41 | <br /> |
42 | 42 | |
43 | 43 | <div class="padding"> |
44 | - <h4 class="espresso-header"><span class="dashicons dashicons-post-trash ee-icon-size-22"></span><?php esc_html_e('Permanently Delete ALL Event Espresso Data', 'event_espresso');?></h4> |
|
44 | + <h4 class="espresso-header"><span class="dashicons dashicons-post-trash ee-icon-size-22"></span><?php esc_html_e('Permanently Delete ALL Event Espresso Data', 'event_espresso'); ?></h4> |
|
45 | 45 | <p><?php esc_html_e(' This will delete data for Event Espresso 4, and all currently active add-ons. Event Espresso will then be deactivated. You may need to manually deactivate each add-on individually.', |
46 | - 'event_espresso');?></p> |
|
47 | - <p><?php esc_html_e('If you know for certain that you will no longer be using Event Espresso and you wish to remove ALL traces of the plugin from your system, then perform the following steps.', 'event_espresso');?></p> |
|
48 | - <p class="important-notice"><?php printf( esc_html__('Please note: %sThis is permanent and can NOT be undone.%s', 'event_espresso'), '<em>', '</em>' ); ?><br/></p> |
|
46 | + 'event_espresso'); ?></p> |
|
47 | + <p><?php esc_html_e('If you know for certain that you will no longer be using Event Espresso and you wish to remove ALL traces of the plugin from your system, then perform the following steps.', 'event_espresso'); ?></p> |
|
48 | + <p class="important-notice"><?php printf(esc_html__('Please note: %sThis is permanent and can NOT be undone.%s', 'event_espresso'), '<em>', '</em>'); ?><br/></p> |
|
49 | 49 | <ol> |
50 | - <li><?php printf( esc_html__('First, click the button below to permanently delete all Event Espresso tables, records, and options from your WordPress database . If you receive a "500 Internal Server Error" or a blank white screen, it means the server has timed out due to the large number of records being updated. This is not a cause for concern. Simply %1$srefresh the page%2$s and the Database Update will continue where it left off.', 'event_espresso'), '<strong>', '</strong>' );?></li> |
|
51 | - <li><?php printf( esc_html__('Then, locate Event Espresso on the WordPress Plugins page, and click on %sDelete%s', 'event_espresso'), '<strong>', '</strong>' ); ?></li> |
|
52 | - <li><?php printf( esc_html__('Once you are on the Delete Plugin page, click on %sYes, Delete these files and data%s', 'event_espresso'), '<strong>', '</strong>' ); ?></li> |
|
50 | + <li><?php printf(esc_html__('First, click the button below to permanently delete all Event Espresso tables, records, and options from your WordPress database . If you receive a "500 Internal Server Error" or a blank white screen, it means the server has timed out due to the large number of records being updated. This is not a cause for concern. Simply %1$srefresh the page%2$s and the Database Update will continue where it left off.', 'event_espresso'), '<strong>', '</strong>'); ?></li> |
|
51 | + <li><?php printf(esc_html__('Then, locate Event Espresso on the WordPress Plugins page, and click on %sDelete%s', 'event_espresso'), '<strong>', '</strong>'); ?></li> |
|
52 | + <li><?php printf(esc_html__('Once you are on the Delete Plugin page, click on %sYes, Delete these files and data%s', 'event_espresso'), '<strong>', '</strong>'); ?></li> |
|
53 | 53 | </ol> |
54 | - <div class="float-right"><a href="<?php echo $delete_db_url; ?>" id="delete-all-data-btn" class="button-primary"><?php esc_html_e('Permanently Delete All Event Espresso Data', 'event_espresso');?></a></div> |
|
54 | + <div class="float-right"><a href="<?php echo $delete_db_url; ?>" id="delete-all-data-btn" class="button-primary"><?php esc_html_e('Permanently Delete All Event Espresso Data', 'event_espresso'); ?></a></div> |
|
55 | 55 | <div class="clear"></div> |
56 | 56 | </div> |
57 | 57 | <br/> |
@@ -14,326 +14,326 @@ |
||
14 | 14 | class EEM_Ticket extends EEM_Soft_Delete_Base |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * private instance of the EEM_Ticket object |
|
19 | - * |
|
20 | - * @var EEM_Ticket $_instance |
|
21 | - */ |
|
22 | - protected static $_instance; |
|
17 | + /** |
|
18 | + * private instance of the EEM_Ticket object |
|
19 | + * |
|
20 | + * @var EEM_Ticket $_instance |
|
21 | + */ |
|
22 | + protected static $_instance; |
|
23 | 23 | |
24 | 24 | |
25 | 25 | |
26 | - /** |
|
27 | - * private constructor to prevent direct creation |
|
28 | - * |
|
29 | - * @Constructor |
|
30 | - * @access private |
|
31 | - * @param string $timezone string representing the timezone we want to set for returned Date Time Strings |
|
32 | - * (and any incoming timezone data that gets saved). |
|
33 | - * Note this just sends the timezone info to the date time model field objects. |
|
34 | - * Default is NULL |
|
35 | - * (and will be assumed using the set timezone in the 'timezone_string' wp option) |
|
36 | - * @throws EE_Error |
|
37 | - */ |
|
38 | - protected function __construct($timezone) |
|
39 | - { |
|
40 | - $this->singular_item = esc_html__('Ticket', 'event_espresso'); |
|
41 | - $this->plural_item = esc_html__('Tickets', 'event_espresso'); |
|
42 | - $this->_tables = array( |
|
43 | - 'Ticket' => new EE_Primary_Table('esp_ticket', 'TKT_ID'), |
|
44 | - ); |
|
45 | - $this->_fields = array( |
|
46 | - 'Ticket' => array( |
|
47 | - 'TKT_ID' => new EE_Primary_Key_Int_Field( |
|
48 | - 'TKT_ID', |
|
49 | - esc_html__('Ticket ID', 'event_espresso') |
|
50 | - ), |
|
51 | - 'TTM_ID' => new EE_Foreign_Key_Int_Field( |
|
52 | - 'TTM_ID', |
|
53 | - esc_html__('Ticket Template ID', 'event_espresso'), |
|
54 | - false, |
|
55 | - 0, |
|
56 | - 'Ticket_Template' |
|
57 | - ), |
|
58 | - 'TKT_name' => new EE_Plain_Text_Field( |
|
59 | - 'TKT_name', |
|
60 | - esc_html__('Ticket Name', 'event_espresso'), |
|
61 | - false, |
|
62 | - '' |
|
63 | - ), |
|
64 | - 'TKT_description' => new EE_Post_Content_Field( |
|
65 | - 'TKT_description', |
|
66 | - esc_html__('Description of Ticket', 'event_espresso'), |
|
67 | - false, |
|
68 | - '' |
|
69 | - ), |
|
70 | - 'TKT_start_date' => new EE_Datetime_Field( |
|
71 | - 'TKT_start_date', |
|
72 | - esc_html__('Start time/date of Ticket', 'event_espresso'), |
|
73 | - false, |
|
74 | - EE_Datetime_Field::now, |
|
75 | - $timezone |
|
76 | - ), |
|
77 | - 'TKT_end_date' => new EE_Datetime_Field( |
|
78 | - 'TKT_end_date', |
|
79 | - esc_html__('End time/date of Ticket', 'event_espresso'), |
|
80 | - false, |
|
81 | - EE_Datetime_Field::now, |
|
82 | - $timezone |
|
83 | - ), |
|
84 | - 'TKT_min' => new EE_Integer_Field( |
|
85 | - 'TKT_min', |
|
86 | - esc_html__('Minimum quantity of this ticket that must be purchased', 'event_espresso'), |
|
87 | - false, |
|
88 | - 0 |
|
89 | - ), |
|
90 | - 'TKT_max' => new EE_Infinite_Integer_Field( |
|
91 | - 'TKT_max', |
|
92 | - esc_html__( |
|
93 | - 'Maximum quantity of this ticket that can be purchased in one transaction', |
|
94 | - 'event_espresso' |
|
95 | - ), |
|
96 | - false, |
|
97 | - EE_INF |
|
98 | - ), |
|
99 | - 'TKT_price' => new EE_Money_Field( |
|
100 | - 'TKT_price', |
|
101 | - esc_html__('Final calculated price for ticket', 'event_espresso'), |
|
102 | - false, |
|
103 | - 0 |
|
104 | - ), |
|
105 | - 'TKT_sold' => new EE_Integer_Field( |
|
106 | - 'TKT_sold', |
|
107 | - esc_html__('Number of this ticket sold', 'event_espresso'), |
|
108 | - false, |
|
109 | - 0 |
|
110 | - ), |
|
111 | - 'TKT_qty' => new EE_Infinite_Integer_Field( |
|
112 | - 'TKT_qty', |
|
113 | - esc_html__('Quantity of this ticket that is available', 'event_espresso'), |
|
114 | - false, |
|
115 | - EE_INF |
|
116 | - ), |
|
117 | - 'TKT_reserved' => new EE_Integer_Field( |
|
118 | - 'TKT_reserved', |
|
119 | - esc_html__( |
|
120 | - 'Quantity of this ticket that is reserved, but not yet fully purchased', |
|
121 | - 'event_espresso' |
|
122 | - ), |
|
123 | - false, |
|
124 | - 0 |
|
125 | - ), |
|
126 | - 'TKT_uses' => new EE_Infinite_Integer_Field( |
|
127 | - 'TKT_uses', |
|
128 | - esc_html__('Number of datetimes this ticket can be used at', 'event_espresso'), |
|
129 | - false, |
|
130 | - EE_INF |
|
131 | - ), |
|
132 | - 'TKT_required' => new EE_Boolean_Field( |
|
133 | - 'TKT_required', |
|
134 | - esc_html__( |
|
135 | - 'Flag indicating whether this ticket must be purchased with a transaction', |
|
136 | - 'event_espresso' |
|
137 | - ), |
|
138 | - false, |
|
139 | - false |
|
140 | - ), |
|
141 | - 'TKT_taxable' => new EE_Boolean_Field( |
|
142 | - 'TKT_taxable', |
|
143 | - esc_html__( |
|
144 | - 'Flag indicating whether there is tax applied on this ticket', |
|
145 | - 'event_espresso' |
|
146 | - ), |
|
147 | - false, |
|
148 | - false |
|
149 | - ), |
|
150 | - 'TKT_is_default' => new EE_Boolean_Field( |
|
151 | - 'TKT_is_default', |
|
152 | - esc_html__('Flag indicating that this ticket is a default ticket', 'event_espresso'), |
|
153 | - false, |
|
154 | - false |
|
155 | - ), |
|
156 | - 'TKT_order' => new EE_Integer_Field( |
|
157 | - 'TKT_order', |
|
158 | - esc_html__( |
|
159 | - 'The order in which the Ticket is displayed in the editor (used for autosaves when the form doesn\'t have the ticket ID yet)', |
|
160 | - 'event_espresso' |
|
161 | - ), |
|
162 | - false, |
|
163 | - 0 |
|
164 | - ), |
|
165 | - 'TKT_row' => new EE_Integer_Field( |
|
166 | - 'TKT_row', |
|
167 | - esc_html__('How tickets are displayed in the ui', 'event_espresso'), |
|
168 | - false, |
|
169 | - 0 |
|
170 | - ), |
|
171 | - 'TKT_deleted' => new EE_Trashed_Flag_Field( |
|
172 | - 'TKT_deleted', |
|
173 | - esc_html__('Flag indicating if this has been archived or not', 'event_espresso'), |
|
174 | - false, |
|
175 | - false |
|
176 | - ), |
|
177 | - 'TKT_wp_user' => new EE_WP_User_Field( |
|
178 | - 'TKT_wp_user', |
|
179 | - esc_html__('Ticket Creator ID', 'event_espresso'), |
|
180 | - false |
|
181 | - ), |
|
182 | - 'TKT_parent' => new EE_Integer_Field( |
|
183 | - 'TKT_parent', |
|
184 | - esc_html__( |
|
185 | - 'Indicates what TKT_ID is the parent of this TKT_ID (used in autosaves/revisions)', |
|
186 | - 'event_espresso' |
|
187 | - ), |
|
188 | - true, |
|
189 | - 0 |
|
190 | - ), |
|
191 | - ), |
|
192 | - ); |
|
193 | - $this->_model_relations = array( |
|
194 | - 'Datetime' => new EE_HABTM_Relation('Datetime_Ticket'), |
|
195 | - 'Datetime_Ticket' => new EE_Has_Many_Relation(), |
|
196 | - 'Price' => new EE_HABTM_Relation('Ticket_Price'), |
|
197 | - 'Ticket_Template' => new EE_Belongs_To_Relation(), |
|
198 | - 'Registration' => new EE_Has_Many_Relation(), |
|
199 | - 'WP_User' => new EE_Belongs_To_Relation(), |
|
200 | - ); |
|
201 | - //this model is generally available for reading |
|
202 | - $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Default_Public( |
|
203 | - 'TKT_is_default', |
|
204 | - 'Datetime.Event' |
|
205 | - ); |
|
206 | - //account for default tickets in the caps |
|
207 | - $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Default_Protected( |
|
208 | - 'TKT_is_default', |
|
209 | - 'Datetime.Event' |
|
210 | - ); |
|
211 | - $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Default_Protected( |
|
212 | - 'TKT_is_default', |
|
213 | - 'Datetime.Event' |
|
214 | - ); |
|
215 | - $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Default_Protected( |
|
216 | - 'TKT_is_default', |
|
217 | - 'Datetime.Event' |
|
218 | - ); |
|
219 | - parent::__construct($timezone); |
|
220 | - } |
|
26 | + /** |
|
27 | + * private constructor to prevent direct creation |
|
28 | + * |
|
29 | + * @Constructor |
|
30 | + * @access private |
|
31 | + * @param string $timezone string representing the timezone we want to set for returned Date Time Strings |
|
32 | + * (and any incoming timezone data that gets saved). |
|
33 | + * Note this just sends the timezone info to the date time model field objects. |
|
34 | + * Default is NULL |
|
35 | + * (and will be assumed using the set timezone in the 'timezone_string' wp option) |
|
36 | + * @throws EE_Error |
|
37 | + */ |
|
38 | + protected function __construct($timezone) |
|
39 | + { |
|
40 | + $this->singular_item = esc_html__('Ticket', 'event_espresso'); |
|
41 | + $this->plural_item = esc_html__('Tickets', 'event_espresso'); |
|
42 | + $this->_tables = array( |
|
43 | + 'Ticket' => new EE_Primary_Table('esp_ticket', 'TKT_ID'), |
|
44 | + ); |
|
45 | + $this->_fields = array( |
|
46 | + 'Ticket' => array( |
|
47 | + 'TKT_ID' => new EE_Primary_Key_Int_Field( |
|
48 | + 'TKT_ID', |
|
49 | + esc_html__('Ticket ID', 'event_espresso') |
|
50 | + ), |
|
51 | + 'TTM_ID' => new EE_Foreign_Key_Int_Field( |
|
52 | + 'TTM_ID', |
|
53 | + esc_html__('Ticket Template ID', 'event_espresso'), |
|
54 | + false, |
|
55 | + 0, |
|
56 | + 'Ticket_Template' |
|
57 | + ), |
|
58 | + 'TKT_name' => new EE_Plain_Text_Field( |
|
59 | + 'TKT_name', |
|
60 | + esc_html__('Ticket Name', 'event_espresso'), |
|
61 | + false, |
|
62 | + '' |
|
63 | + ), |
|
64 | + 'TKT_description' => new EE_Post_Content_Field( |
|
65 | + 'TKT_description', |
|
66 | + esc_html__('Description of Ticket', 'event_espresso'), |
|
67 | + false, |
|
68 | + '' |
|
69 | + ), |
|
70 | + 'TKT_start_date' => new EE_Datetime_Field( |
|
71 | + 'TKT_start_date', |
|
72 | + esc_html__('Start time/date of Ticket', 'event_espresso'), |
|
73 | + false, |
|
74 | + EE_Datetime_Field::now, |
|
75 | + $timezone |
|
76 | + ), |
|
77 | + 'TKT_end_date' => new EE_Datetime_Field( |
|
78 | + 'TKT_end_date', |
|
79 | + esc_html__('End time/date of Ticket', 'event_espresso'), |
|
80 | + false, |
|
81 | + EE_Datetime_Field::now, |
|
82 | + $timezone |
|
83 | + ), |
|
84 | + 'TKT_min' => new EE_Integer_Field( |
|
85 | + 'TKT_min', |
|
86 | + esc_html__('Minimum quantity of this ticket that must be purchased', 'event_espresso'), |
|
87 | + false, |
|
88 | + 0 |
|
89 | + ), |
|
90 | + 'TKT_max' => new EE_Infinite_Integer_Field( |
|
91 | + 'TKT_max', |
|
92 | + esc_html__( |
|
93 | + 'Maximum quantity of this ticket that can be purchased in one transaction', |
|
94 | + 'event_espresso' |
|
95 | + ), |
|
96 | + false, |
|
97 | + EE_INF |
|
98 | + ), |
|
99 | + 'TKT_price' => new EE_Money_Field( |
|
100 | + 'TKT_price', |
|
101 | + esc_html__('Final calculated price for ticket', 'event_espresso'), |
|
102 | + false, |
|
103 | + 0 |
|
104 | + ), |
|
105 | + 'TKT_sold' => new EE_Integer_Field( |
|
106 | + 'TKT_sold', |
|
107 | + esc_html__('Number of this ticket sold', 'event_espresso'), |
|
108 | + false, |
|
109 | + 0 |
|
110 | + ), |
|
111 | + 'TKT_qty' => new EE_Infinite_Integer_Field( |
|
112 | + 'TKT_qty', |
|
113 | + esc_html__('Quantity of this ticket that is available', 'event_espresso'), |
|
114 | + false, |
|
115 | + EE_INF |
|
116 | + ), |
|
117 | + 'TKT_reserved' => new EE_Integer_Field( |
|
118 | + 'TKT_reserved', |
|
119 | + esc_html__( |
|
120 | + 'Quantity of this ticket that is reserved, but not yet fully purchased', |
|
121 | + 'event_espresso' |
|
122 | + ), |
|
123 | + false, |
|
124 | + 0 |
|
125 | + ), |
|
126 | + 'TKT_uses' => new EE_Infinite_Integer_Field( |
|
127 | + 'TKT_uses', |
|
128 | + esc_html__('Number of datetimes this ticket can be used at', 'event_espresso'), |
|
129 | + false, |
|
130 | + EE_INF |
|
131 | + ), |
|
132 | + 'TKT_required' => new EE_Boolean_Field( |
|
133 | + 'TKT_required', |
|
134 | + esc_html__( |
|
135 | + 'Flag indicating whether this ticket must be purchased with a transaction', |
|
136 | + 'event_espresso' |
|
137 | + ), |
|
138 | + false, |
|
139 | + false |
|
140 | + ), |
|
141 | + 'TKT_taxable' => new EE_Boolean_Field( |
|
142 | + 'TKT_taxable', |
|
143 | + esc_html__( |
|
144 | + 'Flag indicating whether there is tax applied on this ticket', |
|
145 | + 'event_espresso' |
|
146 | + ), |
|
147 | + false, |
|
148 | + false |
|
149 | + ), |
|
150 | + 'TKT_is_default' => new EE_Boolean_Field( |
|
151 | + 'TKT_is_default', |
|
152 | + esc_html__('Flag indicating that this ticket is a default ticket', 'event_espresso'), |
|
153 | + false, |
|
154 | + false |
|
155 | + ), |
|
156 | + 'TKT_order' => new EE_Integer_Field( |
|
157 | + 'TKT_order', |
|
158 | + esc_html__( |
|
159 | + 'The order in which the Ticket is displayed in the editor (used for autosaves when the form doesn\'t have the ticket ID yet)', |
|
160 | + 'event_espresso' |
|
161 | + ), |
|
162 | + false, |
|
163 | + 0 |
|
164 | + ), |
|
165 | + 'TKT_row' => new EE_Integer_Field( |
|
166 | + 'TKT_row', |
|
167 | + esc_html__('How tickets are displayed in the ui', 'event_espresso'), |
|
168 | + false, |
|
169 | + 0 |
|
170 | + ), |
|
171 | + 'TKT_deleted' => new EE_Trashed_Flag_Field( |
|
172 | + 'TKT_deleted', |
|
173 | + esc_html__('Flag indicating if this has been archived or not', 'event_espresso'), |
|
174 | + false, |
|
175 | + false |
|
176 | + ), |
|
177 | + 'TKT_wp_user' => new EE_WP_User_Field( |
|
178 | + 'TKT_wp_user', |
|
179 | + esc_html__('Ticket Creator ID', 'event_espresso'), |
|
180 | + false |
|
181 | + ), |
|
182 | + 'TKT_parent' => new EE_Integer_Field( |
|
183 | + 'TKT_parent', |
|
184 | + esc_html__( |
|
185 | + 'Indicates what TKT_ID is the parent of this TKT_ID (used in autosaves/revisions)', |
|
186 | + 'event_espresso' |
|
187 | + ), |
|
188 | + true, |
|
189 | + 0 |
|
190 | + ), |
|
191 | + ), |
|
192 | + ); |
|
193 | + $this->_model_relations = array( |
|
194 | + 'Datetime' => new EE_HABTM_Relation('Datetime_Ticket'), |
|
195 | + 'Datetime_Ticket' => new EE_Has_Many_Relation(), |
|
196 | + 'Price' => new EE_HABTM_Relation('Ticket_Price'), |
|
197 | + 'Ticket_Template' => new EE_Belongs_To_Relation(), |
|
198 | + 'Registration' => new EE_Has_Many_Relation(), |
|
199 | + 'WP_User' => new EE_Belongs_To_Relation(), |
|
200 | + ); |
|
201 | + //this model is generally available for reading |
|
202 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Default_Public( |
|
203 | + 'TKT_is_default', |
|
204 | + 'Datetime.Event' |
|
205 | + ); |
|
206 | + //account for default tickets in the caps |
|
207 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Default_Protected( |
|
208 | + 'TKT_is_default', |
|
209 | + 'Datetime.Event' |
|
210 | + ); |
|
211 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Default_Protected( |
|
212 | + 'TKT_is_default', |
|
213 | + 'Datetime.Event' |
|
214 | + ); |
|
215 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Default_Protected( |
|
216 | + 'TKT_is_default', |
|
217 | + 'Datetime.Event' |
|
218 | + ); |
|
219 | + parent::__construct($timezone); |
|
220 | + } |
|
221 | 221 | |
222 | 222 | |
223 | 223 | |
224 | - /** |
|
225 | - * This returns all tickets that are defaults from the db |
|
226 | - * |
|
227 | - * @return EE_Ticket[] |
|
228 | - * @throws EE_Error |
|
229 | - */ |
|
230 | - public function get_all_default_tickets() |
|
231 | - { |
|
232 | - /** @type EE_Ticket[] $tickets */ |
|
233 | - $tickets = $this->get_all(array(array('TKT_is_default' => 1), 'order_by' => array('TKT_ID' => 'ASC'))); |
|
234 | - //we need to set the start date and end date to today's date and the start of the default dtt |
|
235 | - return $this->_set_default_dates($tickets); |
|
236 | - } |
|
224 | + /** |
|
225 | + * This returns all tickets that are defaults from the db |
|
226 | + * |
|
227 | + * @return EE_Ticket[] |
|
228 | + * @throws EE_Error |
|
229 | + */ |
|
230 | + public function get_all_default_tickets() |
|
231 | + { |
|
232 | + /** @type EE_Ticket[] $tickets */ |
|
233 | + $tickets = $this->get_all(array(array('TKT_is_default' => 1), 'order_by' => array('TKT_ID' => 'ASC'))); |
|
234 | + //we need to set the start date and end date to today's date and the start of the default dtt |
|
235 | + return $this->_set_default_dates($tickets); |
|
236 | + } |
|
237 | 237 | |
238 | 238 | |
239 | 239 | |
240 | - /** |
|
241 | - * sets up relevant start and end date for EE_Ticket (s) |
|
242 | - * |
|
243 | - * @param EE_Ticket[] $tickets |
|
244 | - * @return EE_Ticket[] |
|
245 | - * @throws EE_Error |
|
246 | - */ |
|
247 | - private function _set_default_dates($tickets) |
|
248 | - { |
|
249 | - foreach ($tickets as $ticket) { |
|
250 | - $ticket->set( |
|
251 | - 'TKT_start_date', |
|
252 | - (int)$this->current_time_for_query('TKT_start_date', true) |
|
253 | - ); |
|
254 | - $ticket->set('TKT_end_date', |
|
255 | - (int)$this->current_time_for_query('TKT_end_date', true) + MONTH_IN_SECONDS |
|
256 | - ); |
|
257 | - $ticket->set_end_time($this->convert_datetime_for_query( |
|
258 | - 'TKT_end_date', |
|
259 | - '11:59 pm', |
|
260 | - 'g:i a', |
|
261 | - $this->_timezone) |
|
262 | - ); |
|
263 | - } |
|
264 | - return $tickets; |
|
265 | - } |
|
240 | + /** |
|
241 | + * sets up relevant start and end date for EE_Ticket (s) |
|
242 | + * |
|
243 | + * @param EE_Ticket[] $tickets |
|
244 | + * @return EE_Ticket[] |
|
245 | + * @throws EE_Error |
|
246 | + */ |
|
247 | + private function _set_default_dates($tickets) |
|
248 | + { |
|
249 | + foreach ($tickets as $ticket) { |
|
250 | + $ticket->set( |
|
251 | + 'TKT_start_date', |
|
252 | + (int)$this->current_time_for_query('TKT_start_date', true) |
|
253 | + ); |
|
254 | + $ticket->set('TKT_end_date', |
|
255 | + (int)$this->current_time_for_query('TKT_end_date', true) + MONTH_IN_SECONDS |
|
256 | + ); |
|
257 | + $ticket->set_end_time($this->convert_datetime_for_query( |
|
258 | + 'TKT_end_date', |
|
259 | + '11:59 pm', |
|
260 | + 'g:i a', |
|
261 | + $this->_timezone) |
|
262 | + ); |
|
263 | + } |
|
264 | + return $tickets; |
|
265 | + } |
|
266 | 266 | |
267 | 267 | |
268 | 268 | |
269 | - /** |
|
270 | - * Gets the total number of tickets available at a particular datetime (does |
|
271 | - * NOT take int account the datetime's spaces available) |
|
272 | - * |
|
273 | - * @param int $DTT_ID |
|
274 | - * @param array $query_params |
|
275 | - * @return int |
|
276 | - */ |
|
277 | - public function sum_tickets_currently_available_at_datetime($DTT_ID, $query_params = array()) |
|
278 | - { |
|
279 | - return EEM_Datetime::instance()->sum_tickets_currently_available_at_datetime($DTT_ID, $query_params); |
|
280 | - } |
|
269 | + /** |
|
270 | + * Gets the total number of tickets available at a particular datetime (does |
|
271 | + * NOT take int account the datetime's spaces available) |
|
272 | + * |
|
273 | + * @param int $DTT_ID |
|
274 | + * @param array $query_params |
|
275 | + * @return int |
|
276 | + */ |
|
277 | + public function sum_tickets_currently_available_at_datetime($DTT_ID, $query_params = array()) |
|
278 | + { |
|
279 | + return EEM_Datetime::instance()->sum_tickets_currently_available_at_datetime($DTT_ID, $query_params); |
|
280 | + } |
|
281 | 281 | |
282 | 282 | |
283 | 283 | |
284 | - /** |
|
285 | - * Updates the TKT_sold quantity on all the tickets matching $query_params |
|
286 | - * |
|
287 | - * @param EE_Ticket[] $tickets |
|
288 | - * @return void |
|
289 | - * @throws EE_Error |
|
290 | - */ |
|
291 | - public function update_tickets_sold($tickets) |
|
292 | - { |
|
293 | - foreach ($tickets as $ticket) { |
|
294 | - /* @var $ticket EE_Ticket */ |
|
295 | - $ticket->update_tickets_sold(); |
|
296 | - } |
|
297 | - } |
|
284 | + /** |
|
285 | + * Updates the TKT_sold quantity on all the tickets matching $query_params |
|
286 | + * |
|
287 | + * @param EE_Ticket[] $tickets |
|
288 | + * @return void |
|
289 | + * @throws EE_Error |
|
290 | + */ |
|
291 | + public function update_tickets_sold($tickets) |
|
292 | + { |
|
293 | + foreach ($tickets as $ticket) { |
|
294 | + /* @var $ticket EE_Ticket */ |
|
295 | + $ticket->update_tickets_sold(); |
|
296 | + } |
|
297 | + } |
|
298 | 298 | |
299 | 299 | |
300 | 300 | |
301 | - /** |
|
302 | - * returns an array of EE_Ticket objects with a non-zero value for TKT_reserved |
|
303 | - * |
|
304 | - * @return EE_Base_Class[]|EE_Ticket[] |
|
305 | - * @throws EE_Error |
|
306 | - */ |
|
307 | - public function get_tickets_with_reservations() |
|
308 | - { |
|
309 | - return $this->get_all( |
|
310 | - array( |
|
311 | - array( |
|
312 | - 'TKT_reserved' => array('>', 0), |
|
313 | - ), |
|
314 | - ) |
|
315 | - ); |
|
316 | - } |
|
301 | + /** |
|
302 | + * returns an array of EE_Ticket objects with a non-zero value for TKT_reserved |
|
303 | + * |
|
304 | + * @return EE_Base_Class[]|EE_Ticket[] |
|
305 | + * @throws EE_Error |
|
306 | + */ |
|
307 | + public function get_tickets_with_reservations() |
|
308 | + { |
|
309 | + return $this->get_all( |
|
310 | + array( |
|
311 | + array( |
|
312 | + 'TKT_reserved' => array('>', 0), |
|
313 | + ), |
|
314 | + ) |
|
315 | + ); |
|
316 | + } |
|
317 | 317 | |
318 | 318 | |
319 | 319 | |
320 | - /** |
|
321 | - * returns an array of EE_Ticket objects matching the supplied list of IDs |
|
322 | - * |
|
323 | - * @param array $ticket_IDs |
|
324 | - * @return EE_Base_Class[]|EE_Ticket[] |
|
325 | - * @throws EE_Error |
|
326 | - */ |
|
327 | - public function get_tickets_with_IDs(array $ticket_IDs) |
|
328 | - { |
|
329 | - return $this->get_all( |
|
330 | - array( |
|
331 | - array( |
|
332 | - 'TKT_ID' => array('IN', $ticket_IDs) |
|
333 | - ) |
|
334 | - ) |
|
335 | - ); |
|
336 | - } |
|
320 | + /** |
|
321 | + * returns an array of EE_Ticket objects matching the supplied list of IDs |
|
322 | + * |
|
323 | + * @param array $ticket_IDs |
|
324 | + * @return EE_Base_Class[]|EE_Ticket[] |
|
325 | + * @throws EE_Error |
|
326 | + */ |
|
327 | + public function get_tickets_with_IDs(array $ticket_IDs) |
|
328 | + { |
|
329 | + return $this->get_all( |
|
330 | + array( |
|
331 | + array( |
|
332 | + 'TKT_ID' => array('IN', $ticket_IDs) |
|
333 | + ) |
|
334 | + ) |
|
335 | + ); |
|
336 | + } |
|
337 | 337 | |
338 | 338 | |
339 | 339 |
@@ -2,8 +2,8 @@ discard block |
||
2 | 2 | |
3 | 3 | defined('EVENT_ESPRESSO_VERSION') || exit('No direct script access allowed'); |
4 | 4 | |
5 | -require_once(EE_MODELS . 'EEM_Soft_Delete_Base.model.php'); |
|
6 | -require_once(EE_CLASSES . 'EE_Ticket.class.php'); |
|
5 | +require_once(EE_MODELS.'EEM_Soft_Delete_Base.model.php'); |
|
6 | +require_once(EE_CLASSES.'EE_Ticket.class.php'); |
|
7 | 7 | /** |
8 | 8 | * Ticket Model |
9 | 9 | * |
@@ -249,10 +249,10 @@ discard block |
||
249 | 249 | foreach ($tickets as $ticket) { |
250 | 250 | $ticket->set( |
251 | 251 | 'TKT_start_date', |
252 | - (int)$this->current_time_for_query('TKT_start_date', true) |
|
252 | + (int) $this->current_time_for_query('TKT_start_date', true) |
|
253 | 253 | ); |
254 | 254 | $ticket->set('TKT_end_date', |
255 | - (int)$this->current_time_for_query('TKT_end_date', true) + MONTH_IN_SECONDS |
|
255 | + (int) $this->current_time_for_query('TKT_end_date', true) + MONTH_IN_SECONDS |
|
256 | 256 | ); |
257 | 257 | $ticket->set_end_time($this->convert_datetime_for_query( |
258 | 258 | 'TKT_end_date', |
@@ -11,48 +11,48 @@ |
||
11 | 11 | * @version 4+ |
12 | 12 | */ |
13 | 13 | if (have_posts()) : |
14 | - if (apply_filters('FHEE__archive_espresso_events_template__show_header', true)) : ?> |
|
14 | + if (apply_filters('FHEE__archive_espresso_events_template__show_header', true)) : ?> |
|
15 | 15 | <header class="page-header"> |
16 | 16 | <h1 class="page-title"> |
17 | 17 | <?php |
18 | - if (is_day()) : |
|
19 | - printf(__('Today\'s Events: %s', 'event_espresso'), get_the_date()); |
|
20 | - elseif (is_month()) : |
|
21 | - printf( |
|
22 | - __('Events This Month: %s', 'event_espresso'), |
|
23 | - get_the_date(_x('F Y', 'monthly archives date format', 'event_espresso')) |
|
24 | - ); |
|
25 | - elseif (is_year()) : |
|
26 | - printf( |
|
27 | - __('Events This Year: %s', 'event_espresso'), |
|
28 | - get_the_date(_x('Y', 'yearly archives date format', 'event_espresso')) |
|
29 | - ); |
|
30 | - else : |
|
31 | - echo apply_filters( |
|
32 | - 'FHEE__archive_espresso_events_template__upcoming_events_h1', |
|
33 | - __('Upcoming Events', 'event_espresso') |
|
34 | - ); |
|
35 | - endif; |
|
36 | - ?> |
|
18 | + if (is_day()) : |
|
19 | + printf(__('Today\'s Events: %s', 'event_espresso'), get_the_date()); |
|
20 | + elseif (is_month()) : |
|
21 | + printf( |
|
22 | + __('Events This Month: %s', 'event_espresso'), |
|
23 | + get_the_date(_x('F Y', 'monthly archives date format', 'event_espresso')) |
|
24 | + ); |
|
25 | + elseif (is_year()) : |
|
26 | + printf( |
|
27 | + __('Events This Year: %s', 'event_espresso'), |
|
28 | + get_the_date(_x('Y', 'yearly archives date format', 'event_espresso')) |
|
29 | + ); |
|
30 | + else : |
|
31 | + echo apply_filters( |
|
32 | + 'FHEE__archive_espresso_events_template__upcoming_events_h1', |
|
33 | + __('Upcoming Events', 'event_espresso') |
|
34 | + ); |
|
35 | + endif; |
|
36 | + ?> |
|
37 | 37 | </h1> |
38 | 38 | |
39 | 39 | </header><!-- .page-header --> |
40 | 40 | |
41 | 41 | <?php |
42 | - endif; |
|
43 | - // allow other stuff |
|
44 | - do_action('AHEE__archive_espresso_events_template__before_loop'); |
|
45 | - // Start the Loop. |
|
46 | - while (have_posts()) : the_post(); |
|
47 | - // Include the post TYPE-specific template for the content. |
|
48 | - espresso_get_template_part('content', 'espresso_events-shortcode'); |
|
49 | - endwhile; |
|
50 | - // Previous/next page navigation. |
|
51 | - espresso_pagination(); |
|
52 | - // allow moar other stuff |
|
53 | - do_action('AHEE__archive_espresso_events_template__after_loop'); |
|
42 | + endif; |
|
43 | + // allow other stuff |
|
44 | + do_action('AHEE__archive_espresso_events_template__before_loop'); |
|
45 | + // Start the Loop. |
|
46 | + while (have_posts()) : the_post(); |
|
47 | + // Include the post TYPE-specific template for the content. |
|
48 | + espresso_get_template_part('content', 'espresso_events-shortcode'); |
|
49 | + endwhile; |
|
50 | + // Previous/next page navigation. |
|
51 | + espresso_pagination(); |
|
52 | + // allow moar other stuff |
|
53 | + do_action('AHEE__archive_espresso_events_template__after_loop'); |
|
54 | 54 | else : |
55 | - // If no content, include the "No posts found" template. |
|
56 | - espresso_get_template_part('content', 'none'); |
|
55 | + // If no content, include the "No posts found" template. |
|
56 | + espresso_get_template_part('content', 'none'); |
|
57 | 57 | endif; |
58 | 58 |
@@ -27,11 +27,13 @@ discard block |
||
27 | 27 | __('Events This Year: %s', 'event_espresso'), |
28 | 28 | get_the_date(_x('Y', 'yearly archives date format', 'event_espresso')) |
29 | 29 | ); |
30 | - else : |
|
30 | + else { |
|
31 | + : |
|
31 | 32 | echo apply_filters( |
32 | 33 | 'FHEE__archive_espresso_events_template__upcoming_events_h1', |
33 | 34 | __('Upcoming Events', 'event_espresso') |
34 | 35 | ); |
36 | + } |
|
35 | 37 | endif; |
36 | 38 | ?> |
37 | 39 | </h1> |
@@ -51,8 +53,10 @@ discard block |
||
51 | 53 | espresso_pagination(); |
52 | 54 | // allow moar other stuff |
53 | 55 | do_action('AHEE__archive_espresso_events_template__after_loop'); |
54 | -else : |
|
56 | +else { |
|
57 | + : |
|
55 | 58 | // If no content, include the "No posts found" template. |
56 | 59 | espresso_get_template_part('content', 'none'); |
60 | +} |
|
57 | 61 | endif; |
58 | 62 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <div class="padding"> |
2 | 2 | <p> |
3 | - <?php esc_html_e('Displays a list of events based on a set of criteria on a WordPress page or post. Unless otherwise specified, events are sorted by start date.', 'event_espresso'); ?> <?php echo sprintf( esc_html__('For a full list of available shortcodes, please view the %sshortcode documentation%s on our website.', 'event_espresso'), '<a href="https://eventespresso.com/wiki/ee4-shortcodes-template-variables/">', '</a>' ); ?> |
|
3 | + <?php esc_html_e('Displays a list of events based on a set of criteria on a WordPress page or post. Unless otherwise specified, events are sorted by start date.', 'event_espresso'); ?> <?php echo sprintf(esc_html__('For a full list of available shortcodes, please view the %sshortcode documentation%s on our website.', 'event_espresso'), '<a href="https://eventespresso.com/wiki/ee4-shortcodes-template-variables/">', '</a>'); ?> |
|
4 | 4 | </p> |
5 | 5 | <ul> |
6 | 6 | <li><strong><?php esc_html_e('Show a list of all of your events', 'event_espresso'); ?></strong><br /> [ESPRESSO_EVENTS]</li> |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | <li><strong><?php esc_html_e('Don\'t display a title/heading before the event list', 'event_espresso'); ?></strong><br /> [ESPRESSO_EVENTS show_title=false]</li> |
9 | 9 | <li><strong><?php esc_html_e('Limit (paginate) the number of events that are shown in the event list on a page or post', 'event_espresso'); ?></strong><br />[ESPRESSO_EVENTS limit=5]</li> |
10 | 10 | <li><strong><?php esc_html_e('Add a custom CSS class to each event post/article', 'event_espresso'); ?></strong><br /> [ESPRESSO_EVENTS css_class=my-custom-class]</li> |
11 | - <li><strong><?php esc_html_e('Filter the event list by month and year', 'event_espresso'); ?></strong><br />[ESPRESSO_EVENTS month="<?php echo date( 'F Y' ); ?>"]</li> |
|
11 | + <li><strong><?php esc_html_e('Filter the event list by month and year', 'event_espresso'); ?></strong><br />[ESPRESSO_EVENTS month="<?php echo date('F Y'); ?>"]</li> |
|
12 | 12 | <li><strong><?php esc_html_e('Show expired events in the event list', 'event_espresso'); ?></strong><br />[ESPRESSO_EVENTS show_expired=true]</li> |
13 | 13 | <li><strong><?php esc_html_e('Sorts the event list in ascending order', 'event_espresso'); ?></strong><br />[ESPRESSO_EVENTS sort=ASC]</li> |
14 | 14 | <li><strong><?php esc_html_e('Sorts the event list in descending order', 'event_espresso'); ?></strong><br />[ESPRESSO_EVENTS sort=DESC]</li> |
@@ -450,7 +450,7 @@ |
||
450 | 450 | |
451 | 451 | |
452 | 452 | /** |
453 | - * @param $Request |
|
453 | + * @param string $Request |
|
454 | 454 | * @return mixed |
455 | 455 | */ |
456 | 456 | private function _CURLRequest($Request) |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
3 | - exit('No direct script access allowed'); |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | |
@@ -25,591 +25,591 @@ discard block |
||
25 | 25 | class EEG_Paypal_Pro extends EE_Onsite_Gateway |
26 | 26 | { |
27 | 27 | |
28 | - /** |
|
29 | - * @var $_paypal_api_username string |
|
30 | - */ |
|
31 | - protected $_username = null; |
|
32 | - |
|
33 | - /** |
|
34 | - * @var $_password string |
|
35 | - */ |
|
36 | - protected $_password = null; |
|
37 | - |
|
38 | - /** |
|
39 | - * @var $_signature string |
|
40 | - */ |
|
41 | - protected $_signature = null; |
|
42 | - |
|
43 | - /** |
|
44 | - * @var $_credit_card_types array with the keys for credit card types accepted on this account |
|
45 | - */ |
|
46 | - protected $_credit_card_types = null; |
|
47 | - |
|
48 | - protected $_currencies_supported = array( |
|
49 | - 'USD', |
|
50 | - 'GBP', |
|
51 | - 'CAD', |
|
52 | - 'AUD', |
|
53 | - 'BRL', |
|
54 | - 'CHF', |
|
55 | - 'CZK', |
|
56 | - 'DKK', |
|
57 | - 'EUR', |
|
58 | - 'HKD', |
|
59 | - 'HUF', |
|
60 | - 'ILS', |
|
61 | - 'JPY', |
|
62 | - 'MXN', |
|
63 | - 'MYR', |
|
64 | - 'NOK', |
|
65 | - 'NZD', |
|
66 | - 'PHP', |
|
67 | - 'PLN', |
|
68 | - 'SEK', |
|
69 | - 'SGD', |
|
70 | - 'THB', |
|
71 | - 'TRY', |
|
72 | - 'TWD', |
|
73 | - 'RUB', |
|
74 | - ); |
|
75 | - |
|
76 | - |
|
77 | - |
|
78 | - /** |
|
79 | - * @param EEI_Payment $payment |
|
80 | - * @param array $billing_info { |
|
81 | - * @type string $credit_card |
|
82 | - * @type string $credit_card_type |
|
83 | - * @type string $exp_month always 2 characters |
|
84 | - * @type string $exp_year always 4 characters |
|
85 | - * @type string $cvv |
|
86 | - * } |
|
87 | - * @see parent::do_direct_payment for more info |
|
88 | - * @return EE_Payment|EEI_Payment |
|
89 | - * @throws EE_Error |
|
90 | - */ |
|
91 | - public function do_direct_payment($payment, $billing_info = null) |
|
92 | - { |
|
93 | - $transaction = $payment->transaction(); |
|
94 | - if (! $transaction instanceof EEI_Transaction) { |
|
95 | - throw new EE_Error( |
|
96 | - esc_html__('No transaction for payment while paying with PayPal Pro.', 'event_espresso') |
|
97 | - ); |
|
98 | - } |
|
99 | - $primary_registrant = $transaction->primary_registration(); |
|
100 | - if (! $primary_registrant instanceof EEI_Registration) { |
|
101 | - throw new EE_Error( |
|
102 | - esc_html__( |
|
103 | - 'No primary registration on transaction while paying with PayPal Pro.', |
|
104 | - 'event_espresso' |
|
105 | - ) |
|
106 | - ); |
|
107 | - } |
|
108 | - $attendee = $primary_registrant->attendee(); |
|
109 | - if (! $attendee instanceof EEI_Attendee) { |
|
110 | - throw new EE_Error( |
|
111 | - esc_html__( |
|
112 | - 'No attendee on primary registration while paying with PayPal Pro.', |
|
113 | - 'event_espresso' |
|
114 | - ) |
|
115 | - ); |
|
116 | - } |
|
117 | - $order_description = substr($this->_format_order_description($payment), 0, 127); |
|
118 | - //charge for the full amount. Show itemized list |
|
119 | - if ($this->_can_easily_itemize_transaction_for($payment)) { |
|
120 | - $item_num = 1; |
|
121 | - $total_line_item = $transaction->total_line_item(); |
|
122 | - $order_items = array(); |
|
123 | - foreach ($total_line_item->get_items() as $line_item) { |
|
124 | - //ignore line items with a quantity of 0 |
|
125 | - if ($line_item->quantity() == 0) { |
|
126 | - continue; |
|
127 | - } |
|
128 | - $item = array( |
|
129 | - // Item Name. 127 char max. |
|
130 | - 'l_name' => substr( |
|
131 | - $this->_format_line_item_name($line_item, $payment), |
|
132 | - 0, |
|
133 | - 127 |
|
134 | - ), |
|
135 | - // Item description. 127 char max. |
|
136 | - 'l_desc' => substr( |
|
137 | - $this->_format_line_item_desc($line_item, $payment), |
|
138 | - 0, |
|
139 | - 127 |
|
140 | - ), |
|
141 | - // Cost of individual item. |
|
142 | - 'l_amt' => $line_item->unit_price(), |
|
143 | - // Item Number. 127 char max. |
|
144 | - 'l_number' => $item_num++, |
|
145 | - // Item quantity. Must be any positive integer. |
|
146 | - 'l_qty' => $line_item->quantity(), |
|
147 | - // Item's sales tax amount. |
|
148 | - 'l_taxamt' => '', |
|
149 | - // eBay auction number of item. |
|
150 | - 'l_ebayitemnumber' => '', |
|
151 | - // eBay transaction ID of purchased item. |
|
152 | - 'l_ebayitemauctiontxnid' => '', |
|
153 | - // eBay order ID for the item. |
|
154 | - 'l_ebayitemorderid' => '', |
|
155 | - ); |
|
156 | - // add to array of all items |
|
157 | - array_push($order_items, $item); |
|
158 | - } |
|
159 | - $item_amount = $total_line_item->get_items_total(); |
|
160 | - $tax_amount = $total_line_item->get_total_tax(); |
|
161 | - } else { |
|
162 | - $order_items = array(); |
|
163 | - $item_amount = $payment->amount(); |
|
164 | - $tax_amount = 0; |
|
165 | - array_push($order_items, array( |
|
166 | - // Item Name. 127 char max. |
|
167 | - 'l_name' => substr( |
|
168 | - $this->_format_partial_payment_line_item_name($payment), |
|
169 | - 0, |
|
170 | - 127 |
|
171 | - ), |
|
172 | - // Item description. 127 char max. |
|
173 | - 'l_desc' => substr( |
|
174 | - $this->_format_partial_payment_line_item_desc($payment), |
|
175 | - 0, |
|
176 | - 127 |
|
177 | - ), |
|
178 | - // Cost of individual item. |
|
179 | - 'l_amt' => $payment->amount(), |
|
180 | - // Item Number. 127 char max. |
|
181 | - 'l_number' => 1, |
|
182 | - // Item quantity. Must be any positive integer. |
|
183 | - 'l_qty' => 1, |
|
184 | - )); |
|
185 | - } |
|
186 | - // Populate data arrays with order data. |
|
187 | - $DPFields = array( |
|
188 | - // How you want to obtain payment ? |
|
189 | - // Authorization indicates the payment is a basic auth subject to settlement with Auth & Capture. |
|
190 | - // Sale indicates that this is a final sale for which you are requesting payment. Default is Sale. |
|
191 | - 'paymentaction' => 'Sale', |
|
192 | - // Required. IP address of the payer's browser. |
|
193 | - 'ipaddress' => $_SERVER['REMOTE_ADDR'], |
|
194 | - // Flag to determine whether you want the results returned by FMF. 1 or 0. Default is 0. |
|
195 | - 'returnfmfdetails' => '1', |
|
196 | - ); |
|
197 | - $CCDetails = array( |
|
198 | - // Required. Type of credit card. Visa, MasterCard, Discover, Amex, Maestro, Solo. |
|
199 | - // If Maestro or Solo, the currency code must be GBP. |
|
200 | - // In addition, either start date or issue number must be specified. |
|
201 | - 'creditcardtype' => $billing_info['credit_card_type'], |
|
202 | - // Required. Credit card number. No spaces or punctuation. |
|
203 | - 'acct' => $billing_info['credit_card'], |
|
204 | - // Required. Credit card expiration date. Format is MMYYYY |
|
205 | - 'expdate' => $billing_info['exp_month'] . $billing_info['exp_year'], |
|
206 | - // Requirements determined by your PayPal account settings. Security digits for credit card. |
|
207 | - 'cvv2' => $billing_info['cvv'], |
|
208 | - ); |
|
209 | - $PayerInfo = array( |
|
210 | - // Email address of payer. |
|
211 | - 'email' => $billing_info['email'], |
|
212 | - // Unique PayPal customer ID for payer. |
|
213 | - 'payerid' => '', |
|
214 | - // Status of payer. Values are verified or unverified |
|
215 | - 'payerstatus' => '', |
|
216 | - // Payer's business name. |
|
217 | - 'business' => '', |
|
218 | - ); |
|
219 | - $PayerName = array( |
|
220 | - // Payer's salutation. 20 char max. |
|
221 | - 'salutation' => '', |
|
222 | - // Payer's first name. 25 char max. |
|
223 | - 'firstname' => substr($billing_info['first_name'], 0, 25), |
|
224 | - // Payer's middle name. 25 char max. |
|
225 | - 'middlename' => '', |
|
226 | - // Payer's last name. 25 char max. |
|
227 | - 'lastname' => substr($billing_info['last_name'], 0, 25), |
|
228 | - // Payer's suffix. 12 char max. |
|
229 | - 'suffix' => '', |
|
230 | - ); |
|
231 | - $BillingAddress = array( |
|
232 | - // Required. First street address. |
|
233 | - 'street' => $billing_info['address'], |
|
234 | - // Second street address. |
|
235 | - 'street2' => $billing_info['address2'], |
|
236 | - // Required. Name of City. |
|
237 | - 'city' => $billing_info['city'], |
|
238 | - // Required. Name of State or Province. |
|
239 | - 'state' => substr($billing_info['state'], 0, 40), |
|
240 | - // Required. Country code. |
|
241 | - 'countrycode' => $billing_info['country'], |
|
242 | - // Required. Postal code of payer. |
|
243 | - 'zip' => $billing_info['zip'], |
|
244 | - ); |
|
245 | - //check if the registration info contains the needed fields for paypal pro |
|
246 | - //(see https://developer.paypal.com/docs/classic/api/merchant/DoDirectPayment_API_Operation_NVP/) |
|
247 | - if ($attendee->address() && $attendee->city() && $attendee->country_ID()) { |
|
248 | - $use_registration_address_info = true; |
|
249 | - } else { |
|
250 | - $use_registration_address_info = false; |
|
251 | - } |
|
252 | - //so if the attendee has enough data to fill out PayPal Pro's shipping info, use it. |
|
253 | - // If not, use the billing info again |
|
254 | - $ShippingAddress = array( |
|
255 | - 'shiptoname' => substr($use_registration_address_info |
|
256 | - ? $attendee->full_name() |
|
257 | - : $billing_info['first_name'] . ' ' . $billing_info['last_name'], 0, 32), |
|
258 | - 'shiptostreet' => substr($use_registration_address_info |
|
259 | - ? $attendee->address() |
|
260 | - : $billing_info['address'], 0, 100), |
|
261 | - 'shiptostreet2' => substr($use_registration_address_info |
|
262 | - ? $attendee->address2() : $billing_info['address2'], 0, 100), |
|
263 | - 'shiptocity' => substr($use_registration_address_info |
|
264 | - ? $attendee->city() |
|
265 | - : $billing_info['city'], 0, 40), |
|
266 | - 'state' => substr($use_registration_address_info |
|
267 | - ? $attendee->state_name() |
|
268 | - : $billing_info['state'], 0, 40), |
|
269 | - 'shiptocountry' => $use_registration_address_info |
|
270 | - ? $attendee->country_ID() |
|
271 | - : $billing_info['country'], |
|
272 | - 'shiptozip' => substr($use_registration_address_info |
|
273 | - ? $attendee->zip() |
|
274 | - : $billing_info['zip'], 0, 20), |
|
275 | - 'shiptophonenum' => substr($use_registration_address_info |
|
276 | - ? $attendee->phone() |
|
277 | - : $billing_info['phone'], 0, 20), |
|
278 | - ); |
|
279 | - $PaymentDetails = array( |
|
280 | - // Required. Total amount of order, including shipping, handling, and tax. |
|
281 | - 'amt' => $this->format_currency($payment->amount()), |
|
282 | - // Required. Three-letter currency code. Default is USD. |
|
283 | - 'currencycode' => $payment->currency_code(), |
|
284 | - // Required if you include itemized cart details. (L_AMTn, etc.) |
|
285 | - //Subtotal of items not including S&H, or tax. |
|
286 | - 'itemamt' => $this->format_currency($item_amount),// |
|
287 | - // Total shipping costs for the order. If you specify shippingamt, you must also specify itemamt. |
|
288 | - 'shippingamt' => '', |
|
289 | - // Total handling costs for the order. If you specify handlingamt, you must also specify itemamt. |
|
290 | - 'handlingamt' => '', |
|
291 | - // Required if you specify itemized cart tax details. |
|
292 | - // Sum of tax for all items on the order. Total sales tax. |
|
293 | - 'taxamt' => $this->format_currency($tax_amount), |
|
294 | - // Description of the order the customer is purchasing. 127 char max. |
|
295 | - 'desc' => $order_description, |
|
296 | - // Free-form field for your own use. 256 char max. |
|
297 | - 'custom' => $primary_registrant ? $primary_registrant->ID() : '', |
|
298 | - // Your own invoice or tracking number |
|
299 | - 'invnum' => wp_generate_password(12, false),//$transaction->ID(), |
|
300 | - // URL for receiving Instant Payment Notifications. This overrides what your profile is set to use. |
|
301 | - 'notifyurl' => '', |
|
302 | - 'buttonsource' => 'EventEspresso_SP',//EE will blow up if you change this |
|
303 | - ); |
|
304 | - // Wrap all data arrays into a single, "master" array which will be passed into the class function. |
|
305 | - $PayPalRequestData = array( |
|
306 | - 'DPFields' => $DPFields, |
|
307 | - 'CCDetails' => $CCDetails, |
|
308 | - 'PayerInfo' => $PayerInfo, |
|
309 | - 'PayerName' => $PayerName, |
|
310 | - 'BillingAddress' => $BillingAddress, |
|
311 | - 'ShippingAddress' => $ShippingAddress, |
|
312 | - 'PaymentDetails' => $PaymentDetails, |
|
313 | - 'OrderItems' => $order_items, |
|
314 | - ); |
|
315 | - $this->_log_clean_request($PayPalRequestData, $payment); |
|
316 | - try { |
|
317 | - $PayPalResult = $this->prep_and_curl_request($PayPalRequestData); |
|
318 | - //remove PCI-sensitive data so it doesn't get stored |
|
319 | - $PayPalResult = $this->_log_clean_response($PayPalResult, $payment); |
|
320 | - $message = isset($PayPalResult['L_LONGMESSAGE0']) ? $PayPalResult['L_LONGMESSAGE0'] : $PayPalResult['ACK']; |
|
321 | - if (empty($PayPalResult['RAWRESPONSE'])) { |
|
322 | - $payment->set_status($this->_pay_model->failed_status()); |
|
323 | - $payment->set_gateway_response(__('No response received from Paypal Pro', 'event_espresso')); |
|
324 | - $payment->set_details($PayPalResult); |
|
325 | - } else { |
|
326 | - if ($this->_APICallSuccessful($PayPalResult)) { |
|
327 | - $payment->set_status($this->_pay_model->approved_status()); |
|
328 | - } else { |
|
329 | - $payment->set_status($this->_pay_model->declined_status()); |
|
330 | - } |
|
331 | - //make sure we interpret the AMT as a float, not an international string |
|
332 | - // (where periods are thousand separators) |
|
333 | - $payment->set_amount(isset($PayPalResult['AMT']) ? floatval($PayPalResult['AMT']) : 0); |
|
334 | - $payment->set_gateway_response($message); |
|
335 | - $payment->set_txn_id_chq_nmbr(isset($PayPalResult['TRANSACTIONID']) |
|
336 | - ? $PayPalResult['TRANSACTIONID'] |
|
337 | - : null); |
|
338 | - $primary_registration_code = $primary_registrant instanceof EE_Registration |
|
339 | - ? $primary_registrant->reg_code() |
|
340 | - : ''; |
|
341 | - $payment->set_extra_accntng($primary_registration_code); |
|
342 | - $payment->set_details($PayPalResult); |
|
343 | - } |
|
344 | - } catch (Exception $e) { |
|
345 | - $payment->set_status($this->_pay_model->failed_status()); |
|
346 | - $payment->set_gateway_response($e->getMessage()); |
|
347 | - } |
|
348 | - //$payment->set_status( $this->_pay_model->declined_status() ); |
|
349 | - //$payment->set_gateway_response( '' ); |
|
350 | - return $payment; |
|
351 | - } |
|
352 | - |
|
353 | - |
|
354 | - |
|
355 | - /** |
|
356 | - * CLeans out sensitive CC data and then logs it, and returns the cleaned request |
|
357 | - * |
|
358 | - * @param array $request |
|
359 | - * @param EEI_Payment $payment |
|
360 | - * @return void |
|
361 | - */ |
|
362 | - private function _log_clean_request($request, $payment) |
|
363 | - { |
|
364 | - $cleaned_request_data = $request; |
|
365 | - unset($cleaned_request_data['CCDetails']['acct']); |
|
366 | - unset($cleaned_request_data['CCDetails']['cvv2']); |
|
367 | - unset($cleaned_request_data['CCDetails']['expdate']); |
|
368 | - $this->log(array('Paypal Request' => $cleaned_request_data), $payment); |
|
369 | - } |
|
370 | - |
|
371 | - |
|
372 | - |
|
373 | - /** |
|
374 | - * Cleans the response, logs it, and returns it |
|
375 | - * |
|
376 | - * @param array $response |
|
377 | - * @param EEI_Payment $payment |
|
378 | - * @return array cleaned |
|
379 | - */ |
|
380 | - private function _log_clean_response($response, $payment) |
|
381 | - { |
|
382 | - unset($response['REQUESTDATA']['CREDITCARDTYPE']); |
|
383 | - unset($response['REQUESTDATA']['ACCT']); |
|
384 | - unset($response['REQUESTDATA']['EXPDATE']); |
|
385 | - unset($response['REQUESTDATA']['CVV2']); |
|
386 | - unset($response['RAWREQUEST']); |
|
387 | - $this->log(array('Paypal Response' => $response), $payment); |
|
388 | - return $response; |
|
389 | - } |
|
390 | - |
|
391 | - |
|
392 | - |
|
393 | - /** |
|
394 | - * @param $DataArray |
|
395 | - * @return array |
|
396 | - */ |
|
397 | - private function prep_and_curl_request($DataArray) |
|
398 | - { |
|
399 | - // Create empty holders for each portion of the NVP string |
|
400 | - $DPFieldsNVP = '&METHOD=DoDirectPayment&BUTTONSOURCE=AngellEYE_PHP_Class_DDP'; |
|
401 | - $CCDetailsNVP = ''; |
|
402 | - $PayerInfoNVP = ''; |
|
403 | - $PayerNameNVP = ''; |
|
404 | - $BillingAddressNVP = ''; |
|
405 | - $ShippingAddressNVP = ''; |
|
406 | - $PaymentDetailsNVP = ''; |
|
407 | - $OrderItemsNVP = ''; |
|
408 | - $Secure3DNVP = ''; |
|
409 | - // DP Fields |
|
410 | - $DPFields = isset($DataArray['DPFields']) ? $DataArray['DPFields'] : array(); |
|
411 | - foreach ($DPFields as $DPFieldsVar => $DPFieldsVal) { |
|
412 | - $DPFieldsNVP .= '&' . strtoupper($DPFieldsVar) . '=' . urlencode($DPFieldsVal); |
|
413 | - } |
|
414 | - // CC Details Fields |
|
415 | - $CCDetails = isset($DataArray['CCDetails']) ? $DataArray['CCDetails'] : array(); |
|
416 | - foreach ($CCDetails as $CCDetailsVar => $CCDetailsVal) { |
|
417 | - $CCDetailsNVP .= '&' . strtoupper($CCDetailsVar) . '=' . urlencode($CCDetailsVal); |
|
418 | - } |
|
419 | - // PayerInfo Type Fields |
|
420 | - $PayerInfo = isset($DataArray['PayerInfo']) ? $DataArray['PayerInfo'] : array(); |
|
421 | - foreach ($PayerInfo as $PayerInfoVar => $PayerInfoVal) { |
|
422 | - $PayerInfoNVP .= '&' . strtoupper($PayerInfoVar) . '=' . urlencode($PayerInfoVal); |
|
423 | - } |
|
424 | - // Payer Name Fields |
|
425 | - $PayerName = isset($DataArray['PayerName']) ? $DataArray['PayerName'] : array(); |
|
426 | - foreach ($PayerName as $PayerNameVar => $PayerNameVal) { |
|
427 | - $PayerNameNVP .= '&' . strtoupper($PayerNameVar) . '=' . urlencode($PayerNameVal); |
|
428 | - } |
|
429 | - // Address Fields (Billing) |
|
430 | - $BillingAddress = isset($DataArray['BillingAddress']) ? $DataArray['BillingAddress'] : array(); |
|
431 | - foreach ($BillingAddress as $BillingAddressVar => $BillingAddressVal) { |
|
432 | - $BillingAddressNVP .= '&' . strtoupper($BillingAddressVar) . '=' . urlencode($BillingAddressVal); |
|
433 | - } |
|
434 | - // Payment Details Type Fields |
|
435 | - $PaymentDetails = isset($DataArray['PaymentDetails']) ? $DataArray['PaymentDetails'] : array(); |
|
436 | - foreach ($PaymentDetails as $PaymentDetailsVar => $PaymentDetailsVal) { |
|
437 | - $PaymentDetailsNVP .= '&' . strtoupper($PaymentDetailsVar) . '=' . urlencode($PaymentDetailsVal); |
|
438 | - } |
|
439 | - // Payment Details Item Type Fields |
|
440 | - $OrderItems = isset($DataArray['OrderItems']) ? $DataArray['OrderItems'] : array(); |
|
441 | - $n = 0; |
|
442 | - foreach ($OrderItems as $OrderItemsVar => $OrderItemsVal) { |
|
443 | - $CurrentItem = $OrderItems[$OrderItemsVar]; |
|
444 | - foreach ($CurrentItem as $CurrentItemVar => $CurrentItemVal) { |
|
445 | - $OrderItemsNVP .= '&' . strtoupper($CurrentItemVar) . $n . '=' . urlencode($CurrentItemVal); |
|
446 | - } |
|
447 | - $n++; |
|
448 | - } |
|
449 | - // Ship To Address Fields |
|
450 | - $ShippingAddress = isset($DataArray['ShippingAddress']) ? $DataArray['ShippingAddress'] : array(); |
|
451 | - foreach ($ShippingAddress as $ShippingAddressVar => $ShippingAddressVal) { |
|
452 | - $ShippingAddressNVP .= '&' . strtoupper($ShippingAddressVar) . '=' . urlencode($ShippingAddressVal); |
|
453 | - } |
|
454 | - // 3D Secure Fields |
|
455 | - $Secure3D = isset($DataArray['Secure3D']) ? $DataArray['Secure3D'] : array(); |
|
456 | - foreach ($Secure3D as $Secure3DVar => $Secure3DVal) { |
|
457 | - $Secure3DNVP .= '&' . strtoupper($Secure3DVar) . '=' . urlencode($Secure3DVal); |
|
458 | - } |
|
459 | - // Now that we have each chunk we need to go ahead and append them all together for our entire NVP string |
|
460 | - $NVPRequest = 'USER=' |
|
461 | - . $this->_username |
|
462 | - . '&PWD=' |
|
463 | - . $this->_password |
|
464 | - . '&VERSION=64.0' |
|
465 | - . '&SIGNATURE=' |
|
466 | - . $this->_signature |
|
467 | - . $DPFieldsNVP |
|
468 | - . $CCDetailsNVP |
|
469 | - . $PayerInfoNVP |
|
470 | - . $PayerNameNVP |
|
471 | - . $BillingAddressNVP |
|
472 | - . $PaymentDetailsNVP |
|
473 | - . $OrderItemsNVP |
|
474 | - . $ShippingAddressNVP |
|
475 | - . $Secure3DNVP; |
|
476 | - $NVPResponse = $this->_CURLRequest($NVPRequest); |
|
477 | - $NVPRequestArray = $this->_NVPToArray($NVPRequest); |
|
478 | - $NVPResponseArray = $this->_NVPToArray($NVPResponse); |
|
479 | - $Errors = $this->_GetErrors($NVPResponseArray); |
|
480 | - $NVPResponseArray['ERRORS'] = $Errors; |
|
481 | - $NVPResponseArray['REQUESTDATA'] = $NVPRequestArray; |
|
482 | - $NVPResponseArray['RAWREQUEST'] = $NVPRequest; |
|
483 | - $NVPResponseArray['RAWRESPONSE'] = $NVPResponse; |
|
484 | - return $NVPResponseArray; |
|
485 | - } |
|
486 | - |
|
487 | - |
|
488 | - |
|
489 | - /** |
|
490 | - * @param $Request |
|
491 | - * @return mixed |
|
492 | - */ |
|
493 | - private function _CURLRequest($Request) |
|
494 | - { |
|
495 | - $EndPointURL = $this->_debug_mode ? 'https://api-3t.sandbox.paypal.com/nvp' : 'https://api-3t.paypal.com/nvp'; |
|
496 | - $curl = curl_init(); |
|
497 | - curl_setopt($curl, CURLOPT_VERBOSE, apply_filters('FHEE__EEG_Paypal_Pro__CurlRequest__CURLOPT_VERBOSE', true)); |
|
498 | - curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); |
|
499 | - curl_setopt($curl, CURLOPT_TIMEOUT, 60); |
|
500 | - curl_setopt($curl, CURLOPT_URL, $EndPointURL); |
|
501 | - curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); |
|
502 | - curl_setopt($curl, CURLOPT_POSTFIELDS, $Request); |
|
503 | - curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); |
|
504 | - //execute the curl POST |
|
505 | - $Response = curl_exec($curl); |
|
506 | - curl_close($curl); |
|
507 | - return $Response; |
|
508 | - } |
|
509 | - |
|
510 | - |
|
511 | - |
|
512 | - /** |
|
513 | - * @param $NVPString |
|
514 | - * @return array |
|
515 | - */ |
|
516 | - private function _NVPToArray($NVPString) |
|
517 | - { |
|
518 | - // prepare responses into array |
|
519 | - $proArray = array(); |
|
520 | - while (strlen($NVPString)) { |
|
521 | - // name |
|
522 | - $keypos = strpos($NVPString, '='); |
|
523 | - $keyval = substr($NVPString, 0, $keypos); |
|
524 | - // value |
|
525 | - $valuepos = strpos($NVPString, '&') ? strpos($NVPString, '&') : strlen($NVPString); |
|
526 | - $valval = substr($NVPString, $keypos + 1, $valuepos - $keypos - 1); |
|
527 | - // decoding the response |
|
528 | - $proArray[$keyval] = urldecode($valval); |
|
529 | - $NVPString = substr($NVPString, $valuepos + 1, strlen($NVPString)); |
|
530 | - } |
|
531 | - return $proArray; |
|
532 | - } |
|
533 | - |
|
534 | - |
|
535 | - |
|
536 | - /** |
|
537 | - * @param array $PayPalResult |
|
538 | - * @return bool |
|
539 | - */ |
|
540 | - private function _APICallSuccessful($PayPalResult) |
|
541 | - { |
|
542 | - $approved = false; |
|
543 | - // check main response message from PayPal |
|
544 | - if (isset($PayPalResult['ACK']) && ! empty($PayPalResult['ACK'])) { |
|
545 | - $ack = strtoupper($PayPalResult['ACK']); |
|
546 | - $approved = ($ack == 'SUCCESS' || $ack == 'SUCCESSWITHWARNING' || $ack == 'PARTIALSUCCESS') ? true : false; |
|
547 | - } |
|
548 | - return $approved; |
|
549 | - } |
|
550 | - |
|
551 | - |
|
552 | - |
|
553 | - /** |
|
554 | - * @param $DataArray |
|
555 | - * @return array |
|
556 | - */ |
|
557 | - private function _GetErrors($DataArray) |
|
558 | - { |
|
559 | - $Errors = array(); |
|
560 | - $n = 0; |
|
561 | - while (isset($DataArray['L_ERRORCODE' . $n . ''])) { |
|
562 | - $LErrorCode = isset($DataArray['L_ERRORCODE' . $n . '']) ? $DataArray['L_ERRORCODE' . $n . ''] : ''; |
|
563 | - $LShortMessage = isset($DataArray['L_SHORTMESSAGE' . $n . '']) |
|
564 | - ? $DataArray['L_SHORTMESSAGE' . $n . ''] |
|
565 | - : ''; |
|
566 | - $LLongMessage = isset($DataArray['L_LONGMESSAGE' . $n . '']) |
|
567 | - ? $DataArray['L_LONGMESSAGE' . $n . ''] |
|
568 | - : ''; |
|
569 | - $LSeverityCode = isset($DataArray['L_SEVERITYCODE' . $n . '']) |
|
570 | - ? $DataArray['L_SEVERITYCODE' . $n . ''] |
|
571 | - : ''; |
|
572 | - $CurrentItem = array( |
|
573 | - 'L_ERRORCODE' => $LErrorCode, |
|
574 | - 'L_SHORTMESSAGE' => $LShortMessage, |
|
575 | - 'L_LONGMESSAGE' => $LLongMessage, |
|
576 | - 'L_SEVERITYCODE' => $LSeverityCode, |
|
577 | - ); |
|
578 | - array_push($Errors, $CurrentItem); |
|
579 | - $n++; |
|
580 | - } |
|
581 | - return $Errors; |
|
582 | - } |
|
583 | - |
|
584 | - |
|
585 | - |
|
586 | - /** |
|
587 | - * nothing to see here... move along.... |
|
588 | - * |
|
589 | - * @access protected |
|
590 | - * @param $Errors |
|
591 | - * @return string |
|
592 | - */ |
|
593 | - private function _DisplayErrors($Errors) |
|
594 | - { |
|
595 | - $error = ''; |
|
596 | - foreach ($Errors as $ErrorVar => $ErrorVal) { |
|
597 | - $CurrentError = $Errors[$ErrorVar]; |
|
598 | - foreach ($CurrentError as $CurrentErrorVar => $CurrentErrorVal) { |
|
599 | - $CurrentVarName = ''; |
|
600 | - if ($CurrentErrorVar == 'L_ERRORCODE') { |
|
601 | - $CurrentVarName = 'Error Code'; |
|
602 | - } elseif ($CurrentErrorVar == 'L_SHORTMESSAGE') { |
|
603 | - $CurrentVarName = 'Short Message'; |
|
604 | - } elseif ($CurrentErrorVar == 'L_LONGMESSAGE') { |
|
605 | - $CurrentVarName = 'Long Message'; |
|
606 | - } elseif ($CurrentErrorVar == 'L_SEVERITYCODE') { |
|
607 | - $CurrentVarName = 'Severity Code'; |
|
608 | - } |
|
609 | - $error .= '<br />' . $CurrentVarName . ': ' . $CurrentErrorVal; |
|
610 | - } |
|
611 | - } |
|
612 | - return $error; |
|
613 | - } |
|
28 | + /** |
|
29 | + * @var $_paypal_api_username string |
|
30 | + */ |
|
31 | + protected $_username = null; |
|
32 | + |
|
33 | + /** |
|
34 | + * @var $_password string |
|
35 | + */ |
|
36 | + protected $_password = null; |
|
37 | + |
|
38 | + /** |
|
39 | + * @var $_signature string |
|
40 | + */ |
|
41 | + protected $_signature = null; |
|
42 | + |
|
43 | + /** |
|
44 | + * @var $_credit_card_types array with the keys for credit card types accepted on this account |
|
45 | + */ |
|
46 | + protected $_credit_card_types = null; |
|
47 | + |
|
48 | + protected $_currencies_supported = array( |
|
49 | + 'USD', |
|
50 | + 'GBP', |
|
51 | + 'CAD', |
|
52 | + 'AUD', |
|
53 | + 'BRL', |
|
54 | + 'CHF', |
|
55 | + 'CZK', |
|
56 | + 'DKK', |
|
57 | + 'EUR', |
|
58 | + 'HKD', |
|
59 | + 'HUF', |
|
60 | + 'ILS', |
|
61 | + 'JPY', |
|
62 | + 'MXN', |
|
63 | + 'MYR', |
|
64 | + 'NOK', |
|
65 | + 'NZD', |
|
66 | + 'PHP', |
|
67 | + 'PLN', |
|
68 | + 'SEK', |
|
69 | + 'SGD', |
|
70 | + 'THB', |
|
71 | + 'TRY', |
|
72 | + 'TWD', |
|
73 | + 'RUB', |
|
74 | + ); |
|
75 | + |
|
76 | + |
|
77 | + |
|
78 | + /** |
|
79 | + * @param EEI_Payment $payment |
|
80 | + * @param array $billing_info { |
|
81 | + * @type string $credit_card |
|
82 | + * @type string $credit_card_type |
|
83 | + * @type string $exp_month always 2 characters |
|
84 | + * @type string $exp_year always 4 characters |
|
85 | + * @type string $cvv |
|
86 | + * } |
|
87 | + * @see parent::do_direct_payment for more info |
|
88 | + * @return EE_Payment|EEI_Payment |
|
89 | + * @throws EE_Error |
|
90 | + */ |
|
91 | + public function do_direct_payment($payment, $billing_info = null) |
|
92 | + { |
|
93 | + $transaction = $payment->transaction(); |
|
94 | + if (! $transaction instanceof EEI_Transaction) { |
|
95 | + throw new EE_Error( |
|
96 | + esc_html__('No transaction for payment while paying with PayPal Pro.', 'event_espresso') |
|
97 | + ); |
|
98 | + } |
|
99 | + $primary_registrant = $transaction->primary_registration(); |
|
100 | + if (! $primary_registrant instanceof EEI_Registration) { |
|
101 | + throw new EE_Error( |
|
102 | + esc_html__( |
|
103 | + 'No primary registration on transaction while paying with PayPal Pro.', |
|
104 | + 'event_espresso' |
|
105 | + ) |
|
106 | + ); |
|
107 | + } |
|
108 | + $attendee = $primary_registrant->attendee(); |
|
109 | + if (! $attendee instanceof EEI_Attendee) { |
|
110 | + throw new EE_Error( |
|
111 | + esc_html__( |
|
112 | + 'No attendee on primary registration while paying with PayPal Pro.', |
|
113 | + 'event_espresso' |
|
114 | + ) |
|
115 | + ); |
|
116 | + } |
|
117 | + $order_description = substr($this->_format_order_description($payment), 0, 127); |
|
118 | + //charge for the full amount. Show itemized list |
|
119 | + if ($this->_can_easily_itemize_transaction_for($payment)) { |
|
120 | + $item_num = 1; |
|
121 | + $total_line_item = $transaction->total_line_item(); |
|
122 | + $order_items = array(); |
|
123 | + foreach ($total_line_item->get_items() as $line_item) { |
|
124 | + //ignore line items with a quantity of 0 |
|
125 | + if ($line_item->quantity() == 0) { |
|
126 | + continue; |
|
127 | + } |
|
128 | + $item = array( |
|
129 | + // Item Name. 127 char max. |
|
130 | + 'l_name' => substr( |
|
131 | + $this->_format_line_item_name($line_item, $payment), |
|
132 | + 0, |
|
133 | + 127 |
|
134 | + ), |
|
135 | + // Item description. 127 char max. |
|
136 | + 'l_desc' => substr( |
|
137 | + $this->_format_line_item_desc($line_item, $payment), |
|
138 | + 0, |
|
139 | + 127 |
|
140 | + ), |
|
141 | + // Cost of individual item. |
|
142 | + 'l_amt' => $line_item->unit_price(), |
|
143 | + // Item Number. 127 char max. |
|
144 | + 'l_number' => $item_num++, |
|
145 | + // Item quantity. Must be any positive integer. |
|
146 | + 'l_qty' => $line_item->quantity(), |
|
147 | + // Item's sales tax amount. |
|
148 | + 'l_taxamt' => '', |
|
149 | + // eBay auction number of item. |
|
150 | + 'l_ebayitemnumber' => '', |
|
151 | + // eBay transaction ID of purchased item. |
|
152 | + 'l_ebayitemauctiontxnid' => '', |
|
153 | + // eBay order ID for the item. |
|
154 | + 'l_ebayitemorderid' => '', |
|
155 | + ); |
|
156 | + // add to array of all items |
|
157 | + array_push($order_items, $item); |
|
158 | + } |
|
159 | + $item_amount = $total_line_item->get_items_total(); |
|
160 | + $tax_amount = $total_line_item->get_total_tax(); |
|
161 | + } else { |
|
162 | + $order_items = array(); |
|
163 | + $item_amount = $payment->amount(); |
|
164 | + $tax_amount = 0; |
|
165 | + array_push($order_items, array( |
|
166 | + // Item Name. 127 char max. |
|
167 | + 'l_name' => substr( |
|
168 | + $this->_format_partial_payment_line_item_name($payment), |
|
169 | + 0, |
|
170 | + 127 |
|
171 | + ), |
|
172 | + // Item description. 127 char max. |
|
173 | + 'l_desc' => substr( |
|
174 | + $this->_format_partial_payment_line_item_desc($payment), |
|
175 | + 0, |
|
176 | + 127 |
|
177 | + ), |
|
178 | + // Cost of individual item. |
|
179 | + 'l_amt' => $payment->amount(), |
|
180 | + // Item Number. 127 char max. |
|
181 | + 'l_number' => 1, |
|
182 | + // Item quantity. Must be any positive integer. |
|
183 | + 'l_qty' => 1, |
|
184 | + )); |
|
185 | + } |
|
186 | + // Populate data arrays with order data. |
|
187 | + $DPFields = array( |
|
188 | + // How you want to obtain payment ? |
|
189 | + // Authorization indicates the payment is a basic auth subject to settlement with Auth & Capture. |
|
190 | + // Sale indicates that this is a final sale for which you are requesting payment. Default is Sale. |
|
191 | + 'paymentaction' => 'Sale', |
|
192 | + // Required. IP address of the payer's browser. |
|
193 | + 'ipaddress' => $_SERVER['REMOTE_ADDR'], |
|
194 | + // Flag to determine whether you want the results returned by FMF. 1 or 0. Default is 0. |
|
195 | + 'returnfmfdetails' => '1', |
|
196 | + ); |
|
197 | + $CCDetails = array( |
|
198 | + // Required. Type of credit card. Visa, MasterCard, Discover, Amex, Maestro, Solo. |
|
199 | + // If Maestro or Solo, the currency code must be GBP. |
|
200 | + // In addition, either start date or issue number must be specified. |
|
201 | + 'creditcardtype' => $billing_info['credit_card_type'], |
|
202 | + // Required. Credit card number. No spaces or punctuation. |
|
203 | + 'acct' => $billing_info['credit_card'], |
|
204 | + // Required. Credit card expiration date. Format is MMYYYY |
|
205 | + 'expdate' => $billing_info['exp_month'] . $billing_info['exp_year'], |
|
206 | + // Requirements determined by your PayPal account settings. Security digits for credit card. |
|
207 | + 'cvv2' => $billing_info['cvv'], |
|
208 | + ); |
|
209 | + $PayerInfo = array( |
|
210 | + // Email address of payer. |
|
211 | + 'email' => $billing_info['email'], |
|
212 | + // Unique PayPal customer ID for payer. |
|
213 | + 'payerid' => '', |
|
214 | + // Status of payer. Values are verified or unverified |
|
215 | + 'payerstatus' => '', |
|
216 | + // Payer's business name. |
|
217 | + 'business' => '', |
|
218 | + ); |
|
219 | + $PayerName = array( |
|
220 | + // Payer's salutation. 20 char max. |
|
221 | + 'salutation' => '', |
|
222 | + // Payer's first name. 25 char max. |
|
223 | + 'firstname' => substr($billing_info['first_name'], 0, 25), |
|
224 | + // Payer's middle name. 25 char max. |
|
225 | + 'middlename' => '', |
|
226 | + // Payer's last name. 25 char max. |
|
227 | + 'lastname' => substr($billing_info['last_name'], 0, 25), |
|
228 | + // Payer's suffix. 12 char max. |
|
229 | + 'suffix' => '', |
|
230 | + ); |
|
231 | + $BillingAddress = array( |
|
232 | + // Required. First street address. |
|
233 | + 'street' => $billing_info['address'], |
|
234 | + // Second street address. |
|
235 | + 'street2' => $billing_info['address2'], |
|
236 | + // Required. Name of City. |
|
237 | + 'city' => $billing_info['city'], |
|
238 | + // Required. Name of State or Province. |
|
239 | + 'state' => substr($billing_info['state'], 0, 40), |
|
240 | + // Required. Country code. |
|
241 | + 'countrycode' => $billing_info['country'], |
|
242 | + // Required. Postal code of payer. |
|
243 | + 'zip' => $billing_info['zip'], |
|
244 | + ); |
|
245 | + //check if the registration info contains the needed fields for paypal pro |
|
246 | + //(see https://developer.paypal.com/docs/classic/api/merchant/DoDirectPayment_API_Operation_NVP/) |
|
247 | + if ($attendee->address() && $attendee->city() && $attendee->country_ID()) { |
|
248 | + $use_registration_address_info = true; |
|
249 | + } else { |
|
250 | + $use_registration_address_info = false; |
|
251 | + } |
|
252 | + //so if the attendee has enough data to fill out PayPal Pro's shipping info, use it. |
|
253 | + // If not, use the billing info again |
|
254 | + $ShippingAddress = array( |
|
255 | + 'shiptoname' => substr($use_registration_address_info |
|
256 | + ? $attendee->full_name() |
|
257 | + : $billing_info['first_name'] . ' ' . $billing_info['last_name'], 0, 32), |
|
258 | + 'shiptostreet' => substr($use_registration_address_info |
|
259 | + ? $attendee->address() |
|
260 | + : $billing_info['address'], 0, 100), |
|
261 | + 'shiptostreet2' => substr($use_registration_address_info |
|
262 | + ? $attendee->address2() : $billing_info['address2'], 0, 100), |
|
263 | + 'shiptocity' => substr($use_registration_address_info |
|
264 | + ? $attendee->city() |
|
265 | + : $billing_info['city'], 0, 40), |
|
266 | + 'state' => substr($use_registration_address_info |
|
267 | + ? $attendee->state_name() |
|
268 | + : $billing_info['state'], 0, 40), |
|
269 | + 'shiptocountry' => $use_registration_address_info |
|
270 | + ? $attendee->country_ID() |
|
271 | + : $billing_info['country'], |
|
272 | + 'shiptozip' => substr($use_registration_address_info |
|
273 | + ? $attendee->zip() |
|
274 | + : $billing_info['zip'], 0, 20), |
|
275 | + 'shiptophonenum' => substr($use_registration_address_info |
|
276 | + ? $attendee->phone() |
|
277 | + : $billing_info['phone'], 0, 20), |
|
278 | + ); |
|
279 | + $PaymentDetails = array( |
|
280 | + // Required. Total amount of order, including shipping, handling, and tax. |
|
281 | + 'amt' => $this->format_currency($payment->amount()), |
|
282 | + // Required. Three-letter currency code. Default is USD. |
|
283 | + 'currencycode' => $payment->currency_code(), |
|
284 | + // Required if you include itemized cart details. (L_AMTn, etc.) |
|
285 | + //Subtotal of items not including S&H, or tax. |
|
286 | + 'itemamt' => $this->format_currency($item_amount),// |
|
287 | + // Total shipping costs for the order. If you specify shippingamt, you must also specify itemamt. |
|
288 | + 'shippingamt' => '', |
|
289 | + // Total handling costs for the order. If you specify handlingamt, you must also specify itemamt. |
|
290 | + 'handlingamt' => '', |
|
291 | + // Required if you specify itemized cart tax details. |
|
292 | + // Sum of tax for all items on the order. Total sales tax. |
|
293 | + 'taxamt' => $this->format_currency($tax_amount), |
|
294 | + // Description of the order the customer is purchasing. 127 char max. |
|
295 | + 'desc' => $order_description, |
|
296 | + // Free-form field for your own use. 256 char max. |
|
297 | + 'custom' => $primary_registrant ? $primary_registrant->ID() : '', |
|
298 | + // Your own invoice or tracking number |
|
299 | + 'invnum' => wp_generate_password(12, false),//$transaction->ID(), |
|
300 | + // URL for receiving Instant Payment Notifications. This overrides what your profile is set to use. |
|
301 | + 'notifyurl' => '', |
|
302 | + 'buttonsource' => 'EventEspresso_SP',//EE will blow up if you change this |
|
303 | + ); |
|
304 | + // Wrap all data arrays into a single, "master" array which will be passed into the class function. |
|
305 | + $PayPalRequestData = array( |
|
306 | + 'DPFields' => $DPFields, |
|
307 | + 'CCDetails' => $CCDetails, |
|
308 | + 'PayerInfo' => $PayerInfo, |
|
309 | + 'PayerName' => $PayerName, |
|
310 | + 'BillingAddress' => $BillingAddress, |
|
311 | + 'ShippingAddress' => $ShippingAddress, |
|
312 | + 'PaymentDetails' => $PaymentDetails, |
|
313 | + 'OrderItems' => $order_items, |
|
314 | + ); |
|
315 | + $this->_log_clean_request($PayPalRequestData, $payment); |
|
316 | + try { |
|
317 | + $PayPalResult = $this->prep_and_curl_request($PayPalRequestData); |
|
318 | + //remove PCI-sensitive data so it doesn't get stored |
|
319 | + $PayPalResult = $this->_log_clean_response($PayPalResult, $payment); |
|
320 | + $message = isset($PayPalResult['L_LONGMESSAGE0']) ? $PayPalResult['L_LONGMESSAGE0'] : $PayPalResult['ACK']; |
|
321 | + if (empty($PayPalResult['RAWRESPONSE'])) { |
|
322 | + $payment->set_status($this->_pay_model->failed_status()); |
|
323 | + $payment->set_gateway_response(__('No response received from Paypal Pro', 'event_espresso')); |
|
324 | + $payment->set_details($PayPalResult); |
|
325 | + } else { |
|
326 | + if ($this->_APICallSuccessful($PayPalResult)) { |
|
327 | + $payment->set_status($this->_pay_model->approved_status()); |
|
328 | + } else { |
|
329 | + $payment->set_status($this->_pay_model->declined_status()); |
|
330 | + } |
|
331 | + //make sure we interpret the AMT as a float, not an international string |
|
332 | + // (where periods are thousand separators) |
|
333 | + $payment->set_amount(isset($PayPalResult['AMT']) ? floatval($PayPalResult['AMT']) : 0); |
|
334 | + $payment->set_gateway_response($message); |
|
335 | + $payment->set_txn_id_chq_nmbr(isset($PayPalResult['TRANSACTIONID']) |
|
336 | + ? $PayPalResult['TRANSACTIONID'] |
|
337 | + : null); |
|
338 | + $primary_registration_code = $primary_registrant instanceof EE_Registration |
|
339 | + ? $primary_registrant->reg_code() |
|
340 | + : ''; |
|
341 | + $payment->set_extra_accntng($primary_registration_code); |
|
342 | + $payment->set_details($PayPalResult); |
|
343 | + } |
|
344 | + } catch (Exception $e) { |
|
345 | + $payment->set_status($this->_pay_model->failed_status()); |
|
346 | + $payment->set_gateway_response($e->getMessage()); |
|
347 | + } |
|
348 | + //$payment->set_status( $this->_pay_model->declined_status() ); |
|
349 | + //$payment->set_gateway_response( '' ); |
|
350 | + return $payment; |
|
351 | + } |
|
352 | + |
|
353 | + |
|
354 | + |
|
355 | + /** |
|
356 | + * CLeans out sensitive CC data and then logs it, and returns the cleaned request |
|
357 | + * |
|
358 | + * @param array $request |
|
359 | + * @param EEI_Payment $payment |
|
360 | + * @return void |
|
361 | + */ |
|
362 | + private function _log_clean_request($request, $payment) |
|
363 | + { |
|
364 | + $cleaned_request_data = $request; |
|
365 | + unset($cleaned_request_data['CCDetails']['acct']); |
|
366 | + unset($cleaned_request_data['CCDetails']['cvv2']); |
|
367 | + unset($cleaned_request_data['CCDetails']['expdate']); |
|
368 | + $this->log(array('Paypal Request' => $cleaned_request_data), $payment); |
|
369 | + } |
|
370 | + |
|
371 | + |
|
372 | + |
|
373 | + /** |
|
374 | + * Cleans the response, logs it, and returns it |
|
375 | + * |
|
376 | + * @param array $response |
|
377 | + * @param EEI_Payment $payment |
|
378 | + * @return array cleaned |
|
379 | + */ |
|
380 | + private function _log_clean_response($response, $payment) |
|
381 | + { |
|
382 | + unset($response['REQUESTDATA']['CREDITCARDTYPE']); |
|
383 | + unset($response['REQUESTDATA']['ACCT']); |
|
384 | + unset($response['REQUESTDATA']['EXPDATE']); |
|
385 | + unset($response['REQUESTDATA']['CVV2']); |
|
386 | + unset($response['RAWREQUEST']); |
|
387 | + $this->log(array('Paypal Response' => $response), $payment); |
|
388 | + return $response; |
|
389 | + } |
|
390 | + |
|
391 | + |
|
392 | + |
|
393 | + /** |
|
394 | + * @param $DataArray |
|
395 | + * @return array |
|
396 | + */ |
|
397 | + private function prep_and_curl_request($DataArray) |
|
398 | + { |
|
399 | + // Create empty holders for each portion of the NVP string |
|
400 | + $DPFieldsNVP = '&METHOD=DoDirectPayment&BUTTONSOURCE=AngellEYE_PHP_Class_DDP'; |
|
401 | + $CCDetailsNVP = ''; |
|
402 | + $PayerInfoNVP = ''; |
|
403 | + $PayerNameNVP = ''; |
|
404 | + $BillingAddressNVP = ''; |
|
405 | + $ShippingAddressNVP = ''; |
|
406 | + $PaymentDetailsNVP = ''; |
|
407 | + $OrderItemsNVP = ''; |
|
408 | + $Secure3DNVP = ''; |
|
409 | + // DP Fields |
|
410 | + $DPFields = isset($DataArray['DPFields']) ? $DataArray['DPFields'] : array(); |
|
411 | + foreach ($DPFields as $DPFieldsVar => $DPFieldsVal) { |
|
412 | + $DPFieldsNVP .= '&' . strtoupper($DPFieldsVar) . '=' . urlencode($DPFieldsVal); |
|
413 | + } |
|
414 | + // CC Details Fields |
|
415 | + $CCDetails = isset($DataArray['CCDetails']) ? $DataArray['CCDetails'] : array(); |
|
416 | + foreach ($CCDetails as $CCDetailsVar => $CCDetailsVal) { |
|
417 | + $CCDetailsNVP .= '&' . strtoupper($CCDetailsVar) . '=' . urlencode($CCDetailsVal); |
|
418 | + } |
|
419 | + // PayerInfo Type Fields |
|
420 | + $PayerInfo = isset($DataArray['PayerInfo']) ? $DataArray['PayerInfo'] : array(); |
|
421 | + foreach ($PayerInfo as $PayerInfoVar => $PayerInfoVal) { |
|
422 | + $PayerInfoNVP .= '&' . strtoupper($PayerInfoVar) . '=' . urlencode($PayerInfoVal); |
|
423 | + } |
|
424 | + // Payer Name Fields |
|
425 | + $PayerName = isset($DataArray['PayerName']) ? $DataArray['PayerName'] : array(); |
|
426 | + foreach ($PayerName as $PayerNameVar => $PayerNameVal) { |
|
427 | + $PayerNameNVP .= '&' . strtoupper($PayerNameVar) . '=' . urlencode($PayerNameVal); |
|
428 | + } |
|
429 | + // Address Fields (Billing) |
|
430 | + $BillingAddress = isset($DataArray['BillingAddress']) ? $DataArray['BillingAddress'] : array(); |
|
431 | + foreach ($BillingAddress as $BillingAddressVar => $BillingAddressVal) { |
|
432 | + $BillingAddressNVP .= '&' . strtoupper($BillingAddressVar) . '=' . urlencode($BillingAddressVal); |
|
433 | + } |
|
434 | + // Payment Details Type Fields |
|
435 | + $PaymentDetails = isset($DataArray['PaymentDetails']) ? $DataArray['PaymentDetails'] : array(); |
|
436 | + foreach ($PaymentDetails as $PaymentDetailsVar => $PaymentDetailsVal) { |
|
437 | + $PaymentDetailsNVP .= '&' . strtoupper($PaymentDetailsVar) . '=' . urlencode($PaymentDetailsVal); |
|
438 | + } |
|
439 | + // Payment Details Item Type Fields |
|
440 | + $OrderItems = isset($DataArray['OrderItems']) ? $DataArray['OrderItems'] : array(); |
|
441 | + $n = 0; |
|
442 | + foreach ($OrderItems as $OrderItemsVar => $OrderItemsVal) { |
|
443 | + $CurrentItem = $OrderItems[$OrderItemsVar]; |
|
444 | + foreach ($CurrentItem as $CurrentItemVar => $CurrentItemVal) { |
|
445 | + $OrderItemsNVP .= '&' . strtoupper($CurrentItemVar) . $n . '=' . urlencode($CurrentItemVal); |
|
446 | + } |
|
447 | + $n++; |
|
448 | + } |
|
449 | + // Ship To Address Fields |
|
450 | + $ShippingAddress = isset($DataArray['ShippingAddress']) ? $DataArray['ShippingAddress'] : array(); |
|
451 | + foreach ($ShippingAddress as $ShippingAddressVar => $ShippingAddressVal) { |
|
452 | + $ShippingAddressNVP .= '&' . strtoupper($ShippingAddressVar) . '=' . urlencode($ShippingAddressVal); |
|
453 | + } |
|
454 | + // 3D Secure Fields |
|
455 | + $Secure3D = isset($DataArray['Secure3D']) ? $DataArray['Secure3D'] : array(); |
|
456 | + foreach ($Secure3D as $Secure3DVar => $Secure3DVal) { |
|
457 | + $Secure3DNVP .= '&' . strtoupper($Secure3DVar) . '=' . urlencode($Secure3DVal); |
|
458 | + } |
|
459 | + // Now that we have each chunk we need to go ahead and append them all together for our entire NVP string |
|
460 | + $NVPRequest = 'USER=' |
|
461 | + . $this->_username |
|
462 | + . '&PWD=' |
|
463 | + . $this->_password |
|
464 | + . '&VERSION=64.0' |
|
465 | + . '&SIGNATURE=' |
|
466 | + . $this->_signature |
|
467 | + . $DPFieldsNVP |
|
468 | + . $CCDetailsNVP |
|
469 | + . $PayerInfoNVP |
|
470 | + . $PayerNameNVP |
|
471 | + . $BillingAddressNVP |
|
472 | + . $PaymentDetailsNVP |
|
473 | + . $OrderItemsNVP |
|
474 | + . $ShippingAddressNVP |
|
475 | + . $Secure3DNVP; |
|
476 | + $NVPResponse = $this->_CURLRequest($NVPRequest); |
|
477 | + $NVPRequestArray = $this->_NVPToArray($NVPRequest); |
|
478 | + $NVPResponseArray = $this->_NVPToArray($NVPResponse); |
|
479 | + $Errors = $this->_GetErrors($NVPResponseArray); |
|
480 | + $NVPResponseArray['ERRORS'] = $Errors; |
|
481 | + $NVPResponseArray['REQUESTDATA'] = $NVPRequestArray; |
|
482 | + $NVPResponseArray['RAWREQUEST'] = $NVPRequest; |
|
483 | + $NVPResponseArray['RAWRESPONSE'] = $NVPResponse; |
|
484 | + return $NVPResponseArray; |
|
485 | + } |
|
486 | + |
|
487 | + |
|
488 | + |
|
489 | + /** |
|
490 | + * @param $Request |
|
491 | + * @return mixed |
|
492 | + */ |
|
493 | + private function _CURLRequest($Request) |
|
494 | + { |
|
495 | + $EndPointURL = $this->_debug_mode ? 'https://api-3t.sandbox.paypal.com/nvp' : 'https://api-3t.paypal.com/nvp'; |
|
496 | + $curl = curl_init(); |
|
497 | + curl_setopt($curl, CURLOPT_VERBOSE, apply_filters('FHEE__EEG_Paypal_Pro__CurlRequest__CURLOPT_VERBOSE', true)); |
|
498 | + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); |
|
499 | + curl_setopt($curl, CURLOPT_TIMEOUT, 60); |
|
500 | + curl_setopt($curl, CURLOPT_URL, $EndPointURL); |
|
501 | + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); |
|
502 | + curl_setopt($curl, CURLOPT_POSTFIELDS, $Request); |
|
503 | + curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); |
|
504 | + //execute the curl POST |
|
505 | + $Response = curl_exec($curl); |
|
506 | + curl_close($curl); |
|
507 | + return $Response; |
|
508 | + } |
|
509 | + |
|
510 | + |
|
511 | + |
|
512 | + /** |
|
513 | + * @param $NVPString |
|
514 | + * @return array |
|
515 | + */ |
|
516 | + private function _NVPToArray($NVPString) |
|
517 | + { |
|
518 | + // prepare responses into array |
|
519 | + $proArray = array(); |
|
520 | + while (strlen($NVPString)) { |
|
521 | + // name |
|
522 | + $keypos = strpos($NVPString, '='); |
|
523 | + $keyval = substr($NVPString, 0, $keypos); |
|
524 | + // value |
|
525 | + $valuepos = strpos($NVPString, '&') ? strpos($NVPString, '&') : strlen($NVPString); |
|
526 | + $valval = substr($NVPString, $keypos + 1, $valuepos - $keypos - 1); |
|
527 | + // decoding the response |
|
528 | + $proArray[$keyval] = urldecode($valval); |
|
529 | + $NVPString = substr($NVPString, $valuepos + 1, strlen($NVPString)); |
|
530 | + } |
|
531 | + return $proArray; |
|
532 | + } |
|
533 | + |
|
534 | + |
|
535 | + |
|
536 | + /** |
|
537 | + * @param array $PayPalResult |
|
538 | + * @return bool |
|
539 | + */ |
|
540 | + private function _APICallSuccessful($PayPalResult) |
|
541 | + { |
|
542 | + $approved = false; |
|
543 | + // check main response message from PayPal |
|
544 | + if (isset($PayPalResult['ACK']) && ! empty($PayPalResult['ACK'])) { |
|
545 | + $ack = strtoupper($PayPalResult['ACK']); |
|
546 | + $approved = ($ack == 'SUCCESS' || $ack == 'SUCCESSWITHWARNING' || $ack == 'PARTIALSUCCESS') ? true : false; |
|
547 | + } |
|
548 | + return $approved; |
|
549 | + } |
|
550 | + |
|
551 | + |
|
552 | + |
|
553 | + /** |
|
554 | + * @param $DataArray |
|
555 | + * @return array |
|
556 | + */ |
|
557 | + private function _GetErrors($DataArray) |
|
558 | + { |
|
559 | + $Errors = array(); |
|
560 | + $n = 0; |
|
561 | + while (isset($DataArray['L_ERRORCODE' . $n . ''])) { |
|
562 | + $LErrorCode = isset($DataArray['L_ERRORCODE' . $n . '']) ? $DataArray['L_ERRORCODE' . $n . ''] : ''; |
|
563 | + $LShortMessage = isset($DataArray['L_SHORTMESSAGE' . $n . '']) |
|
564 | + ? $DataArray['L_SHORTMESSAGE' . $n . ''] |
|
565 | + : ''; |
|
566 | + $LLongMessage = isset($DataArray['L_LONGMESSAGE' . $n . '']) |
|
567 | + ? $DataArray['L_LONGMESSAGE' . $n . ''] |
|
568 | + : ''; |
|
569 | + $LSeverityCode = isset($DataArray['L_SEVERITYCODE' . $n . '']) |
|
570 | + ? $DataArray['L_SEVERITYCODE' . $n . ''] |
|
571 | + : ''; |
|
572 | + $CurrentItem = array( |
|
573 | + 'L_ERRORCODE' => $LErrorCode, |
|
574 | + 'L_SHORTMESSAGE' => $LShortMessage, |
|
575 | + 'L_LONGMESSAGE' => $LLongMessage, |
|
576 | + 'L_SEVERITYCODE' => $LSeverityCode, |
|
577 | + ); |
|
578 | + array_push($Errors, $CurrentItem); |
|
579 | + $n++; |
|
580 | + } |
|
581 | + return $Errors; |
|
582 | + } |
|
583 | + |
|
584 | + |
|
585 | + |
|
586 | + /** |
|
587 | + * nothing to see here... move along.... |
|
588 | + * |
|
589 | + * @access protected |
|
590 | + * @param $Errors |
|
591 | + * @return string |
|
592 | + */ |
|
593 | + private function _DisplayErrors($Errors) |
|
594 | + { |
|
595 | + $error = ''; |
|
596 | + foreach ($Errors as $ErrorVar => $ErrorVal) { |
|
597 | + $CurrentError = $Errors[$ErrorVar]; |
|
598 | + foreach ($CurrentError as $CurrentErrorVar => $CurrentErrorVal) { |
|
599 | + $CurrentVarName = ''; |
|
600 | + if ($CurrentErrorVar == 'L_ERRORCODE') { |
|
601 | + $CurrentVarName = 'Error Code'; |
|
602 | + } elseif ($CurrentErrorVar == 'L_SHORTMESSAGE') { |
|
603 | + $CurrentVarName = 'Short Message'; |
|
604 | + } elseif ($CurrentErrorVar == 'L_LONGMESSAGE') { |
|
605 | + $CurrentVarName = 'Long Message'; |
|
606 | + } elseif ($CurrentErrorVar == 'L_SEVERITYCODE') { |
|
607 | + $CurrentVarName = 'Severity Code'; |
|
608 | + } |
|
609 | + $error .= '<br />' . $CurrentVarName . ': ' . $CurrentErrorVal; |
|
610 | + } |
|
611 | + } |
|
612 | + return $error; |
|
613 | + } |
|
614 | 614 | } |
615 | 615 | // End of file EEG_Paypal_Pro.gateway.php |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | 3 | exit('No direct script access allowed'); |
4 | 4 | } |
5 | 5 | |
@@ -91,13 +91,13 @@ discard block |
||
91 | 91 | public function do_direct_payment($payment, $billing_info = null) |
92 | 92 | { |
93 | 93 | $transaction = $payment->transaction(); |
94 | - if (! $transaction instanceof EEI_Transaction) { |
|
94 | + if ( ! $transaction instanceof EEI_Transaction) { |
|
95 | 95 | throw new EE_Error( |
96 | 96 | esc_html__('No transaction for payment while paying with PayPal Pro.', 'event_espresso') |
97 | 97 | ); |
98 | 98 | } |
99 | 99 | $primary_registrant = $transaction->primary_registration(); |
100 | - if (! $primary_registrant instanceof EEI_Registration) { |
|
100 | + if ( ! $primary_registrant instanceof EEI_Registration) { |
|
101 | 101 | throw new EE_Error( |
102 | 102 | esc_html__( |
103 | 103 | 'No primary registration on transaction while paying with PayPal Pro.', |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | ); |
107 | 107 | } |
108 | 108 | $attendee = $primary_registrant->attendee(); |
109 | - if (! $attendee instanceof EEI_Attendee) { |
|
109 | + if ( ! $attendee instanceof EEI_Attendee) { |
|
110 | 110 | throw new EE_Error( |
111 | 111 | esc_html__( |
112 | 112 | 'No attendee on primary registration while paying with PayPal Pro.', |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | // Required. Credit card number. No spaces or punctuation. |
203 | 203 | 'acct' => $billing_info['credit_card'], |
204 | 204 | // Required. Credit card expiration date. Format is MMYYYY |
205 | - 'expdate' => $billing_info['exp_month'] . $billing_info['exp_year'], |
|
205 | + 'expdate' => $billing_info['exp_month'].$billing_info['exp_year'], |
|
206 | 206 | // Requirements determined by your PayPal account settings. Security digits for credit card. |
207 | 207 | 'cvv2' => $billing_info['cvv'], |
208 | 208 | ); |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | $ShippingAddress = array( |
255 | 255 | 'shiptoname' => substr($use_registration_address_info |
256 | 256 | ? $attendee->full_name() |
257 | - : $billing_info['first_name'] . ' ' . $billing_info['last_name'], 0, 32), |
|
257 | + : $billing_info['first_name'].' '.$billing_info['last_name'], 0, 32), |
|
258 | 258 | 'shiptostreet' => substr($use_registration_address_info |
259 | 259 | ? $attendee->address() |
260 | 260 | : $billing_info['address'], 0, 100), |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | 'currencycode' => $payment->currency_code(), |
284 | 284 | // Required if you include itemized cart details. (L_AMTn, etc.) |
285 | 285 | //Subtotal of items not including S&H, or tax. |
286 | - 'itemamt' => $this->format_currency($item_amount),// |
|
286 | + 'itemamt' => $this->format_currency($item_amount), // |
|
287 | 287 | // Total shipping costs for the order. If you specify shippingamt, you must also specify itemamt. |
288 | 288 | 'shippingamt' => '', |
289 | 289 | // Total handling costs for the order. If you specify handlingamt, you must also specify itemamt. |
@@ -296,10 +296,10 @@ discard block |
||
296 | 296 | // Free-form field for your own use. 256 char max. |
297 | 297 | 'custom' => $primary_registrant ? $primary_registrant->ID() : '', |
298 | 298 | // Your own invoice or tracking number |
299 | - 'invnum' => wp_generate_password(12, false),//$transaction->ID(), |
|
299 | + 'invnum' => wp_generate_password(12, false), //$transaction->ID(), |
|
300 | 300 | // URL for receiving Instant Payment Notifications. This overrides what your profile is set to use. |
301 | 301 | 'notifyurl' => '', |
302 | - 'buttonsource' => 'EventEspresso_SP',//EE will blow up if you change this |
|
302 | + 'buttonsource' => 'EventEspresso_SP', //EE will blow up if you change this |
|
303 | 303 | ); |
304 | 304 | // Wrap all data arrays into a single, "master" array which will be passed into the class function. |
305 | 305 | $PayPalRequestData = array( |
@@ -409,32 +409,32 @@ discard block |
||
409 | 409 | // DP Fields |
410 | 410 | $DPFields = isset($DataArray['DPFields']) ? $DataArray['DPFields'] : array(); |
411 | 411 | foreach ($DPFields as $DPFieldsVar => $DPFieldsVal) { |
412 | - $DPFieldsNVP .= '&' . strtoupper($DPFieldsVar) . '=' . urlencode($DPFieldsVal); |
|
412 | + $DPFieldsNVP .= '&'.strtoupper($DPFieldsVar).'='.urlencode($DPFieldsVal); |
|
413 | 413 | } |
414 | 414 | // CC Details Fields |
415 | 415 | $CCDetails = isset($DataArray['CCDetails']) ? $DataArray['CCDetails'] : array(); |
416 | 416 | foreach ($CCDetails as $CCDetailsVar => $CCDetailsVal) { |
417 | - $CCDetailsNVP .= '&' . strtoupper($CCDetailsVar) . '=' . urlencode($CCDetailsVal); |
|
417 | + $CCDetailsNVP .= '&'.strtoupper($CCDetailsVar).'='.urlencode($CCDetailsVal); |
|
418 | 418 | } |
419 | 419 | // PayerInfo Type Fields |
420 | 420 | $PayerInfo = isset($DataArray['PayerInfo']) ? $DataArray['PayerInfo'] : array(); |
421 | 421 | foreach ($PayerInfo as $PayerInfoVar => $PayerInfoVal) { |
422 | - $PayerInfoNVP .= '&' . strtoupper($PayerInfoVar) . '=' . urlencode($PayerInfoVal); |
|
422 | + $PayerInfoNVP .= '&'.strtoupper($PayerInfoVar).'='.urlencode($PayerInfoVal); |
|
423 | 423 | } |
424 | 424 | // Payer Name Fields |
425 | 425 | $PayerName = isset($DataArray['PayerName']) ? $DataArray['PayerName'] : array(); |
426 | 426 | foreach ($PayerName as $PayerNameVar => $PayerNameVal) { |
427 | - $PayerNameNVP .= '&' . strtoupper($PayerNameVar) . '=' . urlencode($PayerNameVal); |
|
427 | + $PayerNameNVP .= '&'.strtoupper($PayerNameVar).'='.urlencode($PayerNameVal); |
|
428 | 428 | } |
429 | 429 | // Address Fields (Billing) |
430 | 430 | $BillingAddress = isset($DataArray['BillingAddress']) ? $DataArray['BillingAddress'] : array(); |
431 | 431 | foreach ($BillingAddress as $BillingAddressVar => $BillingAddressVal) { |
432 | - $BillingAddressNVP .= '&' . strtoupper($BillingAddressVar) . '=' . urlencode($BillingAddressVal); |
|
432 | + $BillingAddressNVP .= '&'.strtoupper($BillingAddressVar).'='.urlencode($BillingAddressVal); |
|
433 | 433 | } |
434 | 434 | // Payment Details Type Fields |
435 | 435 | $PaymentDetails = isset($DataArray['PaymentDetails']) ? $DataArray['PaymentDetails'] : array(); |
436 | 436 | foreach ($PaymentDetails as $PaymentDetailsVar => $PaymentDetailsVal) { |
437 | - $PaymentDetailsNVP .= '&' . strtoupper($PaymentDetailsVar) . '=' . urlencode($PaymentDetailsVal); |
|
437 | + $PaymentDetailsNVP .= '&'.strtoupper($PaymentDetailsVar).'='.urlencode($PaymentDetailsVal); |
|
438 | 438 | } |
439 | 439 | // Payment Details Item Type Fields |
440 | 440 | $OrderItems = isset($DataArray['OrderItems']) ? $DataArray['OrderItems'] : array(); |
@@ -442,19 +442,19 @@ discard block |
||
442 | 442 | foreach ($OrderItems as $OrderItemsVar => $OrderItemsVal) { |
443 | 443 | $CurrentItem = $OrderItems[$OrderItemsVar]; |
444 | 444 | foreach ($CurrentItem as $CurrentItemVar => $CurrentItemVal) { |
445 | - $OrderItemsNVP .= '&' . strtoupper($CurrentItemVar) . $n . '=' . urlencode($CurrentItemVal); |
|
445 | + $OrderItemsNVP .= '&'.strtoupper($CurrentItemVar).$n.'='.urlencode($CurrentItemVal); |
|
446 | 446 | } |
447 | 447 | $n++; |
448 | 448 | } |
449 | 449 | // Ship To Address Fields |
450 | 450 | $ShippingAddress = isset($DataArray['ShippingAddress']) ? $DataArray['ShippingAddress'] : array(); |
451 | 451 | foreach ($ShippingAddress as $ShippingAddressVar => $ShippingAddressVal) { |
452 | - $ShippingAddressNVP .= '&' . strtoupper($ShippingAddressVar) . '=' . urlencode($ShippingAddressVal); |
|
452 | + $ShippingAddressNVP .= '&'.strtoupper($ShippingAddressVar).'='.urlencode($ShippingAddressVal); |
|
453 | 453 | } |
454 | 454 | // 3D Secure Fields |
455 | 455 | $Secure3D = isset($DataArray['Secure3D']) ? $DataArray['Secure3D'] : array(); |
456 | 456 | foreach ($Secure3D as $Secure3DVar => $Secure3DVal) { |
457 | - $Secure3DNVP .= '&' . strtoupper($Secure3DVar) . '=' . urlencode($Secure3DVal); |
|
457 | + $Secure3DNVP .= '&'.strtoupper($Secure3DVar).'='.urlencode($Secure3DVal); |
|
458 | 458 | } |
459 | 459 | // Now that we have each chunk we need to go ahead and append them all together for our entire NVP string |
460 | 460 | $NVPRequest = 'USER=' |
@@ -558,16 +558,16 @@ discard block |
||
558 | 558 | { |
559 | 559 | $Errors = array(); |
560 | 560 | $n = 0; |
561 | - while (isset($DataArray['L_ERRORCODE' . $n . ''])) { |
|
562 | - $LErrorCode = isset($DataArray['L_ERRORCODE' . $n . '']) ? $DataArray['L_ERRORCODE' . $n . ''] : ''; |
|
563 | - $LShortMessage = isset($DataArray['L_SHORTMESSAGE' . $n . '']) |
|
564 | - ? $DataArray['L_SHORTMESSAGE' . $n . ''] |
|
561 | + while (isset($DataArray['L_ERRORCODE'.$n.''])) { |
|
562 | + $LErrorCode = isset($DataArray['L_ERRORCODE'.$n.'']) ? $DataArray['L_ERRORCODE'.$n.''] : ''; |
|
563 | + $LShortMessage = isset($DataArray['L_SHORTMESSAGE'.$n.'']) |
|
564 | + ? $DataArray['L_SHORTMESSAGE'.$n.''] |
|
565 | 565 | : ''; |
566 | - $LLongMessage = isset($DataArray['L_LONGMESSAGE' . $n . '']) |
|
567 | - ? $DataArray['L_LONGMESSAGE' . $n . ''] |
|
566 | + $LLongMessage = isset($DataArray['L_LONGMESSAGE'.$n.'']) |
|
567 | + ? $DataArray['L_LONGMESSAGE'.$n.''] |
|
568 | 568 | : ''; |
569 | - $LSeverityCode = isset($DataArray['L_SEVERITYCODE' . $n . '']) |
|
570 | - ? $DataArray['L_SEVERITYCODE' . $n . ''] |
|
569 | + $LSeverityCode = isset($DataArray['L_SEVERITYCODE'.$n.'']) |
|
570 | + ? $DataArray['L_SEVERITYCODE'.$n.''] |
|
571 | 571 | : ''; |
572 | 572 | $CurrentItem = array( |
573 | 573 | 'L_ERRORCODE' => $LErrorCode, |
@@ -606,7 +606,7 @@ discard block |
||
606 | 606 | } elseif ($CurrentErrorVar == 'L_SEVERITYCODE') { |
607 | 607 | $CurrentVarName = 'Severity Code'; |
608 | 608 | } |
609 | - $error .= '<br />' . $CurrentVarName . ': ' . $CurrentErrorVal; |
|
609 | + $error .= '<br />'.$CurrentVarName.': '.$CurrentErrorVal; |
|
610 | 610 | } |
611 | 611 | } |
612 | 612 | return $error; |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * @param EE_Line_Item $line_item |
78 | 78 | * @param array $options |
79 | 79 | * @param EE_Line_Item $parent_line_item |
80 | - * @return mixed |
|
80 | + * @return string |
|
81 | 81 | * @throws EE_Error |
82 | 82 | */ |
83 | 83 | public function display_line_item( |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | * _event_row - basically a Heading row displayed once above each event's ticket rows |
224 | 224 | * |
225 | 225 | * @param EE_Line_Item $line_item |
226 | - * @return mixed |
|
226 | + * @return string |
|
227 | 227 | */ |
228 | 228 | private function _event_row(EE_Line_Item $line_item) |
229 | 229 | { |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | * |
250 | 250 | * @param EE_Line_Item $line_item |
251 | 251 | * @param array $options |
252 | - * @return mixed |
|
252 | + * @return string |
|
253 | 253 | * @throws EE_Error |
254 | 254 | */ |
255 | 255 | private function _ticket_row(EE_Line_Item $line_item, $options = array()) |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | * |
304 | 304 | * @param EE_Line_Item $line_item |
305 | 305 | * @param array $options |
306 | - * @return mixed |
|
306 | + * @return string |
|
307 | 307 | * @throws EE_Error |
308 | 308 | */ |
309 | 309 | private function _item_row(EE_Line_Item $line_item, $options = array()) |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | * @param EE_Line_Item $line_item |
364 | 364 | * @param array $options |
365 | 365 | * @param EE_Line_Item $parent_line_item |
366 | - * @return mixed |
|
366 | + * @return string |
|
367 | 367 | * @throws EE_Error |
368 | 368 | */ |
369 | 369 | private function _sub_item_row(EE_Line_Item $line_item, $options = array(), EE_Line_Item $parent_line_item = null) |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | * |
408 | 408 | * @param EE_Line_Item $line_item |
409 | 409 | * @param array $options |
410 | - * @return mixed |
|
410 | + * @return string |
|
411 | 411 | * @throws EE_Error |
412 | 412 | */ |
413 | 413 | private function _tax_row(EE_Line_Item $line_item, $options = array()) |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | * |
445 | 445 | * @param EE_Line_Item $line_item |
446 | 446 | * @param string $text |
447 | - * @return mixed |
|
447 | + * @return string |
|
448 | 448 | * @throws EE_Error |
449 | 449 | */ |
450 | 450 | private function _total_tax_row(EE_Line_Item $line_item, $text = '') |
@@ -483,7 +483,7 @@ discard block |
||
483 | 483 | * @param EE_Line_Item $line_item |
484 | 484 | * @param string $text |
485 | 485 | * @param array $options |
486 | - * @return mixed |
|
486 | + * @return string |
|
487 | 487 | * @throws EE_Error |
488 | 488 | */ |
489 | 489 | private function _sub_total_row(EE_Line_Item $line_item, $text = '', $options = array()) |
@@ -519,7 +519,7 @@ discard block |
||
519 | 519 | * |
520 | 520 | * @param EE_Line_Item $line_item |
521 | 521 | * @param string $text |
522 | - * @return mixed |
|
522 | + * @return string |
|
523 | 523 | * @throws EE_Error |
524 | 524 | */ |
525 | 525 | private function _total_row(EE_Line_Item $line_item, $text = '') |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | * |
547 | 547 | * @param EE_Line_Item $line_item |
548 | 548 | * @param array $options |
549 | - * @return mixed |
|
549 | + * @return string |
|
550 | 550 | * @throws EE_Error |
551 | 551 | */ |
552 | 552 | private function _payments_and_amount_owing_rows(EE_Line_Item $line_item, $options = array()) |
@@ -16,609 +16,609 @@ |
||
16 | 16 | class EE_SPCO_Line_Item_Display_Strategy implements EEI_Line_Item_Display |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * array of events |
|
21 | - * |
|
22 | - * @type EE_Line_Item[] $_events |
|
23 | - */ |
|
24 | - private $_events = array(); |
|
25 | - |
|
26 | - /** |
|
27 | - * whether to display the taxes row or not |
|
28 | - * |
|
29 | - * @type bool $_show_taxes |
|
30 | - */ |
|
31 | - private $_show_taxes = false; |
|
32 | - |
|
33 | - /** |
|
34 | - * html for any tax rows |
|
35 | - * |
|
36 | - * @type string $_show_taxes |
|
37 | - */ |
|
38 | - private $_taxes_html = ''; |
|
39 | - |
|
40 | - /** |
|
41 | - * total amount including tax we can bill for at this time |
|
42 | - * |
|
43 | - * @type float $_grand_total |
|
44 | - */ |
|
45 | - private $_grand_total = 0.00; |
|
46 | - |
|
47 | - /** |
|
48 | - * total number of items being billed for |
|
49 | - * |
|
50 | - * @type int $_total_items |
|
51 | - */ |
|
52 | - private $_total_items = 0; |
|
53 | - |
|
54 | - |
|
55 | - |
|
56 | - /** |
|
57 | - * @return float |
|
58 | - */ |
|
59 | - public function grand_total() |
|
60 | - { |
|
61 | - return $this->_grand_total; |
|
62 | - } |
|
63 | - |
|
64 | - |
|
65 | - |
|
66 | - /** |
|
67 | - * @return int |
|
68 | - */ |
|
69 | - public function total_items() |
|
70 | - { |
|
71 | - return $this->_total_items; |
|
72 | - } |
|
73 | - |
|
74 | - |
|
75 | - |
|
76 | - /** |
|
77 | - * @param EE_Line_Item $line_item |
|
78 | - * @param array $options |
|
79 | - * @param EE_Line_Item $parent_line_item |
|
80 | - * @return mixed |
|
81 | - * @throws EE_Error |
|
82 | - */ |
|
83 | - public function display_line_item( |
|
84 | - EE_Line_Item $line_item, |
|
85 | - $options = array(), |
|
86 | - EE_Line_Item $parent_line_item = null |
|
87 | - ) { |
|
88 | - $html = ''; |
|
89 | - // set some default options and merge with incoming |
|
90 | - $default_options = array( |
|
91 | - 'show_desc' => true, // true false |
|
92 | - 'odd' => false, |
|
93 | - ); |
|
94 | - $options = array_merge($default_options, (array)$options); |
|
95 | - switch ($line_item->type()) { |
|
96 | - case EEM_Line_Item::type_line_item: |
|
97 | - $this->_show_taxes = $line_item->is_taxable() ? true : $this->_show_taxes; |
|
98 | - if ($line_item->OBJ_type() === 'Ticket') { |
|
99 | - // item row |
|
100 | - $html .= $this->_ticket_row($line_item, $options); |
|
101 | - } else { |
|
102 | - // item row |
|
103 | - $html .= $this->_item_row($line_item, $options); |
|
104 | - } |
|
105 | - if ( |
|
106 | - apply_filters( |
|
107 | - 'FHEE__EE_SPCO_Line_Item_Display_Strategy__display_line_item__display_sub_line_items', |
|
108 | - true |
|
109 | - ) |
|
110 | - ) { |
|
111 | - // got any kids? |
|
112 | - foreach ($line_item->children() as $child_line_item) { |
|
113 | - $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
114 | - } |
|
115 | - } |
|
116 | - break; |
|
117 | - case EEM_Line_Item::type_sub_line_item: |
|
118 | - $html .= $this->_sub_item_row($line_item, $options, $parent_line_item); |
|
119 | - break; |
|
120 | - case EEM_Line_Item::type_sub_total: |
|
121 | - static $sub_total = 0; |
|
122 | - $event_sub_total = 0; |
|
123 | - $text = esc_html__('Sub-Total', 'event_espresso'); |
|
124 | - if ($line_item->OBJ_type() === 'Event') { |
|
125 | - $options['event_id'] = $event_id = $line_item->OBJ_ID(); |
|
126 | - if (! isset($this->_events[$options['event_id']])) { |
|
127 | - $event = EEM_Event::instance()->get_one_by_ID($options['event_id']); |
|
128 | - // if event has default reg status of Not Approved, then don't display info on it |
|
129 | - if ( |
|
130 | - $event instanceof EE_Event |
|
131 | - && $event->default_registration_status() === EEM_Registration::status_id_not_approved |
|
132 | - ) { |
|
133 | - $display_event = false; |
|
134 | - // unless there are registrations for it that are returning to pay |
|
135 | - if (isset($options['registrations']) && is_array($options['registrations'])) { |
|
136 | - foreach ($options['registrations'] as $registration) { |
|
137 | - if (! $registration instanceof EE_Registration) { |
|
138 | - continue; |
|
139 | - } |
|
140 | - $display_event = $registration->event_ID() === $options['event_id'] |
|
141 | - && $registration->status_ID() !== EEM_Registration::status_id_not_approved |
|
142 | - ? true |
|
143 | - : $display_event; |
|
144 | - } |
|
145 | - } |
|
146 | - if (! $display_event) { |
|
147 | - return ''; |
|
148 | - } |
|
149 | - } |
|
150 | - $this->_events[$options['event_id']] = 0; |
|
151 | - $html .= $this->_event_row($line_item); |
|
152 | - $text = esc_html__('Event Sub-Total', 'event_espresso'); |
|
153 | - } |
|
154 | - } |
|
155 | - $child_line_items = $line_item->children(); |
|
156 | - // loop thru children |
|
157 | - foreach ($child_line_items as $child_line_item) { |
|
158 | - // recursively feed children back into this method |
|
159 | - $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
160 | - } |
|
161 | - $event_sub_total += isset($options['event_id']) ? $this->_events[$options['event_id']] : 0; |
|
162 | - $sub_total += $event_sub_total; |
|
163 | - if ( |
|
164 | - ( |
|
165 | - // event subtotals |
|
166 | - $line_item->code() !== 'pre-tax-subtotal' && count($child_line_items) > 1 |
|
167 | - ) |
|
168 | - || ( |
|
169 | - // pre-tax subtotals |
|
170 | - $line_item->code() === 'pre-tax-subtotal' && count($this->_events) > 1 |
|
171 | - ) |
|
172 | - ) { |
|
173 | - $options['sub_total'] = $line_item->OBJ_type() === 'Event' ? $event_sub_total : $sub_total; |
|
174 | - $html .= $this->_sub_total_row($line_item, $text, $options); |
|
175 | - } |
|
176 | - break; |
|
177 | - case EEM_Line_Item::type_tax: |
|
178 | - if ($this->_show_taxes) { |
|
179 | - $this->_taxes_html .= $this->_tax_row($line_item, $options); |
|
180 | - } |
|
181 | - break; |
|
182 | - case EEM_Line_Item::type_tax_sub_total: |
|
183 | - if ($this->_show_taxes) { |
|
184 | - $child_line_items = $line_item->children(); |
|
185 | - // loop thru children |
|
186 | - foreach ($child_line_items as $child_line_item) { |
|
187 | - // recursively feed children back into this method |
|
188 | - $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
189 | - } |
|
190 | - if (count($child_line_items) > 1) { |
|
191 | - $this->_taxes_html .= $this->_total_tax_row($line_item, esc_html__('Tax Total', 'event_espresso')); |
|
192 | - } |
|
193 | - } |
|
194 | - break; |
|
195 | - case EEM_Line_Item::type_total: |
|
196 | - // get all child line items |
|
197 | - $children = $line_item->children(); |
|
198 | - // loop thru all non-tax child line items |
|
199 | - foreach ($children as $child_line_item) { |
|
200 | - if ($child_line_item->type() !== EEM_Line_Item::type_tax_sub_total) { |
|
201 | - // recursively feed children back into this method |
|
202 | - $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
203 | - } |
|
204 | - } |
|
205 | - // now loop thru tax child line items |
|
206 | - foreach ($children as $child_line_item) { |
|
207 | - if ($child_line_item->type() === EEM_Line_Item::type_tax_sub_total) { |
|
208 | - // recursively feed children back into this method |
|
209 | - $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
210 | - } |
|
211 | - } |
|
212 | - $html .= $this->_taxes_html; |
|
213 | - $html .= $this->_total_row($line_item, esc_html__('Total', 'event_espresso')); |
|
214 | - $html .= $this->_payments_and_amount_owing_rows($line_item, $options); |
|
215 | - break; |
|
216 | - } |
|
217 | - return $html; |
|
218 | - } |
|
219 | - |
|
220 | - |
|
221 | - |
|
222 | - /** |
|
223 | - * _event_row - basically a Heading row displayed once above each event's ticket rows |
|
224 | - * |
|
225 | - * @param EE_Line_Item $line_item |
|
226 | - * @return mixed |
|
227 | - */ |
|
228 | - private function _event_row(EE_Line_Item $line_item) |
|
229 | - { |
|
230 | - // start of row |
|
231 | - $html = EEH_HTML::tr('', 'event-cart-total-row', 'total_tr odd'); |
|
232 | - // event name td |
|
233 | - $html .= EEH_HTML::td( |
|
234 | - EEH_HTML::strong($line_item->name()), |
|
235 | - '', |
|
236 | - 'event-header', |
|
237 | - '', |
|
238 | - ' colspan="4"' |
|
239 | - ); |
|
240 | - // end of row |
|
241 | - $html .= EEH_HTML::trx(); |
|
242 | - return $html; |
|
243 | - } |
|
244 | - |
|
245 | - |
|
246 | - |
|
247 | - /** |
|
248 | - * _ticket_row |
|
249 | - * |
|
250 | - * @param EE_Line_Item $line_item |
|
251 | - * @param array $options |
|
252 | - * @return mixed |
|
253 | - * @throws EE_Error |
|
254 | - */ |
|
255 | - private function _ticket_row(EE_Line_Item $line_item, $options = array()) |
|
256 | - { |
|
257 | - // start of row |
|
258 | - $row_class = $options['odd'] ? 'item odd' : 'item'; |
|
259 | - $html = EEH_HTML::tr('', '', $row_class); |
|
260 | - // name && desc |
|
261 | - $name_and_desc = apply_filters( |
|
262 | - 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name', |
|
263 | - $line_item->name(), |
|
264 | - $line_item |
|
265 | - ); |
|
266 | - $name_and_desc .= apply_filters( |
|
267 | - 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc', |
|
268 | - ( |
|
269 | - $options['show_desc'] |
|
270 | - ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' |
|
271 | - : '' |
|
272 | - ), |
|
273 | - $line_item, |
|
274 | - $options |
|
275 | - ); |
|
276 | - $name_and_desc .= $line_item->is_taxable() ? ' * ' : ''; |
|
277 | - // name td |
|
278 | - $html .= EEH_HTML::td( /*__FUNCTION__ .*/ |
|
279 | - $name_and_desc, '', 'item_l'); |
|
280 | - // price td |
|
281 | - $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
282 | - // quantity td |
|
283 | - $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght'); |
|
284 | - $this->_total_items += $line_item->quantity(); |
|
285 | - // determine total for line item |
|
286 | - $total = $line_item->total(); |
|
287 | - $this->_events[$options['event_id']] += $total; |
|
288 | - // total td |
|
289 | - $html .= EEH_HTML::td( |
|
290 | - EEH_Template::format_currency($total, false, false), |
|
291 | - '', |
|
292 | - 'item_r jst-rght' |
|
293 | - ); |
|
294 | - // end of row |
|
295 | - $html .= EEH_HTML::trx(); |
|
296 | - return $html; |
|
297 | - } |
|
298 | - |
|
299 | - |
|
300 | - |
|
301 | - /** |
|
302 | - * _item_row |
|
303 | - * |
|
304 | - * @param EE_Line_Item $line_item |
|
305 | - * @param array $options |
|
306 | - * @return mixed |
|
307 | - * @throws EE_Error |
|
308 | - */ |
|
309 | - private function _item_row(EE_Line_Item $line_item, $options = array()) |
|
310 | - { |
|
311 | - // start of row |
|
312 | - $row_class = $options['odd'] ? 'item odd' : 'item'; |
|
313 | - $html = EEH_HTML::tr('', '', $row_class); |
|
314 | - $obj_name = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n() . ': ' : ''; |
|
315 | - // name && desc |
|
316 | - $name_and_desc = apply_filters( |
|
317 | - 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name', |
|
318 | - $obj_name . $line_item->name(), |
|
319 | - $line_item |
|
320 | - ); |
|
321 | - $name_and_desc .= apply_filters( |
|
322 | - 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc', |
|
323 | - ( |
|
324 | - $options['show_desc'] |
|
325 | - ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' |
|
326 | - : '' |
|
327 | - ), |
|
328 | - $line_item, |
|
329 | - $options |
|
330 | - ); |
|
331 | - $name_and_desc .= $line_item->is_taxable() ? ' * ' : ''; |
|
332 | - // name td |
|
333 | - $html .= EEH_HTML::td($name_and_desc, '', 'item_l'); |
|
334 | - // price td |
|
335 | - if ($line_item->is_percent()) { |
|
336 | - $html .= EEH_HTML::td($line_item->percent() . '%', '', 'item_c jst-rght'); |
|
337 | - } else { |
|
338 | - $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
339 | - } |
|
340 | - // quantity td |
|
341 | - $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght'); |
|
342 | - //$total = $line_item->total() * $line_item->quantity(); |
|
343 | - $total = $line_item->total(); |
|
344 | - if (isset($options['event_id'], $this->_events[$options['event_id']])) { |
|
345 | - $this->_events[$options['event_id']] += $total; |
|
346 | - } |
|
347 | - // total td |
|
348 | - $html .= EEH_HTML::td( |
|
349 | - EEH_Template::format_currency($total, false, false), |
|
350 | - '', |
|
351 | - 'item_r jst-rght' |
|
352 | - ); |
|
353 | - // end of row |
|
354 | - $html .= EEH_HTML::trx(); |
|
355 | - return $html; |
|
356 | - } |
|
357 | - |
|
358 | - |
|
359 | - |
|
360 | - /** |
|
361 | - * _sub_item_row |
|
362 | - * |
|
363 | - * @param EE_Line_Item $line_item |
|
364 | - * @param array $options |
|
365 | - * @param EE_Line_Item $parent_line_item |
|
366 | - * @return mixed |
|
367 | - * @throws EE_Error |
|
368 | - */ |
|
369 | - private function _sub_item_row(EE_Line_Item $line_item, $options = array(), EE_Line_Item $parent_line_item = null) |
|
370 | - { |
|
371 | - // start of row |
|
372 | - $html = EEH_HTML::tr('', '', 'item sub-item-row'); |
|
373 | - // name && desc |
|
374 | - $name_and_desc = EEH_HTML::span('', '', 'sub-item-row-bullet dashicons dashicons-arrow-right') |
|
375 | - . $line_item->name(); |
|
376 | - $name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: ' |
|
377 | - . $line_item->desc() |
|
378 | - . '</span>' : ''; |
|
379 | - // name td |
|
380 | - $html .= EEH_HTML::td( $name_and_desc, '', 'item_l sub-item'); |
|
381 | - $qty = $parent_line_item instanceof EE_Line_Item ? $parent_line_item->quantity() : 1; |
|
382 | - // discount/surcharge td |
|
383 | - if ($line_item->is_percent()) { |
|
384 | - $html .= EEH_HTML::td( |
|
385 | - EEH_Template::format_currency( |
|
386 | - $line_item->total() / $qty, |
|
387 | - false, false |
|
388 | - ), |
|
389 | - '', 'item_c jst-rght' |
|
390 | - ); |
|
391 | - } else { |
|
392 | - $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
393 | - } |
|
394 | - // no quantity td |
|
395 | - $html .= EEH_HTML::td(); |
|
396 | - // no total td |
|
397 | - $html .= EEH_HTML::td(); |
|
398 | - // end of row |
|
399 | - $html .= EEH_HTML::trx(); |
|
400 | - return $html; |
|
401 | - } |
|
402 | - |
|
403 | - |
|
404 | - |
|
405 | - /** |
|
406 | - * _tax_row |
|
407 | - * |
|
408 | - * @param EE_Line_Item $line_item |
|
409 | - * @param array $options |
|
410 | - * @return mixed |
|
411 | - * @throws EE_Error |
|
412 | - */ |
|
413 | - private function _tax_row(EE_Line_Item $line_item, $options = array()) |
|
414 | - { |
|
415 | - // start of row |
|
416 | - $html = EEH_HTML::tr('', 'item sub-item tax-total'); |
|
417 | - // name && desc |
|
418 | - $name_and_desc = $line_item->name(); |
|
419 | - $name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">' |
|
420 | - . esc_html__(' * taxable items', 'event_espresso') . '</span>'; |
|
421 | - $name_and_desc .= $options['show_desc'] ? '<br/>' . $line_item->desc() : ''; |
|
422 | - // name td |
|
423 | - $html .= EEH_HTML::td( /*__FUNCTION__ .*/ |
|
424 | - $name_and_desc, '', 'item_l sub-item'); |
|
425 | - // percent td |
|
426 | - $html .= EEH_HTML::td($line_item->percent() . '%', '', ' jst-rght', ''); |
|
427 | - // empty td (price) |
|
428 | - $html .= EEH_HTML::td(EEH_HTML::nbsp()); |
|
429 | - // total td |
|
430 | - $html .= EEH_HTML::td(EEH_Template::format_currency( |
|
431 | - $line_item->total(), false, false), |
|
432 | - '', |
|
433 | - 'item_r jst-rght' |
|
434 | - ); |
|
435 | - // end of row |
|
436 | - $html .= EEH_HTML::trx(); |
|
437 | - return $html; |
|
438 | - } |
|
439 | - |
|
440 | - |
|
441 | - |
|
442 | - /** |
|
443 | - * _total_row |
|
444 | - * |
|
445 | - * @param EE_Line_Item $line_item |
|
446 | - * @param string $text |
|
447 | - * @return mixed |
|
448 | - * @throws EE_Error |
|
449 | - */ |
|
450 | - private function _total_tax_row(EE_Line_Item $line_item, $text = '') |
|
451 | - { |
|
452 | - $html = ''; |
|
453 | - if ($line_item->total()) { |
|
454 | - // start of row |
|
455 | - $html = EEH_HTML::tr('', '', 'total_tr odd'); |
|
456 | - // total td |
|
457 | - $html .= EEH_HTML::td( |
|
458 | - $text, |
|
459 | - '', |
|
460 | - 'total_currency total jst-rght', |
|
461 | - '', |
|
462 | - ' colspan="2"' |
|
463 | - ); |
|
464 | - // empty td (price) |
|
465 | - $html .= EEH_HTML::td(EEH_HTML::nbsp()); |
|
466 | - // total td |
|
467 | - $html .= EEH_HTML::td( |
|
468 | - EEH_Template::format_currency($line_item->total(), false, false), |
|
469 | - '', |
|
470 | - 'total jst-rght' |
|
471 | - ); |
|
472 | - // end of row |
|
473 | - $html .= EEH_HTML::trx(); |
|
474 | - } |
|
475 | - return $html; |
|
476 | - } |
|
477 | - |
|
478 | - |
|
479 | - |
|
480 | - /** |
|
481 | - * _total_row |
|
482 | - * |
|
483 | - * @param EE_Line_Item $line_item |
|
484 | - * @param string $text |
|
485 | - * @param array $options |
|
486 | - * @return mixed |
|
487 | - * @throws EE_Error |
|
488 | - */ |
|
489 | - private function _sub_total_row(EE_Line_Item $line_item, $text = '', $options = array()) |
|
490 | - { |
|
491 | - $html = ''; |
|
492 | - if ($line_item->total()) { |
|
493 | - // start of row |
|
494 | - $html = EEH_HTML::tr('', '', 'total_tr odd'); |
|
495 | - // total td |
|
496 | - $html .= EEH_HTML::td( |
|
497 | - $text, |
|
498 | - '', |
|
499 | - 'total_currency total jst-rght', |
|
500 | - '', |
|
501 | - ' colspan="3"' |
|
502 | - ); |
|
503 | - // total td |
|
504 | - $html .= EEH_HTML::td( |
|
505 | - EEH_Template::format_currency($options['sub_total'], false, false), |
|
506 | - '', |
|
507 | - 'total jst-rght' |
|
508 | - ); |
|
509 | - // end of row |
|
510 | - $html .= EEH_HTML::trx(); |
|
511 | - } |
|
512 | - return $html; |
|
513 | - } |
|
514 | - |
|
515 | - |
|
516 | - |
|
517 | - /** |
|
518 | - * _total_row |
|
519 | - * |
|
520 | - * @param EE_Line_Item $line_item |
|
521 | - * @param string $text |
|
522 | - * @return mixed |
|
523 | - * @throws EE_Error |
|
524 | - */ |
|
525 | - private function _total_row(EE_Line_Item $line_item, $text = '') |
|
526 | - { |
|
527 | - // start of row |
|
528 | - $html = EEH_HTML::tr('', '', 'spco-grand-total total_tr odd'); |
|
529 | - // total td |
|
530 | - $html .= EEH_HTML::td($text, '', 'total_currency total jst-rght', '', ' colspan="3"'); |
|
531 | - // total td |
|
532 | - $html .= EEH_HTML::td( |
|
533 | - EEH_Template::format_currency($line_item->total(), false, false), |
|
534 | - '', |
|
535 | - 'total jst-rght' |
|
536 | - ); |
|
537 | - // end of row |
|
538 | - $html .= EEH_HTML::trx(); |
|
539 | - return $html; |
|
540 | - } |
|
541 | - |
|
542 | - |
|
543 | - |
|
544 | - /** |
|
545 | - * _payments_and_amount_owing_rows |
|
546 | - * |
|
547 | - * @param EE_Line_Item $line_item |
|
548 | - * @param array $options |
|
549 | - * @return mixed |
|
550 | - * @throws EE_Error |
|
551 | - */ |
|
552 | - private function _payments_and_amount_owing_rows(EE_Line_Item $line_item, $options = array()) |
|
553 | - { |
|
554 | - $html = ''; |
|
555 | - $owing = $line_item->total(); |
|
556 | - $transaction = EEM_Transaction::instance()->get_one_by_ID($line_item->TXN_ID()); |
|
557 | - if ($transaction instanceof EE_Transaction) { |
|
558 | - $registration_payments = array(); |
|
559 | - $registrations = ! empty($options['registrations']) |
|
560 | - ? $options['registrations'] |
|
561 | - : $transaction->registrations(); |
|
562 | - foreach ($registrations as $registration) { |
|
563 | - if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) { |
|
564 | - $registration_payments += $registration->registration_payments(); |
|
565 | - } |
|
566 | - } |
|
567 | - if (! empty($registration_payments)) { |
|
568 | - foreach ($registration_payments as $registration_payment) { |
|
569 | - if ($registration_payment instanceof EE_Registration_Payment) { |
|
570 | - $owing -= $registration_payment->amount(); |
|
571 | - $payment = $registration_payment->payment(); |
|
572 | - $payment_desc = ''; |
|
573 | - if ($payment instanceof EE_Payment) { |
|
574 | - $payment_desc = sprintf( |
|
575 | - esc_html__('Payment%1$s Received: %2$s', 'event_espresso'), |
|
576 | - $payment->txn_id_chq_nmbr() !== '' |
|
577 | - ? ' <span class="small-text">(#' . $payment->txn_id_chq_nmbr() . ')</span> ' |
|
578 | - : '', |
|
579 | - $payment->timestamp() |
|
580 | - ); |
|
581 | - } |
|
582 | - // start of row |
|
583 | - $html .= EEH_HTML::tr('', '', 'total_tr odd'); |
|
584 | - // payment desc |
|
585 | - $html .= EEH_HTML::td($payment_desc, '', '', '', ' colspan="3"'); |
|
586 | - // total td |
|
587 | - $html .= EEH_HTML::td( |
|
588 | - EEH_Template::format_currency( |
|
589 | - $registration_payment->amount(), |
|
590 | - false, |
|
591 | - false |
|
592 | - ), |
|
593 | - '', |
|
594 | - 'total jst-rght' |
|
595 | - ); |
|
596 | - // end of row |
|
597 | - $html .= EEH_HTML::trx(); |
|
598 | - } |
|
599 | - } |
|
600 | - if ($line_item->total()) { |
|
601 | - // start of row |
|
602 | - $html .= EEH_HTML::tr('', '', 'total_tr odd'); |
|
603 | - // total td |
|
604 | - $html .= EEH_HTML::td( |
|
605 | - esc_html__('Amount Owing', 'event_espresso'), |
|
606 | - '', 'total_currency total jst-rght', '', ' colspan="3"' |
|
607 | - ); |
|
608 | - // total td |
|
609 | - $html .= EEH_HTML::td( |
|
610 | - EEH_Template::format_currency($owing, false, false), |
|
611 | - '', |
|
612 | - 'total jst-rght' |
|
613 | - ); |
|
614 | - // end of row |
|
615 | - $html .= EEH_HTML::trx(); |
|
616 | - } |
|
617 | - } |
|
618 | - } |
|
619 | - $this->_grand_total = $owing; |
|
620 | - return $html; |
|
621 | - } |
|
19 | + /** |
|
20 | + * array of events |
|
21 | + * |
|
22 | + * @type EE_Line_Item[] $_events |
|
23 | + */ |
|
24 | + private $_events = array(); |
|
25 | + |
|
26 | + /** |
|
27 | + * whether to display the taxes row or not |
|
28 | + * |
|
29 | + * @type bool $_show_taxes |
|
30 | + */ |
|
31 | + private $_show_taxes = false; |
|
32 | + |
|
33 | + /** |
|
34 | + * html for any tax rows |
|
35 | + * |
|
36 | + * @type string $_show_taxes |
|
37 | + */ |
|
38 | + private $_taxes_html = ''; |
|
39 | + |
|
40 | + /** |
|
41 | + * total amount including tax we can bill for at this time |
|
42 | + * |
|
43 | + * @type float $_grand_total |
|
44 | + */ |
|
45 | + private $_grand_total = 0.00; |
|
46 | + |
|
47 | + /** |
|
48 | + * total number of items being billed for |
|
49 | + * |
|
50 | + * @type int $_total_items |
|
51 | + */ |
|
52 | + private $_total_items = 0; |
|
53 | + |
|
54 | + |
|
55 | + |
|
56 | + /** |
|
57 | + * @return float |
|
58 | + */ |
|
59 | + public function grand_total() |
|
60 | + { |
|
61 | + return $this->_grand_total; |
|
62 | + } |
|
63 | + |
|
64 | + |
|
65 | + |
|
66 | + /** |
|
67 | + * @return int |
|
68 | + */ |
|
69 | + public function total_items() |
|
70 | + { |
|
71 | + return $this->_total_items; |
|
72 | + } |
|
73 | + |
|
74 | + |
|
75 | + |
|
76 | + /** |
|
77 | + * @param EE_Line_Item $line_item |
|
78 | + * @param array $options |
|
79 | + * @param EE_Line_Item $parent_line_item |
|
80 | + * @return mixed |
|
81 | + * @throws EE_Error |
|
82 | + */ |
|
83 | + public function display_line_item( |
|
84 | + EE_Line_Item $line_item, |
|
85 | + $options = array(), |
|
86 | + EE_Line_Item $parent_line_item = null |
|
87 | + ) { |
|
88 | + $html = ''; |
|
89 | + // set some default options and merge with incoming |
|
90 | + $default_options = array( |
|
91 | + 'show_desc' => true, // true false |
|
92 | + 'odd' => false, |
|
93 | + ); |
|
94 | + $options = array_merge($default_options, (array)$options); |
|
95 | + switch ($line_item->type()) { |
|
96 | + case EEM_Line_Item::type_line_item: |
|
97 | + $this->_show_taxes = $line_item->is_taxable() ? true : $this->_show_taxes; |
|
98 | + if ($line_item->OBJ_type() === 'Ticket') { |
|
99 | + // item row |
|
100 | + $html .= $this->_ticket_row($line_item, $options); |
|
101 | + } else { |
|
102 | + // item row |
|
103 | + $html .= $this->_item_row($line_item, $options); |
|
104 | + } |
|
105 | + if ( |
|
106 | + apply_filters( |
|
107 | + 'FHEE__EE_SPCO_Line_Item_Display_Strategy__display_line_item__display_sub_line_items', |
|
108 | + true |
|
109 | + ) |
|
110 | + ) { |
|
111 | + // got any kids? |
|
112 | + foreach ($line_item->children() as $child_line_item) { |
|
113 | + $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
114 | + } |
|
115 | + } |
|
116 | + break; |
|
117 | + case EEM_Line_Item::type_sub_line_item: |
|
118 | + $html .= $this->_sub_item_row($line_item, $options, $parent_line_item); |
|
119 | + break; |
|
120 | + case EEM_Line_Item::type_sub_total: |
|
121 | + static $sub_total = 0; |
|
122 | + $event_sub_total = 0; |
|
123 | + $text = esc_html__('Sub-Total', 'event_espresso'); |
|
124 | + if ($line_item->OBJ_type() === 'Event') { |
|
125 | + $options['event_id'] = $event_id = $line_item->OBJ_ID(); |
|
126 | + if (! isset($this->_events[$options['event_id']])) { |
|
127 | + $event = EEM_Event::instance()->get_one_by_ID($options['event_id']); |
|
128 | + // if event has default reg status of Not Approved, then don't display info on it |
|
129 | + if ( |
|
130 | + $event instanceof EE_Event |
|
131 | + && $event->default_registration_status() === EEM_Registration::status_id_not_approved |
|
132 | + ) { |
|
133 | + $display_event = false; |
|
134 | + // unless there are registrations for it that are returning to pay |
|
135 | + if (isset($options['registrations']) && is_array($options['registrations'])) { |
|
136 | + foreach ($options['registrations'] as $registration) { |
|
137 | + if (! $registration instanceof EE_Registration) { |
|
138 | + continue; |
|
139 | + } |
|
140 | + $display_event = $registration->event_ID() === $options['event_id'] |
|
141 | + && $registration->status_ID() !== EEM_Registration::status_id_not_approved |
|
142 | + ? true |
|
143 | + : $display_event; |
|
144 | + } |
|
145 | + } |
|
146 | + if (! $display_event) { |
|
147 | + return ''; |
|
148 | + } |
|
149 | + } |
|
150 | + $this->_events[$options['event_id']] = 0; |
|
151 | + $html .= $this->_event_row($line_item); |
|
152 | + $text = esc_html__('Event Sub-Total', 'event_espresso'); |
|
153 | + } |
|
154 | + } |
|
155 | + $child_line_items = $line_item->children(); |
|
156 | + // loop thru children |
|
157 | + foreach ($child_line_items as $child_line_item) { |
|
158 | + // recursively feed children back into this method |
|
159 | + $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
160 | + } |
|
161 | + $event_sub_total += isset($options['event_id']) ? $this->_events[$options['event_id']] : 0; |
|
162 | + $sub_total += $event_sub_total; |
|
163 | + if ( |
|
164 | + ( |
|
165 | + // event subtotals |
|
166 | + $line_item->code() !== 'pre-tax-subtotal' && count($child_line_items) > 1 |
|
167 | + ) |
|
168 | + || ( |
|
169 | + // pre-tax subtotals |
|
170 | + $line_item->code() === 'pre-tax-subtotal' && count($this->_events) > 1 |
|
171 | + ) |
|
172 | + ) { |
|
173 | + $options['sub_total'] = $line_item->OBJ_type() === 'Event' ? $event_sub_total : $sub_total; |
|
174 | + $html .= $this->_sub_total_row($line_item, $text, $options); |
|
175 | + } |
|
176 | + break; |
|
177 | + case EEM_Line_Item::type_tax: |
|
178 | + if ($this->_show_taxes) { |
|
179 | + $this->_taxes_html .= $this->_tax_row($line_item, $options); |
|
180 | + } |
|
181 | + break; |
|
182 | + case EEM_Line_Item::type_tax_sub_total: |
|
183 | + if ($this->_show_taxes) { |
|
184 | + $child_line_items = $line_item->children(); |
|
185 | + // loop thru children |
|
186 | + foreach ($child_line_items as $child_line_item) { |
|
187 | + // recursively feed children back into this method |
|
188 | + $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
189 | + } |
|
190 | + if (count($child_line_items) > 1) { |
|
191 | + $this->_taxes_html .= $this->_total_tax_row($line_item, esc_html__('Tax Total', 'event_espresso')); |
|
192 | + } |
|
193 | + } |
|
194 | + break; |
|
195 | + case EEM_Line_Item::type_total: |
|
196 | + // get all child line items |
|
197 | + $children = $line_item->children(); |
|
198 | + // loop thru all non-tax child line items |
|
199 | + foreach ($children as $child_line_item) { |
|
200 | + if ($child_line_item->type() !== EEM_Line_Item::type_tax_sub_total) { |
|
201 | + // recursively feed children back into this method |
|
202 | + $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
203 | + } |
|
204 | + } |
|
205 | + // now loop thru tax child line items |
|
206 | + foreach ($children as $child_line_item) { |
|
207 | + if ($child_line_item->type() === EEM_Line_Item::type_tax_sub_total) { |
|
208 | + // recursively feed children back into this method |
|
209 | + $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
210 | + } |
|
211 | + } |
|
212 | + $html .= $this->_taxes_html; |
|
213 | + $html .= $this->_total_row($line_item, esc_html__('Total', 'event_espresso')); |
|
214 | + $html .= $this->_payments_and_amount_owing_rows($line_item, $options); |
|
215 | + break; |
|
216 | + } |
|
217 | + return $html; |
|
218 | + } |
|
219 | + |
|
220 | + |
|
221 | + |
|
222 | + /** |
|
223 | + * _event_row - basically a Heading row displayed once above each event's ticket rows |
|
224 | + * |
|
225 | + * @param EE_Line_Item $line_item |
|
226 | + * @return mixed |
|
227 | + */ |
|
228 | + private function _event_row(EE_Line_Item $line_item) |
|
229 | + { |
|
230 | + // start of row |
|
231 | + $html = EEH_HTML::tr('', 'event-cart-total-row', 'total_tr odd'); |
|
232 | + // event name td |
|
233 | + $html .= EEH_HTML::td( |
|
234 | + EEH_HTML::strong($line_item->name()), |
|
235 | + '', |
|
236 | + 'event-header', |
|
237 | + '', |
|
238 | + ' colspan="4"' |
|
239 | + ); |
|
240 | + // end of row |
|
241 | + $html .= EEH_HTML::trx(); |
|
242 | + return $html; |
|
243 | + } |
|
244 | + |
|
245 | + |
|
246 | + |
|
247 | + /** |
|
248 | + * _ticket_row |
|
249 | + * |
|
250 | + * @param EE_Line_Item $line_item |
|
251 | + * @param array $options |
|
252 | + * @return mixed |
|
253 | + * @throws EE_Error |
|
254 | + */ |
|
255 | + private function _ticket_row(EE_Line_Item $line_item, $options = array()) |
|
256 | + { |
|
257 | + // start of row |
|
258 | + $row_class = $options['odd'] ? 'item odd' : 'item'; |
|
259 | + $html = EEH_HTML::tr('', '', $row_class); |
|
260 | + // name && desc |
|
261 | + $name_and_desc = apply_filters( |
|
262 | + 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name', |
|
263 | + $line_item->name(), |
|
264 | + $line_item |
|
265 | + ); |
|
266 | + $name_and_desc .= apply_filters( |
|
267 | + 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc', |
|
268 | + ( |
|
269 | + $options['show_desc'] |
|
270 | + ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' |
|
271 | + : '' |
|
272 | + ), |
|
273 | + $line_item, |
|
274 | + $options |
|
275 | + ); |
|
276 | + $name_and_desc .= $line_item->is_taxable() ? ' * ' : ''; |
|
277 | + // name td |
|
278 | + $html .= EEH_HTML::td( /*__FUNCTION__ .*/ |
|
279 | + $name_and_desc, '', 'item_l'); |
|
280 | + // price td |
|
281 | + $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
282 | + // quantity td |
|
283 | + $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght'); |
|
284 | + $this->_total_items += $line_item->quantity(); |
|
285 | + // determine total for line item |
|
286 | + $total = $line_item->total(); |
|
287 | + $this->_events[$options['event_id']] += $total; |
|
288 | + // total td |
|
289 | + $html .= EEH_HTML::td( |
|
290 | + EEH_Template::format_currency($total, false, false), |
|
291 | + '', |
|
292 | + 'item_r jst-rght' |
|
293 | + ); |
|
294 | + // end of row |
|
295 | + $html .= EEH_HTML::trx(); |
|
296 | + return $html; |
|
297 | + } |
|
298 | + |
|
299 | + |
|
300 | + |
|
301 | + /** |
|
302 | + * _item_row |
|
303 | + * |
|
304 | + * @param EE_Line_Item $line_item |
|
305 | + * @param array $options |
|
306 | + * @return mixed |
|
307 | + * @throws EE_Error |
|
308 | + */ |
|
309 | + private function _item_row(EE_Line_Item $line_item, $options = array()) |
|
310 | + { |
|
311 | + // start of row |
|
312 | + $row_class = $options['odd'] ? 'item odd' : 'item'; |
|
313 | + $html = EEH_HTML::tr('', '', $row_class); |
|
314 | + $obj_name = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n() . ': ' : ''; |
|
315 | + // name && desc |
|
316 | + $name_and_desc = apply_filters( |
|
317 | + 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name', |
|
318 | + $obj_name . $line_item->name(), |
|
319 | + $line_item |
|
320 | + ); |
|
321 | + $name_and_desc .= apply_filters( |
|
322 | + 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc', |
|
323 | + ( |
|
324 | + $options['show_desc'] |
|
325 | + ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' |
|
326 | + : '' |
|
327 | + ), |
|
328 | + $line_item, |
|
329 | + $options |
|
330 | + ); |
|
331 | + $name_and_desc .= $line_item->is_taxable() ? ' * ' : ''; |
|
332 | + // name td |
|
333 | + $html .= EEH_HTML::td($name_and_desc, '', 'item_l'); |
|
334 | + // price td |
|
335 | + if ($line_item->is_percent()) { |
|
336 | + $html .= EEH_HTML::td($line_item->percent() . '%', '', 'item_c jst-rght'); |
|
337 | + } else { |
|
338 | + $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
339 | + } |
|
340 | + // quantity td |
|
341 | + $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght'); |
|
342 | + //$total = $line_item->total() * $line_item->quantity(); |
|
343 | + $total = $line_item->total(); |
|
344 | + if (isset($options['event_id'], $this->_events[$options['event_id']])) { |
|
345 | + $this->_events[$options['event_id']] += $total; |
|
346 | + } |
|
347 | + // total td |
|
348 | + $html .= EEH_HTML::td( |
|
349 | + EEH_Template::format_currency($total, false, false), |
|
350 | + '', |
|
351 | + 'item_r jst-rght' |
|
352 | + ); |
|
353 | + // end of row |
|
354 | + $html .= EEH_HTML::trx(); |
|
355 | + return $html; |
|
356 | + } |
|
357 | + |
|
358 | + |
|
359 | + |
|
360 | + /** |
|
361 | + * _sub_item_row |
|
362 | + * |
|
363 | + * @param EE_Line_Item $line_item |
|
364 | + * @param array $options |
|
365 | + * @param EE_Line_Item $parent_line_item |
|
366 | + * @return mixed |
|
367 | + * @throws EE_Error |
|
368 | + */ |
|
369 | + private function _sub_item_row(EE_Line_Item $line_item, $options = array(), EE_Line_Item $parent_line_item = null) |
|
370 | + { |
|
371 | + // start of row |
|
372 | + $html = EEH_HTML::tr('', '', 'item sub-item-row'); |
|
373 | + // name && desc |
|
374 | + $name_and_desc = EEH_HTML::span('', '', 'sub-item-row-bullet dashicons dashicons-arrow-right') |
|
375 | + . $line_item->name(); |
|
376 | + $name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: ' |
|
377 | + . $line_item->desc() |
|
378 | + . '</span>' : ''; |
|
379 | + // name td |
|
380 | + $html .= EEH_HTML::td( $name_and_desc, '', 'item_l sub-item'); |
|
381 | + $qty = $parent_line_item instanceof EE_Line_Item ? $parent_line_item->quantity() : 1; |
|
382 | + // discount/surcharge td |
|
383 | + if ($line_item->is_percent()) { |
|
384 | + $html .= EEH_HTML::td( |
|
385 | + EEH_Template::format_currency( |
|
386 | + $line_item->total() / $qty, |
|
387 | + false, false |
|
388 | + ), |
|
389 | + '', 'item_c jst-rght' |
|
390 | + ); |
|
391 | + } else { |
|
392 | + $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
393 | + } |
|
394 | + // no quantity td |
|
395 | + $html .= EEH_HTML::td(); |
|
396 | + // no total td |
|
397 | + $html .= EEH_HTML::td(); |
|
398 | + // end of row |
|
399 | + $html .= EEH_HTML::trx(); |
|
400 | + return $html; |
|
401 | + } |
|
402 | + |
|
403 | + |
|
404 | + |
|
405 | + /** |
|
406 | + * _tax_row |
|
407 | + * |
|
408 | + * @param EE_Line_Item $line_item |
|
409 | + * @param array $options |
|
410 | + * @return mixed |
|
411 | + * @throws EE_Error |
|
412 | + */ |
|
413 | + private function _tax_row(EE_Line_Item $line_item, $options = array()) |
|
414 | + { |
|
415 | + // start of row |
|
416 | + $html = EEH_HTML::tr('', 'item sub-item tax-total'); |
|
417 | + // name && desc |
|
418 | + $name_and_desc = $line_item->name(); |
|
419 | + $name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">' |
|
420 | + . esc_html__(' * taxable items', 'event_espresso') . '</span>'; |
|
421 | + $name_and_desc .= $options['show_desc'] ? '<br/>' . $line_item->desc() : ''; |
|
422 | + // name td |
|
423 | + $html .= EEH_HTML::td( /*__FUNCTION__ .*/ |
|
424 | + $name_and_desc, '', 'item_l sub-item'); |
|
425 | + // percent td |
|
426 | + $html .= EEH_HTML::td($line_item->percent() . '%', '', ' jst-rght', ''); |
|
427 | + // empty td (price) |
|
428 | + $html .= EEH_HTML::td(EEH_HTML::nbsp()); |
|
429 | + // total td |
|
430 | + $html .= EEH_HTML::td(EEH_Template::format_currency( |
|
431 | + $line_item->total(), false, false), |
|
432 | + '', |
|
433 | + 'item_r jst-rght' |
|
434 | + ); |
|
435 | + // end of row |
|
436 | + $html .= EEH_HTML::trx(); |
|
437 | + return $html; |
|
438 | + } |
|
439 | + |
|
440 | + |
|
441 | + |
|
442 | + /** |
|
443 | + * _total_row |
|
444 | + * |
|
445 | + * @param EE_Line_Item $line_item |
|
446 | + * @param string $text |
|
447 | + * @return mixed |
|
448 | + * @throws EE_Error |
|
449 | + */ |
|
450 | + private function _total_tax_row(EE_Line_Item $line_item, $text = '') |
|
451 | + { |
|
452 | + $html = ''; |
|
453 | + if ($line_item->total()) { |
|
454 | + // start of row |
|
455 | + $html = EEH_HTML::tr('', '', 'total_tr odd'); |
|
456 | + // total td |
|
457 | + $html .= EEH_HTML::td( |
|
458 | + $text, |
|
459 | + '', |
|
460 | + 'total_currency total jst-rght', |
|
461 | + '', |
|
462 | + ' colspan="2"' |
|
463 | + ); |
|
464 | + // empty td (price) |
|
465 | + $html .= EEH_HTML::td(EEH_HTML::nbsp()); |
|
466 | + // total td |
|
467 | + $html .= EEH_HTML::td( |
|
468 | + EEH_Template::format_currency($line_item->total(), false, false), |
|
469 | + '', |
|
470 | + 'total jst-rght' |
|
471 | + ); |
|
472 | + // end of row |
|
473 | + $html .= EEH_HTML::trx(); |
|
474 | + } |
|
475 | + return $html; |
|
476 | + } |
|
477 | + |
|
478 | + |
|
479 | + |
|
480 | + /** |
|
481 | + * _total_row |
|
482 | + * |
|
483 | + * @param EE_Line_Item $line_item |
|
484 | + * @param string $text |
|
485 | + * @param array $options |
|
486 | + * @return mixed |
|
487 | + * @throws EE_Error |
|
488 | + */ |
|
489 | + private function _sub_total_row(EE_Line_Item $line_item, $text = '', $options = array()) |
|
490 | + { |
|
491 | + $html = ''; |
|
492 | + if ($line_item->total()) { |
|
493 | + // start of row |
|
494 | + $html = EEH_HTML::tr('', '', 'total_tr odd'); |
|
495 | + // total td |
|
496 | + $html .= EEH_HTML::td( |
|
497 | + $text, |
|
498 | + '', |
|
499 | + 'total_currency total jst-rght', |
|
500 | + '', |
|
501 | + ' colspan="3"' |
|
502 | + ); |
|
503 | + // total td |
|
504 | + $html .= EEH_HTML::td( |
|
505 | + EEH_Template::format_currency($options['sub_total'], false, false), |
|
506 | + '', |
|
507 | + 'total jst-rght' |
|
508 | + ); |
|
509 | + // end of row |
|
510 | + $html .= EEH_HTML::trx(); |
|
511 | + } |
|
512 | + return $html; |
|
513 | + } |
|
514 | + |
|
515 | + |
|
516 | + |
|
517 | + /** |
|
518 | + * _total_row |
|
519 | + * |
|
520 | + * @param EE_Line_Item $line_item |
|
521 | + * @param string $text |
|
522 | + * @return mixed |
|
523 | + * @throws EE_Error |
|
524 | + */ |
|
525 | + private function _total_row(EE_Line_Item $line_item, $text = '') |
|
526 | + { |
|
527 | + // start of row |
|
528 | + $html = EEH_HTML::tr('', '', 'spco-grand-total total_tr odd'); |
|
529 | + // total td |
|
530 | + $html .= EEH_HTML::td($text, '', 'total_currency total jst-rght', '', ' colspan="3"'); |
|
531 | + // total td |
|
532 | + $html .= EEH_HTML::td( |
|
533 | + EEH_Template::format_currency($line_item->total(), false, false), |
|
534 | + '', |
|
535 | + 'total jst-rght' |
|
536 | + ); |
|
537 | + // end of row |
|
538 | + $html .= EEH_HTML::trx(); |
|
539 | + return $html; |
|
540 | + } |
|
541 | + |
|
542 | + |
|
543 | + |
|
544 | + /** |
|
545 | + * _payments_and_amount_owing_rows |
|
546 | + * |
|
547 | + * @param EE_Line_Item $line_item |
|
548 | + * @param array $options |
|
549 | + * @return mixed |
|
550 | + * @throws EE_Error |
|
551 | + */ |
|
552 | + private function _payments_and_amount_owing_rows(EE_Line_Item $line_item, $options = array()) |
|
553 | + { |
|
554 | + $html = ''; |
|
555 | + $owing = $line_item->total(); |
|
556 | + $transaction = EEM_Transaction::instance()->get_one_by_ID($line_item->TXN_ID()); |
|
557 | + if ($transaction instanceof EE_Transaction) { |
|
558 | + $registration_payments = array(); |
|
559 | + $registrations = ! empty($options['registrations']) |
|
560 | + ? $options['registrations'] |
|
561 | + : $transaction->registrations(); |
|
562 | + foreach ($registrations as $registration) { |
|
563 | + if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) { |
|
564 | + $registration_payments += $registration->registration_payments(); |
|
565 | + } |
|
566 | + } |
|
567 | + if (! empty($registration_payments)) { |
|
568 | + foreach ($registration_payments as $registration_payment) { |
|
569 | + if ($registration_payment instanceof EE_Registration_Payment) { |
|
570 | + $owing -= $registration_payment->amount(); |
|
571 | + $payment = $registration_payment->payment(); |
|
572 | + $payment_desc = ''; |
|
573 | + if ($payment instanceof EE_Payment) { |
|
574 | + $payment_desc = sprintf( |
|
575 | + esc_html__('Payment%1$s Received: %2$s', 'event_espresso'), |
|
576 | + $payment->txn_id_chq_nmbr() !== '' |
|
577 | + ? ' <span class="small-text">(#' . $payment->txn_id_chq_nmbr() . ')</span> ' |
|
578 | + : '', |
|
579 | + $payment->timestamp() |
|
580 | + ); |
|
581 | + } |
|
582 | + // start of row |
|
583 | + $html .= EEH_HTML::tr('', '', 'total_tr odd'); |
|
584 | + // payment desc |
|
585 | + $html .= EEH_HTML::td($payment_desc, '', '', '', ' colspan="3"'); |
|
586 | + // total td |
|
587 | + $html .= EEH_HTML::td( |
|
588 | + EEH_Template::format_currency( |
|
589 | + $registration_payment->amount(), |
|
590 | + false, |
|
591 | + false |
|
592 | + ), |
|
593 | + '', |
|
594 | + 'total jst-rght' |
|
595 | + ); |
|
596 | + // end of row |
|
597 | + $html .= EEH_HTML::trx(); |
|
598 | + } |
|
599 | + } |
|
600 | + if ($line_item->total()) { |
|
601 | + // start of row |
|
602 | + $html .= EEH_HTML::tr('', '', 'total_tr odd'); |
|
603 | + // total td |
|
604 | + $html .= EEH_HTML::td( |
|
605 | + esc_html__('Amount Owing', 'event_espresso'), |
|
606 | + '', 'total_currency total jst-rght', '', ' colspan="3"' |
|
607 | + ); |
|
608 | + // total td |
|
609 | + $html .= EEH_HTML::td( |
|
610 | + EEH_Template::format_currency($owing, false, false), |
|
611 | + '', |
|
612 | + 'total jst-rght' |
|
613 | + ); |
|
614 | + // end of row |
|
615 | + $html .= EEH_HTML::trx(); |
|
616 | + } |
|
617 | + } |
|
618 | + } |
|
619 | + $this->_grand_total = $owing; |
|
620 | + return $html; |
|
621 | + } |
|
622 | 622 | |
623 | 623 | |
624 | 624 | } |
@@ -88,10 +88,10 @@ discard block |
||
88 | 88 | $html = ''; |
89 | 89 | // set some default options and merge with incoming |
90 | 90 | $default_options = array( |
91 | - 'show_desc' => true, // true false |
|
91 | + 'show_desc' => true, // true false |
|
92 | 92 | 'odd' => false, |
93 | 93 | ); |
94 | - $options = array_merge($default_options, (array)$options); |
|
94 | + $options = array_merge($default_options, (array) $options); |
|
95 | 95 | switch ($line_item->type()) { |
96 | 96 | case EEM_Line_Item::type_line_item: |
97 | 97 | $this->_show_taxes = $line_item->is_taxable() ? true : $this->_show_taxes; |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | $text = esc_html__('Sub-Total', 'event_espresso'); |
124 | 124 | if ($line_item->OBJ_type() === 'Event') { |
125 | 125 | $options['event_id'] = $event_id = $line_item->OBJ_ID(); |
126 | - if (! isset($this->_events[$options['event_id']])) { |
|
126 | + if ( ! isset($this->_events[$options['event_id']])) { |
|
127 | 127 | $event = EEM_Event::instance()->get_one_by_ID($options['event_id']); |
128 | 128 | // if event has default reg status of Not Approved, then don't display info on it |
129 | 129 | if ( |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | // unless there are registrations for it that are returning to pay |
135 | 135 | if (isset($options['registrations']) && is_array($options['registrations'])) { |
136 | 136 | foreach ($options['registrations'] as $registration) { |
137 | - if (! $registration instanceof EE_Registration) { |
|
137 | + if ( ! $registration instanceof EE_Registration) { |
|
138 | 138 | continue; |
139 | 139 | } |
140 | 140 | $display_event = $registration->event_ID() === $options['event_id'] |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | : $display_event; |
144 | 144 | } |
145 | 145 | } |
146 | - if (! $display_event) { |
|
146 | + if ( ! $display_event) { |
|
147 | 147 | return ''; |
148 | 148 | } |
149 | 149 | } |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc', |
268 | 268 | ( |
269 | 269 | $options['show_desc'] |
270 | - ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' |
|
270 | + ? '<span class="line-item-desc-spn smaller-text">: '.$line_item->desc().'</span>' |
|
271 | 271 | : '' |
272 | 272 | ), |
273 | 273 | $line_item, |
@@ -311,18 +311,18 @@ discard block |
||
311 | 311 | // start of row |
312 | 312 | $row_class = $options['odd'] ? 'item odd' : 'item'; |
313 | 313 | $html = EEH_HTML::tr('', '', $row_class); |
314 | - $obj_name = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n() . ': ' : ''; |
|
314 | + $obj_name = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n().': ' : ''; |
|
315 | 315 | // name && desc |
316 | 316 | $name_and_desc = apply_filters( |
317 | 317 | 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name', |
318 | - $obj_name . $line_item->name(), |
|
318 | + $obj_name.$line_item->name(), |
|
319 | 319 | $line_item |
320 | 320 | ); |
321 | 321 | $name_and_desc .= apply_filters( |
322 | 322 | 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc', |
323 | 323 | ( |
324 | 324 | $options['show_desc'] |
325 | - ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' |
|
325 | + ? '<span class="line-item-desc-spn smaller-text">: '.$line_item->desc().'</span>' |
|
326 | 326 | : '' |
327 | 327 | ), |
328 | 328 | $line_item, |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | $html .= EEH_HTML::td($name_and_desc, '', 'item_l'); |
334 | 334 | // price td |
335 | 335 | if ($line_item->is_percent()) { |
336 | - $html .= EEH_HTML::td($line_item->percent() . '%', '', 'item_c jst-rght'); |
|
336 | + $html .= EEH_HTML::td($line_item->percent().'%', '', 'item_c jst-rght'); |
|
337 | 337 | } else { |
338 | 338 | $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
339 | 339 | } |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | . $line_item->desc() |
378 | 378 | . '</span>' : ''; |
379 | 379 | // name td |
380 | - $html .= EEH_HTML::td( $name_and_desc, '', 'item_l sub-item'); |
|
380 | + $html .= EEH_HTML::td($name_and_desc, '', 'item_l sub-item'); |
|
381 | 381 | $qty = $parent_line_item instanceof EE_Line_Item ? $parent_line_item->quantity() : 1; |
382 | 382 | // discount/surcharge td |
383 | 383 | if ($line_item->is_percent()) { |
@@ -417,13 +417,13 @@ discard block |
||
417 | 417 | // name && desc |
418 | 418 | $name_and_desc = $line_item->name(); |
419 | 419 | $name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">' |
420 | - . esc_html__(' * taxable items', 'event_espresso') . '</span>'; |
|
421 | - $name_and_desc .= $options['show_desc'] ? '<br/>' . $line_item->desc() : ''; |
|
420 | + . esc_html__(' * taxable items', 'event_espresso').'</span>'; |
|
421 | + $name_and_desc .= $options['show_desc'] ? '<br/>'.$line_item->desc() : ''; |
|
422 | 422 | // name td |
423 | 423 | $html .= EEH_HTML::td( /*__FUNCTION__ .*/ |
424 | 424 | $name_and_desc, '', 'item_l sub-item'); |
425 | 425 | // percent td |
426 | - $html .= EEH_HTML::td($line_item->percent() . '%', '', ' jst-rght', ''); |
|
426 | + $html .= EEH_HTML::td($line_item->percent().'%', '', ' jst-rght', ''); |
|
427 | 427 | // empty td (price) |
428 | 428 | $html .= EEH_HTML::td(EEH_HTML::nbsp()); |
429 | 429 | // total td |
@@ -564,7 +564,7 @@ discard block |
||
564 | 564 | $registration_payments += $registration->registration_payments(); |
565 | 565 | } |
566 | 566 | } |
567 | - if (! empty($registration_payments)) { |
|
567 | + if ( ! empty($registration_payments)) { |
|
568 | 568 | foreach ($registration_payments as $registration_payment) { |
569 | 569 | if ($registration_payment instanceof EE_Registration_Payment) { |
570 | 570 | $owing -= $registration_payment->amount(); |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | $payment_desc = sprintf( |
575 | 575 | esc_html__('Payment%1$s Received: %2$s', 'event_espresso'), |
576 | 576 | $payment->txn_id_chq_nmbr() !== '' |
577 | - ? ' <span class="small-text">(#' . $payment->txn_id_chq_nmbr() . ')</span> ' |
|
577 | + ? ' <span class="small-text">(#'.$payment->txn_id_chq_nmbr().')</span> ' |
|
578 | 578 | : '', |
579 | 579 | $payment->timestamp() |
580 | 580 | ); |