*/ class MEC_transaction extends MEC_base { public $transaction_id; public $transaction; public $settings; public $ml_settings; /** * @var MEC_book */ private $book; /** * @var MEC_Main */ private $main; /** * Constructor method * @author Webnus * @param $transaction_id */ public function __construct($transaction_id) { $this->main = $this->getMain(); $this->transaction_id = $transaction_id; $this->settings = $this->main->get_settings(); $this->ml_settings = $this->main->get_ml_settings(); $this->book = $this->getBook(); $this->transaction = $this->book->get_transaction($transaction_id); } public function get_total() { return $this->transaction['total'] ?? NULL; } public function get_discount() { return $this->transaction['discount'] ?? NULL; } public function get_price() { return $this->transaction['price'] ?? 0; } public function get_payable() { return $this->transaction['payable'] ?? 0; } public function get_price_html() { $total = $this->get_total(); $payable = $this->get_payable(); if($total == $payable) return ''.esc_html($this->render_price($payable)).''; else return ''.esc_html($this->render_price($total)).'
'.esc_html($this->render_price($payable)).'
'; } public function render_price($amount) { return $this->main->render_price($amount, $this->get_event_id()); } public function is_free() { return !$this->get_payable(); } public function get_event_id() { return $this->transaction['event_id'] ?? 0; } public function get_array() { return $this->transaction; } /** * @return WP_Post */ public function get_event() { return get_post($this->get_event_id()); } public function get_event_link() { $event = $this->get_event(); return ''.MEC_kses::element($event->post_title).''; } public function get_event_featured_image() { $event = $this->get_event(); return get_the_post_thumbnail($event); } public function get_tickets() { $tickets = ((isset($this->transaction['tickets']) and is_array($this->transaction['tickets'])) ? $this->transaction['tickets'] : array()); // Remove Useless Key if(isset($tickets['attachments'])) unset($tickets['attachments']); return $tickets; } public function get_event_tickets() { $tickets = get_post_meta($this->get_event_id(), 'mec_tickets', true); if(!is_array($tickets)) $tickets = []; return $tickets; } public function get_tickets_html() { $html = ''; return $html; } public function get_dates() { $all_dates = (isset($this->transaction['all_dates']) and is_array($this->transaction['all_dates'])) ? $this->transaction['all_dates'] : []; $date = $this->transaction['date'] ?? NULL; return (count($all_dates) ? $all_dates : array($date)); } public function get_dates_html() { $html = ''; return $html; } public function get_coupon() { return $this->transaction['coupon'] ?? NULL; } public function get_price_details() { return (isset($this->transaction['price_details']) and is_array($this->transaction['price_details'])) ? $this->transaction['price_details'] : []; } public function get_price_details_html() { $price_details = $this->get_price_details(); $html = ''; return $html; } }