public function mp_product_order_paid($order) { $cart_info = is_object($order) && is_callable(array($order, 'get_cart')) ? $order->get_cart()->get_items() : (isset($order->mp_cart_info) ? $order->mp_cart_info : array()); $variation_type = MP_Product::get_variations_post_type(); $appointment_ids = array(); if (is_array($cart_info) && count($cart_info)) { foreach ($cart_info as $cart_id => $count) { $variation = get_post($cart_id); if (!empty($variation->post_type) && $variation_type === $variation->post_type && $this->_is_app_mp_page($variation->post_parent)) { $app_id = MP_Product::get_variation_meta($variation->ID, 'name'); if (is_numeric($app_id)) { $appointment_ids[] = $app_id; } } } } $do_send = !empty($this->_core->options["send_confirmation"]) && 'yes' == $this->_core->options["send_confirmation"]; foreach ($appointment_ids as $aid) { if (!$this->_core->change_status('paid', $aid)) { continue; } do_action('app_mp_order_paid', $aid, $order); if ($do_send) { $this->_core->send_confirmation($aid); } } }
/** * Returns properly formatted product price for Event on the front end. */ function show_product_price($price, $event_id) { if (!$this->_is_mp_present()) { return $price; } $event = new Eab_EventModel(get_post($event_id)); $parent_event_id = $event->is_recurring_child(); if (!$parent_event_id) { $linked_product_id = get_post_meta($event_id, 'eab_product_id', true); if (!$linked_product_id) { return $price; } return mp_product_price(false, $linked_product_id, false); } else { // Recurring event child. Figure out parent-linked product ID and appropriate SKU $linked_product_id = get_post_meta($parent_event_id, 'eab_product_id', true); if (!$linked_product_id) { return $price; } $query = new WP_Query(array('post_type' => apply_filters('mp_product_variation_post_type', 'mp_product_variation'), 'posts_per_page' => 1, 'post_parent' => $linked_product_id, 'meta_query' => array(array('key' => 'sku', 'value' => $event_id)), 'fields' => 'ids')); $variation_id = !empty($query->posts[0]) ? $query->posts[0] : false; if (empty($variation_id)) { return $price; } $raw_price = MP_Product::get_variation_meta($variation_id, 'regular_price'); if (!$raw_price) { return $price; } /* $product = new MP_Product($linked_product_id); if ($product->on_sale()) { } // Sales test $is_sale = MP_Product::get_variation_meta($variation_id, 'price'); if ($is_sale) { $sales = maybe_unserialize(get_post_meta($linked_product_id, 'mp_sale_price', true)); if (!empty($sales) && !empty($sales[$price_id])) $raw_price = $sales[$price_id]; } // End sales test */ return apply_filters('mp_product/display_price', '<span class="mp_product_price">' . mp_format_currency('', $raw_price) . '</span>', $raw_price, $linked_product_id); } return $price; // This won't happen, but whatever }