public function get_content_html() { $wootickets = Tribe__Tickets_Plus__Commerce__WooCommerce__Main::get_instance(); $args = array('post_type' => $wootickets->attendee_object, 'meta_key' => $wootickets->atendee_order_key, 'meta_value' => $this->object->id, 'posts_per_page' => -1); $query = new WP_Query($args); $attendees = array(); foreach ($query->posts as $post) { $attendees[] = array('event_id' => get_post_meta($post->ID, $wootickets->atendee_event_key, true), 'ticket_name' => get_post(get_post_meta($post->ID, $wootickets->atendee_product_key, true))->post_title, 'holder_name' => get_post_meta($this->object->id, '_billing_first_name', true) . ' ' . get_post_meta($this->object->id, '_billing_last_name', true), 'order_id' => $this->object->id, 'ticket_id' => $post->ID, 'security_code' => get_post_meta($post->ID, $wootickets->security_code, true)); } return $wootickets->generate_tickets_email_content($attendees); }
/** * Check if WooCommerce is installed and active. * If it is and the version is compatible, load our WooCommerce connector. */ protected function woocommerce() { // Check if the legacy plugin exists if (class_exists('Tribe__Events__Tickets__Woo__Main')) { $args = array('action' => 'deactivate', 'plugin' => $this->get_plugin_file('The Events Calendar: WooCommerce Tickets'), 'plugin_status' => 'all', 'paged' => 1, 's' => ''); $deactivate_url = wp_nonce_url(add_query_arg($args, 'plugins.php'), 'deactivate-plugin_' . $args['plugin']); $this->nag_data['woocommerce'] = array(__('WooCommerce', 'event-tickets-plus'), $deactivate_url, 'legacy-plugin'); return; } if (!class_exists('Woocommerce')) { return; } global $woocommerce; // Here we will check for Comptibility problems if (!version_compare($woocommerce->version, Tribe__Tickets_Plus__Commerce__WooCommerce__Main::REQUIRED_WC_VERSION, '>=')) { $this->nag_data['woocommerce'] = array(__('WooCommerce', 'event-tickets-plus'), add_query_arg(array('tab' => 'plugin-information', 'plugin' => 'woocommerce', 'TB_iframe' => 'true'), admin_url('plugin-install.php')), 'incompatible'); return; } Tribe__Tickets_Plus__Commerce__WooCommerce__Main::get_instance(); }
/** * Get (and instantiate, if necessary) the instance of the class * * @static * @return Tribe__Tickets_Plus__Commerce__WooCommerce__Main */ public static function get_instance() { if (!self::$instance instanceof self) { self::$instance = new self(); } return self::$instance; }
/** * Updates the global stock level and individual product inventories for any ticket products * that utilize global stock. * * @param int $event_id * @param int $stock_level */ public function stock_update_global_tickets($event_id, $stock_level) { $woo_tickets = Tribe__Tickets_Plus__Commerce__WooCommerce__Main::get_instance(); foreach ($woo_tickets->get_tickets($event_id) as $ticket) { /** * @var Tribe__Tickets__Ticket_Object $ticket */ if (Tribe__Tickets__Global_Stock::OWN_STOCK_MODE === $ticket->global_stock_mode()) { continue; } wc_update_product_stock($ticket->ID, $stock_level); } }
public static function get_orders($event_id) { if (!$event_id) { return array(); } if (isset(self::$orders[$event_id])) { return self::$orders[$event_id]; } WC()->api->includes(); WC()->api->register_resources(new WC_API_Server('/')); $main = Tribe__Tickets_Plus__Commerce__WooCommerce__Main::get_instance(); $tickets = $main->get_tickets($event_id); $args = array('post_type' => 'tribe_wooticket', 'posts_per_page' => -1, 'post_status' => array('wc-pending', 'wc-processing', 'wc-on-hold', 'wc-completed', 'publish'), 'meta_query' => array(array('key' => '_tribe_wooticket_event', 'value' => $event_id))); $orders = array(); $query = new WP_Query($args); foreach ($query->posts as &$item) { $order_id = get_post_meta($item->ID, '_tribe_wooticket_order', true); if (isset($orders[$order_id])) { continue; } $order = WC()->api->WC_API_Orders->get_order($order_id); $orders[$order_id] = $order['order']; } self::$orders[$event_id] = $orders; return $orders; }
/** * Returns an instance of the commerce provider. * * This method should be overridden in extending classes. * * @return Tribe__Tickets_Plus__Commerce__WooCommerce__Main */ protected function get_commerce_engine_instance() { return Tribe__Tickets_Plus__Commerce__WooCommerce__Main::get_instance(); }
function wootickets_stop_sending_email() { if (class_exists('Tribe__Tickets_Plus__Commerce__WooCommerce__Main')) { $woo = Tribe__Tickets_Plus__Commerce__WooCommerce__Main::get_instance(); remove_filter('woocommerce_email_classes', array($woo, 'add_email_class_to_woocommerce')); add_action('woocommerce_email_after_order_table', array($woo, 'add_tickets_msg_to_email')); } }
/** * Provides a copy of the global stock integration object. * * @since 4.1 * * @return Tribe__Tickets_Plus__Commerce__WooCommerce__Global_Stock */ public function global_stock() { if (!self::$global_stock) { self::$global_stock = new Tribe__Tickets_Plus__Commerce__WooCommerce__Global_Stock(); } return self::$global_stock; }