*/ 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 (isset($this->transaction['total']) ? $this->transaction['total'] : NULL); } public function get_discount() { return (isset($this->transaction['discount']) ? $this->transaction['discount'] : NULL); } public function get_payable() { return (isset($this->transaction['price']) ? $this->transaction['price'] : 0); } public function get_price_html() { $total = $this->get_total(); $payable = $this->get_payable(); if($total == $payable) return ''.$this->render_price($payable).''; else return ''.$this->render_price($total).'
'.$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() ? false : true); } public function get_event_id() { return (isset($this->transaction['event_id']) ? $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 ''.$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 = array(); 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'] : array()); $date = (isset($this->transaction['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 (isset($this->transaction['coupon']) ? $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'] : array()); } }