@@ -7,7 +7,7 @@ |
||
| 7 | 7 | use EventEspresso\core\services\commands\CommandInterface; |
| 8 | 8 | use EventEspresso\core\services\commands\CommandRequiresCapCheckInterface; |
| 9 | 9 | |
| 10 | -if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 10 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 11 | 11 | exit('No direct script access allowed'); |
| 12 | 12 | } |
| 13 | 13 | |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | use EventEspresso\core\services\commands\CommandRequiresCapCheckInterface; |
| 10 | 10 | |
| 11 | 11 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
| 12 | - exit('No direct script access allowed'); |
|
| 12 | + exit('No direct script access allowed'); |
|
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | |
@@ -29,41 +29,41 @@ discard block |
||
| 29 | 29 | class CapChecker implements CommandBusMiddlewareInterface |
| 30 | 30 | { |
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * @type CapabilitiesCheckerInterface $capabilities_checker |
|
| 34 | - */ |
|
| 35 | - private $capabilities_checker; |
|
| 32 | + /** |
|
| 33 | + * @type CapabilitiesCheckerInterface $capabilities_checker |
|
| 34 | + */ |
|
| 35 | + private $capabilities_checker; |
|
| 36 | 36 | |
| 37 | 37 | |
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * CapChecker constructor |
|
| 41 | - * |
|
| 42 | - * @param CapabilitiesCheckerInterface $capabilities_checker |
|
| 43 | - */ |
|
| 44 | - public function __construct(CapabilitiesCheckerInterface $capabilities_checker) |
|
| 45 | - { |
|
| 46 | - $this->capabilities_checker = $capabilities_checker; |
|
| 47 | - } |
|
| 39 | + /** |
|
| 40 | + * CapChecker constructor |
|
| 41 | + * |
|
| 42 | + * @param CapabilitiesCheckerInterface $capabilities_checker |
|
| 43 | + */ |
|
| 44 | + public function __construct(CapabilitiesCheckerInterface $capabilities_checker) |
|
| 45 | + { |
|
| 46 | + $this->capabilities_checker = $capabilities_checker; |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | 49 | |
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * @param CommandInterface $command |
|
| 53 | - * @param Closure $next |
|
| 54 | - * @return mixed |
|
| 55 | - * @throws InvalidClassException |
|
| 56 | - * @throws InsufficientPermissionsException |
|
| 57 | - */ |
|
| 58 | - public function handle(CommandInterface $command, Closure $next) |
|
| 59 | - { |
|
| 60 | - if ($command instanceof CommandRequiresCapCheckInterface) { |
|
| 61 | - $this->capabilities_checker->processCapCheck( |
|
| 62 | - $command->getCapCheck() |
|
| 63 | - ); |
|
| 64 | - } |
|
| 65 | - return $next($command); |
|
| 66 | - } |
|
| 51 | + /** |
|
| 52 | + * @param CommandInterface $command |
|
| 53 | + * @param Closure $next |
|
| 54 | + * @return mixed |
|
| 55 | + * @throws InvalidClassException |
|
| 56 | + * @throws InsufficientPermissionsException |
|
| 57 | + */ |
|
| 58 | + public function handle(CommandInterface $command, Closure $next) |
|
| 59 | + { |
|
| 60 | + if ($command instanceof CommandRequiresCapCheckInterface) { |
|
| 61 | + $this->capabilities_checker->processCapCheck( |
|
| 62 | + $command->getCapCheck() |
|
| 63 | + ); |
|
| 64 | + } |
|
| 65 | + return $next($command); |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | 68 | |
| 69 | 69 | } |
@@ -24,66 +24,66 @@ |
||
| 24 | 24 | class CreateTransactionCommand extends Command implements CommandRequiresCapCheckInterface |
| 25 | 25 | { |
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * @var EE_Checkout $checkout |
|
| 29 | - */ |
|
| 30 | - protected $checkout; |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * @var array $transaction_details |
|
| 34 | - */ |
|
| 35 | - protected $transaction_details; |
|
| 36 | - |
|
| 37 | - |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * CreateTransactionCommand constructor. |
|
| 41 | - * |
|
| 42 | - * @param EE_Checkout $checkout |
|
| 43 | - * @param array $transaction_details |
|
| 44 | - */ |
|
| 45 | - public function __construct(EE_Checkout $checkout = null, array $transaction_details = array()) |
|
| 46 | - { |
|
| 47 | - $this->checkout = $checkout; |
|
| 48 | - $this->transaction_details = $transaction_details; |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * @return CapCheckInterface |
|
| 55 | - * @throws InvalidDataTypeException |
|
| 56 | - */ |
|
| 57 | - public function getCapCheck() |
|
| 58 | - { |
|
| 59 | - // need cap for non-AJAX admin requests |
|
| 60 | - if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
| 61 | - // there's no specific caps for editing/creating transactions, |
|
| 62 | - // so that's why we are using ee_edit_registrations |
|
| 63 | - return new CapCheck('ee_edit_registrations', 'create_new_transaction'); |
|
| 64 | - } |
|
| 65 | - return new PublicCapabilities('', 'create_new_transaction'); |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * @return EE_Checkout |
|
| 72 | - */ |
|
| 73 | - public function checkout() |
|
| 74 | - { |
|
| 75 | - return $this->checkout; |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - |
|
| 79 | - |
|
| 80 | - /** |
|
| 81 | - * @return array |
|
| 82 | - */ |
|
| 83 | - public function transactionDetails() |
|
| 84 | - { |
|
| 85 | - return $this->transaction_details; |
|
| 86 | - } |
|
| 27 | + /** |
|
| 28 | + * @var EE_Checkout $checkout |
|
| 29 | + */ |
|
| 30 | + protected $checkout; |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * @var array $transaction_details |
|
| 34 | + */ |
|
| 35 | + protected $transaction_details; |
|
| 36 | + |
|
| 37 | + |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * CreateTransactionCommand constructor. |
|
| 41 | + * |
|
| 42 | + * @param EE_Checkout $checkout |
|
| 43 | + * @param array $transaction_details |
|
| 44 | + */ |
|
| 45 | + public function __construct(EE_Checkout $checkout = null, array $transaction_details = array()) |
|
| 46 | + { |
|
| 47 | + $this->checkout = $checkout; |
|
| 48 | + $this->transaction_details = $transaction_details; |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * @return CapCheckInterface |
|
| 55 | + * @throws InvalidDataTypeException |
|
| 56 | + */ |
|
| 57 | + public function getCapCheck() |
|
| 58 | + { |
|
| 59 | + // need cap for non-AJAX admin requests |
|
| 60 | + if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
| 61 | + // there's no specific caps for editing/creating transactions, |
|
| 62 | + // so that's why we are using ee_edit_registrations |
|
| 63 | + return new CapCheck('ee_edit_registrations', 'create_new_transaction'); |
|
| 64 | + } |
|
| 65 | + return new PublicCapabilities('', 'create_new_transaction'); |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * @return EE_Checkout |
|
| 72 | + */ |
|
| 73 | + public function checkout() |
|
| 74 | + { |
|
| 75 | + return $this->checkout; |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + |
|
| 79 | + |
|
| 80 | + /** |
|
| 81 | + * @return array |
|
| 82 | + */ |
|
| 83 | + public function transactionDetails() |
|
| 84 | + { |
|
| 85 | + return $this->transaction_details; |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | 88 | |
| 89 | 89 | |
@@ -57,7 +57,7 @@ |
||
| 57 | 57 | public function getCapCheck() |
| 58 | 58 | { |
| 59 | 59 | // need cap for non-AJAX admin requests |
| 60 | - if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
| 60 | + if ( ! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
| 61 | 61 | // there's no specific caps for editing/creating transactions, |
| 62 | 62 | // so that's why we are using ee_edit_registrations |
| 63 | 63 | return new CapCheck('ee_edit_registrations', 'create_new_transaction'); |
@@ -26,44 +26,44 @@ |
||
| 26 | 26 | { |
| 27 | 27 | |
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * @param CommandInterface $command |
|
| 31 | - * @return mixed |
|
| 32 | - * @throws EE_Error |
|
| 33 | - * @throws InvalidEntityException |
|
| 34 | - */ |
|
| 35 | - public function handle(CommandInterface $command) |
|
| 36 | - { |
|
| 37 | - /** @var CreateTransactionCommand $command */ |
|
| 38 | - if (! $command instanceof CreateTransactionCommand) { |
|
| 39 | - throw new InvalidEntityException(get_class($command), 'CreateTransactionCommand'); |
|
| 40 | - } |
|
| 41 | - $transaction_details = $command->transactionDetails(); |
|
| 42 | - $cart_total = null; |
|
| 43 | - if ($command->checkout() instanceof EE_Checkout) { |
|
| 44 | - // ensure cart totals have been calculated |
|
| 45 | - $command->checkout()->cart->get_grand_total()->recalculate_total_including_taxes(); |
|
| 46 | - // grab the cart grand total |
|
| 47 | - $cart_total = $command->checkout()->cart->get_cart_grand_total(); |
|
| 48 | - $transaction_details['TXN_reg_steps'] = $command->checkout()->initialize_txn_reg_steps_array(); |
|
| 49 | - $transaction_details['TXN_total'] = $cart_total > 0 ? $cart_total : 0; |
|
| 50 | - } |
|
| 51 | - // create new TXN and save it so it has an ID |
|
| 52 | - $transaction = EE_Transaction::new_instance($transaction_details); |
|
| 53 | - if (! $transaction instanceof EE_Transaction) { |
|
| 54 | - throw new InvalidEntityException(get_class($transaction), 'EE_Transaction'); |
|
| 55 | - } |
|
| 56 | - $transaction->save(); |
|
| 57 | - // ensure grand total line item created |
|
| 58 | - $cart_total = $cart_total instanceof EE_Line_Item |
|
| 59 | - ? $cart_total |
|
| 60 | - : EEH_Line_Item::create_total_line_item($transaction); |
|
| 61 | - if (! $cart_total instanceof EE_Line_Item) { |
|
| 62 | - throw new InvalidEntityException(get_class($cart_total), 'EE_Line_Item'); |
|
| 63 | - } |
|
| 64 | - $cart_total->save_this_and_descendants_to_txn($transaction->ID()); |
|
| 65 | - return $transaction; |
|
| 66 | - } |
|
| 29 | + /** |
|
| 30 | + * @param CommandInterface $command |
|
| 31 | + * @return mixed |
|
| 32 | + * @throws EE_Error |
|
| 33 | + * @throws InvalidEntityException |
|
| 34 | + */ |
|
| 35 | + public function handle(CommandInterface $command) |
|
| 36 | + { |
|
| 37 | + /** @var CreateTransactionCommand $command */ |
|
| 38 | + if (! $command instanceof CreateTransactionCommand) { |
|
| 39 | + throw new InvalidEntityException(get_class($command), 'CreateTransactionCommand'); |
|
| 40 | + } |
|
| 41 | + $transaction_details = $command->transactionDetails(); |
|
| 42 | + $cart_total = null; |
|
| 43 | + if ($command->checkout() instanceof EE_Checkout) { |
|
| 44 | + // ensure cart totals have been calculated |
|
| 45 | + $command->checkout()->cart->get_grand_total()->recalculate_total_including_taxes(); |
|
| 46 | + // grab the cart grand total |
|
| 47 | + $cart_total = $command->checkout()->cart->get_cart_grand_total(); |
|
| 48 | + $transaction_details['TXN_reg_steps'] = $command->checkout()->initialize_txn_reg_steps_array(); |
|
| 49 | + $transaction_details['TXN_total'] = $cart_total > 0 ? $cart_total : 0; |
|
| 50 | + } |
|
| 51 | + // create new TXN and save it so it has an ID |
|
| 52 | + $transaction = EE_Transaction::new_instance($transaction_details); |
|
| 53 | + if (! $transaction instanceof EE_Transaction) { |
|
| 54 | + throw new InvalidEntityException(get_class($transaction), 'EE_Transaction'); |
|
| 55 | + } |
|
| 56 | + $transaction->save(); |
|
| 57 | + // ensure grand total line item created |
|
| 58 | + $cart_total = $cart_total instanceof EE_Line_Item |
|
| 59 | + ? $cart_total |
|
| 60 | + : EEH_Line_Item::create_total_line_item($transaction); |
|
| 61 | + if (! $cart_total instanceof EE_Line_Item) { |
|
| 62 | + throw new InvalidEntityException(get_class($cart_total), 'EE_Line_Item'); |
|
| 63 | + } |
|
| 64 | + $cart_total->save_this_and_descendants_to_txn($transaction->ID()); |
|
| 65 | + return $transaction; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | 68 | |
| 69 | 69 | } |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | public function handle(CommandInterface $command) |
| 36 | 36 | { |
| 37 | 37 | /** @var CreateTransactionCommand $command */ |
| 38 | - if (! $command instanceof CreateTransactionCommand) { |
|
| 38 | + if ( ! $command instanceof CreateTransactionCommand) { |
|
| 39 | 39 | throw new InvalidEntityException(get_class($command), 'CreateTransactionCommand'); |
| 40 | 40 | } |
| 41 | 41 | $transaction_details = $command->transactionDetails(); |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | } |
| 51 | 51 | // create new TXN and save it so it has an ID |
| 52 | 52 | $transaction = EE_Transaction::new_instance($transaction_details); |
| 53 | - if (! $transaction instanceof EE_Transaction) { |
|
| 53 | + if ( ! $transaction instanceof EE_Transaction) { |
|
| 54 | 54 | throw new InvalidEntityException(get_class($transaction), 'EE_Transaction'); |
| 55 | 55 | } |
| 56 | 56 | $transaction->save(); |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | $cart_total = $cart_total instanceof EE_Line_Item |
| 59 | 59 | ? $cart_total |
| 60 | 60 | : EEH_Line_Item::create_total_line_item($transaction); |
| 61 | - if (! $cart_total instanceof EE_Line_Item) { |
|
| 61 | + if ( ! $cart_total instanceof EE_Line_Item) { |
|
| 62 | 62 | throw new InvalidEntityException(get_class($cart_total), 'EE_Line_Item'); |
| 63 | 63 | } |
| 64 | 64 | $cart_total->save_this_and_descendants_to_txn($transaction->ID()); |
@@ -24,68 +24,68 @@ |
||
| 24 | 24 | class CreateAttendeeCommand extends Command implements CommandRequiresCapCheckInterface |
| 25 | 25 | { |
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * array of details where keys are names of EEM_Attendee model fields |
|
| 29 | - * |
|
| 30 | - * @var array $attendee_details |
|
| 31 | - */ |
|
| 32 | - protected $attendee_details; |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * an existing registration to associate this attendee with |
|
| 36 | - * |
|
| 37 | - * @var EE_Registration $registration |
|
| 38 | - */ |
|
| 39 | - protected $registration; |
|
| 40 | - |
|
| 41 | - |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * CreateAttendeeCommand constructor. |
|
| 45 | - * |
|
| 46 | - * @param array $attendee_details |
|
| 47 | - * @param EE_Registration $registration |
|
| 48 | - */ |
|
| 49 | - public function __construct(array $attendee_details, EE_Registration $registration) |
|
| 50 | - { |
|
| 51 | - $this->attendee_details = $attendee_details; |
|
| 52 | - $this->registration = $registration; |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * @return array |
|
| 59 | - */ |
|
| 60 | - public function attendeeDetails() |
|
| 61 | - { |
|
| 62 | - return $this->attendee_details; |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * @return EE_Registration |
|
| 69 | - */ |
|
| 70 | - public function registration() |
|
| 71 | - { |
|
| 72 | - return $this->registration; |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - |
|
| 76 | - |
|
| 77 | - /** |
|
| 78 | - * @return CapCheckInterface |
|
| 79 | - * @throws InvalidDataTypeException |
|
| 80 | - */ |
|
| 81 | - public function getCapCheck() |
|
| 82 | - { |
|
| 83 | - // need cap for non-AJAX admin requests |
|
| 84 | - if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
| 85 | - return new CapCheck('ee_edit_contacts', 'create_new_contact'); |
|
| 86 | - } |
|
| 87 | - return new PublicCapabilities('', 'create_new_contact'); |
|
| 88 | - } |
|
| 27 | + /** |
|
| 28 | + * array of details where keys are names of EEM_Attendee model fields |
|
| 29 | + * |
|
| 30 | + * @var array $attendee_details |
|
| 31 | + */ |
|
| 32 | + protected $attendee_details; |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * an existing registration to associate this attendee with |
|
| 36 | + * |
|
| 37 | + * @var EE_Registration $registration |
|
| 38 | + */ |
|
| 39 | + protected $registration; |
|
| 40 | + |
|
| 41 | + |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * CreateAttendeeCommand constructor. |
|
| 45 | + * |
|
| 46 | + * @param array $attendee_details |
|
| 47 | + * @param EE_Registration $registration |
|
| 48 | + */ |
|
| 49 | + public function __construct(array $attendee_details, EE_Registration $registration) |
|
| 50 | + { |
|
| 51 | + $this->attendee_details = $attendee_details; |
|
| 52 | + $this->registration = $registration; |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * @return array |
|
| 59 | + */ |
|
| 60 | + public function attendeeDetails() |
|
| 61 | + { |
|
| 62 | + return $this->attendee_details; |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * @return EE_Registration |
|
| 69 | + */ |
|
| 70 | + public function registration() |
|
| 71 | + { |
|
| 72 | + return $this->registration; |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + |
|
| 76 | + |
|
| 77 | + /** |
|
| 78 | + * @return CapCheckInterface |
|
| 79 | + * @throws InvalidDataTypeException |
|
| 80 | + */ |
|
| 81 | + public function getCapCheck() |
|
| 82 | + { |
|
| 83 | + // need cap for non-AJAX admin requests |
|
| 84 | + if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
| 85 | + return new CapCheck('ee_edit_contacts', 'create_new_contact'); |
|
| 86 | + } |
|
| 87 | + return new PublicCapabilities('', 'create_new_contact'); |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | 90 | |
| 91 | 91 | |
@@ -81,7 +81,7 @@ |
||
| 81 | 81 | public function getCapCheck() |
| 82 | 82 | { |
| 83 | 83 | // need cap for non-AJAX admin requests |
| 84 | - if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
| 84 | + if ( ! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
| 85 | 85 | return new CapCheck('ee_edit_contacts', 'create_new_contact'); |
| 86 | 86 | } |
| 87 | 87 | return new PublicCapabilities('', 'create_new_contact'); |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * @param EEM_Attendee $attendee_model |
| 36 | 36 | */ |
| 37 | 37 | public function __construct(EEM_Attendee $attendee_model ) { |
| 38 | - $this->attendee_model = $attendee_model; |
|
| 38 | + $this->attendee_model = $attendee_model; |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | private function findExistingAttendee( EE_Registration $registration, array $attendee_data ) { |
| 84 | 84 | $existing_attendee = null; |
| 85 | 85 | // does this attendee already exist in the db ? |
| 86 | - // we're searching using a combination of first name, last name, AND email address |
|
| 86 | + // we're searching using a combination of first name, last name, AND email address |
|
| 87 | 87 | $ATT_fname = ! empty( $attendee_data['ATT_fname'] ) |
| 88 | 88 | ? $attendee_data['ATT_fname'] |
| 89 | 89 | : ''; |
@@ -124,8 +124,8 @@ discard block |
||
| 124 | 124 | */ |
| 125 | 125 | private function updateExistingAttendeeData( EE_Attendee $existing_attendee, array $attendee_data ) { |
| 126 | 126 | // first remove fname, lname, and email from attendee data |
| 127 | - // because these properties will be exactly the same as the returned attendee object, |
|
| 128 | - // since they were used in the query to get the attendee object in the first place |
|
| 127 | + // because these properties will be exactly the same as the returned attendee object, |
|
| 128 | + // since they were used in the query to get the attendee object in the first place |
|
| 129 | 129 | $dont_set = array( 'ATT_fname', 'ATT_lname', 'ATT_email' ); |
| 130 | 130 | // now loop thru what's left and add to attendee CPT |
| 131 | 131 | foreach ( $attendee_data as $property_name => $property_value ) { |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | use EventEspresso\core\services\commands\CommandHandler; |
| 10 | 10 | use EventEspresso\core\services\commands\CommandInterface; |
| 11 | 11 | |
| 12 | -defined( 'EVENT_ESPRESSO_VERSION' ) || exit; |
|
| 12 | +defined('EVENT_ESPRESSO_VERSION') || exit; |
|
| 13 | 13 | |
| 14 | 14 | |
| 15 | 15 | |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | /** |
| 35 | 35 | * @param EEM_Attendee $attendee_model |
| 36 | 36 | */ |
| 37 | - public function __construct(EEM_Attendee $attendee_model ) { |
|
| 37 | + public function __construct(EEM_Attendee $attendee_model) { |
|
| 38 | 38 | $this->attendee_model = $attendee_model; |
| 39 | 39 | } |
| 40 | 40 | |
@@ -46,10 +46,10 @@ discard block |
||
| 46 | 46 | * @throws EE_Error |
| 47 | 47 | * @throws InvalidEntityException |
| 48 | 48 | */ |
| 49 | - public function handle( CommandInterface $command ) { |
|
| 49 | + public function handle(CommandInterface $command) { |
|
| 50 | 50 | /** @var CreateAttendeeCommand $command */ |
| 51 | - if ( ! $command instanceof CreateAttendeeCommand ) { |
|
| 52 | - throw new InvalidEntityException( get_class( $command ), 'CreateAttendeeCommand' ); |
|
| 51 | + if ( ! $command instanceof CreateAttendeeCommand) { |
|
| 52 | + throw new InvalidEntityException(get_class($command), 'CreateAttendeeCommand'); |
|
| 53 | 53 | } |
| 54 | 54 | // have we met before? |
| 55 | 55 | $attendee = $this->findExistingAttendee( |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | $command->attendeeDetails() |
| 58 | 58 | ); |
| 59 | 59 | // did we find an already existing record for this attendee ? |
| 60 | - if ( $attendee instanceof EE_Attendee ) { |
|
| 60 | + if ($attendee instanceof EE_Attendee) { |
|
| 61 | 61 | $attendee = $this->updateExistingAttendeeData( |
| 62 | 62 | $attendee, |
| 63 | 63 | $command->attendeeDetails() |
@@ -80,21 +80,21 @@ discard block |
||
| 80 | 80 | * @param array $attendee_data |
| 81 | 81 | * @return EE_Attendee |
| 82 | 82 | */ |
| 83 | - private function findExistingAttendee( EE_Registration $registration, array $attendee_data ) { |
|
| 83 | + private function findExistingAttendee(EE_Registration $registration, array $attendee_data) { |
|
| 84 | 84 | $existing_attendee = null; |
| 85 | 85 | // does this attendee already exist in the db ? |
| 86 | 86 | // we're searching using a combination of first name, last name, AND email address |
| 87 | - $ATT_fname = ! empty( $attendee_data['ATT_fname'] ) |
|
| 87 | + $ATT_fname = ! empty($attendee_data['ATT_fname']) |
|
| 88 | 88 | ? $attendee_data['ATT_fname'] |
| 89 | 89 | : ''; |
| 90 | - $ATT_lname = ! empty( $attendee_data['ATT_lname'] ) |
|
| 90 | + $ATT_lname = ! empty($attendee_data['ATT_lname']) |
|
| 91 | 91 | ? $attendee_data['ATT_lname'] |
| 92 | 92 | : ''; |
| 93 | - $ATT_email = ! empty( $attendee_data['ATT_email'] ) |
|
| 93 | + $ATT_email = ! empty($attendee_data['ATT_email']) |
|
| 94 | 94 | ? $attendee_data['ATT_email'] |
| 95 | 95 | : ''; |
| 96 | 96 | // but only if those have values |
| 97 | - if ( $ATT_fname && $ATT_lname && $ATT_email ) { |
|
| 97 | + if ($ATT_fname && $ATT_lname && $ATT_email) { |
|
| 98 | 98 | $existing_attendee = $this->attendee_model->find_existing_attendee( |
| 99 | 99 | array( |
| 100 | 100 | 'ATT_fname' => $ATT_fname, |
@@ -122,18 +122,18 @@ discard block |
||
| 122 | 122 | * @return EE_Attendee |
| 123 | 123 | * @throws EE_Error |
| 124 | 124 | */ |
| 125 | - private function updateExistingAttendeeData( EE_Attendee $existing_attendee, array $attendee_data ) { |
|
| 125 | + private function updateExistingAttendeeData(EE_Attendee $existing_attendee, array $attendee_data) { |
|
| 126 | 126 | // first remove fname, lname, and email from attendee data |
| 127 | 127 | // because these properties will be exactly the same as the returned attendee object, |
| 128 | 128 | // since they were used in the query to get the attendee object in the first place |
| 129 | - $dont_set = array( 'ATT_fname', 'ATT_lname', 'ATT_email' ); |
|
| 129 | + $dont_set = array('ATT_fname', 'ATT_lname', 'ATT_email'); |
|
| 130 | 130 | // now loop thru what's left and add to attendee CPT |
| 131 | - foreach ( $attendee_data as $property_name => $property_value ) { |
|
| 131 | + foreach ($attendee_data as $property_name => $property_value) { |
|
| 132 | 132 | if ( |
| 133 | - ! in_array( $property_name, $dont_set, true ) |
|
| 134 | - && $this->attendee_model->has_field( $property_name ) |
|
| 133 | + ! in_array($property_name, $dont_set, true) |
|
| 134 | + && $this->attendee_model->has_field($property_name) |
|
| 135 | 135 | ) { |
| 136 | - $existing_attendee->set( $property_name, $property_value ); |
|
| 136 | + $existing_attendee->set($property_name, $property_value); |
|
| 137 | 137 | } |
| 138 | 138 | } |
| 139 | 139 | // better save that now |
@@ -151,11 +151,11 @@ discard block |
||
| 151 | 151 | * @return EE_Attendee |
| 152 | 152 | * @throws EE_Error |
| 153 | 153 | */ |
| 154 | - private function createNewAttendee( EE_Registration $registration, array $attendee_data ) { |
|
| 154 | + private function createNewAttendee(EE_Registration $registration, array $attendee_data) { |
|
| 155 | 155 | // create new attendee object |
| 156 | - $new_attendee = EE_Attendee::new_instance( $attendee_data ); |
|
| 156 | + $new_attendee = EE_Attendee::new_instance($attendee_data); |
|
| 157 | 157 | // set author to event creator |
| 158 | - $new_attendee->set( 'ATT_author', $registration->event()->wp_user() ); |
|
| 158 | + $new_attendee->set('ATT_author', $registration->event()->wp_user()); |
|
| 159 | 159 | $new_attendee->save(); |
| 160 | 160 | return $new_attendee; |
| 161 | 161 | } |
@@ -39,8 +39,8 @@ |
||
| 39 | 39 | * @param EE_Transaction $transaction |
| 40 | 40 | * @param EE_Ticket $ticket |
| 41 | 41 | * @param EE_Line_Item $ticket_line_item |
| 42 | - * @param $reg_count |
|
| 43 | - * @param $reg_group_size |
|
| 42 | + * @param integer $reg_count |
|
| 43 | + * @param integer $reg_group_size |
|
| 44 | 44 | * @param string $reg_status |
| 45 | 45 | * @return EE_Registration |
| 46 | 46 | * @throws OutOfRangeException |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | use OutOfRangeException; |
| 18 | 18 | |
| 19 | 19 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
| 20 | - exit('No direct script access allowed'); |
|
| 20 | + exit('No direct script access allowed'); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | |
@@ -41,54 +41,54 @@ discard block |
||
| 41 | 41 | * @param EE_Line_Item $ticket_line_item |
| 42 | 42 | * @param $reg_count |
| 43 | 43 | * @param $reg_group_size |
| 44 | - * @param string $reg_status |
|
| 45 | - * @return EE_Registration |
|
| 44 | + * @param string $reg_status |
|
| 45 | + * @return EE_Registration |
|
| 46 | 46 | * @throws OutOfRangeException |
| 47 | 47 | * @throws EE_Error |
| 48 | 48 | * @throws UnexpectedEntityException |
| 49 | 49 | */ |
| 50 | - public function create( |
|
| 51 | - EE_Event $event, |
|
| 52 | - EE_Transaction $transaction, |
|
| 53 | - EE_Ticket $ticket, |
|
| 54 | - EE_Line_Item $ticket_line_item, |
|
| 55 | - $reg_count, |
|
| 56 | - $reg_group_size, |
|
| 57 | - $reg_status = EEM_Registration::status_id_incomplete |
|
| 58 | - ) { |
|
| 59 | - $registrations = $transaction->registrations(); |
|
| 60 | - $reg_count = $reg_count ? $reg_count : count($registrations) + 1; |
|
| 61 | - $reg_url_link = new RegUrlLink($reg_count, $ticket_line_item); |
|
| 62 | - $reg_code = new RegCode($reg_url_link, $transaction, $ticket); |
|
| 63 | - // generate new EE_Registration |
|
| 64 | - $registration = EE_Registration::new_instance( |
|
| 65 | - array( |
|
| 66 | - 'EVT_ID' => $event->ID(), |
|
| 67 | - 'TXN_ID' => $transaction->ID(), |
|
| 68 | - 'TKT_ID' => $ticket->ID(), |
|
| 69 | - 'STS_ID' => $reg_status, |
|
| 70 | - 'REG_final_price' => $this->resolveFinalPrice($transaction, $ticket, $ticket_line_item), |
|
| 71 | - 'REG_session' => EE_Registry::instance()->SSN->id(), |
|
| 72 | - 'REG_count' => $reg_count, |
|
| 73 | - 'REG_group_size' => $reg_group_size ? $reg_group_size : $this->incrementRegCount($registrations), |
|
| 74 | - 'REG_url_link' => $reg_url_link, |
|
| 75 | - 'REG_code' => $reg_code, |
|
| 76 | - ) |
|
| 77 | - ); |
|
| 78 | - if ( ! $registration instanceof EE_Registration) { |
|
| 79 | - throw new UnexpectedEntityException($registration, 'EE_Registration'); |
|
| 80 | - } |
|
| 81 | - // save registration so that we have an ID |
|
| 82 | - $registration->save(); |
|
| 83 | - // track reservation on reg but don't adjust ticket and datetime reserved counts |
|
| 84 | - // because that is done as soon as the tickets are added/removed from the cart |
|
| 85 | - $registration->reserve_ticket(); |
|
| 86 | - $registration->_add_relation_to($event, 'Event', array(), $event->ID()); |
|
| 87 | - $registration->_add_relation_to($ticket, 'Ticket', array(), $ticket->ID()); |
|
| 88 | - $transaction->_add_relation_to($registration, 'Registration', array(), $registration->ID()); |
|
| 89 | - $registration->save(); |
|
| 90 | - return $registration; |
|
| 91 | - } |
|
| 50 | + public function create( |
|
| 51 | + EE_Event $event, |
|
| 52 | + EE_Transaction $transaction, |
|
| 53 | + EE_Ticket $ticket, |
|
| 54 | + EE_Line_Item $ticket_line_item, |
|
| 55 | + $reg_count, |
|
| 56 | + $reg_group_size, |
|
| 57 | + $reg_status = EEM_Registration::status_id_incomplete |
|
| 58 | + ) { |
|
| 59 | + $registrations = $transaction->registrations(); |
|
| 60 | + $reg_count = $reg_count ? $reg_count : count($registrations) + 1; |
|
| 61 | + $reg_url_link = new RegUrlLink($reg_count, $ticket_line_item); |
|
| 62 | + $reg_code = new RegCode($reg_url_link, $transaction, $ticket); |
|
| 63 | + // generate new EE_Registration |
|
| 64 | + $registration = EE_Registration::new_instance( |
|
| 65 | + array( |
|
| 66 | + 'EVT_ID' => $event->ID(), |
|
| 67 | + 'TXN_ID' => $transaction->ID(), |
|
| 68 | + 'TKT_ID' => $ticket->ID(), |
|
| 69 | + 'STS_ID' => $reg_status, |
|
| 70 | + 'REG_final_price' => $this->resolveFinalPrice($transaction, $ticket, $ticket_line_item), |
|
| 71 | + 'REG_session' => EE_Registry::instance()->SSN->id(), |
|
| 72 | + 'REG_count' => $reg_count, |
|
| 73 | + 'REG_group_size' => $reg_group_size ? $reg_group_size : $this->incrementRegCount($registrations), |
|
| 74 | + 'REG_url_link' => $reg_url_link, |
|
| 75 | + 'REG_code' => $reg_code, |
|
| 76 | + ) |
|
| 77 | + ); |
|
| 78 | + if ( ! $registration instanceof EE_Registration) { |
|
| 79 | + throw new UnexpectedEntityException($registration, 'EE_Registration'); |
|
| 80 | + } |
|
| 81 | + // save registration so that we have an ID |
|
| 82 | + $registration->save(); |
|
| 83 | + // track reservation on reg but don't adjust ticket and datetime reserved counts |
|
| 84 | + // because that is done as soon as the tickets are added/removed from the cart |
|
| 85 | + $registration->reserve_ticket(); |
|
| 86 | + $registration->_add_relation_to($event, 'Event', array(), $event->ID()); |
|
| 87 | + $registration->_add_relation_to($ticket, 'Ticket', array(), $ticket->ID()); |
|
| 88 | + $transaction->_add_relation_to($registration, 'Registration', array(), $registration->ID()); |
|
| 89 | + $registration->save(); |
|
| 90 | + return $registration; |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | 93 | |
| 94 | 94 | |
@@ -100,40 +100,40 @@ discard block |
||
| 100 | 100 | * @throws EE_Error |
| 101 | 101 | * @throws OutOfRangeException |
| 102 | 102 | */ |
| 103 | - protected function resolveFinalPrice( |
|
| 104 | - EE_Transaction $transaction, |
|
| 105 | - EE_Ticket $ticket, |
|
| 106 | - EE_Line_Item $ticket_line_item |
|
| 107 | - ) { |
|
| 108 | - $final_price = EEH_Line_Item::calculate_final_price_for_ticket_line_item( |
|
| 109 | - $transaction->total_line_item(), |
|
| 110 | - $ticket_line_item |
|
| 111 | - ); |
|
| 112 | - $final_price = $final_price !== null ? $final_price : $ticket->get_ticket_total_with_taxes(); |
|
| 113 | - return (float)$final_price; |
|
| 114 | - } |
|
| 103 | + protected function resolveFinalPrice( |
|
| 104 | + EE_Transaction $transaction, |
|
| 105 | + EE_Ticket $ticket, |
|
| 106 | + EE_Line_Item $ticket_line_item |
|
| 107 | + ) { |
|
| 108 | + $final_price = EEH_Line_Item::calculate_final_price_for_ticket_line_item( |
|
| 109 | + $transaction->total_line_item(), |
|
| 110 | + $ticket_line_item |
|
| 111 | + ); |
|
| 112 | + $final_price = $final_price !== null ? $final_price : $ticket->get_ticket_total_with_taxes(); |
|
| 113 | + return (float)$final_price; |
|
| 114 | + } |
|
| 115 | 115 | |
| 116 | 116 | |
| 117 | 117 | |
| 118 | - /** |
|
| 119 | - * @param EE_Registration[] $registrations |
|
| 120 | - * @param boolean $update_existing_registrations |
|
| 121 | - * @return int |
|
| 122 | - * @throws EE_Error |
|
| 123 | - */ |
|
| 124 | - protected function incrementRegCount(array $registrations, $update_existing_registrations = true) |
|
| 125 | - { |
|
| 126 | - $new_reg_count = count($registrations) + 1; |
|
| 127 | - if ($update_existing_registrations) { |
|
| 128 | - foreach ($registrations as $registration) { |
|
| 129 | - if ($registration instanceof EE_Registration) { |
|
| 130 | - $registration->set_count($new_reg_count); |
|
| 131 | - $registration->save(); |
|
| 132 | - } |
|
| 133 | - } |
|
| 134 | - } |
|
| 135 | - return $new_reg_count; |
|
| 136 | - } |
|
| 118 | + /** |
|
| 119 | + * @param EE_Registration[] $registrations |
|
| 120 | + * @param boolean $update_existing_registrations |
|
| 121 | + * @return int |
|
| 122 | + * @throws EE_Error |
|
| 123 | + */ |
|
| 124 | + protected function incrementRegCount(array $registrations, $update_existing_registrations = true) |
|
| 125 | + { |
|
| 126 | + $new_reg_count = count($registrations) + 1; |
|
| 127 | + if ($update_existing_registrations) { |
|
| 128 | + foreach ($registrations as $registration) { |
|
| 129 | + if ($registration instanceof EE_Registration) { |
|
| 130 | + $registration->set_count($new_reg_count); |
|
| 131 | + $registration->save(); |
|
| 132 | + } |
|
| 133 | + } |
|
| 134 | + } |
|
| 135 | + return $new_reg_count; |
|
| 136 | + } |
|
| 137 | 137 | |
| 138 | 138 | |
| 139 | 139 | } |
@@ -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,44 +21,44 @@ 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 | - $total_line_item = $transaction->total_line_item(); |
|
| 39 | - if (! $total_line_item instanceof \EE_Line_Item) { |
|
| 40 | - throw new UnexpectedEntityException($total_line_item, 'EE_Line_Item'); |
|
| 41 | - } |
|
| 42 | - // create new line item for ticket |
|
| 43 | - $ticket_line_item = \EEH_Line_Item::add_ticket_purchase( |
|
| 44 | - $total_line_item, |
|
| 45 | - $ticket, |
|
| 46 | - $quantity |
|
| 47 | - ); |
|
| 48 | - if ( ! $ticket_line_item instanceof \EE_Line_Item) { |
|
| 49 | - throw new UnexpectedEntityException($ticket_line_item, 'EE_Line_Item'); |
|
| 50 | - } |
|
| 51 | - $total_line_item->save_this_and_descendants_to_txn($transaction->ID()); |
|
| 52 | - // apply any applicable promotions that were initially used during registration to new line items |
|
| 53 | - do_action( |
|
| 54 | - 'AHEE__\EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler__handle__new_ticket_line_item_added', |
|
| 55 | - $total_line_item, |
|
| 56 | - $ticket, |
|
| 57 | - $transaction, |
|
| 58 | - $quantity |
|
| 59 | - ); |
|
| 60 | - return $ticket_line_item; |
|
| 61 | - } |
|
| 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 | + $total_line_item = $transaction->total_line_item(); |
|
| 39 | + if (! $total_line_item instanceof \EE_Line_Item) { |
|
| 40 | + throw new UnexpectedEntityException($total_line_item, 'EE_Line_Item'); |
|
| 41 | + } |
|
| 42 | + // create new line item for ticket |
|
| 43 | + $ticket_line_item = \EEH_Line_Item::add_ticket_purchase( |
|
| 44 | + $total_line_item, |
|
| 45 | + $ticket, |
|
| 46 | + $quantity |
|
| 47 | + ); |
|
| 48 | + if ( ! $ticket_line_item instanceof \EE_Line_Item) { |
|
| 49 | + throw new UnexpectedEntityException($ticket_line_item, 'EE_Line_Item'); |
|
| 50 | + } |
|
| 51 | + $total_line_item->save_this_and_descendants_to_txn($transaction->ID()); |
|
| 52 | + // apply any applicable promotions that were initially used during registration to new line items |
|
| 53 | + do_action( |
|
| 54 | + 'AHEE__\EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler__handle__new_ticket_line_item_added', |
|
| 55 | + $total_line_item, |
|
| 56 | + $ticket, |
|
| 57 | + $transaction, |
|
| 58 | + $quantity |
|
| 59 | + ); |
|
| 60 | + return $ticket_line_item; |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | 63 | |
| 64 | 64 | |
@@ -36,7 +36,7 @@ |
||
| 36 | 36 | ) |
| 37 | 37 | { |
| 38 | 38 | $total_line_item = $transaction->total_line_item(); |
| 39 | - if (! $total_line_item instanceof \EE_Line_Item) { |
|
| 39 | + if ( ! $total_line_item instanceof \EE_Line_Item) { |
|
| 40 | 40 | throw new UnexpectedEntityException($total_line_item, 'EE_Line_Item'); |
| 41 | 41 | } |
| 42 | 42 | // create new line item for ticket |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | use EventEspresso\core\services\commands\CommandInterface; |
| 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 | |
@@ -23,50 +23,50 @@ discard block |
||
| 23 | 23 | class CreateRegistrationCommandHandler extends CommandHandler |
| 24 | 24 | { |
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * @var CreateRegistrationService $registration_service |
|
| 28 | - */ |
|
| 29 | - private $registration_service; |
|
| 26 | + /** |
|
| 27 | + * @var CreateRegistrationService $registration_service |
|
| 28 | + */ |
|
| 29 | + private $registration_service; |
|
| 30 | 30 | |
| 31 | 31 | |
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * Command constructor |
|
| 35 | - * |
|
| 36 | - * @param CreateRegistrationService $registration_service |
|
| 37 | - */ |
|
| 38 | - public function __construct(CreateRegistrationService $registration_service) |
|
| 39 | - { |
|
| 40 | - $this->registration_service = $registration_service; |
|
| 41 | - } |
|
| 33 | + /** |
|
| 34 | + * Command constructor |
|
| 35 | + * |
|
| 36 | + * @param CreateRegistrationService $registration_service |
|
| 37 | + */ |
|
| 38 | + public function __construct(CreateRegistrationService $registration_service) |
|
| 39 | + { |
|
| 40 | + $this->registration_service = $registration_service; |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | 43 | |
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * @param CommandInterface $command |
|
| 47 | - * @return mixed |
|
| 48 | - * @throws \OutOfRangeException |
|
| 49 | - * @throws \EventEspresso\core\exceptions\UnexpectedEntityException |
|
| 50 | - * @throws \EE_Error |
|
| 51 | - * @throws \EventEspresso\core\exceptions\InvalidEntityException |
|
| 52 | - */ |
|
| 53 | - public function handle(CommandInterface $command) |
|
| 54 | - { |
|
| 55 | - /** @var CreateRegistrationCommand $command */ |
|
| 56 | - if ( ! $command instanceof CreateRegistrationCommand) { |
|
| 57 | - throw new InvalidEntityException(get_class($command), 'CreateRegistrationCommand'); |
|
| 58 | - } |
|
| 59 | - // now create a new registration for the ticket |
|
| 60 | - return $this->registration_service->create( |
|
| 61 | - $command->ticket()->get_related_event(), |
|
| 62 | - $command->transaction(), |
|
| 63 | - $command->ticket(), |
|
| 64 | - $command->ticketLineItem(), |
|
| 65 | - $command->regCount(), |
|
| 66 | - $command->regGroupSize(), |
|
| 67 | - $command->regStatus() |
|
| 68 | - ); |
|
| 69 | - } |
|
| 45 | + /** |
|
| 46 | + * @param CommandInterface $command |
|
| 47 | + * @return mixed |
|
| 48 | + * @throws \OutOfRangeException |
|
| 49 | + * @throws \EventEspresso\core\exceptions\UnexpectedEntityException |
|
| 50 | + * @throws \EE_Error |
|
| 51 | + * @throws \EventEspresso\core\exceptions\InvalidEntityException |
|
| 52 | + */ |
|
| 53 | + public function handle(CommandInterface $command) |
|
| 54 | + { |
|
| 55 | + /** @var CreateRegistrationCommand $command */ |
|
| 56 | + if ( ! $command instanceof CreateRegistrationCommand) { |
|
| 57 | + throw new InvalidEntityException(get_class($command), 'CreateRegistrationCommand'); |
|
| 58 | + } |
|
| 59 | + // now create a new registration for the ticket |
|
| 60 | + return $this->registration_service->create( |
|
| 61 | + $command->ticket()->get_related_event(), |
|
| 62 | + $command->transaction(), |
|
| 63 | + $command->ticket(), |
|
| 64 | + $command->ticketLineItem(), |
|
| 65 | + $command->regCount(), |
|
| 66 | + $command->regGroupSize(), |
|
| 67 | + $command->regStatus() |
|
| 68 | + ); |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | 71 | |
| 72 | 72 | |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
| 2 | - exit('No direct script access allowed'); |
|
| 2 | + exit('No direct script access allowed'); |
|
| 3 | 3 | } |
| 4 | 4 | |
| 5 | 5 | |
@@ -16,672 +16,672 @@ discard block |
||
| 16 | 16 | abstract class EE_SPCO_Reg_Step |
| 17 | 17 | { |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * $_completed - TRUE if this step has fully completed it's duties |
|
| 21 | - * |
|
| 22 | - * @access protected |
|
| 23 | - * @type bool $_completed |
|
| 24 | - */ |
|
| 25 | - protected $_completed = false; |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * $_is_current_step - TRUE if this is the current step |
|
| 29 | - * |
|
| 30 | - * @access protected |
|
| 31 | - * @type bool $_is_current_step |
|
| 32 | - */ |
|
| 33 | - protected $_is_current_step = false; |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * $_order - when the reg step should be run relative to other steps |
|
| 37 | - * |
|
| 38 | - * @access protected |
|
| 39 | - * @type int $_template |
|
| 40 | - */ |
|
| 41 | - protected $_order = 0; |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * $_slug - URL param for this step |
|
| 45 | - * |
|
| 46 | - * @access protected |
|
| 47 | - * @type string $_slug |
|
| 48 | - */ |
|
| 49 | - protected $_slug; |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * $_name - Step Name - translatable string |
|
| 53 | - * |
|
| 54 | - * @access protected |
|
| 55 | - * @type string $_slug |
|
| 56 | - */ |
|
| 57 | - protected $_name; |
|
| 58 | - |
|
| 59 | - /** |
|
| 60 | - * $_submit_button_text - translatable string that appears on this step's submit button |
|
| 61 | - * |
|
| 62 | - * @access protected |
|
| 63 | - * @type string $_slug |
|
| 64 | - */ |
|
| 65 | - protected $_submit_button_text; |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * $_template - template name |
|
| 69 | - * |
|
| 70 | - * @access protected |
|
| 71 | - * @type string $_template |
|
| 72 | - */ |
|
| 73 | - protected $_template; |
|
| 74 | - |
|
| 75 | - /** |
|
| 76 | - * $_reg_form_name - the form input name and id attribute |
|
| 77 | - * |
|
| 78 | - * @access protected |
|
| 79 | - * @var string $_reg_form_name |
|
| 80 | - */ |
|
| 81 | - protected $_reg_form_name; |
|
| 82 | - |
|
| 83 | - /** |
|
| 84 | - * $_success_message - text to display upon successful form submission |
|
| 85 | - * |
|
| 86 | - * @access private |
|
| 87 | - * @var string $_success_message |
|
| 88 | - */ |
|
| 89 | - protected $_success_message; |
|
| 90 | - |
|
| 91 | - /** |
|
| 92 | - * $_instructions - a brief description of how to complete the reg step. |
|
| 93 | - * Usually displayed in conjunction with the previous step's success message. |
|
| 94 | - * |
|
| 95 | - * @access private |
|
| 96 | - * @var string $_instructions |
|
| 97 | - */ |
|
| 98 | - protected $_instructions; |
|
| 99 | - |
|
| 100 | - /** |
|
| 101 | - * $_valid_data - the normalized and validated data for this step |
|
| 102 | - * |
|
| 103 | - * @access public |
|
| 104 | - * @var array $_valid_data |
|
| 105 | - */ |
|
| 106 | - protected $_valid_data = array(); |
|
| 107 | - |
|
| 108 | - /** |
|
| 109 | - * $reg_form - the registration form for this step |
|
| 110 | - * |
|
| 111 | - * @access public |
|
| 112 | - * @var EE_Form_Section_Proper $reg_form |
|
| 113 | - */ |
|
| 114 | - public $reg_form; |
|
| 115 | - |
|
| 116 | - /** |
|
| 117 | - * $checkout - EE_Checkout object for handling the properties of the current checkout process |
|
| 118 | - * |
|
| 119 | - * @access public |
|
| 120 | - * @var EE_Checkout $checkout |
|
| 121 | - */ |
|
| 122 | - public $checkout; |
|
| 123 | - |
|
| 124 | - |
|
| 125 | - |
|
| 126 | - /** |
|
| 127 | - * @return void |
|
| 128 | - */ |
|
| 129 | - abstract public function translate_js_strings(); |
|
| 130 | - |
|
| 131 | - |
|
| 19 | + /** |
|
| 20 | + * $_completed - TRUE if this step has fully completed it's duties |
|
| 21 | + * |
|
| 22 | + * @access protected |
|
| 23 | + * @type bool $_completed |
|
| 24 | + */ |
|
| 25 | + protected $_completed = false; |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * $_is_current_step - TRUE if this is the current step |
|
| 29 | + * |
|
| 30 | + * @access protected |
|
| 31 | + * @type bool $_is_current_step |
|
| 32 | + */ |
|
| 33 | + protected $_is_current_step = false; |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * $_order - when the reg step should be run relative to other steps |
|
| 37 | + * |
|
| 38 | + * @access protected |
|
| 39 | + * @type int $_template |
|
| 40 | + */ |
|
| 41 | + protected $_order = 0; |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * $_slug - URL param for this step |
|
| 45 | + * |
|
| 46 | + * @access protected |
|
| 47 | + * @type string $_slug |
|
| 48 | + */ |
|
| 49 | + protected $_slug; |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * $_name - Step Name - translatable string |
|
| 53 | + * |
|
| 54 | + * @access protected |
|
| 55 | + * @type string $_slug |
|
| 56 | + */ |
|
| 57 | + protected $_name; |
|
| 58 | + |
|
| 59 | + /** |
|
| 60 | + * $_submit_button_text - translatable string that appears on this step's submit button |
|
| 61 | + * |
|
| 62 | + * @access protected |
|
| 63 | + * @type string $_slug |
|
| 64 | + */ |
|
| 65 | + protected $_submit_button_text; |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * $_template - template name |
|
| 69 | + * |
|
| 70 | + * @access protected |
|
| 71 | + * @type string $_template |
|
| 72 | + */ |
|
| 73 | + protected $_template; |
|
| 74 | + |
|
| 75 | + /** |
|
| 76 | + * $_reg_form_name - the form input name and id attribute |
|
| 77 | + * |
|
| 78 | + * @access protected |
|
| 79 | + * @var string $_reg_form_name |
|
| 80 | + */ |
|
| 81 | + protected $_reg_form_name; |
|
| 82 | + |
|
| 83 | + /** |
|
| 84 | + * $_success_message - text to display upon successful form submission |
|
| 85 | + * |
|
| 86 | + * @access private |
|
| 87 | + * @var string $_success_message |
|
| 88 | + */ |
|
| 89 | + protected $_success_message; |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * $_instructions - a brief description of how to complete the reg step. |
|
| 93 | + * Usually displayed in conjunction with the previous step's success message. |
|
| 94 | + * |
|
| 95 | + * @access private |
|
| 96 | + * @var string $_instructions |
|
| 97 | + */ |
|
| 98 | + protected $_instructions; |
|
| 99 | + |
|
| 100 | + /** |
|
| 101 | + * $_valid_data - the normalized and validated data for this step |
|
| 102 | + * |
|
| 103 | + * @access public |
|
| 104 | + * @var array $_valid_data |
|
| 105 | + */ |
|
| 106 | + protected $_valid_data = array(); |
|
| 107 | + |
|
| 108 | + /** |
|
| 109 | + * $reg_form - the registration form for this step |
|
| 110 | + * |
|
| 111 | + * @access public |
|
| 112 | + * @var EE_Form_Section_Proper $reg_form |
|
| 113 | + */ |
|
| 114 | + public $reg_form; |
|
| 115 | + |
|
| 116 | + /** |
|
| 117 | + * $checkout - EE_Checkout object for handling the properties of the current checkout process |
|
| 118 | + * |
|
| 119 | + * @access public |
|
| 120 | + * @var EE_Checkout $checkout |
|
| 121 | + */ |
|
| 122 | + public $checkout; |
|
| 123 | + |
|
| 124 | + |
|
| 125 | + |
|
| 126 | + /** |
|
| 127 | + * @return void |
|
| 128 | + */ |
|
| 129 | + abstract public function translate_js_strings(); |
|
| 130 | + |
|
| 131 | + |
|
| 132 | 132 | |
| 133 | - /** |
|
| 134 | - * @return void |
|
| 135 | - */ |
|
| 136 | - abstract public function enqueue_styles_and_scripts(); |
|
| 137 | - |
|
| 138 | - |
|
| 139 | - |
|
| 140 | - /** |
|
| 141 | - * @return boolean |
|
| 142 | - */ |
|
| 143 | - abstract public function initialize_reg_step(); |
|
| 144 | - |
|
| 145 | - |
|
| 146 | - |
|
| 147 | - /** |
|
| 148 | - * @return string |
|
| 149 | - */ |
|
| 150 | - abstract public function generate_reg_form(); |
|
| 151 | - |
|
| 152 | - |
|
| 153 | - |
|
| 154 | - /** |
|
| 155 | - * @return boolean |
|
| 156 | - */ |
|
| 157 | - abstract public function process_reg_step(); |
|
| 158 | - |
|
| 159 | - |
|
| 160 | - |
|
| 161 | - /** |
|
| 162 | - * @return boolean |
|
| 163 | - */ |
|
| 164 | - abstract public function update_reg_step(); |
|
| 165 | - |
|
| 166 | - |
|
| 167 | - |
|
| 168 | - /** |
|
| 169 | - * @return boolean |
|
| 170 | - */ |
|
| 171 | - public function completed() |
|
| 172 | - { |
|
| 173 | - return $this->_completed; |
|
| 174 | - } |
|
| 133 | + /** |
|
| 134 | + * @return void |
|
| 135 | + */ |
|
| 136 | + abstract public function enqueue_styles_and_scripts(); |
|
| 137 | + |
|
| 138 | + |
|
| 139 | + |
|
| 140 | + /** |
|
| 141 | + * @return boolean |
|
| 142 | + */ |
|
| 143 | + abstract public function initialize_reg_step(); |
|
| 144 | + |
|
| 145 | + |
|
| 146 | + |
|
| 147 | + /** |
|
| 148 | + * @return string |
|
| 149 | + */ |
|
| 150 | + abstract public function generate_reg_form(); |
|
| 151 | + |
|
| 152 | + |
|
| 153 | + |
|
| 154 | + /** |
|
| 155 | + * @return boolean |
|
| 156 | + */ |
|
| 157 | + abstract public function process_reg_step(); |
|
| 158 | + |
|
| 159 | + |
|
| 160 | + |
|
| 161 | + /** |
|
| 162 | + * @return boolean |
|
| 163 | + */ |
|
| 164 | + abstract public function update_reg_step(); |
|
| 165 | + |
|
| 166 | + |
|
| 167 | + |
|
| 168 | + /** |
|
| 169 | + * @return boolean |
|
| 170 | + */ |
|
| 171 | + public function completed() |
|
| 172 | + { |
|
| 173 | + return $this->_completed; |
|
| 174 | + } |
|
| 175 | 175 | |
| 176 | 176 | |
| 177 | 177 | |
| 178 | - /** |
|
| 179 | - * set_completed - toggles $_completed to TRUE |
|
| 180 | - */ |
|
| 181 | - public function set_completed() |
|
| 182 | - { |
|
| 183 | - // DEBUG LOG |
|
| 184 | - //$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ ); |
|
| 185 | - $this->_completed = apply_filters('FHEE__EE_SPCO_Reg_Step__set_completed___completed', true, $this); |
|
| 186 | - } |
|
| 178 | + /** |
|
| 179 | + * set_completed - toggles $_completed to TRUE |
|
| 180 | + */ |
|
| 181 | + public function set_completed() |
|
| 182 | + { |
|
| 183 | + // DEBUG LOG |
|
| 184 | + //$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ ); |
|
| 185 | + $this->_completed = apply_filters('FHEE__EE_SPCO_Reg_Step__set_completed___completed', true, $this); |
|
| 186 | + } |
|
| 187 | 187 | |
| 188 | 188 | |
| 189 | 189 | |
| 190 | - /** |
|
| 191 | - * set_completed - toggles $_completed to FALSE |
|
| 192 | - */ |
|
| 193 | - public function set_not_completed() |
|
| 194 | - { |
|
| 195 | - $this->_completed = false; |
|
| 196 | - } |
|
| 190 | + /** |
|
| 191 | + * set_completed - toggles $_completed to FALSE |
|
| 192 | + */ |
|
| 193 | + public function set_not_completed() |
|
| 194 | + { |
|
| 195 | + $this->_completed = false; |
|
| 196 | + } |
|
| 197 | 197 | |
| 198 | 198 | |
| 199 | 199 | |
| 200 | - /** |
|
| 201 | - * @return string |
|
| 202 | - */ |
|
| 203 | - public function name() |
|
| 204 | - { |
|
| 205 | - return $this->_name; |
|
| 206 | - } |
|
| 200 | + /** |
|
| 201 | + * @return string |
|
| 202 | + */ |
|
| 203 | + public function name() |
|
| 204 | + { |
|
| 205 | + return $this->_name; |
|
| 206 | + } |
|
| 207 | 207 | |
| 208 | 208 | |
| 209 | 209 | |
| 210 | - /** |
|
| 211 | - * @return string |
|
| 212 | - */ |
|
| 213 | - public function slug() |
|
| 214 | - { |
|
| 215 | - return $this->_slug; |
|
| 216 | - } |
|
| 210 | + /** |
|
| 211 | + * @return string |
|
| 212 | + */ |
|
| 213 | + public function slug() |
|
| 214 | + { |
|
| 215 | + return $this->_slug; |
|
| 216 | + } |
|
| 217 | 217 | |
| 218 | 218 | |
| 219 | 219 | |
| 220 | - /** |
|
| 221 | - * submit_button_text |
|
| 222 | - * the text that appears on the reg step form submit button |
|
| 223 | - * |
|
| 224 | - * @return string |
|
| 225 | - */ |
|
| 226 | - public function submit_button_text() |
|
| 227 | - { |
|
| 228 | - return $this->_submit_button_text; |
|
| 229 | - } |
|
| 220 | + /** |
|
| 221 | + * submit_button_text |
|
| 222 | + * the text that appears on the reg step form submit button |
|
| 223 | + * |
|
| 224 | + * @return string |
|
| 225 | + */ |
|
| 226 | + public function submit_button_text() |
|
| 227 | + { |
|
| 228 | + return $this->_submit_button_text; |
|
| 229 | + } |
|
| 230 | 230 | |
| 231 | 231 | |
| 232 | 232 | |
| 233 | - /** |
|
| 234 | - * set_submit_button_text |
|
| 235 | - * sets the text that appears on the reg step form submit button |
|
| 236 | - * |
|
| 237 | - * @param string $submit_button_text |
|
| 238 | - */ |
|
| 239 | - public function set_submit_button_text($submit_button_text = '') |
|
| 240 | - { |
|
| 241 | - if (! empty($submit_button_text)) { |
|
| 242 | - $this->_submit_button_text = $submit_button_text; |
|
| 243 | - } else if ($this->checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
| 244 | - if ($this->checkout->revisit) { |
|
| 245 | - $this->_submit_button_text = sprintf( |
|
| 246 | - __('Update %s', 'event_espresso'), |
|
| 247 | - $this->checkout->current_step->name() |
|
| 248 | - ); |
|
| 249 | - } else { |
|
| 250 | - $this->_submit_button_text = sprintf( |
|
| 251 | - __('Proceed to %s', 'event_espresso'), |
|
| 252 | - $this->checkout->next_step->name() |
|
| 253 | - ); |
|
| 254 | - } |
|
| 255 | - } |
|
| 256 | - // filters the submit button text |
|
| 257 | - $this->_submit_button_text = apply_filters( |
|
| 258 | - 'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', |
|
| 259 | - $this->_submit_button_text, |
|
| 260 | - $this->checkout |
|
| 261 | - ); |
|
| 262 | - } |
|
| 233 | + /** |
|
| 234 | + * set_submit_button_text |
|
| 235 | + * sets the text that appears on the reg step form submit button |
|
| 236 | + * |
|
| 237 | + * @param string $submit_button_text |
|
| 238 | + */ |
|
| 239 | + public function set_submit_button_text($submit_button_text = '') |
|
| 240 | + { |
|
| 241 | + if (! empty($submit_button_text)) { |
|
| 242 | + $this->_submit_button_text = $submit_button_text; |
|
| 243 | + } else if ($this->checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
| 244 | + if ($this->checkout->revisit) { |
|
| 245 | + $this->_submit_button_text = sprintf( |
|
| 246 | + __('Update %s', 'event_espresso'), |
|
| 247 | + $this->checkout->current_step->name() |
|
| 248 | + ); |
|
| 249 | + } else { |
|
| 250 | + $this->_submit_button_text = sprintf( |
|
| 251 | + __('Proceed to %s', 'event_espresso'), |
|
| 252 | + $this->checkout->next_step->name() |
|
| 253 | + ); |
|
| 254 | + } |
|
| 255 | + } |
|
| 256 | + // filters the submit button text |
|
| 257 | + $this->_submit_button_text = apply_filters( |
|
| 258 | + 'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', |
|
| 259 | + $this->_submit_button_text, |
|
| 260 | + $this->checkout |
|
| 261 | + ); |
|
| 262 | + } |
|
| 263 | 263 | |
| 264 | 264 | |
| 265 | 265 | |
| 266 | - /** |
|
| 267 | - * @param boolean $is_current_step |
|
| 268 | - */ |
|
| 269 | - public function set_is_current_step($is_current_step) |
|
| 270 | - { |
|
| 271 | - $this->_is_current_step = $is_current_step; |
|
| 272 | - } |
|
| 266 | + /** |
|
| 267 | + * @param boolean $is_current_step |
|
| 268 | + */ |
|
| 269 | + public function set_is_current_step($is_current_step) |
|
| 270 | + { |
|
| 271 | + $this->_is_current_step = $is_current_step; |
|
| 272 | + } |
|
| 273 | 273 | |
| 274 | 274 | |
| 275 | 275 | |
| 276 | - /** |
|
| 277 | - * @return boolean |
|
| 278 | - */ |
|
| 279 | - public function is_current_step() |
|
| 280 | - { |
|
| 281 | - return $this->_is_current_step; |
|
| 282 | - } |
|
| 276 | + /** |
|
| 277 | + * @return boolean |
|
| 278 | + */ |
|
| 279 | + public function is_current_step() |
|
| 280 | + { |
|
| 281 | + return $this->_is_current_step; |
|
| 282 | + } |
|
| 283 | 283 | |
| 284 | 284 | |
| 285 | 285 | |
| 286 | - /** |
|
| 287 | - * @return boolean |
|
| 288 | - */ |
|
| 289 | - public function is_final_step() |
|
| 290 | - { |
|
| 291 | - return $this instanceof EE_SPCO_Reg_Step_Finalize_Registration ? true : false; |
|
| 292 | - } |
|
| 286 | + /** |
|
| 287 | + * @return boolean |
|
| 288 | + */ |
|
| 289 | + public function is_final_step() |
|
| 290 | + { |
|
| 291 | + return $this instanceof EE_SPCO_Reg_Step_Finalize_Registration ? true : false; |
|
| 292 | + } |
|
| 293 | 293 | |
| 294 | 294 | |
| 295 | 295 | |
| 296 | - /** |
|
| 297 | - * @param int $order |
|
| 298 | - */ |
|
| 299 | - public function set_order($order) |
|
| 300 | - { |
|
| 301 | - $this->_order = $order; |
|
| 302 | - } |
|
| 303 | - |
|
| 304 | - |
|
| 296 | + /** |
|
| 297 | + * @param int $order |
|
| 298 | + */ |
|
| 299 | + public function set_order($order) |
|
| 300 | + { |
|
| 301 | + $this->_order = $order; |
|
| 302 | + } |
|
| 303 | + |
|
| 304 | + |
|
| 305 | 305 | |
| 306 | - /** |
|
| 307 | - * @return int |
|
| 308 | - */ |
|
| 309 | - public function order() |
|
| 310 | - { |
|
| 311 | - return $this->_order; |
|
| 312 | - } |
|
| 313 | - |
|
| 314 | - |
|
| 315 | - |
|
| 316 | - /** |
|
| 317 | - * @return string |
|
| 318 | - */ |
|
| 319 | - public function template() |
|
| 320 | - { |
|
| 321 | - return $this->_template; |
|
| 322 | - } |
|
| 323 | - |
|
| 324 | - |
|
| 325 | - |
|
| 326 | - /** |
|
| 327 | - * @return string |
|
| 328 | - */ |
|
| 329 | - public function success_message() |
|
| 330 | - { |
|
| 331 | - return $this->_success_message; |
|
| 332 | - } |
|
| 333 | - |
|
| 334 | - |
|
| 335 | - |
|
| 336 | - /** |
|
| 337 | - * _set_success_message |
|
| 338 | - * |
|
| 339 | - * @param string $success_message |
|
| 340 | - */ |
|
| 341 | - protected function _set_success_message($success_message) |
|
| 342 | - { |
|
| 343 | - $this->_success_message = $success_message; |
|
| 344 | - } |
|
| 345 | - |
|
| 346 | - |
|
| 347 | - |
|
| 348 | - /** |
|
| 349 | - * _reset_success_message |
|
| 350 | - * |
|
| 351 | - * @return void |
|
| 352 | - */ |
|
| 353 | - protected function _reset_success_message() |
|
| 354 | - { |
|
| 355 | - $this->_success_message = ''; |
|
| 356 | - } |
|
| 306 | + /** |
|
| 307 | + * @return int |
|
| 308 | + */ |
|
| 309 | + public function order() |
|
| 310 | + { |
|
| 311 | + return $this->_order; |
|
| 312 | + } |
|
| 313 | + |
|
| 314 | + |
|
| 315 | + |
|
| 316 | + /** |
|
| 317 | + * @return string |
|
| 318 | + */ |
|
| 319 | + public function template() |
|
| 320 | + { |
|
| 321 | + return $this->_template; |
|
| 322 | + } |
|
| 323 | + |
|
| 324 | + |
|
| 325 | + |
|
| 326 | + /** |
|
| 327 | + * @return string |
|
| 328 | + */ |
|
| 329 | + public function success_message() |
|
| 330 | + { |
|
| 331 | + return $this->_success_message; |
|
| 332 | + } |
|
| 333 | + |
|
| 334 | + |
|
| 335 | + |
|
| 336 | + /** |
|
| 337 | + * _set_success_message |
|
| 338 | + * |
|
| 339 | + * @param string $success_message |
|
| 340 | + */ |
|
| 341 | + protected function _set_success_message($success_message) |
|
| 342 | + { |
|
| 343 | + $this->_success_message = $success_message; |
|
| 344 | + } |
|
| 345 | + |
|
| 346 | + |
|
| 347 | + |
|
| 348 | + /** |
|
| 349 | + * _reset_success_message |
|
| 350 | + * |
|
| 351 | + * @return void |
|
| 352 | + */ |
|
| 353 | + protected function _reset_success_message() |
|
| 354 | + { |
|
| 355 | + $this->_success_message = ''; |
|
| 356 | + } |
|
| 357 | 357 | |
| 358 | 358 | |
| 359 | 359 | |
| 360 | - /** |
|
| 361 | - * @return string |
|
| 362 | - */ |
|
| 363 | - public function _instructions() |
|
| 364 | - { |
|
| 365 | - return $this->_instructions; |
|
| 366 | - } |
|
| 367 | - |
|
| 368 | - |
|
| 369 | - |
|
| 370 | - /** |
|
| 371 | - * @param string $instructions |
|
| 372 | - */ |
|
| 373 | - public function set_instructions($instructions) |
|
| 374 | - { |
|
| 375 | - $this->_instructions = apply_filters( |
|
| 376 | - 'FHEE__EE_SPCO_Reg_Step__set_instructions__instructions', |
|
| 377 | - $instructions, |
|
| 378 | - $this |
|
| 379 | - ); |
|
| 380 | - } |
|
| 381 | - |
|
| 382 | - |
|
| 383 | - |
|
| 384 | - /** |
|
| 385 | - * @param array $valid_data |
|
| 386 | - */ |
|
| 387 | - public function set_valid_data($valid_data) |
|
| 388 | - { |
|
| 389 | - $this->_valid_data = $valid_data; |
|
| 390 | - } |
|
| 391 | - |
|
| 392 | - |
|
| 393 | - |
|
| 394 | - /** |
|
| 395 | - * @return array |
|
| 396 | - */ |
|
| 397 | - public function valid_data() |
|
| 398 | - { |
|
| 399 | - if (empty($this->_valid_data)) { |
|
| 400 | - $this->_valid_data = $this->reg_form->valid_data(); |
|
| 401 | - } |
|
| 402 | - return $this->_valid_data; |
|
| 403 | - } |
|
| 404 | - |
|
| 405 | - |
|
| 406 | - |
|
| 407 | - /** |
|
| 408 | - * @return string |
|
| 409 | - */ |
|
| 410 | - public function reg_form_name() |
|
| 411 | - { |
|
| 412 | - if (empty($this->_reg_form_name)) { |
|
| 413 | - $this->set_reg_form_name('ee-spco-' . $this->slug() . '-reg-step-form'); |
|
| 414 | - } |
|
| 415 | - return $this->_reg_form_name; |
|
| 416 | - } |
|
| 417 | - |
|
| 418 | - |
|
| 419 | - |
|
| 420 | - /** |
|
| 421 | - * @param string $reg_form_name |
|
| 422 | - */ |
|
| 423 | - protected function set_reg_form_name($reg_form_name) |
|
| 424 | - { |
|
| 425 | - $this->_reg_form_name = $reg_form_name; |
|
| 426 | - } |
|
| 427 | - |
|
| 428 | - |
|
| 429 | - |
|
| 430 | - /** |
|
| 431 | - * reg_step_url |
|
| 432 | - * |
|
| 433 | - * @param string $action |
|
| 434 | - * @return string |
|
| 435 | - */ |
|
| 436 | - public function reg_step_url($action = '') |
|
| 437 | - { |
|
| 438 | - $query_args = array('step' => $this->slug()); |
|
| 439 | - if (! empty($action)) { |
|
| 440 | - $query_args['action'] = $action; |
|
| 441 | - } |
|
| 442 | - // final step has no display |
|
| 443 | - if ($this instanceof EE_SPCO_Reg_Step_Finalize_Registration && $action === 'display_spco_reg_step') { |
|
| 444 | - $query_args['action'] = 'process_reg_step'; |
|
| 445 | - } |
|
| 446 | - if ($this->checkout->revisit) { |
|
| 447 | - $query_args['revisit'] = true; |
|
| 448 | - } |
|
| 449 | - if ($this->checkout->reg_url_link) { |
|
| 450 | - $query_args['e_reg_url_link'] = $this->checkout->reg_url_link; |
|
| 451 | - } |
|
| 452 | - return add_query_arg($query_args, $this->checkout->reg_page_base_url); |
|
| 453 | - } |
|
| 454 | - |
|
| 455 | - |
|
| 456 | - |
|
| 457 | - /** |
|
| 458 | - * creates the default hidden inputs section |
|
| 459 | - * |
|
| 460 | - * @return EE_Form_Section_Proper |
|
| 461 | - * @throws \EE_Error |
|
| 462 | - */ |
|
| 463 | - public function reg_step_hidden_inputs() |
|
| 464 | - { |
|
| 465 | - // hidden inputs for admin registrations |
|
| 466 | - if ($this->checkout->admin_request) { |
|
| 467 | - return new EE_Form_Section_Proper( |
|
| 468 | - array( |
|
| 469 | - 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
|
| 470 | - 'html_id' => 'ee-' . $this->slug() . '-hidden-inputs', |
|
| 471 | - 'subsections' => array( |
|
| 472 | - 'next_step' => new EE_Fixed_Hidden_Input( |
|
| 473 | - array( |
|
| 474 | - 'html_name' => 'next_step', |
|
| 475 | - 'html_id' => 'spco-' . $this->slug() . '-next-step', |
|
| 476 | - 'default' => $this->checkout->next_step instanceof EE_SPCO_Reg_Step |
|
| 477 | - ? $this->checkout->next_step->slug() |
|
| 478 | - : '', |
|
| 479 | - ) |
|
| 480 | - ), |
|
| 481 | - ), |
|
| 482 | - ) |
|
| 483 | - ); |
|
| 484 | - } else { |
|
| 485 | - $default_form_action = apply_filters( |
|
| 486 | - 'FHEE__EE_SPCO_Reg_Step__reg_step_hidden_inputs__default_form_action', |
|
| 487 | - empty($this->checkout->reg_url_link) |
|
| 488 | - ? 'process_reg_step' |
|
| 489 | - : 'update_reg_step', |
|
| 490 | - $this |
|
| 491 | - ); |
|
| 492 | - // hidden inputs for frontend registrations |
|
| 493 | - return new EE_Form_Section_Proper( |
|
| 494 | - array( |
|
| 495 | - 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
|
| 496 | - 'html_id' => 'ee-' . $this->slug() . '-hidden-inputs', |
|
| 497 | - 'subsections' => array( |
|
| 498 | - 'action' => new EE_Fixed_Hidden_Input( |
|
| 499 | - array( |
|
| 500 | - 'html_name' => 'action', |
|
| 501 | - 'html_id' => 'spco-' . $this->slug() . '-action', |
|
| 502 | - 'default' => $default_form_action, |
|
| 503 | - ) |
|
| 504 | - ), |
|
| 505 | - 'next_step' => new EE_Fixed_Hidden_Input( |
|
| 506 | - array( |
|
| 507 | - 'html_name' => 'next_step', |
|
| 508 | - 'html_id' => 'spco-' . $this->slug() . '-next-step', |
|
| 509 | - 'default' => $this->checkout->next_step instanceof EE_SPCO_Reg_Step |
|
| 510 | - ? $this->checkout->next_step->slug() |
|
| 511 | - : '', |
|
| 512 | - ) |
|
| 513 | - ), |
|
| 514 | - 'e_reg_url_link' => new EE_Fixed_Hidden_Input( |
|
| 515 | - array( |
|
| 516 | - 'html_name' => 'e_reg_url_link', |
|
| 517 | - 'html_id' => 'spco-reg_url_link', |
|
| 518 | - 'default' => $this->checkout->reg_url_link, |
|
| 519 | - ) |
|
| 520 | - ), |
|
| 521 | - 'revisit' => new EE_Fixed_Hidden_Input( |
|
| 522 | - array( |
|
| 523 | - 'html_name' => 'revisit', |
|
| 524 | - 'html_id' => 'spco-revisit', |
|
| 525 | - 'default' => $this->checkout->revisit, |
|
| 526 | - ) |
|
| 527 | - ), |
|
| 528 | - ), |
|
| 529 | - ) |
|
| 530 | - ); |
|
| 531 | - } |
|
| 532 | - } |
|
| 533 | - |
|
| 534 | - |
|
| 535 | - |
|
| 536 | - /** |
|
| 537 | - * generate_reg_form_for_actions |
|
| 538 | - * |
|
| 539 | - * @param array $actions |
|
| 540 | - * @return void |
|
| 541 | - */ |
|
| 542 | - public function generate_reg_form_for_actions($actions = array()) |
|
| 543 | - { |
|
| 544 | - $actions = array_merge( |
|
| 545 | - array( |
|
| 546 | - 'generate_reg_form', |
|
| 547 | - 'display_spco_reg_step', |
|
| 548 | - 'process_reg_step', |
|
| 549 | - 'update_reg_step', |
|
| 550 | - ), |
|
| 551 | - $actions |
|
| 552 | - ); |
|
| 553 | - $this->checkout->generate_reg_form = in_array($this->checkout->action, $actions, true) ? true : false; |
|
| 554 | - } |
|
| 555 | - |
|
| 556 | - |
|
| 557 | - |
|
| 558 | - /** |
|
| 559 | - * @return string |
|
| 560 | - * @throws \EE_Error |
|
| 561 | - */ |
|
| 562 | - public function display_reg_form() |
|
| 563 | - { |
|
| 564 | - $html = ''; |
|
| 565 | - if ($this->reg_form instanceof EE_Form_Section_Proper) { |
|
| 566 | - $html .= ! $this->checkout->admin_request ? $this->reg_form->form_open($this->reg_step_url()) : ''; |
|
| 567 | - if (EE_Registry::instance()->REQ->ajax) { |
|
| 568 | - $this->reg_form->localize_validation_rules(); |
|
| 569 | - $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization()); |
|
| 570 | - } |
|
| 571 | - $html .= $this->reg_form->get_html(); |
|
| 572 | - $html .= ! $this->checkout->admin_request ? $this->reg_step_submit_button() : ''; |
|
| 573 | - $html .= ! $this->checkout->admin_request ? $this->reg_form->form_close() : ''; |
|
| 574 | - } |
|
| 575 | - return $html; |
|
| 576 | - } |
|
| 577 | - |
|
| 578 | - |
|
| 579 | - |
|
| 580 | - /** |
|
| 581 | - * div_class - returns nothing for current step, but a css class of "hidden" for others |
|
| 582 | - * |
|
| 583 | - * @return string |
|
| 584 | - * @throws \EE_Error |
|
| 585 | - */ |
|
| 586 | - public function reg_step_submit_button() |
|
| 587 | - { |
|
| 588 | - if (! $this->checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
| 589 | - return ''; |
|
| 590 | - } |
|
| 591 | - ob_start(); |
|
| 592 | - do_action( |
|
| 593 | - 'AHEE__before_spco_whats_next_buttons', |
|
| 594 | - $this->slug(), |
|
| 595 | - $this->checkout->next_step->slug(), |
|
| 596 | - $this->checkout |
|
| 597 | - ); |
|
| 598 | - $html = ob_get_clean(); |
|
| 599 | - // generate submit button |
|
| 600 | - $sbmt_btn = new EE_Submit_Input(array( |
|
| 601 | - 'html_name' => 'spco-go-to-step-' . $this->checkout->next_step->slug(), |
|
| 602 | - 'html_id' => 'spco-go-to-step-' . $this->checkout->next_step->slug(), |
|
| 603 | - 'html_class' => 'spco-next-step-btn', |
|
| 604 | - 'other_html_attributes' => ' rel="' . $this->slug() . '"', |
|
| 605 | - 'default' => $this->submit_button_text(), |
|
| 606 | - )); |
|
| 607 | - $sbmt_btn->set_button_css_attributes(true, 'large'); |
|
| 608 | - $sbmt_btn_html = $sbmt_btn->get_html_for_input(); |
|
| 609 | - $html .= EEH_HTML::div( |
|
| 610 | - apply_filters('FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', $sbmt_btn_html, $this), |
|
| 611 | - 'spco-' . $this->slug() . '-whats-next-buttons-dv', |
|
| 612 | - 'spco-whats-next-buttons' |
|
| 613 | - ); |
|
| 614 | - return $html; |
|
| 615 | - } |
|
| 616 | - |
|
| 617 | - |
|
| 618 | - |
|
| 619 | - /** |
|
| 620 | - * div_class - returns nothing for current step, but a css class of "hidden" for others |
|
| 621 | - * |
|
| 622 | - * @return string |
|
| 623 | - */ |
|
| 624 | - public function div_class() |
|
| 625 | - { |
|
| 626 | - return $this->is_current_step() ? '' : ' hidden'; |
|
| 627 | - } |
|
| 628 | - |
|
| 629 | - |
|
| 630 | - |
|
| 631 | - /** |
|
| 632 | - * div_class - returns a css class of "hidden" for current step, but nothing for others |
|
| 633 | - * |
|
| 634 | - * @return string |
|
| 635 | - */ |
|
| 636 | - public function edit_lnk_url() |
|
| 637 | - { |
|
| 638 | - return add_query_arg(array('step' => $this->slug()), $this->checkout->reg_page_base_url); |
|
| 639 | - } |
|
| 640 | - |
|
| 641 | - |
|
| 642 | - |
|
| 643 | - /** |
|
| 644 | - * div_class - returns a css class of "hidden" for current step, but nothing for others |
|
| 645 | - * |
|
| 646 | - * @return string |
|
| 647 | - */ |
|
| 648 | - public function edit_link_class() |
|
| 649 | - { |
|
| 650 | - return $this->is_current_step() ? ' hidden' : ''; |
|
| 651 | - } |
|
| 652 | - |
|
| 653 | - |
|
| 654 | - |
|
| 655 | - /** |
|
| 656 | - * update_checkout with changes that have been made to the cart |
|
| 657 | - * |
|
| 658 | - * @return void |
|
| 659 | - * @throws \EE_Error |
|
| 660 | - */ |
|
| 661 | - public function update_checkout() |
|
| 662 | - { |
|
| 663 | - // grab the cart grand total and reset TXN total |
|
| 664 | - $this->checkout->transaction->set_total($this->checkout->cart->get_cart_grand_total()); |
|
| 665 | - $this->checkout->stash_transaction_and_checkout(); |
|
| 666 | - } |
|
| 667 | - |
|
| 668 | - |
|
| 669 | - |
|
| 670 | - |
|
| 671 | - |
|
| 672 | - /** |
|
| 673 | - * __sleep |
|
| 674 | - * to conserve db space, let's remove the reg_form and the EE_Checkout object from EE_SPCO_Reg_Step objects upon |
|
| 675 | - * serialization EE_Checkout will handle the reimplementation of itself upon waking, but we won't bother with the |
|
| 676 | - * reg form, because if needed, it will be regenerated anyways |
|
| 677 | - * |
|
| 678 | - * @return array |
|
| 679 | - */ |
|
| 680 | - public function __sleep() |
|
| 681 | - { |
|
| 682 | - // remove the reg form and the checkout |
|
| 683 | - return array_diff(array_keys(get_object_vars($this)), array('reg_form', 'checkout')); |
|
| 684 | - } |
|
| 360 | + /** |
|
| 361 | + * @return string |
|
| 362 | + */ |
|
| 363 | + public function _instructions() |
|
| 364 | + { |
|
| 365 | + return $this->_instructions; |
|
| 366 | + } |
|
| 367 | + |
|
| 368 | + |
|
| 369 | + |
|
| 370 | + /** |
|
| 371 | + * @param string $instructions |
|
| 372 | + */ |
|
| 373 | + public function set_instructions($instructions) |
|
| 374 | + { |
|
| 375 | + $this->_instructions = apply_filters( |
|
| 376 | + 'FHEE__EE_SPCO_Reg_Step__set_instructions__instructions', |
|
| 377 | + $instructions, |
|
| 378 | + $this |
|
| 379 | + ); |
|
| 380 | + } |
|
| 381 | + |
|
| 382 | + |
|
| 383 | + |
|
| 384 | + /** |
|
| 385 | + * @param array $valid_data |
|
| 386 | + */ |
|
| 387 | + public function set_valid_data($valid_data) |
|
| 388 | + { |
|
| 389 | + $this->_valid_data = $valid_data; |
|
| 390 | + } |
|
| 391 | + |
|
| 392 | + |
|
| 393 | + |
|
| 394 | + /** |
|
| 395 | + * @return array |
|
| 396 | + */ |
|
| 397 | + public function valid_data() |
|
| 398 | + { |
|
| 399 | + if (empty($this->_valid_data)) { |
|
| 400 | + $this->_valid_data = $this->reg_form->valid_data(); |
|
| 401 | + } |
|
| 402 | + return $this->_valid_data; |
|
| 403 | + } |
|
| 404 | + |
|
| 405 | + |
|
| 406 | + |
|
| 407 | + /** |
|
| 408 | + * @return string |
|
| 409 | + */ |
|
| 410 | + public function reg_form_name() |
|
| 411 | + { |
|
| 412 | + if (empty($this->_reg_form_name)) { |
|
| 413 | + $this->set_reg_form_name('ee-spco-' . $this->slug() . '-reg-step-form'); |
|
| 414 | + } |
|
| 415 | + return $this->_reg_form_name; |
|
| 416 | + } |
|
| 417 | + |
|
| 418 | + |
|
| 419 | + |
|
| 420 | + /** |
|
| 421 | + * @param string $reg_form_name |
|
| 422 | + */ |
|
| 423 | + protected function set_reg_form_name($reg_form_name) |
|
| 424 | + { |
|
| 425 | + $this->_reg_form_name = $reg_form_name; |
|
| 426 | + } |
|
| 427 | + |
|
| 428 | + |
|
| 429 | + |
|
| 430 | + /** |
|
| 431 | + * reg_step_url |
|
| 432 | + * |
|
| 433 | + * @param string $action |
|
| 434 | + * @return string |
|
| 435 | + */ |
|
| 436 | + public function reg_step_url($action = '') |
|
| 437 | + { |
|
| 438 | + $query_args = array('step' => $this->slug()); |
|
| 439 | + if (! empty($action)) { |
|
| 440 | + $query_args['action'] = $action; |
|
| 441 | + } |
|
| 442 | + // final step has no display |
|
| 443 | + if ($this instanceof EE_SPCO_Reg_Step_Finalize_Registration && $action === 'display_spco_reg_step') { |
|
| 444 | + $query_args['action'] = 'process_reg_step'; |
|
| 445 | + } |
|
| 446 | + if ($this->checkout->revisit) { |
|
| 447 | + $query_args['revisit'] = true; |
|
| 448 | + } |
|
| 449 | + if ($this->checkout->reg_url_link) { |
|
| 450 | + $query_args['e_reg_url_link'] = $this->checkout->reg_url_link; |
|
| 451 | + } |
|
| 452 | + return add_query_arg($query_args, $this->checkout->reg_page_base_url); |
|
| 453 | + } |
|
| 454 | + |
|
| 455 | + |
|
| 456 | + |
|
| 457 | + /** |
|
| 458 | + * creates the default hidden inputs section |
|
| 459 | + * |
|
| 460 | + * @return EE_Form_Section_Proper |
|
| 461 | + * @throws \EE_Error |
|
| 462 | + */ |
|
| 463 | + public function reg_step_hidden_inputs() |
|
| 464 | + { |
|
| 465 | + // hidden inputs for admin registrations |
|
| 466 | + if ($this->checkout->admin_request) { |
|
| 467 | + return new EE_Form_Section_Proper( |
|
| 468 | + array( |
|
| 469 | + 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
|
| 470 | + 'html_id' => 'ee-' . $this->slug() . '-hidden-inputs', |
|
| 471 | + 'subsections' => array( |
|
| 472 | + 'next_step' => new EE_Fixed_Hidden_Input( |
|
| 473 | + array( |
|
| 474 | + 'html_name' => 'next_step', |
|
| 475 | + 'html_id' => 'spco-' . $this->slug() . '-next-step', |
|
| 476 | + 'default' => $this->checkout->next_step instanceof EE_SPCO_Reg_Step |
|
| 477 | + ? $this->checkout->next_step->slug() |
|
| 478 | + : '', |
|
| 479 | + ) |
|
| 480 | + ), |
|
| 481 | + ), |
|
| 482 | + ) |
|
| 483 | + ); |
|
| 484 | + } else { |
|
| 485 | + $default_form_action = apply_filters( |
|
| 486 | + 'FHEE__EE_SPCO_Reg_Step__reg_step_hidden_inputs__default_form_action', |
|
| 487 | + empty($this->checkout->reg_url_link) |
|
| 488 | + ? 'process_reg_step' |
|
| 489 | + : 'update_reg_step', |
|
| 490 | + $this |
|
| 491 | + ); |
|
| 492 | + // hidden inputs for frontend registrations |
|
| 493 | + return new EE_Form_Section_Proper( |
|
| 494 | + array( |
|
| 495 | + 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
|
| 496 | + 'html_id' => 'ee-' . $this->slug() . '-hidden-inputs', |
|
| 497 | + 'subsections' => array( |
|
| 498 | + 'action' => new EE_Fixed_Hidden_Input( |
|
| 499 | + array( |
|
| 500 | + 'html_name' => 'action', |
|
| 501 | + 'html_id' => 'spco-' . $this->slug() . '-action', |
|
| 502 | + 'default' => $default_form_action, |
|
| 503 | + ) |
|
| 504 | + ), |
|
| 505 | + 'next_step' => new EE_Fixed_Hidden_Input( |
|
| 506 | + array( |
|
| 507 | + 'html_name' => 'next_step', |
|
| 508 | + 'html_id' => 'spco-' . $this->slug() . '-next-step', |
|
| 509 | + 'default' => $this->checkout->next_step instanceof EE_SPCO_Reg_Step |
|
| 510 | + ? $this->checkout->next_step->slug() |
|
| 511 | + : '', |
|
| 512 | + ) |
|
| 513 | + ), |
|
| 514 | + 'e_reg_url_link' => new EE_Fixed_Hidden_Input( |
|
| 515 | + array( |
|
| 516 | + 'html_name' => 'e_reg_url_link', |
|
| 517 | + 'html_id' => 'spco-reg_url_link', |
|
| 518 | + 'default' => $this->checkout->reg_url_link, |
|
| 519 | + ) |
|
| 520 | + ), |
|
| 521 | + 'revisit' => new EE_Fixed_Hidden_Input( |
|
| 522 | + array( |
|
| 523 | + 'html_name' => 'revisit', |
|
| 524 | + 'html_id' => 'spco-revisit', |
|
| 525 | + 'default' => $this->checkout->revisit, |
|
| 526 | + ) |
|
| 527 | + ), |
|
| 528 | + ), |
|
| 529 | + ) |
|
| 530 | + ); |
|
| 531 | + } |
|
| 532 | + } |
|
| 533 | + |
|
| 534 | + |
|
| 535 | + |
|
| 536 | + /** |
|
| 537 | + * generate_reg_form_for_actions |
|
| 538 | + * |
|
| 539 | + * @param array $actions |
|
| 540 | + * @return void |
|
| 541 | + */ |
|
| 542 | + public function generate_reg_form_for_actions($actions = array()) |
|
| 543 | + { |
|
| 544 | + $actions = array_merge( |
|
| 545 | + array( |
|
| 546 | + 'generate_reg_form', |
|
| 547 | + 'display_spco_reg_step', |
|
| 548 | + 'process_reg_step', |
|
| 549 | + 'update_reg_step', |
|
| 550 | + ), |
|
| 551 | + $actions |
|
| 552 | + ); |
|
| 553 | + $this->checkout->generate_reg_form = in_array($this->checkout->action, $actions, true) ? true : false; |
|
| 554 | + } |
|
| 555 | + |
|
| 556 | + |
|
| 557 | + |
|
| 558 | + /** |
|
| 559 | + * @return string |
|
| 560 | + * @throws \EE_Error |
|
| 561 | + */ |
|
| 562 | + public function display_reg_form() |
|
| 563 | + { |
|
| 564 | + $html = ''; |
|
| 565 | + if ($this->reg_form instanceof EE_Form_Section_Proper) { |
|
| 566 | + $html .= ! $this->checkout->admin_request ? $this->reg_form->form_open($this->reg_step_url()) : ''; |
|
| 567 | + if (EE_Registry::instance()->REQ->ajax) { |
|
| 568 | + $this->reg_form->localize_validation_rules(); |
|
| 569 | + $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization()); |
|
| 570 | + } |
|
| 571 | + $html .= $this->reg_form->get_html(); |
|
| 572 | + $html .= ! $this->checkout->admin_request ? $this->reg_step_submit_button() : ''; |
|
| 573 | + $html .= ! $this->checkout->admin_request ? $this->reg_form->form_close() : ''; |
|
| 574 | + } |
|
| 575 | + return $html; |
|
| 576 | + } |
|
| 577 | + |
|
| 578 | + |
|
| 579 | + |
|
| 580 | + /** |
|
| 581 | + * div_class - returns nothing for current step, but a css class of "hidden" for others |
|
| 582 | + * |
|
| 583 | + * @return string |
|
| 584 | + * @throws \EE_Error |
|
| 585 | + */ |
|
| 586 | + public function reg_step_submit_button() |
|
| 587 | + { |
|
| 588 | + if (! $this->checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
| 589 | + return ''; |
|
| 590 | + } |
|
| 591 | + ob_start(); |
|
| 592 | + do_action( |
|
| 593 | + 'AHEE__before_spco_whats_next_buttons', |
|
| 594 | + $this->slug(), |
|
| 595 | + $this->checkout->next_step->slug(), |
|
| 596 | + $this->checkout |
|
| 597 | + ); |
|
| 598 | + $html = ob_get_clean(); |
|
| 599 | + // generate submit button |
|
| 600 | + $sbmt_btn = new EE_Submit_Input(array( |
|
| 601 | + 'html_name' => 'spco-go-to-step-' . $this->checkout->next_step->slug(), |
|
| 602 | + 'html_id' => 'spco-go-to-step-' . $this->checkout->next_step->slug(), |
|
| 603 | + 'html_class' => 'spco-next-step-btn', |
|
| 604 | + 'other_html_attributes' => ' rel="' . $this->slug() . '"', |
|
| 605 | + 'default' => $this->submit_button_text(), |
|
| 606 | + )); |
|
| 607 | + $sbmt_btn->set_button_css_attributes(true, 'large'); |
|
| 608 | + $sbmt_btn_html = $sbmt_btn->get_html_for_input(); |
|
| 609 | + $html .= EEH_HTML::div( |
|
| 610 | + apply_filters('FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', $sbmt_btn_html, $this), |
|
| 611 | + 'spco-' . $this->slug() . '-whats-next-buttons-dv', |
|
| 612 | + 'spco-whats-next-buttons' |
|
| 613 | + ); |
|
| 614 | + return $html; |
|
| 615 | + } |
|
| 616 | + |
|
| 617 | + |
|
| 618 | + |
|
| 619 | + /** |
|
| 620 | + * div_class - returns nothing for current step, but a css class of "hidden" for others |
|
| 621 | + * |
|
| 622 | + * @return string |
|
| 623 | + */ |
|
| 624 | + public function div_class() |
|
| 625 | + { |
|
| 626 | + return $this->is_current_step() ? '' : ' hidden'; |
|
| 627 | + } |
|
| 628 | + |
|
| 629 | + |
|
| 630 | + |
|
| 631 | + /** |
|
| 632 | + * div_class - returns a css class of "hidden" for current step, but nothing for others |
|
| 633 | + * |
|
| 634 | + * @return string |
|
| 635 | + */ |
|
| 636 | + public function edit_lnk_url() |
|
| 637 | + { |
|
| 638 | + return add_query_arg(array('step' => $this->slug()), $this->checkout->reg_page_base_url); |
|
| 639 | + } |
|
| 640 | + |
|
| 641 | + |
|
| 642 | + |
|
| 643 | + /** |
|
| 644 | + * div_class - returns a css class of "hidden" for current step, but nothing for others |
|
| 645 | + * |
|
| 646 | + * @return string |
|
| 647 | + */ |
|
| 648 | + public function edit_link_class() |
|
| 649 | + { |
|
| 650 | + return $this->is_current_step() ? ' hidden' : ''; |
|
| 651 | + } |
|
| 652 | + |
|
| 653 | + |
|
| 654 | + |
|
| 655 | + /** |
|
| 656 | + * update_checkout with changes that have been made to the cart |
|
| 657 | + * |
|
| 658 | + * @return void |
|
| 659 | + * @throws \EE_Error |
|
| 660 | + */ |
|
| 661 | + public function update_checkout() |
|
| 662 | + { |
|
| 663 | + // grab the cart grand total and reset TXN total |
|
| 664 | + $this->checkout->transaction->set_total($this->checkout->cart->get_cart_grand_total()); |
|
| 665 | + $this->checkout->stash_transaction_and_checkout(); |
|
| 666 | + } |
|
| 667 | + |
|
| 668 | + |
|
| 669 | + |
|
| 670 | + |
|
| 671 | + |
|
| 672 | + /** |
|
| 673 | + * __sleep |
|
| 674 | + * to conserve db space, let's remove the reg_form and the EE_Checkout object from EE_SPCO_Reg_Step objects upon |
|
| 675 | + * serialization EE_Checkout will handle the reimplementation of itself upon waking, but we won't bother with the |
|
| 676 | + * reg form, because if needed, it will be regenerated anyways |
|
| 677 | + * |
|
| 678 | + * @return array |
|
| 679 | + */ |
|
| 680 | + public function __sleep() |
|
| 681 | + { |
|
| 682 | + // remove the reg form and the checkout |
|
| 683 | + return array_diff(array_keys(get_object_vars($this)), array('reg_form', 'checkout')); |
|
| 684 | + } |
|
| 685 | 685 | |
| 686 | 686 | |
| 687 | 687 | |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 2 | 2 | exit('No direct script access allowed'); |
| 3 | 3 | } |
| 4 | 4 | |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | */ |
| 239 | 239 | public function set_submit_button_text($submit_button_text = '') |
| 240 | 240 | { |
| 241 | - if (! empty($submit_button_text)) { |
|
| 241 | + if ( ! empty($submit_button_text)) { |
|
| 242 | 242 | $this->_submit_button_text = $submit_button_text; |
| 243 | 243 | } else if ($this->checkout->next_step instanceof EE_SPCO_Reg_Step) { |
| 244 | 244 | if ($this->checkout->revisit) { |
@@ -410,7 +410,7 @@ discard block |
||
| 410 | 410 | public function reg_form_name() |
| 411 | 411 | { |
| 412 | 412 | if (empty($this->_reg_form_name)) { |
| 413 | - $this->set_reg_form_name('ee-spco-' . $this->slug() . '-reg-step-form'); |
|
| 413 | + $this->set_reg_form_name('ee-spco-'.$this->slug().'-reg-step-form'); |
|
| 414 | 414 | } |
| 415 | 415 | return $this->_reg_form_name; |
| 416 | 416 | } |
@@ -436,7 +436,7 @@ discard block |
||
| 436 | 436 | public function reg_step_url($action = '') |
| 437 | 437 | { |
| 438 | 438 | $query_args = array('step' => $this->slug()); |
| 439 | - if (! empty($action)) { |
|
| 439 | + if ( ! empty($action)) { |
|
| 440 | 440 | $query_args['action'] = $action; |
| 441 | 441 | } |
| 442 | 442 | // final step has no display |
@@ -467,12 +467,12 @@ discard block |
||
| 467 | 467 | return new EE_Form_Section_Proper( |
| 468 | 468 | array( |
| 469 | 469 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
| 470 | - 'html_id' => 'ee-' . $this->slug() . '-hidden-inputs', |
|
| 470 | + 'html_id' => 'ee-'.$this->slug().'-hidden-inputs', |
|
| 471 | 471 | 'subsections' => array( |
| 472 | 472 | 'next_step' => new EE_Fixed_Hidden_Input( |
| 473 | 473 | array( |
| 474 | 474 | 'html_name' => 'next_step', |
| 475 | - 'html_id' => 'spco-' . $this->slug() . '-next-step', |
|
| 475 | + 'html_id' => 'spco-'.$this->slug().'-next-step', |
|
| 476 | 476 | 'default' => $this->checkout->next_step instanceof EE_SPCO_Reg_Step |
| 477 | 477 | ? $this->checkout->next_step->slug() |
| 478 | 478 | : '', |
@@ -493,19 +493,19 @@ discard block |
||
| 493 | 493 | return new EE_Form_Section_Proper( |
| 494 | 494 | array( |
| 495 | 495 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
| 496 | - 'html_id' => 'ee-' . $this->slug() . '-hidden-inputs', |
|
| 496 | + 'html_id' => 'ee-'.$this->slug().'-hidden-inputs', |
|
| 497 | 497 | 'subsections' => array( |
| 498 | 498 | 'action' => new EE_Fixed_Hidden_Input( |
| 499 | 499 | array( |
| 500 | 500 | 'html_name' => 'action', |
| 501 | - 'html_id' => 'spco-' . $this->slug() . '-action', |
|
| 501 | + 'html_id' => 'spco-'.$this->slug().'-action', |
|
| 502 | 502 | 'default' => $default_form_action, |
| 503 | 503 | ) |
| 504 | 504 | ), |
| 505 | 505 | 'next_step' => new EE_Fixed_Hidden_Input( |
| 506 | 506 | array( |
| 507 | 507 | 'html_name' => 'next_step', |
| 508 | - 'html_id' => 'spco-' . $this->slug() . '-next-step', |
|
| 508 | + 'html_id' => 'spco-'.$this->slug().'-next-step', |
|
| 509 | 509 | 'default' => $this->checkout->next_step instanceof EE_SPCO_Reg_Step |
| 510 | 510 | ? $this->checkout->next_step->slug() |
| 511 | 511 | : '', |
@@ -585,7 +585,7 @@ discard block |
||
| 585 | 585 | */ |
| 586 | 586 | public function reg_step_submit_button() |
| 587 | 587 | { |
| 588 | - if (! $this->checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
| 588 | + if ( ! $this->checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
| 589 | 589 | return ''; |
| 590 | 590 | } |
| 591 | 591 | ob_start(); |
@@ -598,17 +598,17 @@ discard block |
||
| 598 | 598 | $html = ob_get_clean(); |
| 599 | 599 | // generate submit button |
| 600 | 600 | $sbmt_btn = new EE_Submit_Input(array( |
| 601 | - 'html_name' => 'spco-go-to-step-' . $this->checkout->next_step->slug(), |
|
| 602 | - 'html_id' => 'spco-go-to-step-' . $this->checkout->next_step->slug(), |
|
| 601 | + 'html_name' => 'spco-go-to-step-'.$this->checkout->next_step->slug(), |
|
| 602 | + 'html_id' => 'spco-go-to-step-'.$this->checkout->next_step->slug(), |
|
| 603 | 603 | 'html_class' => 'spco-next-step-btn', |
| 604 | - 'other_html_attributes' => ' rel="' . $this->slug() . '"', |
|
| 604 | + 'other_html_attributes' => ' rel="'.$this->slug().'"', |
|
| 605 | 605 | 'default' => $this->submit_button_text(), |
| 606 | 606 | )); |
| 607 | 607 | $sbmt_btn->set_button_css_attributes(true, 'large'); |
| 608 | 608 | $sbmt_btn_html = $sbmt_btn->get_html_for_input(); |
| 609 | 609 | $html .= EEH_HTML::div( |
| 610 | 610 | apply_filters('FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', $sbmt_btn_html, $this), |
| 611 | - 'spco-' . $this->slug() . '-whats-next-buttons-dv', |
|
| 611 | + 'spco-'.$this->slug().'-whats-next-buttons-dv', |
|
| 612 | 612 | 'spco-whats-next-buttons' |
| 613 | 613 | ); |
| 614 | 614 | return $html; |