@@ -49,7 +49,7 @@ |
||
| 49 | 49 | */ |
| 50 | 50 | private function loadCollection() |
| 51 | 51 | { |
| 52 | - if (! $this->loader instanceof CollectionLoader) { |
|
| 52 | + if ( ! $this->loader instanceof CollectionLoader) { |
|
| 53 | 53 | $this->loader = new CollectionLoader( |
| 54 | 54 | new CollectionDetails( |
| 55 | 55 | // collection name |
@@ -20,86 +20,86 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | class ConnectionCollection extends Collection |
| 22 | 22 | { |
| 23 | - const COLLECTION_NAME = 'espresso_graphql_connections'; |
|
| 23 | + const COLLECTION_NAME = 'espresso_graphql_connections'; |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * @var CollectionLoader $loader |
|
| 27 | - */ |
|
| 28 | - protected $loader; |
|
| 25 | + /** |
|
| 26 | + * @var CollectionLoader $loader |
|
| 27 | + */ |
|
| 28 | + protected $loader; |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * ConnectionCollection constructor |
|
| 32 | - * |
|
| 33 | - * @throws InvalidInterfaceException |
|
| 34 | - */ |
|
| 35 | - public function __construct() |
|
| 36 | - { |
|
| 37 | - parent::__construct( |
|
| 38 | - 'EventEspresso\core\services\graphql\connections\ConnectionInterface', |
|
| 39 | - ConnectionCollection::COLLECTION_NAME |
|
| 40 | - ); |
|
| 41 | - } |
|
| 30 | + /** |
|
| 31 | + * ConnectionCollection constructor |
|
| 32 | + * |
|
| 33 | + * @throws InvalidInterfaceException |
|
| 34 | + */ |
|
| 35 | + public function __construct() |
|
| 36 | + { |
|
| 37 | + parent::__construct( |
|
| 38 | + 'EventEspresso\core\services\graphql\connections\ConnectionInterface', |
|
| 39 | + ConnectionCollection::COLLECTION_NAME |
|
| 40 | + ); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * @throws CollectionDetailsException |
|
| 46 | - * @throws CollectionLoaderException |
|
| 47 | - * @since 5.0.0.p |
|
| 48 | - */ |
|
| 49 | - private function loadCollection() |
|
| 50 | - { |
|
| 51 | - if (! $this->loader instanceof CollectionLoader) { |
|
| 52 | - $this->loader = new CollectionLoader( |
|
| 53 | - new CollectionDetails( |
|
| 54 | - // collection name |
|
| 55 | - ConnectionCollection::COLLECTION_NAME, |
|
| 56 | - // collection interface |
|
| 57 | - 'EventEspresso\core\services\graphql\connections\ConnectionInterface', |
|
| 58 | - // FQCNs for classes to add (all classes within each namespace will be loaded) |
|
| 59 | - apply_filters( |
|
| 60 | - 'FHEE__EventEspresso_core_services_graphql_ConnectionCollection__loadCollection__collection_FQCNs', |
|
| 61 | - ['EventEspresso\core\domain\services\graphql\connections'] |
|
| 62 | - ), |
|
| 63 | - // filepaths to classes to add |
|
| 64 | - array(), |
|
| 65 | - // file mask to use if parsing folder for files to add |
|
| 66 | - '', |
|
| 67 | - // what to use as identifier for collection entities |
|
| 68 | - // using CLASS NAME prevents duplicates (works like a singleton) |
|
| 69 | - CollectionDetails::ID_CLASS_NAME |
|
| 70 | - ), |
|
| 71 | - $this |
|
| 72 | - ); |
|
| 73 | - } |
|
| 74 | - } |
|
| 44 | + /** |
|
| 45 | + * @throws CollectionDetailsException |
|
| 46 | + * @throws CollectionLoaderException |
|
| 47 | + * @since 5.0.0.p |
|
| 48 | + */ |
|
| 49 | + private function loadCollection() |
|
| 50 | + { |
|
| 51 | + if (! $this->loader instanceof CollectionLoader) { |
|
| 52 | + $this->loader = new CollectionLoader( |
|
| 53 | + new CollectionDetails( |
|
| 54 | + // collection name |
|
| 55 | + ConnectionCollection::COLLECTION_NAME, |
|
| 56 | + // collection interface |
|
| 57 | + 'EventEspresso\core\services\graphql\connections\ConnectionInterface', |
|
| 58 | + // FQCNs for classes to add (all classes within each namespace will be loaded) |
|
| 59 | + apply_filters( |
|
| 60 | + 'FHEE__EventEspresso_core_services_graphql_ConnectionCollection__loadCollection__collection_FQCNs', |
|
| 61 | + ['EventEspresso\core\domain\services\graphql\connections'] |
|
| 62 | + ), |
|
| 63 | + // filepaths to classes to add |
|
| 64 | + array(), |
|
| 65 | + // file mask to use if parsing folder for files to add |
|
| 66 | + '', |
|
| 67 | + // what to use as identifier for collection entities |
|
| 68 | + // using CLASS NAME prevents duplicates (works like a singleton) |
|
| 69 | + CollectionDetails::ID_CLASS_NAME |
|
| 70 | + ), |
|
| 71 | + $this |
|
| 72 | + ); |
|
| 73 | + } |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | 76 | |
| 77 | - /** |
|
| 78 | - * @return CollectionInterface |
|
| 79 | - * @throws CollectionDetailsException |
|
| 80 | - * @throws CollectionLoaderException |
|
| 81 | - * @since 5.0.0.p |
|
| 82 | - */ |
|
| 83 | - public function loadConnections() |
|
| 84 | - { |
|
| 85 | - $this->loadCollection(); |
|
| 86 | - return $this->loader->getCollection(); |
|
| 87 | - } |
|
| 77 | + /** |
|
| 78 | + * @return CollectionInterface |
|
| 79 | + * @throws CollectionDetailsException |
|
| 80 | + * @throws CollectionLoaderException |
|
| 81 | + * @since 5.0.0.p |
|
| 82 | + */ |
|
| 83 | + public function loadConnections() |
|
| 84 | + { |
|
| 85 | + $this->loadCollection(); |
|
| 86 | + return $this->loader->getCollection(); |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | 89 | |
| 90 | - /** |
|
| 91 | - * getIdentifier |
|
| 92 | - * Overrides EventEspresso\core\services\collections\Collection::getIdentifier() |
|
| 93 | - * If no $identifier is supplied, then the fully qualified class name is used |
|
| 94 | - * |
|
| 95 | - * @param $object |
|
| 96 | - * @param mixed $identifier |
|
| 97 | - * @return bool |
|
| 98 | - */ |
|
| 99 | - public function getIdentifier($object, $identifier = null) |
|
| 100 | - { |
|
| 101 | - return ! empty($identifier) |
|
| 102 | - ? $identifier |
|
| 103 | - : get_class($object); |
|
| 104 | - } |
|
| 90 | + /** |
|
| 91 | + * getIdentifier |
|
| 92 | + * Overrides EventEspresso\core\services\collections\Collection::getIdentifier() |
|
| 93 | + * If no $identifier is supplied, then the fully qualified class name is used |
|
| 94 | + * |
|
| 95 | + * @param $object |
|
| 96 | + * @param mixed $identifier |
|
| 97 | + * @return bool |
|
| 98 | + */ |
|
| 99 | + public function getIdentifier($object, $identifier = null) |
|
| 100 | + { |
|
| 101 | + return ! empty($identifier) |
|
| 102 | + ? $identifier |
|
| 103 | + : get_class($object); |
|
| 104 | + } |
|
| 105 | 105 | } |
@@ -37,7 +37,7 @@ |
||
| 37 | 37 | if (get_option(RewriteRules::OPTION_KEY_FLUSH_REWRITE_RULES, true)) { |
| 38 | 38 | add_action( |
| 39 | 39 | 'shutdown', |
| 40 | - static function () { |
|
| 40 | + static function() { |
|
| 41 | 41 | flush_rewrite_rules(); |
| 42 | 42 | update_option(RewriteRules::OPTION_KEY_FLUSH_REWRITE_RULES, false); |
| 43 | 43 | } |
@@ -12,35 +12,35 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class RewriteRules |
| 14 | 14 | { |
| 15 | - const OPTION_KEY_FLUSH_REWRITE_RULES = 'ee_flush_rewrite_rules'; |
|
| 15 | + const OPTION_KEY_FLUSH_REWRITE_RULES = 'ee_flush_rewrite_rules'; |
|
| 16 | 16 | |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * This will flush rewrite rules on demand. This actually gets called around wp init priority level 100. |
|
| 20 | - * |
|
| 21 | - * @return void |
|
| 22 | - */ |
|
| 23 | - public function flush() |
|
| 24 | - { |
|
| 25 | - update_option(RewriteRules::OPTION_KEY_FLUSH_REWRITE_RULES, true); |
|
| 26 | - } |
|
| 18 | + /** |
|
| 19 | + * This will flush rewrite rules on demand. This actually gets called around wp init priority level 100. |
|
| 20 | + * |
|
| 21 | + * @return void |
|
| 22 | + */ |
|
| 23 | + public function flush() |
|
| 24 | + { |
|
| 25 | + update_option(RewriteRules::OPTION_KEY_FLUSH_REWRITE_RULES, true); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * This will flush rewrite rules on demand. This actually gets called around wp init priority level 100. |
|
| 31 | - * |
|
| 32 | - * @return void |
|
| 33 | - */ |
|
| 34 | - public function flushRewriteRules() |
|
| 35 | - { |
|
| 36 | - if (get_option(RewriteRules::OPTION_KEY_FLUSH_REWRITE_RULES, true)) { |
|
| 37 | - add_action( |
|
| 38 | - 'shutdown', |
|
| 39 | - static function () { |
|
| 40 | - flush_rewrite_rules(); |
|
| 41 | - update_option(RewriteRules::OPTION_KEY_FLUSH_REWRITE_RULES, false); |
|
| 42 | - } |
|
| 43 | - ); |
|
| 44 | - } |
|
| 45 | - } |
|
| 29 | + /** |
|
| 30 | + * This will flush rewrite rules on demand. This actually gets called around wp init priority level 100. |
|
| 31 | + * |
|
| 32 | + * @return void |
|
| 33 | + */ |
|
| 34 | + public function flushRewriteRules() |
|
| 35 | + { |
|
| 36 | + if (get_option(RewriteRules::OPTION_KEY_FLUSH_REWRITE_RULES, true)) { |
|
| 37 | + add_action( |
|
| 38 | + 'shutdown', |
|
| 39 | + static function () { |
|
| 40 | + flush_rewrite_rules(); |
|
| 41 | + update_option(RewriteRules::OPTION_KEY_FLUSH_REWRITE_RULES, false); |
|
| 42 | + } |
|
| 43 | + ); |
|
| 44 | + } |
|
| 45 | + } |
|
| 46 | 46 | } |
@@ -68,7 +68,7 @@ |
||
| 68 | 68 | */ |
| 69 | 69 | public function visit($model_objects_to_identify) |
| 70 | 70 | { |
| 71 | - if (! $this->isDiscovered()) { |
|
| 71 | + if ( ! $this->isDiscovered()) { |
|
| 72 | 72 | $this->discover(); |
| 73 | 73 | } |
| 74 | 74 | if ($this->isComplete()) { |
@@ -31,106 +31,106 @@ |
||
| 31 | 31 | */ |
| 32 | 32 | abstract class BaseNode |
| 33 | 33 | { |
| 34 | - protected ?bool $complete = null; |
|
| 34 | + protected ?bool $complete = null; |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * @var array of model names we don't want to traverse |
|
| 38 | - */ |
|
| 39 | - protected array $dont_traverse_models = []; |
|
| 36 | + /** |
|
| 37 | + * @var array of model names we don't want to traverse |
|
| 38 | + */ |
|
| 39 | + protected array $dont_traverse_models = []; |
|
| 40 | 40 | |
| 41 | 41 | |
| 42 | - public ?bool $sleep_complete = null; |
|
| 43 | - public ?array $sleep_dtm = null; |
|
| 42 | + public ?bool $sleep_complete = null; |
|
| 43 | + public ?array $sleep_dtm = null; |
|
| 44 | 44 | |
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * Whether this item has already been initialized |
|
| 48 | - */ |
|
| 49 | - abstract protected function isDiscovered(); |
|
| 46 | + /** |
|
| 47 | + * Whether this item has already been initialized |
|
| 48 | + */ |
|
| 49 | + abstract protected function isDiscovered(); |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * Determines if the work is done yet or not. Requires you to have first discovered what work exists by calling |
|
| 53 | - * discover(). |
|
| 54 | - * @since 4.10.12.p |
|
| 55 | - * @return boolean |
|
| 56 | - */ |
|
| 57 | - abstract public function isComplete(); |
|
| 51 | + /** |
|
| 52 | + * Determines if the work is done yet or not. Requires you to have first discovered what work exists by calling |
|
| 53 | + * discover(). |
|
| 54 | + * @since 4.10.12.p |
|
| 55 | + * @return boolean |
|
| 56 | + */ |
|
| 57 | + abstract public function isComplete(); |
|
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * Discovers what work needs to be done to complete traversing this node and its children. |
|
| 61 | - * Note that this is separate from the constructor, so we can create child nodes without |
|
| 62 | - * discovering them immediately. |
|
| 63 | - * @since 4.10.12.p |
|
| 64 | - * @return mixed |
|
| 65 | - */ |
|
| 66 | - abstract protected function discover(); |
|
| 59 | + /** |
|
| 60 | + * Discovers what work needs to be done to complete traversing this node and its children. |
|
| 61 | + * Note that this is separate from the constructor, so we can create child nodes without |
|
| 62 | + * discovering them immediately. |
|
| 63 | + * @since 4.10.12.p |
|
| 64 | + * @return mixed |
|
| 65 | + */ |
|
| 66 | + abstract protected function discover(); |
|
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * Identifies model objects, up to the limit $model_objects_to_identify. |
|
| 70 | - * @since 4.10.12.p |
|
| 71 | - * @param int $model_objects_to_identify |
|
| 72 | - * @return int units of work done |
|
| 73 | - */ |
|
| 74 | - abstract protected function work($model_objects_to_identify); |
|
| 68 | + /** |
|
| 69 | + * Identifies model objects, up to the limit $model_objects_to_identify. |
|
| 70 | + * @since 4.10.12.p |
|
| 71 | + * @param int $model_objects_to_identify |
|
| 72 | + * @return int units of work done |
|
| 73 | + */ |
|
| 74 | + abstract protected function work($model_objects_to_identify); |
|
| 75 | 75 | |
| 76 | - /** |
|
| 77 | - * Shows the entity/relation node as an array. |
|
| 78 | - * @since 4.10.12.p |
|
| 79 | - * @return array |
|
| 80 | - */ |
|
| 81 | - abstract public function toArray(); |
|
| 76 | + /** |
|
| 77 | + * Shows the entity/relation node as an array. |
|
| 78 | + * @since 4.10.12.p |
|
| 79 | + * @return array |
|
| 80 | + */ |
|
| 81 | + abstract public function toArray(); |
|
| 82 | 82 | |
| 83 | - /** |
|
| 84 | - * Discovers how much work there is to do, double-checks the work isn't already finished, and then does the work. |
|
| 85 | - * Note: do not call when site is in maintenance mode level 2. |
|
| 86 | - * |
|
| 87 | - * @since 4.10.12.p |
|
| 88 | - * @param $model_objects_to_identify |
|
| 89 | - * @return int number of model objects we want to identify during this call. On subsequent calls we'll continue |
|
| 90 | - * where we left off. |
|
| 91 | - */ |
|
| 92 | - public function visit($model_objects_to_identify) |
|
| 93 | - { |
|
| 94 | - if (! $this->isDiscovered()) { |
|
| 95 | - $this->discover(); |
|
| 96 | - } |
|
| 97 | - if ($this->isComplete()) { |
|
| 98 | - return 0; |
|
| 99 | - } |
|
| 100 | - return $this->work($model_objects_to_identify); |
|
| 101 | - } |
|
| 83 | + /** |
|
| 84 | + * Discovers how much work there is to do, double-checks the work isn't already finished, and then does the work. |
|
| 85 | + * Note: do not call when site is in maintenance mode level 2. |
|
| 86 | + * |
|
| 87 | + * @since 4.10.12.p |
|
| 88 | + * @param $model_objects_to_identify |
|
| 89 | + * @return int number of model objects we want to identify during this call. On subsequent calls we'll continue |
|
| 90 | + * where we left off. |
|
| 91 | + */ |
|
| 92 | + public function visit($model_objects_to_identify) |
|
| 93 | + { |
|
| 94 | + if (! $this->isDiscovered()) { |
|
| 95 | + $this->discover(); |
|
| 96 | + } |
|
| 97 | + if ($this->isComplete()) { |
|
| 98 | + return 0; |
|
| 99 | + } |
|
| 100 | + return $this->work($model_objects_to_identify); |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | - /** |
|
| 104 | - * Gets the IDs of completely identified model objects that can be deleted. |
|
| 105 | - * @since 4.10.12.p |
|
| 106 | - * @return mixed |
|
| 107 | - */ |
|
| 108 | - abstract public function getIds(); |
|
| 103 | + /** |
|
| 104 | + * Gets the IDs of completely identified model objects that can be deleted. |
|
| 105 | + * @since 4.10.12.p |
|
| 106 | + * @return mixed |
|
| 107 | + */ |
|
| 108 | + abstract public function getIds(); |
|
| 109 | 109 | |
| 110 | - /** |
|
| 111 | - * Make sure we encode whether its complete or not, but don't use such a long name. |
|
| 112 | - * @since 4.10.12.p |
|
| 113 | - * @return array |
|
| 114 | - */ |
|
| 115 | - public function __sleep() |
|
| 116 | - { |
|
| 117 | - $this->sleep_complete = $this->complete; |
|
| 118 | - $this->sleep_dtm = $this->dont_traverse_models; |
|
| 119 | - return [ |
|
| 120 | - 'sleep_complete', |
|
| 121 | - 'sleep_dtm' |
|
| 122 | - ]; |
|
| 123 | - } |
|
| 110 | + /** |
|
| 111 | + * Make sure we encode whether its complete or not, but don't use such a long name. |
|
| 112 | + * @since 4.10.12.p |
|
| 113 | + * @return array |
|
| 114 | + */ |
|
| 115 | + public function __sleep() |
|
| 116 | + { |
|
| 117 | + $this->sleep_complete = $this->complete; |
|
| 118 | + $this->sleep_dtm = $this->dont_traverse_models; |
|
| 119 | + return [ |
|
| 120 | + 'sleep_complete', |
|
| 121 | + 'sleep_dtm' |
|
| 122 | + ]; |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | - /** |
|
| 126 | - * Use the dynamic property to set the "complete" property. |
|
| 127 | - * @since 4.10.12.p |
|
| 128 | - */ |
|
| 129 | - public function __wakeup() |
|
| 130 | - { |
|
| 131 | - $this->complete = $this->sleep_complete; |
|
| 132 | - $this->dont_traverse_models = $this->sleep_dtm; |
|
| 133 | - } |
|
| 125 | + /** |
|
| 126 | + * Use the dynamic property to set the "complete" property. |
|
| 127 | + * @since 4.10.12.p |
|
| 128 | + */ |
|
| 129 | + public function __wakeup() |
|
| 130 | + { |
|
| 131 | + $this->complete = $this->sleep_complete; |
|
| 132 | + $this->dont_traverse_models = $this->sleep_dtm; |
|
| 133 | + } |
|
| 134 | 134 | } |
| 135 | 135 | // End of file BaseNode.php |
| 136 | 136 | // Location: EventEspresso\core\services\orm\tree_traversal/BaseNode.php |
@@ -419,7 +419,7 @@ |
||
| 419 | 419 | { |
| 420 | 420 | return ! $this->is_percent() |
| 421 | 421 | ? $this->get_pretty('PRC_amount') |
| 422 | - : $this->get('PRC_amount') . '%'; |
|
| 422 | + : $this->get('PRC_amount').'%'; |
|
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | |
@@ -14,373 +14,373 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class EE_Price extends EE_Soft_Delete_Base_Class |
| 16 | 16 | { |
| 17 | - /** |
|
| 18 | - * @param array $props_n_values incoming values |
|
| 19 | - * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
| 20 | - * used.) |
|
| 21 | - * @param array $date_formats incoming date_formats in an array where the first value is the |
|
| 22 | - * date_format and the second value is the time format |
|
| 23 | - * @return EE_Price |
|
| 24 | - * @throws EE_Error |
|
| 25 | - * @throws ReflectionException |
|
| 26 | - */ |
|
| 27 | - public static function new_instance($props_n_values = [], $timezone = '', $date_formats = []) |
|
| 28 | - { |
|
| 29 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
| 30 | - return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * @param array $props_n_values incoming values from the database |
|
| 36 | - * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
| 37 | - * the website will be used. |
|
| 38 | - * @return EE_Price |
|
| 39 | - * @throws EE_Error |
|
| 40 | - * @throws ReflectionException |
|
| 41 | - */ |
|
| 42 | - public static function new_instance_from_db($props_n_values = [], $timezone = '') |
|
| 43 | - { |
|
| 44 | - return new self($props_n_values, true, $timezone); |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * Set Price type ID |
|
| 50 | - * |
|
| 51 | - * @param int $PRT_ID |
|
| 52 | - * @throws EE_Error |
|
| 53 | - * @throws ReflectionException |
|
| 54 | - */ |
|
| 55 | - public function set_type($PRT_ID = 0) |
|
| 56 | - { |
|
| 57 | - $this->set('PRT_ID', $PRT_ID); |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - |
|
| 61 | - /** |
|
| 62 | - * Set Price Amount |
|
| 63 | - * |
|
| 64 | - * @param float $PRC_amount |
|
| 65 | - * @throws EE_Error |
|
| 66 | - * @throws ReflectionException |
|
| 67 | - */ |
|
| 68 | - public function set_amount($PRC_amount = 0.00) |
|
| 69 | - { |
|
| 70 | - $this->set('PRC_amount', $PRC_amount); |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - |
|
| 74 | - /** |
|
| 75 | - * Set Price Name |
|
| 76 | - * |
|
| 77 | - * @param string $PRC_name |
|
| 78 | - * @throws EE_Error |
|
| 79 | - * @throws ReflectionException |
|
| 80 | - */ |
|
| 81 | - public function set_name($PRC_name = '') |
|
| 82 | - { |
|
| 83 | - $this->set('PRC_name', $PRC_name); |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * Set Price Description |
|
| 89 | - * |
|
| 90 | - * @param string $PRC_desc |
|
| 91 | - * @throws EE_Error |
|
| 92 | - * @throws ReflectionException |
|
| 93 | - */ |
|
| 94 | - public function set_description($PRC_desc = '') |
|
| 95 | - { |
|
| 96 | - $this->Set('PRC_desc', $PRC_desc); |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - |
|
| 100 | - /** |
|
| 101 | - * set is_default |
|
| 102 | - * |
|
| 103 | - * @param bool $PRC_is_default |
|
| 104 | - * @throws EE_Error |
|
| 105 | - * @throws ReflectionException |
|
| 106 | - */ |
|
| 107 | - public function set_is_default($PRC_is_default = false) |
|
| 108 | - { |
|
| 109 | - $this->set('PRC_is_default', $PRC_is_default); |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - |
|
| 113 | - /** |
|
| 114 | - * set deleted |
|
| 115 | - * |
|
| 116 | - * @param bool $PRC_deleted |
|
| 117 | - * @throws EE_Error |
|
| 118 | - * @throws ReflectionException |
|
| 119 | - */ |
|
| 120 | - public function set_deleted($PRC_deleted = null) |
|
| 121 | - { |
|
| 122 | - $this->set('PRC_deleted', $PRC_deleted); |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - |
|
| 126 | - /** |
|
| 127 | - * get Price type |
|
| 128 | - * |
|
| 129 | - * @return int |
|
| 130 | - * @throws EE_Error |
|
| 131 | - * @throws ReflectionException |
|
| 132 | - */ |
|
| 133 | - public function type(): int |
|
| 134 | - { |
|
| 135 | - return (int) $this->get('PRT_ID'); |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - |
|
| 139 | - /** |
|
| 140 | - * get Price Amount |
|
| 141 | - * |
|
| 142 | - * @return float |
|
| 143 | - * @throws EE_Error |
|
| 144 | - * @throws ReflectionException |
|
| 145 | - */ |
|
| 146 | - public function amount(): float |
|
| 147 | - { |
|
| 148 | - return (float) $this->get('PRC_amount'); |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - |
|
| 152 | - /** |
|
| 153 | - * get Price Name |
|
| 154 | - * |
|
| 155 | - * @return string |
|
| 156 | - * @throws EE_Error |
|
| 157 | - * @throws ReflectionException |
|
| 158 | - */ |
|
| 159 | - public function name() |
|
| 160 | - { |
|
| 161 | - return $this->get('PRC_name'); |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - |
|
| 165 | - /** |
|
| 166 | - * get Price description |
|
| 167 | - * |
|
| 168 | - * @return string |
|
| 169 | - * @throws EE_Error |
|
| 170 | - * @throws ReflectionException |
|
| 171 | - */ |
|
| 172 | - public function desc() |
|
| 173 | - { |
|
| 174 | - return $this->get('PRC_desc'); |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - |
|
| 178 | - /** |
|
| 179 | - * get overrides |
|
| 180 | - * |
|
| 181 | - * @return int |
|
| 182 | - * @throws EE_Error |
|
| 183 | - * @throws ReflectionException |
|
| 184 | - */ |
|
| 185 | - public function overrides() |
|
| 186 | - { |
|
| 187 | - return $this->get('PRC_overrides'); |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - |
|
| 191 | - /** |
|
| 192 | - * get order |
|
| 193 | - * |
|
| 194 | - * @return int |
|
| 195 | - * @throws EE_Error |
|
| 196 | - * @throws ReflectionException |
|
| 197 | - */ |
|
| 198 | - public function order() |
|
| 199 | - { |
|
| 200 | - return $this->get('PRC_order'); |
|
| 201 | - } |
|
| 202 | - |
|
| 203 | - |
|
| 204 | - /** |
|
| 205 | - * get the author of the price |
|
| 206 | - * |
|
| 207 | - * @return int |
|
| 208 | - * @throws EE_Error |
|
| 209 | - * @throws ReflectionException |
|
| 210 | - * @since 4.5.0 |
|
| 211 | - */ |
|
| 212 | - public function wp_user() |
|
| 213 | - { |
|
| 214 | - return $this->get('PRC_wp_user'); |
|
| 215 | - } |
|
| 216 | - |
|
| 217 | - |
|
| 218 | - /** |
|
| 219 | - * get is_default |
|
| 220 | - * |
|
| 221 | - * @return bool |
|
| 222 | - * @throws EE_Error |
|
| 223 | - * @throws ReflectionException |
|
| 224 | - */ |
|
| 225 | - public function is_default() |
|
| 226 | - { |
|
| 227 | - return $this->get('PRC_is_default'); |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - |
|
| 231 | - /** |
|
| 232 | - * get deleted |
|
| 233 | - * |
|
| 234 | - * @return bool |
|
| 235 | - * @throws EE_Error |
|
| 236 | - * @throws ReflectionException |
|
| 237 | - */ |
|
| 238 | - public function deleted() |
|
| 239 | - { |
|
| 240 | - return $this->get('PRC_deleted'); |
|
| 241 | - } |
|
| 242 | - |
|
| 243 | - |
|
| 244 | - /** |
|
| 245 | - * @return bool |
|
| 246 | - * @throws EE_Error |
|
| 247 | - * @throws ReflectionException |
|
| 248 | - */ |
|
| 249 | - public function parent() |
|
| 250 | - { |
|
| 251 | - return $this->get('PRC_parent'); |
|
| 252 | - } |
|
| 253 | - |
|
| 254 | - |
|
| 255 | - // some helper methods for getting info on the price_type for this price |
|
| 256 | - |
|
| 257 | - /** |
|
| 258 | - * @return EE_Price_Type|null |
|
| 259 | - * @throws EE_Error |
|
| 260 | - * @throws ReflectionException |
|
| 261 | - */ |
|
| 262 | - public function type_obj(): ?EE_Price_Type |
|
| 263 | - { |
|
| 264 | - return $this->get_first_related('Price_Type'); |
|
| 265 | - } |
|
| 266 | - |
|
| 267 | - |
|
| 268 | - /** |
|
| 269 | - * @return int |
|
| 270 | - * @throws EE_Error |
|
| 271 | - * @throws ReflectionException |
|
| 272 | - */ |
|
| 273 | - public function type_order(): int |
|
| 274 | - { |
|
| 275 | - $price_type = $this->type_obj(); |
|
| 276 | - return $price_type instanceof EE_Price_Type ? $price_type->order() : 0; |
|
| 277 | - } |
|
| 278 | - |
|
| 279 | - |
|
| 280 | - /** |
|
| 281 | - * return whether the price is a base price or not |
|
| 282 | - * |
|
| 283 | - * @return bool |
|
| 284 | - * @throws EE_Error |
|
| 285 | - * @throws InvalidArgumentException |
|
| 286 | - * @throws InvalidDataTypeException |
|
| 287 | - * @throws InvalidInterfaceException |
|
| 288 | - * @throws ReflectionException |
|
| 289 | - */ |
|
| 290 | - public function is_base_price(): bool |
|
| 291 | - { |
|
| 292 | - $price_type = $this->type_obj(); |
|
| 293 | - return $price_type instanceof EE_Price_Type && $price_type->is_base_price(); |
|
| 294 | - } |
|
| 295 | - |
|
| 296 | - |
|
| 297 | - /** |
|
| 298 | - * Simply indicates whether this price increases or decreases the total |
|
| 299 | - * |
|
| 300 | - * @return bool true = discount, otherwise adds to the total |
|
| 301 | - * @throws EE_Error |
|
| 302 | - * @throws ReflectionException |
|
| 303 | - */ |
|
| 304 | - public function is_discount(): bool |
|
| 305 | - { |
|
| 306 | - $price_type = $this->type_obj(); |
|
| 307 | - return $price_type instanceof EE_Price_Type && $price_type->is_discount(); |
|
| 308 | - } |
|
| 309 | - |
|
| 310 | - |
|
| 311 | - /** |
|
| 312 | - * whether the price is a percentage or not |
|
| 313 | - * |
|
| 314 | - * @return bool |
|
| 315 | - * @throws EE_Error |
|
| 316 | - * @throws InvalidArgumentException |
|
| 317 | - * @throws InvalidDataTypeException |
|
| 318 | - * @throws InvalidInterfaceException |
|
| 319 | - * @throws ReflectionException |
|
| 320 | - */ |
|
| 321 | - public function is_percent(): bool |
|
| 322 | - { |
|
| 323 | - $price_type = $this->type_obj(); |
|
| 324 | - return $price_type instanceof EE_Price_Type && $price_type->is_percent(); |
|
| 325 | - } |
|
| 326 | - |
|
| 327 | - |
|
| 328 | - /** |
|
| 329 | - * whether the price is a percentage or not |
|
| 330 | - * |
|
| 331 | - * @return bool |
|
| 332 | - * @throws EE_Error |
|
| 333 | - * @throws ReflectionException |
|
| 334 | - */ |
|
| 335 | - public function is_surcharge(): bool |
|
| 336 | - { |
|
| 337 | - $price_type = $this->type_obj(); |
|
| 338 | - return $price_type instanceof EE_Price_Type && $price_type->is_surcharge(); |
|
| 339 | - } |
|
| 340 | - |
|
| 341 | - |
|
| 342 | - |
|
| 343 | - /** |
|
| 344 | - * whether the price is a percentage or not |
|
| 345 | - * |
|
| 346 | - * @return bool |
|
| 347 | - * @throws EE_Error |
|
| 348 | - * @throws ReflectionException |
|
| 349 | - */ |
|
| 350 | - public function is_tax(): bool |
|
| 351 | - { |
|
| 352 | - $price_type = $this->type_obj(); |
|
| 353 | - return $price_type instanceof EE_Price_Type && $price_type->is_tax(); |
|
| 354 | - } |
|
| 355 | - |
|
| 356 | - |
|
| 357 | - /** |
|
| 358 | - * return pretty price dependant on whether its a dollar or percent. |
|
| 359 | - * |
|
| 360 | - * @return string |
|
| 361 | - * @throws EE_Error |
|
| 362 | - * @throws ReflectionException |
|
| 363 | - * @since 4.4.0 |
|
| 364 | - */ |
|
| 365 | - public function pretty_price(): string |
|
| 366 | - { |
|
| 367 | - return ! $this->is_percent() |
|
| 368 | - ? $this->get_pretty('PRC_amount') |
|
| 369 | - : $this->get('PRC_amount') . '%'; |
|
| 370 | - } |
|
| 371 | - |
|
| 372 | - |
|
| 373 | - /** |
|
| 374 | - * @return mixed |
|
| 375 | - * @throws EE_Error |
|
| 376 | - * @throws ReflectionException |
|
| 377 | - */ |
|
| 378 | - public function get_price_without_currency_symbol() |
|
| 379 | - { |
|
| 380 | - return str_replace( |
|
| 381 | - EE_Registry::instance()->CFG->currency->sign, |
|
| 382 | - '', |
|
| 383 | - $this->get_pretty('PRC_amount') |
|
| 384 | - ); |
|
| 385 | - } |
|
| 17 | + /** |
|
| 18 | + * @param array $props_n_values incoming values |
|
| 19 | + * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
| 20 | + * used.) |
|
| 21 | + * @param array $date_formats incoming date_formats in an array where the first value is the |
|
| 22 | + * date_format and the second value is the time format |
|
| 23 | + * @return EE_Price |
|
| 24 | + * @throws EE_Error |
|
| 25 | + * @throws ReflectionException |
|
| 26 | + */ |
|
| 27 | + public static function new_instance($props_n_values = [], $timezone = '', $date_formats = []) |
|
| 28 | + { |
|
| 29 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
| 30 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * @param array $props_n_values incoming values from the database |
|
| 36 | + * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
| 37 | + * the website will be used. |
|
| 38 | + * @return EE_Price |
|
| 39 | + * @throws EE_Error |
|
| 40 | + * @throws ReflectionException |
|
| 41 | + */ |
|
| 42 | + public static function new_instance_from_db($props_n_values = [], $timezone = '') |
|
| 43 | + { |
|
| 44 | + return new self($props_n_values, true, $timezone); |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * Set Price type ID |
|
| 50 | + * |
|
| 51 | + * @param int $PRT_ID |
|
| 52 | + * @throws EE_Error |
|
| 53 | + * @throws ReflectionException |
|
| 54 | + */ |
|
| 55 | + public function set_type($PRT_ID = 0) |
|
| 56 | + { |
|
| 57 | + $this->set('PRT_ID', $PRT_ID); |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + |
|
| 61 | + /** |
|
| 62 | + * Set Price Amount |
|
| 63 | + * |
|
| 64 | + * @param float $PRC_amount |
|
| 65 | + * @throws EE_Error |
|
| 66 | + * @throws ReflectionException |
|
| 67 | + */ |
|
| 68 | + public function set_amount($PRC_amount = 0.00) |
|
| 69 | + { |
|
| 70 | + $this->set('PRC_amount', $PRC_amount); |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + |
|
| 74 | + /** |
|
| 75 | + * Set Price Name |
|
| 76 | + * |
|
| 77 | + * @param string $PRC_name |
|
| 78 | + * @throws EE_Error |
|
| 79 | + * @throws ReflectionException |
|
| 80 | + */ |
|
| 81 | + public function set_name($PRC_name = '') |
|
| 82 | + { |
|
| 83 | + $this->set('PRC_name', $PRC_name); |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * Set Price Description |
|
| 89 | + * |
|
| 90 | + * @param string $PRC_desc |
|
| 91 | + * @throws EE_Error |
|
| 92 | + * @throws ReflectionException |
|
| 93 | + */ |
|
| 94 | + public function set_description($PRC_desc = '') |
|
| 95 | + { |
|
| 96 | + $this->Set('PRC_desc', $PRC_desc); |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + |
|
| 100 | + /** |
|
| 101 | + * set is_default |
|
| 102 | + * |
|
| 103 | + * @param bool $PRC_is_default |
|
| 104 | + * @throws EE_Error |
|
| 105 | + * @throws ReflectionException |
|
| 106 | + */ |
|
| 107 | + public function set_is_default($PRC_is_default = false) |
|
| 108 | + { |
|
| 109 | + $this->set('PRC_is_default', $PRC_is_default); |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + |
|
| 113 | + /** |
|
| 114 | + * set deleted |
|
| 115 | + * |
|
| 116 | + * @param bool $PRC_deleted |
|
| 117 | + * @throws EE_Error |
|
| 118 | + * @throws ReflectionException |
|
| 119 | + */ |
|
| 120 | + public function set_deleted($PRC_deleted = null) |
|
| 121 | + { |
|
| 122 | + $this->set('PRC_deleted', $PRC_deleted); |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + |
|
| 126 | + /** |
|
| 127 | + * get Price type |
|
| 128 | + * |
|
| 129 | + * @return int |
|
| 130 | + * @throws EE_Error |
|
| 131 | + * @throws ReflectionException |
|
| 132 | + */ |
|
| 133 | + public function type(): int |
|
| 134 | + { |
|
| 135 | + return (int) $this->get('PRT_ID'); |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + |
|
| 139 | + /** |
|
| 140 | + * get Price Amount |
|
| 141 | + * |
|
| 142 | + * @return float |
|
| 143 | + * @throws EE_Error |
|
| 144 | + * @throws ReflectionException |
|
| 145 | + */ |
|
| 146 | + public function amount(): float |
|
| 147 | + { |
|
| 148 | + return (float) $this->get('PRC_amount'); |
|
| 149 | + } |
|
| 150 | + |
|
| 151 | + |
|
| 152 | + /** |
|
| 153 | + * get Price Name |
|
| 154 | + * |
|
| 155 | + * @return string |
|
| 156 | + * @throws EE_Error |
|
| 157 | + * @throws ReflectionException |
|
| 158 | + */ |
|
| 159 | + public function name() |
|
| 160 | + { |
|
| 161 | + return $this->get('PRC_name'); |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + |
|
| 165 | + /** |
|
| 166 | + * get Price description |
|
| 167 | + * |
|
| 168 | + * @return string |
|
| 169 | + * @throws EE_Error |
|
| 170 | + * @throws ReflectionException |
|
| 171 | + */ |
|
| 172 | + public function desc() |
|
| 173 | + { |
|
| 174 | + return $this->get('PRC_desc'); |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + |
|
| 178 | + /** |
|
| 179 | + * get overrides |
|
| 180 | + * |
|
| 181 | + * @return int |
|
| 182 | + * @throws EE_Error |
|
| 183 | + * @throws ReflectionException |
|
| 184 | + */ |
|
| 185 | + public function overrides() |
|
| 186 | + { |
|
| 187 | + return $this->get('PRC_overrides'); |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + |
|
| 191 | + /** |
|
| 192 | + * get order |
|
| 193 | + * |
|
| 194 | + * @return int |
|
| 195 | + * @throws EE_Error |
|
| 196 | + * @throws ReflectionException |
|
| 197 | + */ |
|
| 198 | + public function order() |
|
| 199 | + { |
|
| 200 | + return $this->get('PRC_order'); |
|
| 201 | + } |
|
| 202 | + |
|
| 203 | + |
|
| 204 | + /** |
|
| 205 | + * get the author of the price |
|
| 206 | + * |
|
| 207 | + * @return int |
|
| 208 | + * @throws EE_Error |
|
| 209 | + * @throws ReflectionException |
|
| 210 | + * @since 4.5.0 |
|
| 211 | + */ |
|
| 212 | + public function wp_user() |
|
| 213 | + { |
|
| 214 | + return $this->get('PRC_wp_user'); |
|
| 215 | + } |
|
| 216 | + |
|
| 217 | + |
|
| 218 | + /** |
|
| 219 | + * get is_default |
|
| 220 | + * |
|
| 221 | + * @return bool |
|
| 222 | + * @throws EE_Error |
|
| 223 | + * @throws ReflectionException |
|
| 224 | + */ |
|
| 225 | + public function is_default() |
|
| 226 | + { |
|
| 227 | + return $this->get('PRC_is_default'); |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + |
|
| 231 | + /** |
|
| 232 | + * get deleted |
|
| 233 | + * |
|
| 234 | + * @return bool |
|
| 235 | + * @throws EE_Error |
|
| 236 | + * @throws ReflectionException |
|
| 237 | + */ |
|
| 238 | + public function deleted() |
|
| 239 | + { |
|
| 240 | + return $this->get('PRC_deleted'); |
|
| 241 | + } |
|
| 242 | + |
|
| 243 | + |
|
| 244 | + /** |
|
| 245 | + * @return bool |
|
| 246 | + * @throws EE_Error |
|
| 247 | + * @throws ReflectionException |
|
| 248 | + */ |
|
| 249 | + public function parent() |
|
| 250 | + { |
|
| 251 | + return $this->get('PRC_parent'); |
|
| 252 | + } |
|
| 253 | + |
|
| 254 | + |
|
| 255 | + // some helper methods for getting info on the price_type for this price |
|
| 256 | + |
|
| 257 | + /** |
|
| 258 | + * @return EE_Price_Type|null |
|
| 259 | + * @throws EE_Error |
|
| 260 | + * @throws ReflectionException |
|
| 261 | + */ |
|
| 262 | + public function type_obj(): ?EE_Price_Type |
|
| 263 | + { |
|
| 264 | + return $this->get_first_related('Price_Type'); |
|
| 265 | + } |
|
| 266 | + |
|
| 267 | + |
|
| 268 | + /** |
|
| 269 | + * @return int |
|
| 270 | + * @throws EE_Error |
|
| 271 | + * @throws ReflectionException |
|
| 272 | + */ |
|
| 273 | + public function type_order(): int |
|
| 274 | + { |
|
| 275 | + $price_type = $this->type_obj(); |
|
| 276 | + return $price_type instanceof EE_Price_Type ? $price_type->order() : 0; |
|
| 277 | + } |
|
| 278 | + |
|
| 279 | + |
|
| 280 | + /** |
|
| 281 | + * return whether the price is a base price or not |
|
| 282 | + * |
|
| 283 | + * @return bool |
|
| 284 | + * @throws EE_Error |
|
| 285 | + * @throws InvalidArgumentException |
|
| 286 | + * @throws InvalidDataTypeException |
|
| 287 | + * @throws InvalidInterfaceException |
|
| 288 | + * @throws ReflectionException |
|
| 289 | + */ |
|
| 290 | + public function is_base_price(): bool |
|
| 291 | + { |
|
| 292 | + $price_type = $this->type_obj(); |
|
| 293 | + return $price_type instanceof EE_Price_Type && $price_type->is_base_price(); |
|
| 294 | + } |
|
| 295 | + |
|
| 296 | + |
|
| 297 | + /** |
|
| 298 | + * Simply indicates whether this price increases or decreases the total |
|
| 299 | + * |
|
| 300 | + * @return bool true = discount, otherwise adds to the total |
|
| 301 | + * @throws EE_Error |
|
| 302 | + * @throws ReflectionException |
|
| 303 | + */ |
|
| 304 | + public function is_discount(): bool |
|
| 305 | + { |
|
| 306 | + $price_type = $this->type_obj(); |
|
| 307 | + return $price_type instanceof EE_Price_Type && $price_type->is_discount(); |
|
| 308 | + } |
|
| 309 | + |
|
| 310 | + |
|
| 311 | + /** |
|
| 312 | + * whether the price is a percentage or not |
|
| 313 | + * |
|
| 314 | + * @return bool |
|
| 315 | + * @throws EE_Error |
|
| 316 | + * @throws InvalidArgumentException |
|
| 317 | + * @throws InvalidDataTypeException |
|
| 318 | + * @throws InvalidInterfaceException |
|
| 319 | + * @throws ReflectionException |
|
| 320 | + */ |
|
| 321 | + public function is_percent(): bool |
|
| 322 | + { |
|
| 323 | + $price_type = $this->type_obj(); |
|
| 324 | + return $price_type instanceof EE_Price_Type && $price_type->is_percent(); |
|
| 325 | + } |
|
| 326 | + |
|
| 327 | + |
|
| 328 | + /** |
|
| 329 | + * whether the price is a percentage or not |
|
| 330 | + * |
|
| 331 | + * @return bool |
|
| 332 | + * @throws EE_Error |
|
| 333 | + * @throws ReflectionException |
|
| 334 | + */ |
|
| 335 | + public function is_surcharge(): bool |
|
| 336 | + { |
|
| 337 | + $price_type = $this->type_obj(); |
|
| 338 | + return $price_type instanceof EE_Price_Type && $price_type->is_surcharge(); |
|
| 339 | + } |
|
| 340 | + |
|
| 341 | + |
|
| 342 | + |
|
| 343 | + /** |
|
| 344 | + * whether the price is a percentage or not |
|
| 345 | + * |
|
| 346 | + * @return bool |
|
| 347 | + * @throws EE_Error |
|
| 348 | + * @throws ReflectionException |
|
| 349 | + */ |
|
| 350 | + public function is_tax(): bool |
|
| 351 | + { |
|
| 352 | + $price_type = $this->type_obj(); |
|
| 353 | + return $price_type instanceof EE_Price_Type && $price_type->is_tax(); |
|
| 354 | + } |
|
| 355 | + |
|
| 356 | + |
|
| 357 | + /** |
|
| 358 | + * return pretty price dependant on whether its a dollar or percent. |
|
| 359 | + * |
|
| 360 | + * @return string |
|
| 361 | + * @throws EE_Error |
|
| 362 | + * @throws ReflectionException |
|
| 363 | + * @since 4.4.0 |
|
| 364 | + */ |
|
| 365 | + public function pretty_price(): string |
|
| 366 | + { |
|
| 367 | + return ! $this->is_percent() |
|
| 368 | + ? $this->get_pretty('PRC_amount') |
|
| 369 | + : $this->get('PRC_amount') . '%'; |
|
| 370 | + } |
|
| 371 | + |
|
| 372 | + |
|
| 373 | + /** |
|
| 374 | + * @return mixed |
|
| 375 | + * @throws EE_Error |
|
| 376 | + * @throws ReflectionException |
|
| 377 | + */ |
|
| 378 | + public function get_price_without_currency_symbol() |
|
| 379 | + { |
|
| 380 | + return str_replace( |
|
| 381 | + EE_Registry::instance()->CFG->currency->sign, |
|
| 382 | + '', |
|
| 383 | + $this->get_pretty('PRC_amount') |
|
| 384 | + ); |
|
| 385 | + } |
|
| 386 | 386 | } |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | public function __construct() |
| 22 | 22 | { |
| 23 | - $this->setName($this->namespace . 'DatetimesConnectionOrderbyEnum'); |
|
| 23 | + $this->setName($this->namespace.'DatetimesConnectionOrderbyEnum'); |
|
| 24 | 24 | $this->setDescription(esc_html__('Field to order the connection by', 'event_espresso')); |
| 25 | 25 | parent::__construct(); |
| 26 | 26 | } |
@@ -14,31 +14,31 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class DatetimesConnectionOrderbyEnum extends EnumBase |
| 16 | 16 | { |
| 17 | - /** |
|
| 18 | - * DatetimesConnectionOrderbyEnum constructor. |
|
| 19 | - */ |
|
| 20 | - public function __construct() |
|
| 21 | - { |
|
| 22 | - $this->setName($this->namespace . 'DatetimesConnectionOrderbyEnum'); |
|
| 23 | - $this->setDescription(esc_html__('Field to order the connection by', 'event_espresso')); |
|
| 24 | - parent::__construct(); |
|
| 25 | - } |
|
| 17 | + /** |
|
| 18 | + * DatetimesConnectionOrderbyEnum constructor. |
|
| 19 | + */ |
|
| 20 | + public function __construct() |
|
| 21 | + { |
|
| 22 | + $this->setName($this->namespace . 'DatetimesConnectionOrderbyEnum'); |
|
| 23 | + $this->setDescription(esc_html__('Field to order the connection by', 'event_espresso')); |
|
| 24 | + parent::__construct(); |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * @return array |
|
| 30 | - */ |
|
| 31 | - protected function getValues(): array |
|
| 32 | - { |
|
| 33 | - return [ |
|
| 34 | - 'NAME' => [ |
|
| 35 | - 'value' => 'DTT_name', |
|
| 36 | - 'description' => esc_html__('Order by name', 'event_espresso'), |
|
| 37 | - ], |
|
| 38 | - 'START_DATE' => [ |
|
| 39 | - 'value' => 'DTT_EVT_start', |
|
| 40 | - 'description' => esc_html__('Order by start date', 'event_espresso'), |
|
| 41 | - ], |
|
| 42 | - ]; |
|
| 43 | - } |
|
| 28 | + /** |
|
| 29 | + * @return array |
|
| 30 | + */ |
|
| 31 | + protected function getValues(): array |
|
| 32 | + { |
|
| 33 | + return [ |
|
| 34 | + 'NAME' => [ |
|
| 35 | + 'value' => 'DTT_name', |
|
| 36 | + 'description' => esc_html__('Order by name', 'event_espresso'), |
|
| 37 | + ], |
|
| 38 | + 'START_DATE' => [ |
|
| 39 | + 'value' => 'DTT_EVT_start', |
|
| 40 | + 'description' => esc_html__('Order by start date', 'event_espresso'), |
|
| 41 | + ], |
|
| 42 | + ]; |
|
| 43 | + } |
|
| 44 | 44 | } |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | public function __construct() |
| 22 | 22 | { |
| 23 | - $this->setName($this->namespace . 'TicketsConnectionOrderbyEnum'); |
|
| 23 | + $this->setName($this->namespace.'TicketsConnectionOrderbyEnum'); |
|
| 24 | 24 | $this->setDescription(esc_html__('Field to order the connection by', 'event_espresso')); |
| 25 | 25 | parent::__construct(); |
| 26 | 26 | } |
@@ -14,31 +14,31 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class TicketsConnectionOrderbyEnum extends EnumBase |
| 16 | 16 | { |
| 17 | - /** |
|
| 18 | - * TicketsConnectionOrderbyEnum constructor. |
|
| 19 | - */ |
|
| 20 | - public function __construct() |
|
| 21 | - { |
|
| 22 | - $this->setName($this->namespace . 'TicketsConnectionOrderbyEnum'); |
|
| 23 | - $this->setDescription(esc_html__('Field to order the connection by', 'event_espresso')); |
|
| 24 | - parent::__construct(); |
|
| 25 | - } |
|
| 17 | + /** |
|
| 18 | + * TicketsConnectionOrderbyEnum constructor. |
|
| 19 | + */ |
|
| 20 | + public function __construct() |
|
| 21 | + { |
|
| 22 | + $this->setName($this->namespace . 'TicketsConnectionOrderbyEnum'); |
|
| 23 | + $this->setDescription(esc_html__('Field to order the connection by', 'event_espresso')); |
|
| 24 | + parent::__construct(); |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * @return array |
|
| 30 | - */ |
|
| 31 | - protected function getValues(): array |
|
| 32 | - { |
|
| 33 | - return [ |
|
| 34 | - 'NAME' => [ |
|
| 35 | - 'value' => 'TKT_name', |
|
| 36 | - 'description' => esc_html__('Order by name', 'event_espresso'), |
|
| 37 | - ], |
|
| 38 | - 'START_DATE' => [ |
|
| 39 | - 'value' => 'TKT_start_date', |
|
| 40 | - 'description' => esc_html__('Order by start date', 'event_espresso'), |
|
| 41 | - ], |
|
| 42 | - ]; |
|
| 43 | - } |
|
| 28 | + /** |
|
| 29 | + * @return array |
|
| 30 | + */ |
|
| 31 | + protected function getValues(): array |
|
| 32 | + { |
|
| 33 | + return [ |
|
| 34 | + 'NAME' => [ |
|
| 35 | + 'value' => 'TKT_name', |
|
| 36 | + 'description' => esc_html__('Order by name', 'event_espresso'), |
|
| 37 | + ], |
|
| 38 | + 'START_DATE' => [ |
|
| 39 | + 'value' => 'TKT_start_date', |
|
| 40 | + 'description' => esc_html__('Order by start date', 'event_espresso'), |
|
| 41 | + ], |
|
| 42 | + ]; |
|
| 43 | + } |
|
| 44 | 44 | } |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | public function __construct() |
| 23 | 23 | { |
| 24 | - $this->setName($this->namespace . 'PriceBaseTypeEnum'); |
|
| 24 | + $this->setName($this->namespace.'PriceBaseTypeEnum'); |
|
| 25 | 25 | $this->setDescription(esc_html__('Price Base type ID', 'event_espresso')); |
| 26 | 26 | parent::__construct(); |
| 27 | 27 | } |
@@ -15,35 +15,35 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | class PriceBaseTypeEnum extends EnumBase |
| 17 | 17 | { |
| 18 | - /** |
|
| 19 | - * PriceBaseTypeEnum constructor. |
|
| 20 | - */ |
|
| 21 | - public function __construct() |
|
| 22 | - { |
|
| 23 | - $this->setName($this->namespace . 'PriceBaseTypeEnum'); |
|
| 24 | - $this->setDescription(esc_html__('Price Base type ID', 'event_espresso')); |
|
| 25 | - parent::__construct(); |
|
| 26 | - } |
|
| 18 | + /** |
|
| 19 | + * PriceBaseTypeEnum constructor. |
|
| 20 | + */ |
|
| 21 | + public function __construct() |
|
| 22 | + { |
|
| 23 | + $this->setName($this->namespace . 'PriceBaseTypeEnum'); |
|
| 24 | + $this->setDescription(esc_html__('Price Base type ID', 'event_espresso')); |
|
| 25 | + parent::__construct(); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * @return array |
|
| 31 | - */ |
|
| 32 | - protected function getValues(): array |
|
| 33 | - { |
|
| 34 | - return [ |
|
| 35 | - 'BASE_PRICE' => [ |
|
| 36 | - 'value' => EEM_Price_Type::base_type_base_price, |
|
| 37 | - ], |
|
| 38 | - 'DISCOUNT' => [ |
|
| 39 | - 'value' => EEM_Price_Type::base_type_discount, |
|
| 40 | - ], |
|
| 41 | - 'SURCHARGE' => [ |
|
| 42 | - 'value' => EEM_Price_Type::base_type_surcharge, |
|
| 43 | - ], |
|
| 44 | - 'TAX' => [ |
|
| 45 | - 'value' => EEM_Price_Type::base_type_tax, |
|
| 46 | - ], |
|
| 47 | - ]; |
|
| 48 | - } |
|
| 29 | + /** |
|
| 30 | + * @return array |
|
| 31 | + */ |
|
| 32 | + protected function getValues(): array |
|
| 33 | + { |
|
| 34 | + return [ |
|
| 35 | + 'BASE_PRICE' => [ |
|
| 36 | + 'value' => EEM_Price_Type::base_type_base_price, |
|
| 37 | + ], |
|
| 38 | + 'DISCOUNT' => [ |
|
| 39 | + 'value' => EEM_Price_Type::base_type_discount, |
|
| 40 | + ], |
|
| 41 | + 'SURCHARGE' => [ |
|
| 42 | + 'value' => EEM_Price_Type::base_type_surcharge, |
|
| 43 | + ], |
|
| 44 | + 'TAX' => [ |
|
| 45 | + 'value' => EEM_Price_Type::base_type_tax, |
|
| 46 | + ], |
|
| 47 | + ]; |
|
| 48 | + } |
|
| 49 | 49 | } |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | public function __construct() |
| 26 | 26 | { |
| 27 | - $this->setName($this->namespace . 'DatetimesConnectionOrderbyInput'); |
|
| 27 | + $this->setName($this->namespace.'DatetimesConnectionOrderbyInput'); |
|
| 28 | 28 | $this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso')); |
| 29 | 29 | parent::__construct(); |
| 30 | 30 | } |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | return [ |
| 40 | 40 | new GraphQLField( |
| 41 | 41 | 'field', |
| 42 | - ['non_null' => $this->namespace . 'DatetimesConnectionOrderbyEnum'] |
|
| 42 | + ['non_null' => $this->namespace.'DatetimesConnectionOrderbyEnum'] |
|
| 43 | 43 | ), |
| 44 | 44 | new GraphQLField( |
| 45 | 45 | 'order', |
@@ -16,31 +16,31 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class DatetimesConnectionOrderbyInput extends InputBase |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * DatetimesConnectionOrderbyInput constructor. |
|
| 21 | - */ |
|
| 22 | - public function __construct() |
|
| 23 | - { |
|
| 24 | - $this->setName($this->namespace . 'DatetimesConnectionOrderbyInput'); |
|
| 25 | - $this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso')); |
|
| 26 | - parent::__construct(); |
|
| 27 | - } |
|
| 19 | + /** |
|
| 20 | + * DatetimesConnectionOrderbyInput constructor. |
|
| 21 | + */ |
|
| 22 | + public function __construct() |
|
| 23 | + { |
|
| 24 | + $this->setName($this->namespace . 'DatetimesConnectionOrderbyInput'); |
|
| 25 | + $this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso')); |
|
| 26 | + parent::__construct(); |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * @return GraphQLFieldInterface[] |
|
| 32 | - */ |
|
| 33 | - protected function getFields(): array |
|
| 34 | - { |
|
| 35 | - return [ |
|
| 36 | - new GraphQLField( |
|
| 37 | - 'field', |
|
| 38 | - ['non_null' => $this->namespace . 'DatetimesConnectionOrderbyEnum'] |
|
| 39 | - ), |
|
| 40 | - new GraphQLField( |
|
| 41 | - 'order', |
|
| 42 | - 'OrderEnum' |
|
| 43 | - ), |
|
| 44 | - ]; |
|
| 45 | - } |
|
| 30 | + /** |
|
| 31 | + * @return GraphQLFieldInterface[] |
|
| 32 | + */ |
|
| 33 | + protected function getFields(): array |
|
| 34 | + { |
|
| 35 | + return [ |
|
| 36 | + new GraphQLField( |
|
| 37 | + 'field', |
|
| 38 | + ['non_null' => $this->namespace . 'DatetimesConnectionOrderbyEnum'] |
|
| 39 | + ), |
|
| 40 | + new GraphQLField( |
|
| 41 | + 'order', |
|
| 42 | + 'OrderEnum' |
|
| 43 | + ), |
|
| 44 | + ]; |
|
| 45 | + } |
|
| 46 | 46 | } |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | public function __construct() |
| 26 | 26 | { |
| 27 | - $this->setName($this->namespace . 'TicketsConnectionOrderbyInput'); |
|
| 27 | + $this->setName($this->namespace.'TicketsConnectionOrderbyInput'); |
|
| 28 | 28 | $this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso')); |
| 29 | 29 | parent::__construct(); |
| 30 | 30 | } |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | return [ |
| 40 | 40 | new GraphQLField( |
| 41 | 41 | 'field', |
| 42 | - ['non_null' => $this->namespace . 'TicketsConnectionOrderbyEnum'] |
|
| 42 | + ['non_null' => $this->namespace.'TicketsConnectionOrderbyEnum'] |
|
| 43 | 43 | ), |
| 44 | 44 | new GraphQLField( |
| 45 | 45 | 'order', |
@@ -16,31 +16,31 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class TicketsConnectionOrderbyInput extends InputBase |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * TicketsConnectionOrderbyInput constructor. |
|
| 21 | - */ |
|
| 22 | - public function __construct() |
|
| 23 | - { |
|
| 24 | - $this->setName($this->namespace . 'TicketsConnectionOrderbyInput'); |
|
| 25 | - $this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso')); |
|
| 26 | - parent::__construct(); |
|
| 27 | - } |
|
| 19 | + /** |
|
| 20 | + * TicketsConnectionOrderbyInput constructor. |
|
| 21 | + */ |
|
| 22 | + public function __construct() |
|
| 23 | + { |
|
| 24 | + $this->setName($this->namespace . 'TicketsConnectionOrderbyInput'); |
|
| 25 | + $this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso')); |
|
| 26 | + parent::__construct(); |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * @return GraphQLFieldInterface[] |
|
| 32 | - */ |
|
| 33 | - protected function getFields(): array |
|
| 34 | - { |
|
| 35 | - return [ |
|
| 36 | - new GraphQLField( |
|
| 37 | - 'field', |
|
| 38 | - ['non_null' => $this->namespace . 'TicketsConnectionOrderbyEnum'] |
|
| 39 | - ), |
|
| 40 | - new GraphQLField( |
|
| 41 | - 'order', |
|
| 42 | - 'OrderEnum' |
|
| 43 | - ), |
|
| 44 | - ]; |
|
| 45 | - } |
|
| 30 | + /** |
|
| 31 | + * @return GraphQLFieldInterface[] |
|
| 32 | + */ |
|
| 33 | + protected function getFields(): array |
|
| 34 | + { |
|
| 35 | + return [ |
|
| 36 | + new GraphQLField( |
|
| 37 | + 'field', |
|
| 38 | + ['non_null' => $this->namespace . 'TicketsConnectionOrderbyEnum'] |
|
| 39 | + ), |
|
| 40 | + new GraphQLField( |
|
| 41 | + 'order', |
|
| 42 | + 'OrderEnum' |
|
| 43 | + ), |
|
| 44 | + ]; |
|
| 45 | + } |
|
| 46 | 46 | } |