@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | namespace EventEspresso\core\services\container; |
3 | 3 | |
4 | 4 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
5 | - exit('No direct script access allowed'); |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -24,26 +24,26 @@ discard block |
||
24 | 24 | class LoadOnlyCoffeeMaker extends CoffeeMaker |
25 | 25 | { |
26 | 26 | |
27 | - /** |
|
28 | - * @return string |
|
29 | - */ |
|
30 | - public function type() |
|
31 | - { |
|
32 | - return CoffeeMaker::BREW_LOAD_ONLY; |
|
33 | - } |
|
34 | - |
|
35 | - |
|
36 | - |
|
37 | - /** |
|
38 | - * @param RecipeInterface $recipe |
|
39 | - * @param array $arguments |
|
40 | - * @return mixed |
|
41 | - */ |
|
42 | - public function brew(RecipeInterface $recipe, $arguments = array()) |
|
43 | - { |
|
44 | - $this->resolveClassAndFilepath($recipe); |
|
45 | - return null; |
|
46 | - } |
|
27 | + /** |
|
28 | + * @return string |
|
29 | + */ |
|
30 | + public function type() |
|
31 | + { |
|
32 | + return CoffeeMaker::BREW_LOAD_ONLY; |
|
33 | + } |
|
34 | + |
|
35 | + |
|
36 | + |
|
37 | + /** |
|
38 | + * @param RecipeInterface $recipe |
|
39 | + * @param array $arguments |
|
40 | + * @return mixed |
|
41 | + */ |
|
42 | + public function brew(RecipeInterface $recipe, $arguments = array()) |
|
43 | + { |
|
44 | + $this->resolveClassAndFilepath($recipe); |
|
45 | + return null; |
|
46 | + } |
|
47 | 47 | |
48 | 48 | |
49 | 49 |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | use BadMethodCallException; |
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 | |
@@ -20,27 +20,27 @@ discard block |
||
20 | 20 | class InstantiationException extends BadMethodCallException |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * InstantiationException constructor. |
|
25 | - * |
|
26 | - * @param string $identifier the name of the requested entity or service |
|
27 | - * @param string $message |
|
28 | - * @param int $code |
|
29 | - * @param \Exception $previous |
|
30 | - */ |
|
31 | - public function __construct($identifier, $message = '', $code = 0, \Exception $previous = null) |
|
32 | - { |
|
33 | - if (empty($message)) { |
|
34 | - $message = sprintf( |
|
35 | - __( |
|
36 | - 'The "%1$s" class could not be constructed.', |
|
37 | - 'event_espresso' |
|
38 | - ), |
|
39 | - $identifier |
|
40 | - ); |
|
41 | - } |
|
42 | - parent::__construct($message, $code, $previous); |
|
43 | - } |
|
23 | + /** |
|
24 | + * InstantiationException constructor. |
|
25 | + * |
|
26 | + * @param string $identifier the name of the requested entity or service |
|
27 | + * @param string $message |
|
28 | + * @param int $code |
|
29 | + * @param \Exception $previous |
|
30 | + */ |
|
31 | + public function __construct($identifier, $message = '', $code = 0, \Exception $previous = null) |
|
32 | + { |
|
33 | + if (empty($message)) { |
|
34 | + $message = sprintf( |
|
35 | + __( |
|
36 | + 'The "%1$s" class could not be constructed.', |
|
37 | + 'event_espresso' |
|
38 | + ), |
|
39 | + $identifier |
|
40 | + ); |
|
41 | + } |
|
42 | + parent::__construct($message, $code, $previous); |
|
43 | + } |
|
44 | 44 | |
45 | 45 | } |
46 | 46 | // End of file InstantiationException.php |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | namespace EventEspresso\core\services\container; |
3 | 3 | |
4 | 4 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
5 | - exit('No direct script access allowed'); |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -18,70 +18,70 @@ discard block |
||
18 | 18 | |
19 | 19 | |
20 | 20 | |
21 | - /** |
|
22 | - * returns an instance of the requested entity type using the supplied arguments. |
|
23 | - * If a shared service is requested and an instance is already in the carafe, then it will be returned. |
|
24 | - * If it is not already in the carafe, then the service will be constructed, added to the carafe, and returned |
|
25 | - * If the request is for a new entity and a closure exists in the reservoir for creating it, |
|
26 | - * then a new entity will be instantiated from the closure and returned. |
|
27 | - * If a closure does not exist, then one will be built and added to the reservoir |
|
28 | - * before instantiating the requested entity. |
|
29 | - * |
|
30 | - * @param string $identifier Identifier for the entity class to be constructed. |
|
31 | - * Typically a Fully Qualified Class Name |
|
32 | - * @param array $arguments an array of arguments to be passed to the entity constructor |
|
33 | - * @param string $type |
|
34 | - * @return mixed |
|
35 | - */ |
|
36 | - public function brew($identifier, $arguments = array(), $type = ''); |
|
21 | + /** |
|
22 | + * returns an instance of the requested entity type using the supplied arguments. |
|
23 | + * If a shared service is requested and an instance is already in the carafe, then it will be returned. |
|
24 | + * If it is not already in the carafe, then the service will be constructed, added to the carafe, and returned |
|
25 | + * If the request is for a new entity and a closure exists in the reservoir for creating it, |
|
26 | + * then a new entity will be instantiated from the closure and returned. |
|
27 | + * If a closure does not exist, then one will be built and added to the reservoir |
|
28 | + * before instantiating the requested entity. |
|
29 | + * |
|
30 | + * @param string $identifier Identifier for the entity class to be constructed. |
|
31 | + * Typically a Fully Qualified Class Name |
|
32 | + * @param array $arguments an array of arguments to be passed to the entity constructor |
|
33 | + * @param string $type |
|
34 | + * @return mixed |
|
35 | + */ |
|
36 | + public function brew($identifier, $arguments = array(), $type = ''); |
|
37 | 37 | |
38 | 38 | |
39 | 39 | |
40 | - /** |
|
41 | - * @param string $identifier |
|
42 | - * @param callable $closure |
|
43 | - */ |
|
44 | - public function addClosure($identifier, $closure); |
|
40 | + /** |
|
41 | + * @param string $identifier |
|
42 | + * @param callable $closure |
|
43 | + */ |
|
44 | + public function addClosure($identifier, $closure); |
|
45 | 45 | |
46 | 46 | |
47 | 47 | |
48 | - /** |
|
49 | - * @param string $identifier |
|
50 | - * @param mixed $service |
|
51 | - * @return boolean |
|
52 | - */ |
|
53 | - public function addService($identifier, $service); |
|
48 | + /** |
|
49 | + * @param string $identifier |
|
50 | + * @param mixed $service |
|
51 | + * @return boolean |
|
52 | + */ |
|
53 | + public function addService($identifier, $service); |
|
54 | 54 | |
55 | 55 | |
56 | 56 | |
57 | - /** |
|
58 | - * Adds instructions on how to brew objects |
|
59 | - * |
|
60 | - * @param RecipeInterface $recipe |
|
61 | - * @return mixed |
|
62 | - */ |
|
63 | - public function addRecipe(RecipeInterface $recipe); |
|
57 | + /** |
|
58 | + * Adds instructions on how to brew objects |
|
59 | + * |
|
60 | + * @param RecipeInterface $recipe |
|
61 | + * @return mixed |
|
62 | + */ |
|
63 | + public function addRecipe(RecipeInterface $recipe); |
|
64 | 64 | |
65 | 65 | |
66 | 66 | |
67 | - /** |
|
68 | - * Get instructions on how to brew objects |
|
69 | - * |
|
70 | - * @param string $identifier |
|
71 | - * @return Recipe |
|
72 | - */ |
|
73 | - public function getRecipe($identifier); |
|
67 | + /** |
|
68 | + * Get instructions on how to brew objects |
|
69 | + * |
|
70 | + * @param string $identifier |
|
71 | + * @return Recipe |
|
72 | + */ |
|
73 | + public function getRecipe($identifier); |
|
74 | 74 | |
75 | 75 | |
76 | 76 | |
77 | - /** |
|
78 | - * adds class name aliases to list of filters |
|
79 | - * |
|
80 | - * @param string $identifier |
|
81 | - * @param array $aliases |
|
82 | - * @return string |
|
83 | - */ |
|
84 | - public function addAliases($identifier, $aliases); |
|
77 | + /** |
|
78 | + * adds class name aliases to list of filters |
|
79 | + * |
|
80 | + * @param string $identifier |
|
81 | + * @param array $aliases |
|
82 | + * @return string |
|
83 | + */ |
|
84 | + public function addAliases($identifier, $aliases); |
|
85 | 85 | |
86 | 86 | |
87 | 87 |
@@ -29,8 +29,8 @@ |
||
29 | 29 | * @param \EE_Transaction $transaction |
30 | 30 | * @param \EE_Ticket $ticket |
31 | 31 | * @param \EE_Line_Item $ticket_line_item |
32 | - * @param $reg_count |
|
33 | - * @param $reg_group_size |
|
32 | + * @param integer $reg_count |
|
33 | + * @param integer $reg_group_size |
|
34 | 34 | * @return \EE_Registration |
35 | 35 | * @throws \EE_Error |
36 | 36 | * @throws UnexpectedEntityException |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | use EventEspresso\core\exceptions\UnexpectedEntityException; |
8 | 8 | |
9 | 9 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
10 | - exit('No direct script access allowed'); |
|
10 | + exit('No direct script access allowed'); |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | |
@@ -24,98 +24,98 @@ discard block |
||
24 | 24 | { |
25 | 25 | |
26 | 26 | |
27 | - /** |
|
28 | - * @param \EE_Event $event |
|
29 | - * @param \EE_Transaction $transaction |
|
30 | - * @param \EE_Ticket $ticket |
|
31 | - * @param \EE_Line_Item $ticket_line_item |
|
32 | - * @param $reg_count |
|
33 | - * @param $reg_group_size |
|
34 | - * @return \EE_Registration |
|
35 | - * @throws \EE_Error |
|
36 | - * @throws UnexpectedEntityException |
|
37 | - */ |
|
38 | - public function create( |
|
39 | - \EE_Event $event, |
|
40 | - \EE_Transaction $transaction, |
|
41 | - \EE_Ticket $ticket, |
|
42 | - \EE_Line_Item $ticket_line_item, |
|
43 | - $reg_count, |
|
44 | - $reg_group_size |
|
45 | - ) { |
|
46 | - $registrations = $transaction->registrations(); |
|
47 | - $reg_count = $reg_count ? $reg_count : count($registrations) + 1; |
|
48 | - $reg_url_link = new RegUrlLink($reg_count, $ticket_line_item); |
|
49 | - $reg_code = new RegCode($reg_url_link, $transaction, $ticket); |
|
50 | - // generate new EE_Registration |
|
51 | - $registration = \EE_Registration::new_instance( |
|
52 | - array( |
|
53 | - 'EVT_ID' => $event->ID(), |
|
54 | - 'TXN_ID' => $transaction->ID(), |
|
55 | - 'TKT_ID' => $ticket->ID(), |
|
56 | - 'STS_ID' => \EEM_Registration::status_id_incomplete, |
|
57 | - 'REG_date' => time(), |
|
58 | - 'REG_final_price' => $this->resolveFinalPrice($transaction, $ticket, $ticket_line_item), |
|
59 | - 'REG_session' => \EE_Registry::instance()->SSN->id(), |
|
60 | - 'REG_count' => $reg_count, |
|
61 | - 'REG_group_size' => $reg_group_size ? $reg_group_size : $this->incrementRegCount($registrations), |
|
62 | - 'REG_url_link' => $reg_url_link, |
|
63 | - 'REG_code' => $reg_code, |
|
64 | - ) |
|
65 | - ); |
|
66 | - if ( ! $registration instanceof \EE_Registration) { |
|
67 | - throw new UnexpectedEntityException($registration, 'EE_Registration'); |
|
68 | - } |
|
69 | - $registration->save(); |
|
70 | - $registration->_add_relation_to($event, 'Event', array(), $event->ID()); |
|
71 | - $registration->_add_relation_to($ticket, 'Ticket', array(), $ticket->ID()); |
|
72 | - $transaction->_add_relation_to($registration, 'Registration', array(), $registration->ID()); |
|
73 | - $registration->save(); |
|
74 | - return $registration; |
|
75 | - } |
|
27 | + /** |
|
28 | + * @param \EE_Event $event |
|
29 | + * @param \EE_Transaction $transaction |
|
30 | + * @param \EE_Ticket $ticket |
|
31 | + * @param \EE_Line_Item $ticket_line_item |
|
32 | + * @param $reg_count |
|
33 | + * @param $reg_group_size |
|
34 | + * @return \EE_Registration |
|
35 | + * @throws \EE_Error |
|
36 | + * @throws UnexpectedEntityException |
|
37 | + */ |
|
38 | + public function create( |
|
39 | + \EE_Event $event, |
|
40 | + \EE_Transaction $transaction, |
|
41 | + \EE_Ticket $ticket, |
|
42 | + \EE_Line_Item $ticket_line_item, |
|
43 | + $reg_count, |
|
44 | + $reg_group_size |
|
45 | + ) { |
|
46 | + $registrations = $transaction->registrations(); |
|
47 | + $reg_count = $reg_count ? $reg_count : count($registrations) + 1; |
|
48 | + $reg_url_link = new RegUrlLink($reg_count, $ticket_line_item); |
|
49 | + $reg_code = new RegCode($reg_url_link, $transaction, $ticket); |
|
50 | + // generate new EE_Registration |
|
51 | + $registration = \EE_Registration::new_instance( |
|
52 | + array( |
|
53 | + 'EVT_ID' => $event->ID(), |
|
54 | + 'TXN_ID' => $transaction->ID(), |
|
55 | + 'TKT_ID' => $ticket->ID(), |
|
56 | + 'STS_ID' => \EEM_Registration::status_id_incomplete, |
|
57 | + 'REG_date' => time(), |
|
58 | + 'REG_final_price' => $this->resolveFinalPrice($transaction, $ticket, $ticket_line_item), |
|
59 | + 'REG_session' => \EE_Registry::instance()->SSN->id(), |
|
60 | + 'REG_count' => $reg_count, |
|
61 | + 'REG_group_size' => $reg_group_size ? $reg_group_size : $this->incrementRegCount($registrations), |
|
62 | + 'REG_url_link' => $reg_url_link, |
|
63 | + 'REG_code' => $reg_code, |
|
64 | + ) |
|
65 | + ); |
|
66 | + if ( ! $registration instanceof \EE_Registration) { |
|
67 | + throw new UnexpectedEntityException($registration, 'EE_Registration'); |
|
68 | + } |
|
69 | + $registration->save(); |
|
70 | + $registration->_add_relation_to($event, 'Event', array(), $event->ID()); |
|
71 | + $registration->_add_relation_to($ticket, 'Ticket', array(), $ticket->ID()); |
|
72 | + $transaction->_add_relation_to($registration, 'Registration', array(), $registration->ID()); |
|
73 | + $registration->save(); |
|
74 | + return $registration; |
|
75 | + } |
|
76 | 76 | |
77 | 77 | |
78 | 78 | |
79 | - /** |
|
80 | - * @param \EE_Transaction $transaction |
|
81 | - * @param \EE_Ticket $ticket |
|
82 | - * @param \EE_Line_Item $ticket_line_item |
|
83 | - * @return float |
|
84 | - */ |
|
85 | - protected function resolveFinalPrice( |
|
86 | - \EE_Transaction $transaction, |
|
87 | - \EE_Ticket $ticket, |
|
88 | - \EE_Line_Item $ticket_line_item |
|
89 | - ) { |
|
90 | - $final_price = \EEH_Line_Item::calculate_final_price_for_ticket_line_item( |
|
91 | - $transaction->total_line_item(), |
|
92 | - $ticket_line_item |
|
93 | - ); |
|
94 | - $final_price = $final_price !== null ? $final_price : $ticket->get_ticket_total_with_taxes(); |
|
95 | - return (float)$final_price; |
|
96 | - } |
|
79 | + /** |
|
80 | + * @param \EE_Transaction $transaction |
|
81 | + * @param \EE_Ticket $ticket |
|
82 | + * @param \EE_Line_Item $ticket_line_item |
|
83 | + * @return float |
|
84 | + */ |
|
85 | + protected function resolveFinalPrice( |
|
86 | + \EE_Transaction $transaction, |
|
87 | + \EE_Ticket $ticket, |
|
88 | + \EE_Line_Item $ticket_line_item |
|
89 | + ) { |
|
90 | + $final_price = \EEH_Line_Item::calculate_final_price_for_ticket_line_item( |
|
91 | + $transaction->total_line_item(), |
|
92 | + $ticket_line_item |
|
93 | + ); |
|
94 | + $final_price = $final_price !== null ? $final_price : $ticket->get_ticket_total_with_taxes(); |
|
95 | + return (float)$final_price; |
|
96 | + } |
|
97 | 97 | |
98 | 98 | |
99 | 99 | |
100 | - /** |
|
101 | - * @param \EE_Registration[] $registrations |
|
102 | - * @param boolean $update_existing_registrations |
|
103 | - * @return int |
|
104 | - * @throws \EE_Error |
|
105 | - */ |
|
106 | - protected function incrementRegCount(array $registrations, $update_existing_registrations = true) |
|
107 | - { |
|
108 | - $new_reg_count = count($registrations) + 1; |
|
109 | - if ($update_existing_registrations) { |
|
110 | - foreach ($registrations as $registration) { |
|
111 | - if ($registration instanceof \EE_Registration) { |
|
112 | - $registration->set_count($new_reg_count); |
|
113 | - $registration->save(); |
|
114 | - } |
|
115 | - } |
|
116 | - } |
|
117 | - return $new_reg_count; |
|
118 | - } |
|
100 | + /** |
|
101 | + * @param \EE_Registration[] $registrations |
|
102 | + * @param boolean $update_existing_registrations |
|
103 | + * @return int |
|
104 | + * @throws \EE_Error |
|
105 | + */ |
|
106 | + protected function incrementRegCount(array $registrations, $update_existing_registrations = true) |
|
107 | + { |
|
108 | + $new_reg_count = count($registrations) + 1; |
|
109 | + if ($update_existing_registrations) { |
|
110 | + foreach ($registrations as $registration) { |
|
111 | + if ($registration instanceof \EE_Registration) { |
|
112 | + $registration->set_count($new_reg_count); |
|
113 | + $registration->save(); |
|
114 | + } |
|
115 | + } |
|
116 | + } |
|
117 | + return $new_reg_count; |
|
118 | + } |
|
119 | 119 | |
120 | 120 | |
121 | 121 | } |
@@ -92,7 +92,7 @@ |
||
92 | 92 | $ticket_line_item |
93 | 93 | ); |
94 | 94 | $final_price = $final_price !== null ? $final_price : $ticket->get_ticket_total_with_taxes(); |
95 | - return (float)$final_price; |
|
95 | + return (float) $final_price; |
|
96 | 96 | } |
97 | 97 | |
98 | 98 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php use EventEspresso\core\exceptions\InvalidEntityException; |
2 | 2 | |
3 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');} |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); } |
|
4 | 4 | /** |
5 | 5 | * Single Page Checkout (SPCO) |
6 | 6 | * |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | * @return EED_Single_Page_Checkout |
50 | 50 | */ |
51 | 51 | public static function instance() { |
52 | - add_filter( 'EED_Single_Page_Checkout__SPCO_active', '__return_true' ); |
|
53 | - return parent::get_instance( __CLASS__ ); |
|
52 | + add_filter('EED_Single_Page_Checkout__SPCO_active', '__return_true'); |
|
53 | + return parent::get_instance(__CLASS__); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | |
@@ -95,22 +95,22 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public static function set_hooks_admin() { |
97 | 97 | EED_Single_Page_Checkout::set_definitions(); |
98 | - if ( defined( 'DOING_AJAX' )) { |
|
98 | + if (defined('DOING_AJAX')) { |
|
99 | 99 | // going to start an output buffer in case anything gets accidentally output that might disrupt our JSON response |
100 | 100 | ob_start(); |
101 | 101 | EED_Single_Page_Checkout::load_request_handler(); |
102 | 102 | EED_Single_Page_Checkout::load_reg_steps(); |
103 | 103 | } else { |
104 | 104 | // hook into the top of pre_get_posts to set the reg step routing, which gives other modules or plugins a chance to modify the reg steps, but just before the routes get called |
105 | - add_action( 'pre_get_posts', array( 'EED_Single_Page_Checkout', 'load_reg_steps' ), 1 ); |
|
105 | + add_action('pre_get_posts', array('EED_Single_Page_Checkout', 'load_reg_steps'), 1); |
|
106 | 106 | } |
107 | 107 | // set ajax hooks |
108 | - add_action( 'wp_ajax_process_reg_step', array( 'EED_Single_Page_Checkout', 'process_reg_step' )); |
|
109 | - add_action( 'wp_ajax_nopriv_process_reg_step', array( 'EED_Single_Page_Checkout', 'process_reg_step' )); |
|
110 | - add_action( 'wp_ajax_display_spco_reg_step', array( 'EED_Single_Page_Checkout', 'display_reg_step' )); |
|
111 | - add_action( 'wp_ajax_nopriv_display_spco_reg_step', array( 'EED_Single_Page_Checkout', 'display_reg_step' )); |
|
112 | - add_action( 'wp_ajax_update_reg_step', array( 'EED_Single_Page_Checkout', 'update_reg_step' )); |
|
113 | - add_action( 'wp_ajax_nopriv_update_reg_step', array( 'EED_Single_Page_Checkout', 'update_reg_step' )); |
|
108 | + add_action('wp_ajax_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
109 | + add_action('wp_ajax_nopriv_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
110 | + add_action('wp_ajax_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
111 | + add_action('wp_ajax_nopriv_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
112 | + add_action('wp_ajax_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
113 | + add_action('wp_ajax_nopriv_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | |
@@ -121,8 +121,8 @@ discard block |
||
121 | 121 | * @param string $ajax_action |
122 | 122 | * @throws \EE_Error |
123 | 123 | */ |
124 | - public static function process_ajax_request( $ajax_action ) { |
|
125 | - EE_Registry::instance()->REQ->set( 'action', $ajax_action ); |
|
124 | + public static function process_ajax_request($ajax_action) { |
|
125 | + EE_Registry::instance()->REQ->set('action', $ajax_action); |
|
126 | 126 | EED_Single_Page_Checkout::instance()->_initialize(); |
127 | 127 | } |
128 | 128 | |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | * @throws \EE_Error |
135 | 135 | */ |
136 | 136 | public static function display_reg_step() { |
137 | - EED_Single_Page_Checkout::process_ajax_request( 'display_spco_reg_step' ); |
|
137 | + EED_Single_Page_Checkout::process_ajax_request('display_spco_reg_step'); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | * @throws \EE_Error |
146 | 146 | */ |
147 | 147 | public static function process_reg_step() { |
148 | - EED_Single_Page_Checkout::process_ajax_request( 'process_reg_step' ); |
|
148 | + EED_Single_Page_Checkout::process_ajax_request('process_reg_step'); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | * @throws \EE_Error |
157 | 157 | */ |
158 | 158 | public static function update_reg_step() { |
159 | - EED_Single_Page_Checkout::process_ajax_request( 'update_reg_step' ); |
|
159 | + EED_Single_Page_Checkout::process_ajax_request('update_reg_step'); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | * @throws \EE_Error |
170 | 170 | */ |
171 | 171 | public static function update_checkout() { |
172 | - EED_Single_Page_Checkout::process_ajax_request( 'update_checkout' ); |
|
172 | + EED_Single_Page_Checkout::process_ajax_request('update_checkout'); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | |
@@ -182,8 +182,8 @@ discard block |
||
182 | 182 | */ |
183 | 183 | public static function load_request_handler() { |
184 | 184 | // load core Request_Handler class |
185 | - if ( ! isset( EE_Registry::instance()->REQ )) { |
|
186 | - EE_Registry::instance()->load_core( 'Request_Handler' ); |
|
185 | + if ( ! isset(EE_Registry::instance()->REQ)) { |
|
186 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
187 | 187 | } |
188 | 188 | } |
189 | 189 | |
@@ -197,14 +197,14 @@ discard block |
||
197 | 197 | * @throws \EE_Error |
198 | 198 | */ |
199 | 199 | public static function set_definitions() { |
200 | - define( 'SPCO_BASE_PATH', rtrim( str_replace( array( '\\', '/' ), DS, plugin_dir_path( __FILE__ )), DS ) . DS ); |
|
201 | - define( 'SPCO_CSS_URL', plugin_dir_url( __FILE__ ) . 'css' . DS ); |
|
202 | - define( 'SPCO_IMG_URL', plugin_dir_url( __FILE__ ) . 'img' . DS ); |
|
203 | - define( 'SPCO_JS_URL', plugin_dir_url( __FILE__ ) . 'js' . DS ); |
|
204 | - define( 'SPCO_INC_PATH', SPCO_BASE_PATH . 'inc' . DS ); |
|
205 | - define( 'SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps' . DS ); |
|
206 | - define( 'SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates' . DS ); |
|
207 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( SPCO_BASE_PATH, TRUE ); |
|
200 | + define('SPCO_BASE_PATH', rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS).DS); |
|
201 | + define('SPCO_CSS_URL', plugin_dir_url(__FILE__).'css'.DS); |
|
202 | + define('SPCO_IMG_URL', plugin_dir_url(__FILE__).'img'.DS); |
|
203 | + define('SPCO_JS_URL', plugin_dir_url(__FILE__).'js'.DS); |
|
204 | + define('SPCO_INC_PATH', SPCO_BASE_PATH.'inc'.DS); |
|
205 | + define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH.'reg_steps'.DS); |
|
206 | + define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH.'templates'.DS); |
|
207 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, TRUE); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | */ |
220 | 220 | public static function load_reg_steps() { |
221 | 221 | static $reg_steps_loaded = FALSE; |
222 | - if ( $reg_steps_loaded ) { |
|
222 | + if ($reg_steps_loaded) { |
|
223 | 223 | return; |
224 | 224 | } |
225 | 225 | // filter list of reg_steps |
@@ -228,24 +228,24 @@ discard block |
||
228 | 228 | EED_Single_Page_Checkout::get_reg_steps() |
229 | 229 | ); |
230 | 230 | // sort by key (order) |
231 | - ksort( $reg_steps_to_load ); |
|
231 | + ksort($reg_steps_to_load); |
|
232 | 232 | // loop through folders |
233 | - foreach ( $reg_steps_to_load as $order => $reg_step ) { |
|
233 | + foreach ($reg_steps_to_load as $order => $reg_step) { |
|
234 | 234 | // we need a |
235 | - if ( isset( $reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'] )) { |
|
235 | + if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
236 | 236 | // copy over to the reg_steps_array |
237 | - EED_Single_Page_Checkout::$_reg_steps_array[ $order ] = $reg_step; |
|
237 | + EED_Single_Page_Checkout::$_reg_steps_array[$order] = $reg_step; |
|
238 | 238 | // register custom key route for each reg step |
239 | 239 | // ie: step=>"slug" - this is the entire reason we load the reg steps array now |
240 | - EE_Config::register_route( $reg_step['slug'], 'EED_Single_Page_Checkout', 'run', 'step' ); |
|
240 | + EE_Config::register_route($reg_step['slug'], 'EED_Single_Page_Checkout', 'run', 'step'); |
|
241 | 241 | // add AJAX or other hooks |
242 | - if ( isset( $reg_step['has_hooks'] ) && $reg_step['has_hooks'] ) { |
|
242 | + if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) { |
|
243 | 243 | // setup autoloaders if necessary |
244 | - if ( ! class_exists( $reg_step['class_name'] )) { |
|
245 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( $reg_step['file_path'], TRUE ); |
|
244 | + if ( ! class_exists($reg_step['class_name'])) { |
|
245 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder($reg_step['file_path'], TRUE); |
|
246 | 246 | } |
247 | - if ( is_callable( $reg_step['class_name'], 'set_hooks' )) { |
|
248 | - call_user_func( array( $reg_step['class_name'], 'set_hooks' )); |
|
247 | + if (is_callable($reg_step['class_name'], 'set_hooks')) { |
|
248 | + call_user_func(array($reg_step['class_name'], 'set_hooks')); |
|
249 | 249 | } |
250 | 250 | } |
251 | 251 | } |
@@ -264,28 +264,28 @@ discard block |
||
264 | 264 | */ |
265 | 265 | public static function get_reg_steps() { |
266 | 266 | $reg_steps = EE_Registry::instance()->CFG->registration->reg_steps; |
267 | - if ( empty( $reg_steps )) { |
|
267 | + if (empty($reg_steps)) { |
|
268 | 268 | $reg_steps = array( |
269 | 269 | 10 => array( |
270 | - 'file_path' => SPCO_REG_STEPS_PATH . 'attendee_information', |
|
270 | + 'file_path' => SPCO_REG_STEPS_PATH.'attendee_information', |
|
271 | 271 | 'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information', |
272 | 272 | 'slug' => 'attendee_information', |
273 | 273 | 'has_hooks' => FALSE |
274 | 274 | ), |
275 | 275 | 20 => array( |
276 | - 'file_path' => SPCO_REG_STEPS_PATH . 'registration_confirmation', |
|
276 | + 'file_path' => SPCO_REG_STEPS_PATH.'registration_confirmation', |
|
277 | 277 | 'class_name' => 'EE_SPCO_Reg_Step_Registration_Confirmation', |
278 | 278 | 'slug' => 'registration_confirmation', |
279 | 279 | 'has_hooks' => FALSE |
280 | 280 | ), |
281 | 281 | 30 => array( |
282 | - 'file_path' => SPCO_REG_STEPS_PATH . 'payment_options', |
|
282 | + 'file_path' => SPCO_REG_STEPS_PATH.'payment_options', |
|
283 | 283 | 'class_name' => 'EE_SPCO_Reg_Step_Payment_Options', |
284 | 284 | 'slug' => 'payment_options', |
285 | 285 | 'has_hooks' => TRUE |
286 | 286 | ), |
287 | 287 | 999 => array( |
288 | - 'file_path' => SPCO_REG_STEPS_PATH . 'finalize_registration', |
|
288 | + 'file_path' => SPCO_REG_STEPS_PATH.'finalize_registration', |
|
289 | 289 | 'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration', |
290 | 290 | 'slug' => 'finalize_registration', |
291 | 291 | 'has_hooks' => FALSE |
@@ -306,9 +306,9 @@ discard block |
||
306 | 306 | */ |
307 | 307 | public static function registration_checkout_for_admin() { |
308 | 308 | EED_Single_Page_Checkout::load_reg_steps(); |
309 | - EE_Registry::instance()->REQ->set( 'step', 'attendee_information' ); |
|
310 | - EE_Registry::instance()->REQ->set( 'action', 'display_spco_reg_step' ); |
|
311 | - EE_Registry::instance()->REQ->set( 'process_form_submission', false ); |
|
309 | + EE_Registry::instance()->REQ->set('step', 'attendee_information'); |
|
310 | + EE_Registry::instance()->REQ->set('action', 'display_spco_reg_step'); |
|
311 | + EE_Registry::instance()->REQ->set('process_form_submission', false); |
|
312 | 312 | EED_Single_Page_Checkout::instance()->_initialize(); |
313 | 313 | EED_Single_Page_Checkout::instance()->_display_spco_reg_form(); |
314 | 314 | return EE_Registry::instance()->REQ->get_output(); |
@@ -325,15 +325,15 @@ discard block |
||
325 | 325 | */ |
326 | 326 | public static function process_registration_from_admin() { |
327 | 327 | EED_Single_Page_Checkout::load_reg_steps(); |
328 | - EE_Registry::instance()->REQ->set( 'step', 'attendee_information' ); |
|
329 | - EE_Registry::instance()->REQ->set( 'action', 'process_reg_step' ); |
|
330 | - EE_Registry::instance()->REQ->set( 'process_form_submission', true ); |
|
328 | + EE_Registry::instance()->REQ->set('step', 'attendee_information'); |
|
329 | + EE_Registry::instance()->REQ->set('action', 'process_reg_step'); |
|
330 | + EE_Registry::instance()->REQ->set('process_form_submission', true); |
|
331 | 331 | EED_Single_Page_Checkout::instance()->_initialize(); |
332 | - if ( EED_Single_Page_Checkout::instance()->checkout->current_step->completed() ) { |
|
333 | - $final_reg_step = end( EED_Single_Page_Checkout::instance()->checkout->reg_steps ); |
|
334 | - if ( $final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration ) { |
|
335 | - EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated( $final_reg_step ); |
|
336 | - if ( $final_reg_step->process_reg_step() ) { |
|
332 | + if (EED_Single_Page_Checkout::instance()->checkout->current_step->completed()) { |
|
333 | + $final_reg_step = end(EED_Single_Page_Checkout::instance()->checkout->reg_steps); |
|
334 | + if ($final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) { |
|
335 | + EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated($final_reg_step); |
|
336 | + if ($final_reg_step->process_reg_step()) { |
|
337 | 337 | $final_reg_step->set_completed(); |
338 | 338 | EED_Single_Page_Checkout::instance()->checkout->update_txn_reg_steps_array(); |
339 | 339 | return EED_Single_Page_Checkout::instance()->checkout->transaction; |
@@ -353,11 +353,11 @@ discard block |
||
353 | 353 | * @return void |
354 | 354 | * @throws \EE_Error |
355 | 355 | */ |
356 | - public function run( $WP_Query ) { |
|
356 | + public function run($WP_Query) { |
|
357 | 357 | if ( |
358 | 358 | $WP_Query instanceof WP_Query |
359 | 359 | && $WP_Query->is_main_query() |
360 | - && apply_filters( 'FHEE__EED_Single_Page_Checkout__run', true ) |
|
360 | + && apply_filters('FHEE__EED_Single_Page_Checkout__run', true) |
|
361 | 361 | ) { |
362 | 362 | $this->_initialize(); |
363 | 363 | } |
@@ -373,8 +373,8 @@ discard block |
||
373 | 373 | * @return void |
374 | 374 | * @throws \EE_Error |
375 | 375 | */ |
376 | - public static function init( $WP_Query ) { |
|
377 | - EED_Single_Page_Checkout::instance()->run( $WP_Query ); |
|
376 | + public static function init($WP_Query) { |
|
377 | + EED_Single_Page_Checkout::instance()->run($WP_Query); |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | |
@@ -388,34 +388,34 @@ discard block |
||
388 | 388 | */ |
389 | 389 | private function _initialize() { |
390 | 390 | // ensure SPCO doesn't run twice |
391 | - if ( EED_Single_Page_Checkout::$_initialized ) { |
|
391 | + if (EED_Single_Page_Checkout::$_initialized) { |
|
392 | 392 | return; |
393 | 393 | } |
394 | 394 | try { |
395 | 395 | // setup the EE_Checkout object |
396 | 396 | $this->checkout = $this->_initialize_checkout(); |
397 | 397 | // filter checkout |
398 | - $this->checkout = apply_filters( 'FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout ); |
|
398 | + $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout); |
|
399 | 399 | // get the $_GET |
400 | 400 | $this->_get_request_vars(); |
401 | 401 | // filter continue_reg |
402 | - $this->checkout->continue_reg = apply_filters( 'FHEE__EED_Single_Page_Checkout__init___continue_reg', TRUE, $this->checkout ); |
|
402 | + $this->checkout->continue_reg = apply_filters('FHEE__EED_Single_Page_Checkout__init___continue_reg', TRUE, $this->checkout); |
|
403 | 403 | // load the reg steps array |
404 | - if ( ! $this->_load_and_instantiate_reg_steps() ) { |
|
404 | + if ( ! $this->_load_and_instantiate_reg_steps()) { |
|
405 | 405 | EED_Single_Page_Checkout::$_initialized = true; |
406 | 406 | return; |
407 | 407 | } |
408 | 408 | // set the current step |
409 | - $this->checkout->set_current_step( $this->checkout->step ); |
|
409 | + $this->checkout->set_current_step($this->checkout->step); |
|
410 | 410 | // and the next step |
411 | 411 | $this->checkout->set_next_step(); |
412 | 412 | // was there already a valid transaction in the checkout from the session ? |
413 | - if ( ! $this->checkout->transaction instanceof EE_Transaction ) { |
|
413 | + if ( ! $this->checkout->transaction instanceof EE_Transaction) { |
|
414 | 414 | // get transaction from db or session |
415 | 415 | $this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin() |
416 | 416 | ? $this->_get_transaction_and_cart_for_previous_visit() |
417 | 417 | : $this->_get_cart_for_current_session_and_setup_new_transaction(); |
418 | - if ( ! $this->checkout->transaction instanceof EE_Transaction ) { |
|
418 | + if ( ! $this->checkout->transaction instanceof EE_Transaction) { |
|
419 | 419 | // add some style and make it dance |
420 | 420 | $this->checkout->transaction = EE_Transaction::new_instance(); |
421 | 421 | $this->add_styles_and_scripts(); |
@@ -423,10 +423,10 @@ discard block |
||
423 | 423 | return; |
424 | 424 | } |
425 | 425 | // and the registrations for the transaction |
426 | - $this->_get_registrations( $this->checkout->transaction ); |
|
426 | + $this->_get_registrations($this->checkout->transaction); |
|
427 | 427 | } |
428 | 428 | // verify that everything has been setup correctly |
429 | - if ( ! $this->_final_verifications() ) { |
|
429 | + if ( ! $this->_final_verifications()) { |
|
430 | 430 | EED_Single_Page_Checkout::$_initialized = true; |
431 | 431 | return; |
432 | 432 | } |
@@ -451,9 +451,9 @@ discard block |
||
451 | 451 | // set no cache headers and constants |
452 | 452 | EE_System::do_not_cache(); |
453 | 453 | // add anchor |
454 | - add_action( 'loop_start', array( $this, 'set_checkout_anchor' ), 1 ); |
|
455 | - } catch ( Exception $e ) { |
|
456 | - EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__ ); |
|
454 | + add_action('loop_start', array($this, 'set_checkout_anchor'), 1); |
|
455 | + } catch (Exception $e) { |
|
456 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
457 | 457 | } |
458 | 458 | } |
459 | 459 | |
@@ -471,20 +471,20 @@ discard block |
||
471 | 471 | // look in session for existing checkout |
472 | 472 | $checkout = EE_Registry::instance()->SSN->checkout(); |
473 | 473 | // verify |
474 | - if ( ! $checkout instanceof EE_Checkout ) { |
|
474 | + if ( ! $checkout instanceof EE_Checkout) { |
|
475 | 475 | // instantiate EE_Checkout object for handling the properties of the current checkout process |
476 | - $checkout = EE_Registry::instance()->load_file( SPCO_INC_PATH, 'EE_Checkout', 'class', array(), FALSE ); |
|
476 | + $checkout = EE_Registry::instance()->load_file(SPCO_INC_PATH, 'EE_Checkout', 'class', array(), FALSE); |
|
477 | 477 | } else { |
478 | - if ( $checkout->current_step->is_final_step() && $checkout->exit_spco() === true ) { |
|
478 | + if ($checkout->current_step->is_final_step() && $checkout->exit_spco() === true) { |
|
479 | 479 | $this->unlock_transaction(); |
480 | - wp_safe_redirect( $checkout->redirect_url ); |
|
480 | + wp_safe_redirect($checkout->redirect_url); |
|
481 | 481 | exit(); |
482 | 482 | } |
483 | 483 | } |
484 | - $checkout = apply_filters( 'FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout ); |
|
484 | + $checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout); |
|
485 | 485 | // verify again |
486 | - if ( ! $checkout instanceof EE_Checkout ) { |
|
487 | - throw new EE_Error( __( 'The EE_Checkout class could not be loaded.', 'event_espresso' ) ); |
|
486 | + if ( ! $checkout instanceof EE_Checkout) { |
|
487 | + throw new EE_Error(__('The EE_Checkout class could not be loaded.', 'event_espresso')); |
|
488 | 488 | } |
489 | 489 | // reset anything that needs a clean slate for each request |
490 | 490 | $checkout->reset_for_current_request(); |
@@ -504,24 +504,24 @@ discard block |
||
504 | 504 | // load classes |
505 | 505 | EED_Single_Page_Checkout::load_request_handler(); |
506 | 506 | //make sure this request is marked as belonging to EE |
507 | - EE_Registry::instance()->REQ->set_espresso_page( TRUE ); |
|
507 | + EE_Registry::instance()->REQ->set_espresso_page(TRUE); |
|
508 | 508 | // which step is being requested ? |
509 | - $this->checkout->step = EE_Registry::instance()->REQ->get( 'step', $this->_get_first_step() ); |
|
509 | + $this->checkout->step = EE_Registry::instance()->REQ->get('step', $this->_get_first_step()); |
|
510 | 510 | // which step is being edited ? |
511 | - $this->checkout->edit_step = EE_Registry::instance()->REQ->get( 'edit_step', '' ); |
|
511 | + $this->checkout->edit_step = EE_Registry::instance()->REQ->get('edit_step', ''); |
|
512 | 512 | // and what we're doing on the current step |
513 | - $this->checkout->action = EE_Registry::instance()->REQ->get( 'action', 'display_spco_reg_step' ); |
|
513 | + $this->checkout->action = EE_Registry::instance()->REQ->get('action', 'display_spco_reg_step'); |
|
514 | 514 | // returning to edit ? |
515 | - $this->checkout->reg_url_link = EE_Registry::instance()->REQ->get( 'e_reg_url_link', '' ); |
|
515 | + $this->checkout->reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link', ''); |
|
516 | 516 | // or some other kind of revisit ? |
517 | - $this->checkout->revisit = EE_Registry::instance()->REQ->get( 'revisit', FALSE ); |
|
517 | + $this->checkout->revisit = EE_Registry::instance()->REQ->get('revisit', FALSE); |
|
518 | 518 | // and whether or not to generate a reg form for this request |
519 | - $this->checkout->generate_reg_form = EE_Registry::instance()->REQ->get( 'generate_reg_form', TRUE ); // TRUE FALSE |
|
519 | + $this->checkout->generate_reg_form = EE_Registry::instance()->REQ->get('generate_reg_form', TRUE); // TRUE FALSE |
|
520 | 520 | // and whether or not to process a reg form submission for this request |
521 | - $this->checkout->process_form_submission = EE_Registry::instance()->REQ->get( 'process_form_submission', FALSE ); // TRUE FALSE |
|
521 | + $this->checkout->process_form_submission = EE_Registry::instance()->REQ->get('process_form_submission', FALSE); // TRUE FALSE |
|
522 | 522 | $this->checkout->process_form_submission = $this->checkout->action !== 'display_spco_reg_step' |
523 | 523 | ? $this->checkout->process_form_submission |
524 | - : FALSE; // TRUE FALSE |
|
524 | + : FALSE; // TRUE FALSE |
|
525 | 525 | // $this->_display_request_vars(); |
526 | 526 | } |
527 | 527 | |
@@ -534,17 +534,17 @@ discard block |
||
534 | 534 | * @return void |
535 | 535 | */ |
536 | 536 | protected function _display_request_vars() { |
537 | - if ( ! WP_DEBUG ) { |
|
537 | + if ( ! WP_DEBUG) { |
|
538 | 538 | return; |
539 | 539 | } |
540 | - EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ ); |
|
541 | - EEH_Debug_Tools::printr( $this->checkout->step, '$this->checkout->step', __FILE__, __LINE__ ); |
|
542 | - EEH_Debug_Tools::printr( $this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__ ); |
|
543 | - EEH_Debug_Tools::printr( $this->checkout->action, '$this->checkout->action', __FILE__, __LINE__ ); |
|
544 | - EEH_Debug_Tools::printr( $this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__ ); |
|
545 | - EEH_Debug_Tools::printr( $this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__ ); |
|
546 | - EEH_Debug_Tools::printr( $this->checkout->generate_reg_form, '$this->checkout->generate_reg_form', __FILE__, __LINE__ ); |
|
547 | - EEH_Debug_Tools::printr( $this->checkout->process_form_submission, '$this->checkout->process_form_submission', __FILE__, __LINE__ ); |
|
540 | + EEH_Debug_Tools::printr($_REQUEST, '$_REQUEST', __FILE__, __LINE__); |
|
541 | + EEH_Debug_Tools::printr($this->checkout->step, '$this->checkout->step', __FILE__, __LINE__); |
|
542 | + EEH_Debug_Tools::printr($this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__); |
|
543 | + EEH_Debug_Tools::printr($this->checkout->action, '$this->checkout->action', __FILE__, __LINE__); |
|
544 | + EEH_Debug_Tools::printr($this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__); |
|
545 | + EEH_Debug_Tools::printr($this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__); |
|
546 | + EEH_Debug_Tools::printr($this->checkout->generate_reg_form, '$this->checkout->generate_reg_form', __FILE__, __LINE__); |
|
547 | + EEH_Debug_Tools::printr($this->checkout->process_form_submission, '$this->checkout->process_form_submission', __FILE__, __LINE__); |
|
548 | 548 | } |
549 | 549 | |
550 | 550 | |
@@ -558,8 +558,8 @@ discard block |
||
558 | 558 | * @return array |
559 | 559 | */ |
560 | 560 | private function _get_first_step() { |
561 | - $first_step = reset( EED_Single_Page_Checkout::$_reg_steps_array ); |
|
562 | - return isset( $first_step['slug'] ) ? $first_step['slug'] : 'attendee_information'; |
|
561 | + $first_step = reset(EED_Single_Page_Checkout::$_reg_steps_array); |
|
562 | + return isset($first_step['slug']) ? $first_step['slug'] : 'attendee_information'; |
|
563 | 563 | } |
564 | 564 | |
565 | 565 | |
@@ -575,27 +575,27 @@ discard block |
||
575 | 575 | private function _load_and_instantiate_reg_steps() { |
576 | 576 | // have reg_steps already been instantiated ? |
577 | 577 | if ( |
578 | - empty( $this->checkout->reg_steps ) || |
|
579 | - apply_filters( 'FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout ) |
|
578 | + empty($this->checkout->reg_steps) || |
|
579 | + apply_filters('FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout) |
|
580 | 580 | ) { |
581 | 581 | // if not, then loop through raw reg steps array |
582 | - foreach ( EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step ) { |
|
583 | - if ( ! $this->_load_and_instantiate_reg_step( $reg_step, $order )) { |
|
582 | + foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) { |
|
583 | + if ( ! $this->_load_and_instantiate_reg_step($reg_step, $order)) { |
|
584 | 584 | return false; |
585 | 585 | } |
586 | 586 | } |
587 | 587 | EE_Registry::instance()->CFG->registration->skip_reg_confirmation = TRUE; |
588 | 588 | EE_Registry::instance()->CFG->registration->reg_confirmation_last = TRUE; |
589 | 589 | // skip the registration_confirmation page ? |
590 | - if ( EE_Registry::instance()->CFG->registration->skip_reg_confirmation ) { |
|
590 | + if (EE_Registry::instance()->CFG->registration->skip_reg_confirmation) { |
|
591 | 591 | // just remove it from the reg steps array |
592 | - $this->checkout->remove_reg_step( 'registration_confirmation', false ); |
|
592 | + $this->checkout->remove_reg_step('registration_confirmation', false); |
|
593 | 593 | } else if ( |
594 | - isset( $this->checkout->reg_steps['registration_confirmation'] ) |
|
594 | + isset($this->checkout->reg_steps['registration_confirmation']) |
|
595 | 595 | && EE_Registry::instance()->CFG->registration->reg_confirmation_last |
596 | 596 | ) { |
597 | 597 | // set the order to something big like 100 |
598 | - $this->checkout->set_reg_step_order( 'registration_confirmation', 100 ); |
|
598 | + $this->checkout->set_reg_step_order('registration_confirmation', 100); |
|
599 | 599 | } |
600 | 600 | // filter the array for good luck |
601 | 601 | $this->checkout->reg_steps = apply_filters( |
@@ -605,13 +605,13 @@ discard block |
||
605 | 605 | // finally re-sort based on the reg step class order properties |
606 | 606 | $this->checkout->sort_reg_steps(); |
607 | 607 | } else { |
608 | - foreach ( $this->checkout->reg_steps as $reg_step ) { |
|
608 | + foreach ($this->checkout->reg_steps as $reg_step) { |
|
609 | 609 | // set all current step stati to FALSE |
610 | - $reg_step->set_is_current_step( FALSE ); |
|
610 | + $reg_step->set_is_current_step(FALSE); |
|
611 | 611 | } |
612 | 612 | } |
613 | - if ( empty( $this->checkout->reg_steps )) { |
|
614 | - EE_Error::add_error( __( 'No Reg Steps were loaded..', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
613 | + if (empty($this->checkout->reg_steps)) { |
|
614 | + EE_Error::add_error(__('No Reg Steps were loaded..', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
615 | 615 | return false; |
616 | 616 | } |
617 | 617 | // make reg step details available to JS |
@@ -629,10 +629,10 @@ discard block |
||
629 | 629 | * @param int $order |
630 | 630 | * @return bool |
631 | 631 | */ |
632 | - private function _load_and_instantiate_reg_step( $reg_step = array(), $order = 0 ) { |
|
632 | + private function _load_and_instantiate_reg_step($reg_step = array(), $order = 0) { |
|
633 | 633 | |
634 | 634 | // we need a file_path, class_name, and slug to add a reg step |
635 | - if ( isset( $reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'] )) { |
|
635 | + if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
636 | 636 | // if editing a specific step, but this is NOT that step... (and it's not the 'finalize_registration' step) |
637 | 637 | if ( |
638 | 638 | $this->checkout->reg_url_link |
@@ -650,26 +650,26 @@ discard block |
||
650 | 650 | FALSE |
651 | 651 | ); |
652 | 652 | // did we gets the goods ? |
653 | - if ( $reg_step_obj instanceof EE_SPCO_Reg_Step ) { |
|
653 | + if ($reg_step_obj instanceof EE_SPCO_Reg_Step) { |
|
654 | 654 | // set reg step order based on config |
655 | - $reg_step_obj->set_order( $order ); |
|
655 | + $reg_step_obj->set_order($order); |
|
656 | 656 | // add instantiated reg step object to the master reg steps array |
657 | - $this->checkout->add_reg_step( $reg_step_obj ); |
|
657 | + $this->checkout->add_reg_step($reg_step_obj); |
|
658 | 658 | } else { |
659 | 659 | EE_Error::add_error( |
660 | - __( 'The current step could not be set.', 'event_espresso' ), |
|
660 | + __('The current step could not be set.', 'event_espresso'), |
|
661 | 661 | __FILE__, __FUNCTION__, __LINE__ |
662 | 662 | ); |
663 | 663 | return false; |
664 | 664 | } |
665 | 665 | } else { |
666 | - if ( WP_DEBUG ) { |
|
666 | + if (WP_DEBUG) { |
|
667 | 667 | EE_Error::add_error( |
668 | 668 | sprintf( |
669 | - __( 'A registration step could not be loaded. One or more of the following data points is invalid:%4$s%5$sFile Path: %1$s%6$s%5$sClass Name: %2$s%6$s%5$sSlug: %3$s%6$s%7$s', 'event_espresso' ), |
|
670 | - isset( $reg_step['file_path'] ) ? $reg_step['file_path'] : '', |
|
671 | - isset( $reg_step['class_name'] ) ? $reg_step['class_name'] : '', |
|
672 | - isset( $reg_step['slug'] ) ? $reg_step['slug'] : '', |
|
669 | + __('A registration step could not be loaded. One or more of the following data points is invalid:%4$s%5$sFile Path: %1$s%6$s%5$sClass Name: %2$s%6$s%5$sSlug: %3$s%6$s%7$s', 'event_espresso'), |
|
670 | + isset($reg_step['file_path']) ? $reg_step['file_path'] : '', |
|
671 | + isset($reg_step['class_name']) ? $reg_step['class_name'] : '', |
|
672 | + isset($reg_step['slug']) ? $reg_step['slug'] : '', |
|
673 | 673 | '<ul>', |
674 | 674 | '<li>', |
675 | 675 | '</li>', |
@@ -693,16 +693,16 @@ discard block |
||
693 | 693 | */ |
694 | 694 | private function _get_transaction_and_cart_for_previous_visit() { |
695 | 695 | /** @var $TXN_model EEM_Transaction */ |
696 | - $TXN_model = EE_Registry::instance()->load_model( 'Transaction' ); |
|
696 | + $TXN_model = EE_Registry::instance()->load_model('Transaction'); |
|
697 | 697 | // because the reg_url_link is present in the request, this is a return visit to SPCO, so we'll get the transaction data from the db |
698 | - $transaction = $TXN_model->get_transaction_from_reg_url_link( $this->checkout->reg_url_link ); |
|
698 | + $transaction = $TXN_model->get_transaction_from_reg_url_link($this->checkout->reg_url_link); |
|
699 | 699 | // verify transaction |
700 | - if ( $transaction instanceof EE_Transaction ) { |
|
700 | + if ($transaction instanceof EE_Transaction) { |
|
701 | 701 | // and get the cart that was used for that transaction |
702 | - $this->checkout->cart = $this->_get_cart_for_transaction( $transaction ); |
|
702 | + $this->checkout->cart = $this->_get_cart_for_transaction($transaction); |
|
703 | 703 | return $transaction; |
704 | 704 | } else { |
705 | - EE_Error::add_error( __( 'Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
705 | + EE_Error::add_error(__('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
706 | 706 | return NULL; |
707 | 707 | } |
708 | 708 | } |
@@ -716,8 +716,8 @@ discard block |
||
716 | 716 | * @param EE_Transaction $transaction |
717 | 717 | * @return EE_Cart |
718 | 718 | */ |
719 | - private function _get_cart_for_transaction( $transaction ) { |
|
720 | - return $this->checkout->get_cart_for_transaction( $transaction ); |
|
719 | + private function _get_cart_for_transaction($transaction) { |
|
720 | + return $this->checkout->get_cart_for_transaction($transaction); |
|
721 | 721 | } |
722 | 722 | |
723 | 723 | |
@@ -729,8 +729,8 @@ discard block |
||
729 | 729 | * @param EE_Transaction $transaction |
730 | 730 | * @return EE_Cart |
731 | 731 | */ |
732 | - public function get_cart_for_transaction( EE_Transaction $transaction ) { |
|
733 | - return $this->checkout->get_cart_for_transaction( $transaction ); |
|
732 | + public function get_cart_for_transaction(EE_Transaction $transaction) { |
|
733 | + return $this->checkout->get_cart_for_transaction($transaction); |
|
734 | 734 | } |
735 | 735 | |
736 | 736 | |
@@ -746,17 +746,17 @@ discard block |
||
746 | 746 | private function _get_cart_for_current_session_and_setup_new_transaction() { |
747 | 747 | // if there's no transaction, then this is the FIRST visit to SPCO |
748 | 748 | // so load up the cart ( passing nothing for the TXN because it doesn't exist yet ) |
749 | - $this->checkout->cart = $this->_get_cart_for_transaction( NULL ); |
|
749 | + $this->checkout->cart = $this->_get_cart_for_transaction(NULL); |
|
750 | 750 | // and then create a new transaction |
751 | 751 | $transaction = $this->_initialize_transaction(); |
752 | 752 | // verify transaction |
753 | - if ( $transaction instanceof EE_Transaction ) { |
|
753 | + if ($transaction instanceof EE_Transaction) { |
|
754 | 754 | // save it so that we have an ID for other objects to use |
755 | 755 | $transaction->save(); |
756 | 756 | // and save TXN data to the cart |
757 | - $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn( $transaction->ID() ); |
|
757 | + $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($transaction->ID()); |
|
758 | 758 | } else { |
759 | - EE_Error::add_error( __( 'A Valid Transaction could not be initialized.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
759 | + EE_Error::add_error(__('A Valid Transaction could not be initialized.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
760 | 760 | } |
761 | 761 | return $transaction; |
762 | 762 | } |
@@ -776,15 +776,15 @@ discard block |
||
776 | 776 | // grab the cart grand total |
777 | 777 | $cart_total = $this->checkout->cart->get_cart_grand_total(); |
778 | 778 | // create new TXN |
779 | - return EE_Transaction::new_instance( array( |
|
779 | + return EE_Transaction::new_instance(array( |
|
780 | 780 | 'TXN_timestamp' => time(), |
781 | 781 | 'TXN_reg_steps' => $this->checkout->initialize_txn_reg_steps_array(), |
782 | 782 | 'TXN_total' => $cart_total > 0 ? $cart_total : 0, |
783 | 783 | 'TXN_paid' => 0, |
784 | 784 | 'STS_ID' => EEM_Transaction::failed_status_code, |
785 | 785 | )); |
786 | - } catch( Exception $e ) { |
|
787 | - EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
786 | + } catch (Exception $e) { |
|
787 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
788 | 788 | } |
789 | 789 | return NULL; |
790 | 790 | } |
@@ -799,38 +799,38 @@ discard block |
||
799 | 799 | * @return EE_Cart |
800 | 800 | * @throws \EE_Error |
801 | 801 | */ |
802 | - private function _get_registrations( EE_Transaction $transaction ) { |
|
802 | + private function _get_registrations(EE_Transaction $transaction) { |
|
803 | 803 | // first step: grab the registrants { : o |
804 | - $registrations = $transaction->registrations( $this->checkout->reg_cache_where_params, true ); |
|
804 | + $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, true); |
|
805 | 805 | // verify registrations have been set |
806 | - if ( empty( $registrations )) { |
|
806 | + if (empty($registrations)) { |
|
807 | 807 | // if no cached registrations, then check the db |
808 | - $registrations = $transaction->registrations( $this->checkout->reg_cache_where_params, false ); |
|
808 | + $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false); |
|
809 | 809 | // still nothing ? well as long as this isn't a revisit |
810 | - if ( empty( $registrations ) && ! $this->checkout->revisit ) { |
|
810 | + if (empty($registrations) && ! $this->checkout->revisit) { |
|
811 | 811 | // generate new registrations from scratch |
812 | - $registrations = $this->_initialize_registrations( $transaction ); |
|
812 | + $registrations = $this->_initialize_registrations($transaction); |
|
813 | 813 | } |
814 | 814 | } |
815 | 815 | // sort by their original registration order |
816 | - usort( $registrations, array( 'EED_Single_Page_Checkout', 'sort_registrations_by_REG_count' )); |
|
816 | + usort($registrations, array('EED_Single_Page_Checkout', 'sort_registrations_by_REG_count')); |
|
817 | 817 | // then loop thru the array |
818 | - foreach ( $registrations as $registration ) { |
|
818 | + foreach ($registrations as $registration) { |
|
819 | 819 | // verify each registration |
820 | - if ( $registration instanceof EE_Registration ) { |
|
820 | + if ($registration instanceof EE_Registration) { |
|
821 | 821 | // we display all attendee info for the primary registrant |
822 | - if ( $this->checkout->reg_url_link === $registration->reg_url_link() |
|
822 | + if ($this->checkout->reg_url_link === $registration->reg_url_link() |
|
823 | 823 | && $registration->is_primary_registrant() |
824 | 824 | ) { |
825 | 825 | $this->checkout->primary_revisit = true; |
826 | 826 | break; |
827 | - } else if ( $this->checkout->revisit |
|
827 | + } else if ($this->checkout->revisit |
|
828 | 828 | && $this->checkout->reg_url_link !== $registration->reg_url_link() |
829 | 829 | ) { |
830 | 830 | // but hide info if it doesn't belong to you |
831 | - $transaction->clear_cache( 'Registration', $registration->ID() ); |
|
831 | + $transaction->clear_cache('Registration', $registration->ID()); |
|
832 | 832 | } |
833 | - $this->checkout->set_reg_status_updated( $registration->ID(), false ); |
|
833 | + $this->checkout->set_reg_status_updated($registration->ID(), false); |
|
834 | 834 | } |
835 | 835 | } |
836 | 836 | } |
@@ -845,17 +845,17 @@ discard block |
||
845 | 845 | * @return array |
846 | 846 | * @throws \EE_Error |
847 | 847 | */ |
848 | - private function _initialize_registrations( EE_Transaction $transaction ) { |
|
848 | + private function _initialize_registrations(EE_Transaction $transaction) { |
|
849 | 849 | $att_nmbr = 0; |
850 | 850 | $registrations = array(); |
851 | - if ( $transaction instanceof EE_Transaction ) { |
|
851 | + if ($transaction instanceof EE_Transaction) { |
|
852 | 852 | /** @type EE_Registration_Processor $registration_processor */ |
853 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
853 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
854 | 854 | $this->checkout->total_ticket_count = $this->checkout->cart->all_ticket_quantity_count(); |
855 | 855 | // now let's add the cart items to the $transaction |
856 | - foreach ( $this->checkout->cart->get_tickets() as $line_item ) { |
|
856 | + foreach ($this->checkout->cart->get_tickets() as $line_item) { |
|
857 | 857 | //do the following for each ticket of this type they selected |
858 | - for ( $x = 1; $x <= $line_item->quantity(); $x++ ) { |
|
858 | + for ($x = 1; $x <= $line_item->quantity(); $x++) { |
|
859 | 859 | $att_nmbr++; |
860 | 860 | $CreateRegistrationCommand = EE_Registry::instance() |
861 | 861 | ->create( |
@@ -867,17 +867,17 @@ discard block |
||
867 | 867 | $this->checkout->total_ticket_count |
868 | 868 | ) |
869 | 869 | ); |
870 | - $registration = EE_Registry::instance()->BUS->execute( $CreateRegistrationCommand ); |
|
871 | - if ( ! $registration instanceof EE_Registration ) { |
|
870 | + $registration = EE_Registry::instance()->BUS->execute($CreateRegistrationCommand); |
|
871 | + if ( ! $registration instanceof EE_Registration) { |
|
872 | 872 | throw new InvalidEntityException( |
873 | - is_object( $registration ) ? get_class( $registration ) : gettype( $registration ), |
|
873 | + is_object($registration) ? get_class($registration) : gettype($registration), |
|
874 | 874 | 'EE_Registration' |
875 | 875 | ); |
876 | 876 | } |
877 | - $registrations[ $registration->ID() ] = $registration; |
|
877 | + $registrations[$registration->ID()] = $registration; |
|
878 | 878 | } |
879 | 879 | } |
880 | - $registration_processor->fix_reg_final_price_rounding_issue( $transaction ); |
|
880 | + $registration_processor->fix_reg_final_price_rounding_issue($transaction); |
|
881 | 881 | } |
882 | 882 | return $registrations; |
883 | 883 | } |
@@ -892,12 +892,12 @@ discard block |
||
892 | 892 | * @param EE_Registration $reg_B |
893 | 893 | * @return array() |
894 | 894 | */ |
895 | - public static function sort_registrations_by_REG_count( EE_Registration $reg_A, EE_Registration $reg_B ) { |
|
895 | + public static function sort_registrations_by_REG_count(EE_Registration $reg_A, EE_Registration $reg_B) { |
|
896 | 896 | // this shouldn't ever happen within the same TXN, but oh well |
897 | - if ( $reg_A->count() === $reg_B->count() ) { |
|
897 | + if ($reg_A->count() === $reg_B->count()) { |
|
898 | 898 | return 0; |
899 | 899 | } |
900 | - return ( $reg_A->count() > $reg_B->count() ) ? 1 : -1; |
|
900 | + return ($reg_A->count() > $reg_B->count()) ? 1 : -1; |
|
901 | 901 | } |
902 | 902 | |
903 | 903 | |
@@ -912,21 +912,21 @@ discard block |
||
912 | 912 | */ |
913 | 913 | private function _final_verifications() { |
914 | 914 | // filter checkout |
915 | - $this->checkout = apply_filters( 'FHEE__EED_Single_Page_Checkout___final_verifications__checkout', $this->checkout ); |
|
915 | + $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___final_verifications__checkout', $this->checkout); |
|
916 | 916 | //verify that current step is still set correctly |
917 | - if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step ) { |
|
918 | - EE_Error::add_error( __( 'We\'re sorry but the registration process can not proceed because one or more registration steps were not setup correctly. Please refresh the page and try again or contact support.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
917 | + if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) { |
|
918 | + EE_Error::add_error(__('We\'re sorry but the registration process can not proceed because one or more registration steps were not setup correctly. Please refresh the page and try again or contact support.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
919 | 919 | return false; |
920 | 920 | } |
921 | 921 | // if returning to SPCO, then verify that primary registrant is set |
922 | - if ( ! empty( $this->checkout->reg_url_link )) { |
|
922 | + if ( ! empty($this->checkout->reg_url_link)) { |
|
923 | 923 | $valid_registrant = $this->checkout->transaction->primary_registration(); |
924 | - if ( ! $valid_registrant instanceof EE_Registration ) { |
|
925 | - EE_Error::add_error( __( 'We\'re sorry but there appears to be an error with the "reg_url_link" or the primary registrant for this transaction. Please refresh the page and try again or contact support.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
924 | + if ( ! $valid_registrant instanceof EE_Registration) { |
|
925 | + EE_Error::add_error(__('We\'re sorry but there appears to be an error with the "reg_url_link" or the primary registrant for this transaction. Please refresh the page and try again or contact support.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
926 | 926 | return false; |
927 | 927 | } |
928 | 928 | $valid_registrant = null; |
929 | - foreach ( $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ) as $registration ) { |
|
929 | + foreach ($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) as $registration) { |
|
930 | 930 | if ( |
931 | 931 | $registration instanceof EE_Registration |
932 | 932 | && $registration->reg_url_link() === $this->checkout->reg_url_link |
@@ -934,9 +934,9 @@ discard block |
||
934 | 934 | $valid_registrant = $registration; |
935 | 935 | } |
936 | 936 | } |
937 | - if ( ! $valid_registrant instanceof EE_Registration ) { |
|
937 | + if ( ! $valid_registrant instanceof EE_Registration) { |
|
938 | 938 | // hmmm... maybe we have the wrong session because the user is opening multiple tabs ? |
939 | - if ( EED_Single_Page_Checkout::$_checkout_verified ) { |
|
939 | + if (EED_Single_Page_Checkout::$_checkout_verified) { |
|
940 | 940 | // clear the session, mark the checkout as unverified, and try again |
941 | 941 | EE_Registry::instance()->SSN->clear_session(); |
942 | 942 | EED_Single_Page_Checkout::$_initialized = false; |
@@ -945,13 +945,13 @@ discard block |
||
945 | 945 | EE_Error::reset_notices(); |
946 | 946 | return false; |
947 | 947 | } |
948 | - EE_Error::add_error( __( 'We\'re sorry but there appears to be an error with the "reg_url_link" or the transaction itself. Please refresh the page and try again or contact support.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
948 | + EE_Error::add_error(__('We\'re sorry but there appears to be an error with the "reg_url_link" or the transaction itself. Please refresh the page and try again or contact support.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
949 | 949 | return false; |
950 | 950 | } |
951 | 951 | } |
952 | 952 | // now that things have been kinda sufficiently verified, |
953 | 953 | // let's add the checkout to the session so that's available other systems |
954 | - EE_Registry::instance()->SSN->set_checkout( $this->checkout ); |
|
954 | + EE_Registry::instance()->SSN->set_checkout($this->checkout); |
|
955 | 955 | return true; |
956 | 956 | } |
957 | 957 | |
@@ -966,15 +966,15 @@ discard block |
||
966 | 966 | * @param bool $reinitializing |
967 | 967 | * @throws \EE_Error |
968 | 968 | */ |
969 | - private function _initialize_reg_steps( $reinitializing = false ) { |
|
970 | - $this->checkout->set_reg_step_initiated( $this->checkout->current_step ); |
|
969 | + private function _initialize_reg_steps($reinitializing = false) { |
|
970 | + $this->checkout->set_reg_step_initiated($this->checkout->current_step); |
|
971 | 971 | // loop thru all steps to call their individual "initialize" methods and set i18n strings for JS |
972 | - foreach ( $this->checkout->reg_steps as $reg_step ) { |
|
973 | - if ( ! $reg_step->initialize_reg_step() ) { |
|
972 | + foreach ($this->checkout->reg_steps as $reg_step) { |
|
973 | + if ( ! $reg_step->initialize_reg_step()) { |
|
974 | 974 | // if not initialized then maybe this step is being removed... |
975 | - if ( ! $reinitializing && $reg_step->is_current_step() ) { |
|
975 | + if ( ! $reinitializing && $reg_step->is_current_step()) { |
|
976 | 976 | // if it was the current step, then we need to start over here |
977 | - $this->_initialize_reg_steps( true ); |
|
977 | + $this->_initialize_reg_steps(true); |
|
978 | 978 | return; |
979 | 979 | } |
980 | 980 | continue; |
@@ -983,13 +983,13 @@ discard block |
||
983 | 983 | $reg_step->enqueue_styles_and_scripts(); |
984 | 984 | // i18n |
985 | 985 | $reg_step->translate_js_strings(); |
986 | - if ( $reg_step->is_current_step() ) { |
|
986 | + if ($reg_step->is_current_step()) { |
|
987 | 987 | // the text that appears on the reg step form submit button |
988 | 988 | $reg_step->set_submit_button_text(); |
989 | 989 | } |
990 | 990 | } |
991 | 991 | // dynamically creates hook point like: AHEE__Single_Page_Checkout___initialize_reg_step__attendee_information |
992 | - do_action( "AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}", $this->checkout->current_step ); |
|
992 | + do_action("AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}", $this->checkout->current_step); |
|
993 | 993 | } |
994 | 994 | |
995 | 995 | |
@@ -1002,43 +1002,43 @@ discard block |
||
1002 | 1002 | */ |
1003 | 1003 | private function _check_form_submission() { |
1004 | 1004 | //does this request require the reg form to be generated ? |
1005 | - if ( $this->checkout->generate_reg_form ) { |
|
1005 | + if ($this->checkout->generate_reg_form) { |
|
1006 | 1006 | // ever heard that song by Blue Rodeo ? |
1007 | 1007 | try { |
1008 | 1008 | $this->checkout->current_step->reg_form = $this->checkout->current_step->generate_reg_form(); |
1009 | 1009 | // if not displaying a form, then check for form submission |
1010 | - if ( $this->checkout->process_form_submission && $this->checkout->current_step->reg_form->was_submitted() ) { |
|
1010 | + if ($this->checkout->process_form_submission && $this->checkout->current_step->reg_form->was_submitted()) { |
|
1011 | 1011 | // clear out any old data in case this step is being run again |
1012 | - $this->checkout->current_step->set_valid_data( array() ); |
|
1012 | + $this->checkout->current_step->set_valid_data(array()); |
|
1013 | 1013 | // capture submitted form data |
1014 | 1014 | $this->checkout->current_step->reg_form->receive_form_submission( |
1015 | - apply_filters( 'FHEE__Single_Page_Checkout___check_form_submission__request_params', EE_Registry::instance()->REQ->params(), $this->checkout ) |
|
1015 | + apply_filters('FHEE__Single_Page_Checkout___check_form_submission__request_params', EE_Registry::instance()->REQ->params(), $this->checkout) |
|
1016 | 1016 | ); |
1017 | 1017 | // validate submitted form data |
1018 | - if ( ! $this->checkout->continue_reg && ! $this->checkout->current_step->reg_form->is_valid() ) { |
|
1018 | + if ( ! $this->checkout->continue_reg && ! $this->checkout->current_step->reg_form->is_valid()) { |
|
1019 | 1019 | // thou shall not pass !!! |
1020 | 1020 | $this->checkout->continue_reg = FALSE; |
1021 | 1021 | // any form validation errors? |
1022 | - if ( $this->checkout->current_step->reg_form->submission_error_message() !== '' ) { |
|
1022 | + if ($this->checkout->current_step->reg_form->submission_error_message() !== '') { |
|
1023 | 1023 | $submission_error_messages = array(); |
1024 | 1024 | // bad, bad, bad registrant |
1025 | - foreach( $this->checkout->current_step->reg_form->get_validation_errors_accumulated() as $validation_error ){ |
|
1026 | - if ( $validation_error instanceof EE_Validation_Error ) { |
|
1025 | + foreach ($this->checkout->current_step->reg_form->get_validation_errors_accumulated() as $validation_error) { |
|
1026 | + if ($validation_error instanceof EE_Validation_Error) { |
|
1027 | 1027 | $submission_error_messages[] = sprintf( |
1028 | - __( '%s : %s', 'event_espresso' ), |
|
1028 | + __('%s : %s', 'event_espresso'), |
|
1029 | 1029 | $validation_error->get_form_section()->html_label_text(), |
1030 | 1030 | $validation_error->getMessage() |
1031 | 1031 | ); |
1032 | 1032 | } |
1033 | 1033 | } |
1034 | - EE_Error::add_error( implode( '<br />', $submission_error_messages ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1034 | + EE_Error::add_error(implode('<br />', $submission_error_messages), __FILE__, __FUNCTION__, __LINE__); |
|
1035 | 1035 | } |
1036 | 1036 | // well not really... what will happen is we'll just get redirected back to redo the current step |
1037 | 1037 | $this->go_to_next_step(); |
1038 | 1038 | return; |
1039 | 1039 | } |
1040 | 1040 | } |
1041 | - } catch( EE_Error $e ) { |
|
1041 | + } catch (EE_Error $e) { |
|
1042 | 1042 | $e->get_error(); |
1043 | 1043 | } |
1044 | 1044 | } |
@@ -1055,22 +1055,22 @@ discard block |
||
1055 | 1055 | */ |
1056 | 1056 | private function _process_form_action() { |
1057 | 1057 | // what cha wanna do? |
1058 | - switch( $this->checkout->action ) { |
|
1058 | + switch ($this->checkout->action) { |
|
1059 | 1059 | // AJAX next step reg form |
1060 | 1060 | case 'display_spco_reg_step' : |
1061 | 1061 | $this->checkout->redirect = FALSE; |
1062 | - if ( EE_Registry::instance()->REQ->ajax ) { |
|
1063 | - $this->checkout->json_response->set_reg_step_html( $this->checkout->current_step->display_reg_form() ); |
|
1062 | + if (EE_Registry::instance()->REQ->ajax) { |
|
1063 | + $this->checkout->json_response->set_reg_step_html($this->checkout->current_step->display_reg_form()); |
|
1064 | 1064 | } |
1065 | 1065 | break; |
1066 | 1066 | |
1067 | 1067 | default : |
1068 | 1068 | // meh... do one of those other steps first |
1069 | - if ( ! empty( $this->checkout->action ) && is_callable( array( $this->checkout->current_step, $this->checkout->action ))) { |
|
1069 | + if ( ! empty($this->checkout->action) && is_callable(array($this->checkout->current_step, $this->checkout->action))) { |
|
1070 | 1070 | // dynamically creates hook point like: AHEE__Single_Page_Checkout__before_attendee_information__process_reg_step |
1071 | - do_action( "AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step ); |
|
1071 | + do_action("AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step); |
|
1072 | 1072 | // call action on current step |
1073 | - if ( call_user_func( array( $this->checkout->current_step, $this->checkout->action )) ) { |
|
1073 | + if (call_user_func(array($this->checkout->current_step, $this->checkout->action))) { |
|
1074 | 1074 | // good registrant, you get to proceed |
1075 | 1075 | if ( |
1076 | 1076 | $this->checkout->current_step->success_message() !== '' |
@@ -1081,7 +1081,7 @@ discard block |
||
1081 | 1081 | ) { |
1082 | 1082 | EE_Error::add_success( |
1083 | 1083 | $this->checkout->current_step->success_message() |
1084 | - . '<br />' . $this->checkout->next_step->_instructions() |
|
1084 | + . '<br />'.$this->checkout->next_step->_instructions() |
|
1085 | 1085 | ); |
1086 | 1086 | |
1087 | 1087 | } |
@@ -1089,12 +1089,12 @@ discard block |
||
1089 | 1089 | $this->_setup_redirect(); |
1090 | 1090 | } |
1091 | 1091 | // dynamically creates hook point like: AHEE__Single_Page_Checkout__after_payment_options__process_reg_step |
1092 | - do_action( "AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step ); |
|
1092 | + do_action("AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step); |
|
1093 | 1093 | |
1094 | 1094 | } else { |
1095 | 1095 | EE_Error::add_error( |
1096 | 1096 | sprintf( |
1097 | - __( 'The requested form action "%s" does not exist for the current "%s" registration step.', 'event_espresso' ), |
|
1097 | + __('The requested form action "%s" does not exist for the current "%s" registration step.', 'event_espresso'), |
|
1098 | 1098 | $this->checkout->action, |
1099 | 1099 | $this->checkout->current_step->name() |
1100 | 1100 | ), |
@@ -1120,10 +1120,10 @@ discard block |
||
1120 | 1120 | public function add_styles_and_scripts() { |
1121 | 1121 | // i18n |
1122 | 1122 | $this->translate_js_strings(); |
1123 | - if ( $this->checkout->admin_request ) { |
|
1124 | - add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10 ); |
|
1123 | + if ($this->checkout->admin_request) { |
|
1124 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10); |
|
1125 | 1125 | } else { |
1126 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles_and_scripts' ), 10 ); |
|
1126 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10); |
|
1127 | 1127 | } |
1128 | 1128 | } |
1129 | 1129 | |
@@ -1139,42 +1139,42 @@ discard block |
||
1139 | 1139 | EE_Registry::$i18n_js_strings['revisit'] = $this->checkout->revisit; |
1140 | 1140 | EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->checkout->reg_url_link; |
1141 | 1141 | EE_Registry::$i18n_js_strings['server_error'] = __('An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again or contact support.', 'event_espresso'); |
1142 | - EE_Registry::$i18n_js_strings['invalid_json_response'] = __( 'An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.', 'event_espresso' ); |
|
1143 | - EE_Registry::$i18n_js_strings['validation_error'] = __( 'There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.', 'event_espresso' ); |
|
1144 | - EE_Registry::$i18n_js_strings['invalid_payment_method'] = __( 'There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.', 'event_espresso' ); |
|
1142 | + EE_Registry::$i18n_js_strings['invalid_json_response'] = __('An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.', 'event_espresso'); |
|
1143 | + EE_Registry::$i18n_js_strings['validation_error'] = __('There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.', 'event_espresso'); |
|
1144 | + EE_Registry::$i18n_js_strings['invalid_payment_method'] = __('There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.', 'event_espresso'); |
|
1145 | 1145 | EE_Registry::$i18n_js_strings['reg_step_error'] = __('This registration step could not be completed. Please refresh the page and try again.', 'event_espresso'); |
1146 | 1146 | EE_Registry::$i18n_js_strings['invalid_coupon'] = __('We\'re sorry but that coupon code does not appear to be valid. If this is incorrect, please contact the site administrator.', 'event_espresso'); |
1147 | - EE_Registry::$i18n_js_strings['process_registration'] = sprintf( __( 'Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.', 'event_espresso' ), '<br/>', '<br/>' ); |
|
1148 | - EE_Registry::$i18n_js_strings['language'] = get_bloginfo( 'language' ); |
|
1147 | + EE_Registry::$i18n_js_strings['process_registration'] = sprintf(__('Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.', 'event_espresso'), '<br/>', '<br/>'); |
|
1148 | + EE_Registry::$i18n_js_strings['language'] = get_bloginfo('language'); |
|
1149 | 1149 | EE_Registry::$i18n_js_strings['EESID'] = EE_Registry::instance()->SSN->id(); |
1150 | 1150 | EE_Registry::$i18n_js_strings['currency'] = EE_Registry::instance()->CFG->currency; |
1151 | 1151 | EE_Registry::$i18n_js_strings['datepicker_yearRange'] = '-150:+20'; |
1152 | - EE_Registry::$i18n_js_strings['timer_years'] = __( 'years', 'event_espresso' ); |
|
1153 | - EE_Registry::$i18n_js_strings['timer_months'] = __( 'months', 'event_espresso' ); |
|
1154 | - EE_Registry::$i18n_js_strings['timer_weeks'] = __( 'weeks', 'event_espresso' ); |
|
1155 | - EE_Registry::$i18n_js_strings['timer_days'] = __( 'days', 'event_espresso' ); |
|
1156 | - EE_Registry::$i18n_js_strings['timer_hours'] = __( 'hours', 'event_espresso' ); |
|
1157 | - EE_Registry::$i18n_js_strings['timer_minutes'] = __( 'minutes', 'event_espresso' ); |
|
1158 | - EE_Registry::$i18n_js_strings['timer_seconds'] = __( 'seconds', 'event_espresso' ); |
|
1159 | - EE_Registry::$i18n_js_strings['timer_year'] = __( 'year', 'event_espresso' ); |
|
1160 | - EE_Registry::$i18n_js_strings['timer_month'] = __( 'month', 'event_espresso' ); |
|
1161 | - EE_Registry::$i18n_js_strings['timer_week'] = __( 'week', 'event_espresso' ); |
|
1162 | - EE_Registry::$i18n_js_strings['timer_day'] = __( 'day', 'event_espresso' ); |
|
1163 | - EE_Registry::$i18n_js_strings['timer_hour'] = __( 'hour', 'event_espresso' ); |
|
1164 | - EE_Registry::$i18n_js_strings['timer_minute'] = __( 'minute', 'event_espresso' ); |
|
1165 | - EE_Registry::$i18n_js_strings['timer_second'] = __( 'second', 'event_espresso' ); |
|
1152 | + EE_Registry::$i18n_js_strings['timer_years'] = __('years', 'event_espresso'); |
|
1153 | + EE_Registry::$i18n_js_strings['timer_months'] = __('months', 'event_espresso'); |
|
1154 | + EE_Registry::$i18n_js_strings['timer_weeks'] = __('weeks', 'event_espresso'); |
|
1155 | + EE_Registry::$i18n_js_strings['timer_days'] = __('days', 'event_espresso'); |
|
1156 | + EE_Registry::$i18n_js_strings['timer_hours'] = __('hours', 'event_espresso'); |
|
1157 | + EE_Registry::$i18n_js_strings['timer_minutes'] = __('minutes', 'event_espresso'); |
|
1158 | + EE_Registry::$i18n_js_strings['timer_seconds'] = __('seconds', 'event_espresso'); |
|
1159 | + EE_Registry::$i18n_js_strings['timer_year'] = __('year', 'event_espresso'); |
|
1160 | + EE_Registry::$i18n_js_strings['timer_month'] = __('month', 'event_espresso'); |
|
1161 | + EE_Registry::$i18n_js_strings['timer_week'] = __('week', 'event_espresso'); |
|
1162 | + EE_Registry::$i18n_js_strings['timer_day'] = __('day', 'event_espresso'); |
|
1163 | + EE_Registry::$i18n_js_strings['timer_hour'] = __('hour', 'event_espresso'); |
|
1164 | + EE_Registry::$i18n_js_strings['timer_minute'] = __('minute', 'event_espresso'); |
|
1165 | + EE_Registry::$i18n_js_strings['timer_second'] = __('second', 'event_espresso'); |
|
1166 | 1166 | EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf( |
1167 | - __( '%1$sWe\'re sorry, but your registration time has expired.%2$s%3$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please except our apologies for any inconvenience this may have caused.%8$s', 'event_espresso' ), |
|
1167 | + __('%1$sWe\'re sorry, but your registration time has expired.%2$s%3$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please except our apologies for any inconvenience this may have caused.%8$s', 'event_espresso'), |
|
1168 | 1168 | '<h4 class="important-notice">', |
1169 | 1169 | '</h4>', |
1170 | 1170 | '<br />', |
1171 | 1171 | '<p>', |
1172 | - '<a href="'. get_post_type_archive_link( 'espresso_events' ) . '" title="', |
|
1172 | + '<a href="'.get_post_type_archive_link('espresso_events').'" title="', |
|
1173 | 1173 | '">', |
1174 | 1174 | '</a>', |
1175 | 1175 | '</p>' |
1176 | 1176 | ); |
1177 | - EE_Registry::$i18n_js_strings[ 'ajax_submit' ] = apply_filters( 'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', true ); |
|
1177 | + EE_Registry::$i18n_js_strings['ajax_submit'] = apply_filters('FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', true); |
|
1178 | 1178 | } |
1179 | 1179 | |
1180 | 1180 | |
@@ -1187,25 +1187,25 @@ discard block |
||
1187 | 1187 | */ |
1188 | 1188 | public function enqueue_styles_and_scripts() { |
1189 | 1189 | // load css |
1190 | - wp_register_style( 'single_page_checkout', SPCO_CSS_URL . 'single_page_checkout.css', array(), EVENT_ESPRESSO_VERSION ); |
|
1191 | - wp_enqueue_style( 'single_page_checkout' ); |
|
1190 | + wp_register_style('single_page_checkout', SPCO_CSS_URL.'single_page_checkout.css', array(), EVENT_ESPRESSO_VERSION); |
|
1191 | + wp_enqueue_style('single_page_checkout'); |
|
1192 | 1192 | // load JS |
1193 | - wp_register_script( 'jquery_plugin', EE_THIRD_PARTY_URL . 'jquery .plugin.min.js', array( 'jquery' ), '1.0.1', TRUE ); |
|
1194 | - wp_register_script( 'jquery_countdown', EE_THIRD_PARTY_URL . 'jquery .countdown.min.js', array( 'jquery_plugin' ), '2.0.2', TRUE ); |
|
1195 | - wp_register_script( 'single_page_checkout', SPCO_JS_URL . 'single_page_checkout.js', array( 'espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown' ), EVENT_ESPRESSO_VERSION, TRUE ); |
|
1196 | - wp_enqueue_script( 'single_page_checkout' ); |
|
1193 | + wp_register_script('jquery_plugin', EE_THIRD_PARTY_URL.'jquery .plugin.min.js', array('jquery'), '1.0.1', TRUE); |
|
1194 | + wp_register_script('jquery_countdown', EE_THIRD_PARTY_URL.'jquery .countdown.min.js', array('jquery_plugin'), '2.0.2', TRUE); |
|
1195 | + wp_register_script('single_page_checkout', SPCO_JS_URL.'single_page_checkout.js', array('espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown'), EVENT_ESPRESSO_VERSION, TRUE); |
|
1196 | + wp_enqueue_script('single_page_checkout'); |
|
1197 | 1197 | |
1198 | 1198 | /** |
1199 | 1199 | * global action hook for enqueueing styles and scripts with |
1200 | 1200 | * spco calls. |
1201 | 1201 | */ |
1202 | - do_action( 'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this ); |
|
1202 | + do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this); |
|
1203 | 1203 | |
1204 | 1204 | /** |
1205 | 1205 | * dynamic action hook for enqueueing styles and scripts with spco calls. |
1206 | 1206 | * The hook will end up being something like AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information |
1207 | 1207 | */ |
1208 | - do_action( 'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(), $this ); |
|
1208 | + do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__'.$this->checkout->current_step->slug(), $this); |
|
1209 | 1209 | |
1210 | 1210 | } |
1211 | 1211 | |
@@ -1220,19 +1220,19 @@ discard block |
||
1220 | 1220 | */ |
1221 | 1221 | private function _display_spco_reg_form() { |
1222 | 1222 | // if registering via the admin, just display the reg form for the current step |
1223 | - if ( $this->checkout->admin_request ) { |
|
1224 | - EE_Registry::instance()->REQ->add_output( $this->checkout->current_step->display_reg_form() ); |
|
1223 | + if ($this->checkout->admin_request) { |
|
1224 | + EE_Registry::instance()->REQ->add_output($this->checkout->current_step->display_reg_form()); |
|
1225 | 1225 | } else { |
1226 | 1226 | // add powered by EE msg |
1227 | - add_action( 'AHEE__SPCO__reg_form_footer', array( 'EED_Single_Page_Checkout', 'display_registration_footer' )); |
|
1227 | + add_action('AHEE__SPCO__reg_form_footer', array('EED_Single_Page_Checkout', 'display_registration_footer')); |
|
1228 | 1228 | |
1229 | - $empty_cart = count( $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ) ) < 1 ? true : false; |
|
1229 | + $empty_cart = count($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params)) < 1 ? true : false; |
|
1230 | 1230 | $cookies_not_set_msg = ''; |
1231 | - if ( $empty_cart && ! isset( $_COOKIE[ 'ee_cookie_test' ] ) ) { |
|
1231 | + if ($empty_cart && ! isset($_COOKIE['ee_cookie_test'])) { |
|
1232 | 1232 | $cookies_not_set_msg = apply_filters( |
1233 | 1233 | 'FHEE__Single_Page_Checkout__display_spco_reg_form__cookies_not_set_msg', |
1234 | 1234 | sprintf( |
1235 | - __( '%1$s%3$sIt appears your browser is not currently set to accept Cookies%4$s%5$sIn order to register for events, you need to enable cookies.%7$sIf you require assistance, then click the following link to learn how to %8$senable cookies%9$s%6$s%2$s', 'event_espresso' ), |
|
1235 | + __('%1$s%3$sIt appears your browser is not currently set to accept Cookies%4$s%5$sIn order to register for events, you need to enable cookies.%7$sIf you require assistance, then click the following link to learn how to %8$senable cookies%9$s%6$s%2$s', 'event_espresso'), |
|
1236 | 1236 | '<div class="ee-attention">', |
1237 | 1237 | '</div>', |
1238 | 1238 | '<h6 class="important-notice">', |
@@ -1252,7 +1252,7 @@ discard block |
||
1252 | 1252 | 'layout_strategy' => |
1253 | 1253 | new EE_Template_Layout( |
1254 | 1254 | array( |
1255 | - 'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php', |
|
1255 | + 'layout_template_file' => SPCO_TEMPLATES_PATH.'registration_page_wrapper.template.php', |
|
1256 | 1256 | 'template_args' => array( |
1257 | 1257 | 'empty_cart' => $empty_cart, |
1258 | 1258 | 'revisit' => $this->checkout->revisit, |
@@ -1261,8 +1261,8 @@ discard block |
||
1261 | 1261 | 'empty_msg' => apply_filters( |
1262 | 1262 | 'FHEE__Single_Page_Checkout__display_spco_reg_form__empty_msg', |
1263 | 1263 | sprintf( |
1264 | - __( 'You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.', 'event_espresso' ), |
|
1265 | - '<a href="' . get_post_type_archive_link( 'espresso_events' ) . '" title="', |
|
1264 | + __('You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.', 'event_espresso'), |
|
1265 | + '<a href="'.get_post_type_archive_link('espresso_events').'" title="', |
|
1266 | 1266 | '">', |
1267 | 1267 | '</a>' |
1268 | 1268 | ) |
@@ -1270,14 +1270,14 @@ discard block |
||
1270 | 1270 | 'cookies_not_set_msg' => $cookies_not_set_msg, |
1271 | 1271 | 'registration_time_limit' => $this->checkout->get_registration_time_limit(), |
1272 | 1272 | 'session_expiration' => |
1273 | - gmdate( 'M d, Y H:i:s', EE_Registry::instance()->SSN->expiration() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ) |
|
1273 | + gmdate('M d, Y H:i:s', EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS)) |
|
1274 | 1274 | ) |
1275 | 1275 | ) |
1276 | 1276 | ) |
1277 | 1277 | ) |
1278 | 1278 | ); |
1279 | 1279 | // load template and add to output sent that gets filtered into the_content() |
1280 | - EE_Registry::instance()->REQ->add_output( $this->checkout->registration_form->get_html_and_js() ); |
|
1280 | + EE_Registry::instance()->REQ->add_output($this->checkout->registration_form->get_html_and_js()); |
|
1281 | 1281 | } |
1282 | 1282 | } |
1283 | 1283 | |
@@ -1291,8 +1291,8 @@ discard block |
||
1291 | 1291 | * @internal param string $label |
1292 | 1292 | * @return string |
1293 | 1293 | */ |
1294 | - public function add_extra_finalize_registration_inputs( $next_step ) { |
|
1295 | - if ( $next_step === 'finalize_registration' ) { |
|
1294 | + public function add_extra_finalize_registration_inputs($next_step) { |
|
1295 | + if ($next_step === 'finalize_registration') { |
|
1296 | 1296 | echo '<div id="spco-extra-finalize_registration-inputs-dv"></div>'; |
1297 | 1297 | } |
1298 | 1298 | } |
@@ -1306,18 +1306,18 @@ discard block |
||
1306 | 1306 | * @return string |
1307 | 1307 | */ |
1308 | 1308 | public static function display_registration_footer() { |
1309 | - if ( apply_filters( 'FHEE__EE_Front__Controller__show_reg_footer', EE_Registry::instance()->CFG->admin->show_reg_footer ) ) { |
|
1310 | - EE_Registry::instance()->CFG->admin->affiliate_id = ! empty( EE_Registry::instance()->CFG->admin->affiliate_id ) ? EE_Registry::instance()->CFG->admin->affiliate_id : 'default'; |
|
1311 | - $url = add_query_arg( array( 'ap_id' => EE_Registry::instance()->CFG->admin->affiliate_id ), 'https://eventespresso.com/' ); |
|
1312 | - $url = apply_filters( 'FHEE__EE_Front_Controller__registration_footer__url', $url ); |
|
1309 | + if (apply_filters('FHEE__EE_Front__Controller__show_reg_footer', EE_Registry::instance()->CFG->admin->show_reg_footer)) { |
|
1310 | + EE_Registry::instance()->CFG->admin->affiliate_id = ! empty(EE_Registry::instance()->CFG->admin->affiliate_id) ? EE_Registry::instance()->CFG->admin->affiliate_id : 'default'; |
|
1311 | + $url = add_query_arg(array('ap_id' => EE_Registry::instance()->CFG->admin->affiliate_id), 'https://eventespresso.com/'); |
|
1312 | + $url = apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url); |
|
1313 | 1313 | echo apply_filters( |
1314 | 1314 | 'FHEE__EE_Front_Controller__display_registration_footer', |
1315 | 1315 | sprintf( |
1316 | - __( '%1$sEvent Registration Powered by Event Espresso%2$sEvent Registration and Ticketing%3$s Powered by %4$sEvent Espresso - Event Registration and Management System for WordPress%5$sEvent Espresso%6$s', 'event_espresso' ), |
|
1317 | - '<div id="espresso-registration-footer-dv"><a href="' . $url . '" title="', |
|
1316 | + __('%1$sEvent Registration Powered by Event Espresso%2$sEvent Registration and Ticketing%3$s Powered by %4$sEvent Espresso - Event Registration and Management System for WordPress%5$sEvent Espresso%6$s', 'event_espresso'), |
|
1317 | + '<div id="espresso-registration-footer-dv"><a href="'.$url.'" title="', |
|
1318 | 1318 | '" target="_blank">', |
1319 | 1319 | '</a>', |
1320 | - '<a href="' . $url . '" title="', |
|
1320 | + '<a href="'.$url.'" title="', |
|
1321 | 1321 | '" target="_blank">', |
1322 | 1322 | '</a></div>' |
1323 | 1323 | ) |
@@ -1335,7 +1335,7 @@ discard block |
||
1335 | 1335 | * @throws \EE_Error |
1336 | 1336 | */ |
1337 | 1337 | public function unlock_transaction() { |
1338 | - if ( $this->checkout->transaction instanceof EE_Transaction ) { |
|
1338 | + if ($this->checkout->transaction instanceof EE_Transaction) { |
|
1339 | 1339 | $this->checkout->transaction->unlock(); |
1340 | 1340 | } |
1341 | 1341 | } |
@@ -1350,12 +1350,12 @@ discard block |
||
1350 | 1350 | * @return array |
1351 | 1351 | */ |
1352 | 1352 | private function _setup_redirect() { |
1353 | - if ( $this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step ) { |
|
1353 | + if ($this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
1354 | 1354 | $this->checkout->redirect = TRUE; |
1355 | - if ( empty( $this->checkout->redirect_url )) { |
|
1355 | + if (empty($this->checkout->redirect_url)) { |
|
1356 | 1356 | $this->checkout->redirect_url = $this->checkout->next_step->reg_step_url(); |
1357 | 1357 | } |
1358 | - $this->checkout->redirect_url = apply_filters( 'FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url', $this->checkout->redirect_url, $this->checkout ); |
|
1358 | + $this->checkout->redirect_url = apply_filters('FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url', $this->checkout->redirect_url, $this->checkout); |
|
1359 | 1359 | } |
1360 | 1360 | } |
1361 | 1361 | |
@@ -1369,9 +1369,9 @@ discard block |
||
1369 | 1369 | * @throws \EE_Error |
1370 | 1370 | */ |
1371 | 1371 | public function go_to_next_step() { |
1372 | - if ( EE_Registry::instance()->REQ->ajax ) { |
|
1372 | + if (EE_Registry::instance()->REQ->ajax) { |
|
1373 | 1373 | // capture contents of output buffer we started earlier in the request, and insert into JSON response |
1374 | - $this->checkout->json_response->set_unexpected_errors( ob_get_clean() ); |
|
1374 | + $this->checkout->json_response->set_unexpected_errors(ob_get_clean()); |
|
1375 | 1375 | } |
1376 | 1376 | $this->unlock_transaction(); |
1377 | 1377 | // just return for these conditions |
@@ -1400,7 +1400,7 @@ discard block |
||
1400 | 1400 | */ |
1401 | 1401 | protected function _handle_json_response() { |
1402 | 1402 | // if this is an ajax request |
1403 | - if ( EE_Registry::instance()->REQ->ajax ) { |
|
1403 | + if (EE_Registry::instance()->REQ->ajax) { |
|
1404 | 1404 | // DEBUG LOG |
1405 | 1405 | //$this->checkout->log( |
1406 | 1406 | // __CLASS__, __FUNCTION__, __LINE__, |
@@ -1413,7 +1413,7 @@ discard block |
||
1413 | 1413 | $this->checkout->json_response->set_registration_time_limit( |
1414 | 1414 | $this->checkout->get_registration_time_limit() |
1415 | 1415 | ); |
1416 | - $this->checkout->json_response->set_payment_amount( $this->checkout->amount_owing ); |
|
1416 | + $this->checkout->json_response->set_payment_amount($this->checkout->amount_owing); |
|
1417 | 1417 | // just send the ajax ( |
1418 | 1418 | $json_response = apply_filters( |
1419 | 1419 | 'FHEE__EE_Single_Page_Checkout__JSON_response', |
@@ -1434,9 +1434,9 @@ discard block |
||
1434 | 1434 | */ |
1435 | 1435 | protected function _handle_html_redirects() { |
1436 | 1436 | // going somewhere ? |
1437 | - if ( $this->checkout->redirect && ! empty( $this->checkout->redirect_url ) ) { |
|
1437 | + if ($this->checkout->redirect && ! empty($this->checkout->redirect_url)) { |
|
1438 | 1438 | // store notices in a transient |
1439 | - EE_Error::get_notices( false, true, true ); |
|
1439 | + EE_Error::get_notices(false, true, true); |
|
1440 | 1440 | // DEBUG LOG |
1441 | 1441 | //$this->checkout->log( |
1442 | 1442 | // __CLASS__, __FUNCTION__, __LINE__, |
@@ -1446,7 +1446,7 @@ discard block |
||
1446 | 1446 | // 'headers_list' => headers_list(), |
1447 | 1447 | // ) |
1448 | 1448 | //); |
1449 | - wp_safe_redirect( $this->checkout->redirect_url ); |
|
1449 | + wp_safe_redirect($this->checkout->redirect_url); |
|
1450 | 1450 | exit(); |
1451 | 1451 | } |
1452 | 1452 | } |
@@ -820,12 +820,12 @@ discard block |
||
820 | 820 | if ( $registration instanceof EE_Registration ) { |
821 | 821 | // we display all attendee info for the primary registrant |
822 | 822 | if ( $this->checkout->reg_url_link === $registration->reg_url_link() |
823 | - && $registration->is_primary_registrant() |
|
823 | + && $registration->is_primary_registrant() |
|
824 | 824 | ) { |
825 | 825 | $this->checkout->primary_revisit = true; |
826 | 826 | break; |
827 | 827 | } else if ( $this->checkout->revisit |
828 | - && $this->checkout->reg_url_link !== $registration->reg_url_link() |
|
828 | + && $this->checkout->reg_url_link !== $registration->reg_url_link() |
|
829 | 829 | ) { |
830 | 830 | // but hide info if it doesn't belong to you |
831 | 831 | $transaction->clear_cache( 'Registration', $registration->ID() ); |
@@ -857,24 +857,24 @@ discard block |
||
857 | 857 | //do the following for each ticket of this type they selected |
858 | 858 | for ( $x = 1; $x <= $line_item->quantity(); $x++ ) { |
859 | 859 | $att_nmbr++; |
860 | - /** @var EventEspresso\core\services\commands\registration\CreateRegistrationCommand $CreateRegistrationCommand */ |
|
861 | - $CreateRegistrationCommand = EE_Registry::instance() |
|
862 | - ->create( |
|
863 | - 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
864 | - array( |
|
865 | - $transaction, |
|
866 | - $line_item, |
|
867 | - $att_nmbr, |
|
868 | - $this->checkout->total_ticket_count |
|
869 | - ) |
|
870 | - ); |
|
871 | - // override capabilities for frontend registrations |
|
872 | - if ( ! is_admin()) { |
|
873 | - $CreateRegistrationCommand->setCapCheck( |
|
874 | - new \EventEspresso\core\domain\services\capabilities\PublicCapabilities('', |
|
875 | - 'create_new_registration') |
|
876 | - ); |
|
877 | - } |
|
860 | + /** @var EventEspresso\core\services\commands\registration\CreateRegistrationCommand $CreateRegistrationCommand */ |
|
861 | + $CreateRegistrationCommand = EE_Registry::instance() |
|
862 | + ->create( |
|
863 | + 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
864 | + array( |
|
865 | + $transaction, |
|
866 | + $line_item, |
|
867 | + $att_nmbr, |
|
868 | + $this->checkout->total_ticket_count |
|
869 | + ) |
|
870 | + ); |
|
871 | + // override capabilities for frontend registrations |
|
872 | + if ( ! is_admin()) { |
|
873 | + $CreateRegistrationCommand->setCapCheck( |
|
874 | + new \EventEspresso\core\domain\services\capabilities\PublicCapabilities('', |
|
875 | + 'create_new_registration') |
|
876 | + ); |
|
877 | + } |
|
878 | 878 | $registration = EE_Registry::instance()->BUS->execute( $CreateRegistrationCommand ); |
879 | 879 | if ( ! $registration instanceof EE_Registration ) { |
880 | 880 | throw new InvalidEntityException( |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | /** |
6 | 6 | * Class EE_Line_Item_Filter_Collection |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | use EventEspresso\core\exceptions\UnexpectedEntityException; |
6 | 6 | |
7 | 7 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
8 | - exit('No direct script access allowed'); |
|
8 | + exit('No direct script access allowed'); |
|
9 | 9 | } |
10 | 10 | |
11 | 11 | |
@@ -21,39 +21,39 @@ discard block |
||
21 | 21 | class CreateTicketLineItemService extends DomainService |
22 | 22 | { |
23 | 23 | |
24 | - /** |
|
25 | - * @param \EE_Transaction $transaction |
|
26 | - * @param \EE_Ticket $ticket |
|
27 | - * @param int $quantity |
|
28 | - * @return \EE_Line_Item |
|
29 | - * @throws \EE_Error |
|
30 | - * @throws UnexpectedEntityException |
|
31 | - */ |
|
32 | - public function create( |
|
33 | - \EE_Transaction $transaction, |
|
34 | - \EE_Ticket $ticket, |
|
35 | - $quantity = 1 |
|
36 | - ) |
|
37 | - { |
|
38 | - // create new line item for ticket |
|
39 | - $ticket_line_item = \EEH_Line_Item::add_ticket_purchase( |
|
40 | - $transaction->total_line_item(), |
|
41 | - $ticket, |
|
42 | - $quantity |
|
43 | - ); |
|
44 | - if ( ! $ticket_line_item instanceof \EE_Line_Item) { |
|
45 | - throw new UnexpectedEntityException($ticket_line_item, 'EE_Line_Item'); |
|
46 | - } |
|
47 | - // apply any applicable promotions that were initially used during registration to new line items |
|
48 | - do_action( |
|
49 | - 'AHEE__\EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler__handle__new_ticket_line_item_added', |
|
50 | - $transaction->total_line_item(), |
|
51 | - $ticket, |
|
52 | - $transaction, |
|
53 | - $quantity |
|
54 | - ); |
|
55 | - return $ticket_line_item; |
|
56 | - } |
|
24 | + /** |
|
25 | + * @param \EE_Transaction $transaction |
|
26 | + * @param \EE_Ticket $ticket |
|
27 | + * @param int $quantity |
|
28 | + * @return \EE_Line_Item |
|
29 | + * @throws \EE_Error |
|
30 | + * @throws UnexpectedEntityException |
|
31 | + */ |
|
32 | + public function create( |
|
33 | + \EE_Transaction $transaction, |
|
34 | + \EE_Ticket $ticket, |
|
35 | + $quantity = 1 |
|
36 | + ) |
|
37 | + { |
|
38 | + // create new line item for ticket |
|
39 | + $ticket_line_item = \EEH_Line_Item::add_ticket_purchase( |
|
40 | + $transaction->total_line_item(), |
|
41 | + $ticket, |
|
42 | + $quantity |
|
43 | + ); |
|
44 | + if ( ! $ticket_line_item instanceof \EE_Line_Item) { |
|
45 | + throw new UnexpectedEntityException($ticket_line_item, 'EE_Line_Item'); |
|
46 | + } |
|
47 | + // apply any applicable promotions that were initially used during registration to new line items |
|
48 | + do_action( |
|
49 | + 'AHEE__\EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler__handle__new_ticket_line_item_added', |
|
50 | + $transaction->total_line_item(), |
|
51 | + $ticket, |
|
52 | + $transaction, |
|
53 | + $quantity |
|
54 | + ); |
|
55 | + return $ticket_line_item; |
|
56 | + } |
|
57 | 57 | |
58 | 58 | |
59 | 59 |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | use EventEspresso\core\exceptions\EntityNotFoundException; |
6 | 6 | |
7 | 7 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
8 | - exit('No direct script access allowed'); |
|
8 | + exit('No direct script access allowed'); |
|
9 | 9 | } |
10 | 10 | |
11 | 11 | |
@@ -25,116 +25,116 @@ discard block |
||
25 | 25 | { |
26 | 26 | |
27 | 27 | |
28 | - /** |
|
29 | - * @param \EE_Registration $registration |
|
30 | - * @param int $quantity |
|
31 | - * @return bool|int |
|
32 | - */ |
|
33 | - public function forRegistration(\EE_Registration $registration,$quantity = 1) { |
|
34 | - return $this->cancel( |
|
35 | - $registration->transaction(), |
|
36 | - $registration->ticket(), |
|
37 | - $quantity, |
|
38 | - $registration->ticket_line_item() |
|
39 | - ); |
|
40 | - } |
|
28 | + /** |
|
29 | + * @param \EE_Registration $registration |
|
30 | + * @param int $quantity |
|
31 | + * @return bool|int |
|
32 | + */ |
|
33 | + public function forRegistration(\EE_Registration $registration,$quantity = 1) { |
|
34 | + return $this->cancel( |
|
35 | + $registration->transaction(), |
|
36 | + $registration->ticket(), |
|
37 | + $quantity, |
|
38 | + $registration->ticket_line_item() |
|
39 | + ); |
|
40 | + } |
|
41 | 41 | |
42 | 42 | |
43 | - /** |
|
44 | - * @param \EE_Transaction $transaction |
|
45 | - * @param \EE_Ticket $ticket |
|
46 | - * @param int $quantity |
|
47 | - * @param \EE_Line_Item $ticket_line_item |
|
48 | - * @return bool|int |
|
49 | - */ |
|
50 | - public function cancel( |
|
51 | - \EE_Transaction $transaction, |
|
52 | - \EE_Ticket $ticket, |
|
53 | - $quantity = 1, |
|
54 | - \EE_Line_Item $ticket_line_item = null |
|
55 | - ) { |
|
56 | - $ticket_line_item = $ticket_line_item instanceof \EE_Line_Item |
|
57 | - ? $ticket_line_item |
|
58 | - : $this->getTicketLineItem($transaction, $ticket); |
|
59 | - // first we need to decrement the ticket quantity |
|
60 | - \EEH_Line_Item::decrement_quantity($ticket_line_item, $quantity); |
|
61 | - // no tickets left for this line item ? |
|
62 | - if ((int)$ticket_line_item->quantity() === 0) { |
|
63 | - // then just set this line item as cancelled, save, and get out |
|
64 | - $ticket_line_item->set_type(\EEM_Line_Item::type_cancellation); |
|
65 | - $success = $ticket_line_item->save(); |
|
66 | - } else { |
|
67 | - // otherwise create a new cancelled line item, so that we have a record of the cancellation |
|
68 | - $items_subtotal = \EEH_Line_Item::get_pre_tax_subtotal( |
|
69 | - \EEH_Line_Item::get_event_line_item_for_ticket( |
|
70 | - $transaction->total_line_item(), |
|
71 | - $ticket |
|
72 | - ) |
|
73 | - ); |
|
74 | - $cancelled_line_item = \EE_Line_Item::new_instance( |
|
75 | - array( |
|
76 | - 'LIN_name' => $ticket_line_item->name(), |
|
77 | - 'LIN_desc' => sprintf( |
|
78 | - __('%1$s Cancelled: %2$s', 'event_espresso'), |
|
79 | - $ticket_line_item->desc(), |
|
80 | - date('Y-m-d h:i a') |
|
81 | - ), |
|
82 | - 'LIN_unit_price' => (float)$ticket_line_item->unit_price(), |
|
83 | - 'LIN_quantity' => $quantity, |
|
84 | - 'LIN_percent' => null, |
|
85 | - 'LIN_is_taxable' => false, |
|
86 | - 'LIN_order' => $items_subtotal instanceof \EE_Line_Item |
|
87 | - ? count($items_subtotal->children()) |
|
88 | - : 0, |
|
89 | - 'LIN_total' => (float)$ticket_line_item->unit_price(), |
|
90 | - 'LIN_type' => \EEM_Line_Item::type_cancellation |
|
91 | - ) |
|
92 | - ); |
|
93 | - $success = \EEH_Line_Item::add_item($transaction->total_line_item(), $cancelled_line_item); |
|
94 | - } |
|
95 | - if ( ! $success) { |
|
96 | - throw new \RuntimeException( |
|
97 | - sprintf( |
|
98 | - __('An error occurred while attempting to cancel ticket line item %1$s', 'event_espresso'), |
|
99 | - $ticket_line_item->ID() |
|
100 | - ) |
|
101 | - ); |
|
102 | - } |
|
103 | - return $success; |
|
104 | - } |
|
43 | + /** |
|
44 | + * @param \EE_Transaction $transaction |
|
45 | + * @param \EE_Ticket $ticket |
|
46 | + * @param int $quantity |
|
47 | + * @param \EE_Line_Item $ticket_line_item |
|
48 | + * @return bool|int |
|
49 | + */ |
|
50 | + public function cancel( |
|
51 | + \EE_Transaction $transaction, |
|
52 | + \EE_Ticket $ticket, |
|
53 | + $quantity = 1, |
|
54 | + \EE_Line_Item $ticket_line_item = null |
|
55 | + ) { |
|
56 | + $ticket_line_item = $ticket_line_item instanceof \EE_Line_Item |
|
57 | + ? $ticket_line_item |
|
58 | + : $this->getTicketLineItem($transaction, $ticket); |
|
59 | + // first we need to decrement the ticket quantity |
|
60 | + \EEH_Line_Item::decrement_quantity($ticket_line_item, $quantity); |
|
61 | + // no tickets left for this line item ? |
|
62 | + if ((int)$ticket_line_item->quantity() === 0) { |
|
63 | + // then just set this line item as cancelled, save, and get out |
|
64 | + $ticket_line_item->set_type(\EEM_Line_Item::type_cancellation); |
|
65 | + $success = $ticket_line_item->save(); |
|
66 | + } else { |
|
67 | + // otherwise create a new cancelled line item, so that we have a record of the cancellation |
|
68 | + $items_subtotal = \EEH_Line_Item::get_pre_tax_subtotal( |
|
69 | + \EEH_Line_Item::get_event_line_item_for_ticket( |
|
70 | + $transaction->total_line_item(), |
|
71 | + $ticket |
|
72 | + ) |
|
73 | + ); |
|
74 | + $cancelled_line_item = \EE_Line_Item::new_instance( |
|
75 | + array( |
|
76 | + 'LIN_name' => $ticket_line_item->name(), |
|
77 | + 'LIN_desc' => sprintf( |
|
78 | + __('%1$s Cancelled: %2$s', 'event_espresso'), |
|
79 | + $ticket_line_item->desc(), |
|
80 | + date('Y-m-d h:i a') |
|
81 | + ), |
|
82 | + 'LIN_unit_price' => (float)$ticket_line_item->unit_price(), |
|
83 | + 'LIN_quantity' => $quantity, |
|
84 | + 'LIN_percent' => null, |
|
85 | + 'LIN_is_taxable' => false, |
|
86 | + 'LIN_order' => $items_subtotal instanceof \EE_Line_Item |
|
87 | + ? count($items_subtotal->children()) |
|
88 | + : 0, |
|
89 | + 'LIN_total' => (float)$ticket_line_item->unit_price(), |
|
90 | + 'LIN_type' => \EEM_Line_Item::type_cancellation |
|
91 | + ) |
|
92 | + ); |
|
93 | + $success = \EEH_Line_Item::add_item($transaction->total_line_item(), $cancelled_line_item); |
|
94 | + } |
|
95 | + if ( ! $success) { |
|
96 | + throw new \RuntimeException( |
|
97 | + sprintf( |
|
98 | + __('An error occurred while attempting to cancel ticket line item %1$s', 'event_espresso'), |
|
99 | + $ticket_line_item->ID() |
|
100 | + ) |
|
101 | + ); |
|
102 | + } |
|
103 | + return $success; |
|
104 | + } |
|
105 | 105 | |
106 | 106 | |
107 | 107 | |
108 | - /** |
|
109 | - * @param \EE_Transaction $transaction |
|
110 | - * @param \EE_Ticket $ticket |
|
111 | - * @return \EE_Line_Item |
|
112 | - * @throws EntityNotFoundException |
|
113 | - * @throws \EE_Error |
|
114 | - */ |
|
115 | - protected static function getTicketLineItem(\EE_Transaction $transaction, \EE_Ticket $ticket) |
|
116 | - { |
|
117 | - $line_item = null; |
|
118 | - $ticket_line_items = \EEH_Line_Item::get_line_items_by_object_type_and_IDs( |
|
119 | - $transaction->total_line_item(), |
|
120 | - 'Ticket', |
|
121 | - array($ticket->ID()) |
|
122 | - ); |
|
123 | - foreach ($ticket_line_items as $ticket_line_item) { |
|
124 | - if ( |
|
125 | - $ticket_line_item instanceof \EE_Line_Item |
|
126 | - && $ticket_line_item->OBJ_type() === 'Ticket' |
|
127 | - && $ticket_line_item->OBJ_ID() === $ticket->ID() |
|
128 | - ) { |
|
129 | - $line_item = $ticket_line_item; |
|
130 | - break; |
|
131 | - } |
|
132 | - } |
|
133 | - if ( ! ($line_item instanceof \EE_Line_Item && $line_item->OBJ_type() === 'Ticket')) { |
|
134 | - throw new EntityNotFoundException('Line Item Ticket ID', $ticket->ID()); |
|
135 | - } |
|
136 | - return $line_item; |
|
137 | - } |
|
108 | + /** |
|
109 | + * @param \EE_Transaction $transaction |
|
110 | + * @param \EE_Ticket $ticket |
|
111 | + * @return \EE_Line_Item |
|
112 | + * @throws EntityNotFoundException |
|
113 | + * @throws \EE_Error |
|
114 | + */ |
|
115 | + protected static function getTicketLineItem(\EE_Transaction $transaction, \EE_Ticket $ticket) |
|
116 | + { |
|
117 | + $line_item = null; |
|
118 | + $ticket_line_items = \EEH_Line_Item::get_line_items_by_object_type_and_IDs( |
|
119 | + $transaction->total_line_item(), |
|
120 | + 'Ticket', |
|
121 | + array($ticket->ID()) |
|
122 | + ); |
|
123 | + foreach ($ticket_line_items as $ticket_line_item) { |
|
124 | + if ( |
|
125 | + $ticket_line_item instanceof \EE_Line_Item |
|
126 | + && $ticket_line_item->OBJ_type() === 'Ticket' |
|
127 | + && $ticket_line_item->OBJ_ID() === $ticket->ID() |
|
128 | + ) { |
|
129 | + $line_item = $ticket_line_item; |
|
130 | + break; |
|
131 | + } |
|
132 | + } |
|
133 | + if ( ! ($line_item instanceof \EE_Line_Item && $line_item->OBJ_type() === 'Ticket')) { |
|
134 | + throw new EntityNotFoundException('Line Item Ticket ID', $ticket->ID()); |
|
135 | + } |
|
136 | + return $line_item; |
|
137 | + } |
|
138 | 138 | |
139 | 139 | |
140 | 140 | } |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @param int $quantity |
31 | 31 | * @return bool|int |
32 | 32 | */ |
33 | - public function forRegistration(\EE_Registration $registration,$quantity = 1) { |
|
33 | + public function forRegistration(\EE_Registration $registration, $quantity = 1) { |
|
34 | 34 | return $this->cancel( |
35 | 35 | $registration->transaction(), |
36 | 36 | $registration->ticket(), |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | // first we need to decrement the ticket quantity |
60 | 60 | \EEH_Line_Item::decrement_quantity($ticket_line_item, $quantity); |
61 | 61 | // no tickets left for this line item ? |
62 | - if ((int)$ticket_line_item->quantity() === 0) { |
|
62 | + if ((int) $ticket_line_item->quantity() === 0) { |
|
63 | 63 | // then just set this line item as cancelled, save, and get out |
64 | 64 | $ticket_line_item->set_type(\EEM_Line_Item::type_cancellation); |
65 | 65 | $success = $ticket_line_item->save(); |
@@ -79,14 +79,14 @@ discard block |
||
79 | 79 | $ticket_line_item->desc(), |
80 | 80 | date('Y-m-d h:i a') |
81 | 81 | ), |
82 | - 'LIN_unit_price' => (float)$ticket_line_item->unit_price(), |
|
82 | + 'LIN_unit_price' => (float) $ticket_line_item->unit_price(), |
|
83 | 83 | 'LIN_quantity' => $quantity, |
84 | 84 | 'LIN_percent' => null, |
85 | 85 | 'LIN_is_taxable' => false, |
86 | 86 | 'LIN_order' => $items_subtotal instanceof \EE_Line_Item |
87 | 87 | ? count($items_subtotal->children()) |
88 | 88 | : 0, |
89 | - 'LIN_total' => (float)$ticket_line_item->unit_price(), |
|
89 | + 'LIN_total' => (float) $ticket_line_item->unit_price(), |
|
90 | 90 | 'LIN_type' => \EEM_Line_Item::type_cancellation |
91 | 91 | ) |
92 | 92 | ); |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | /** |
6 | 6 | * Class EE_Line_Item_Filter_Collection |