static function get_instance()
 {
     if (is_null(self::$_instance)) {
         $klass = get_class();
         self::$_instance = new $klass();
     }
     return self::$_instance;
 }
 function render_order_details($attrs = array(), $inner_content = '')
 {
     $retval = __('Oops! This page usually displays details for image purchases, but you have not ordered any images yet. Please feel free to continue browsing. Thanks for visiting.', 'nextgen-gallery-pro');
     // Get the order to display
     $order_id = FALSE;
     $method = FALSE;
     if (isset($attrs['order'])) {
         $order_id = $attrs['order'];
         $method = 'find_by_hash';
     } elseif (isset($_REQUEST['order'])) {
         $order_id = $_REQUEST['order'];
         $method = 'find_by_hash';
     } elseif (isset($attrs['order_id'])) {
         $order_id = $attrs['order_id'];
         $method = 'find';
     }
     // If we have an order, continue...
     if ($method && ($order = C_Order_Mapper::get_instance()->{$method}($order_id, TRUE))) {
         // If no inner connect has been added, then use our own
         if (!$inner_content) {
             $inner_content = __("Thank you for your order, [customer_name]. You ordered the following items:\n                [items]\n\n                <h3>Order Details</h3>\n                <p>\n                Subtotal: [subtotal_amount]<br/>\n                [if_ordered_shippable_items]Shipping: [shipping_amount]<br/>[/if_ordered_shippable_items]\n                Total: [total_amount]<br/>\n                </p>\n\n                [if_ordered_shippable_items]\n                <p>\n                We will be shipping your items to:<br/>\n                [shipping_street_address]<br/>\n                [shipping_city], [shipping_state] [shipping_zip]<br/>\n                [shipping_country]\n                </p>\n                [/if_ordered_shippable_items]\n\n                [if_ordered_digital_downloads]\n                <h3>Digital Downloads</h3>\n                <p>You may download your digital products <a href='[digital_downloads_page_url]'>here.</a></p>\n                [/if_ordered_digital_downloads]\n            ", 'nextgen-gallery-pro');
         }
         $retval = $inner_content;
         // Add some other values to the order object
         $other_values = array('subtotal' => $order->get_cart()->get_subtotal(), 'subtotal_amount' => $order->get_cart()->get_subtotal(), 'shipping' => $order->get_cart()->get_shipping($order->use_home_country), 'shipping_amount' => $order->get_cart()->get_shipping($order->use_home_country), 'digital_downloads_page_url' => $this->get_digital_downloads_url($order->hash), 'total' => $order->get_cart()->get_total($order->use_home_country), 'total_total' => $order->get_cart()->get_total($order->use_home_country));
         foreach ($other_values as $key => $value) {
             $order->{$key} = $value;
         }
         // Substitute placeholders for each variable of the order
         foreach (get_object_vars($order->get_entity()) as $key => $value) {
             $escape = TRUE;
             switch ($key) {
                 case 'ID':
                     $key = 'order_id';
                     break;
                 case 'post_date':
                     $key = 'order_date';
                     break;
                 case 'post_author':
                 case 'post_title':
                 case 'post_excerpt':
                 case 'post_status':
                 case 'comment_status':
                 case 'ping_status':
                 case 'post_name':
                 case 'to_ping':
                 case 'pinged':
                 case 'post_content_filtered':
                 case 'post_content':
                 case 'menu_order':
                 case 'post_type':
                     continue;
                     break;
                 case 'meta_value':
                     $key = 'order_hash';
                     break;
                 case 'total_amount':
                 case 'shipping':
                 case 'shipping_amount':
                 case 'subtotal':
                 case 'subtotal_amount':
                     $value = self::get_formatted_price($value);
                     $escape = FALSE;
                     break;
             }
             if (!is_array($value)) {
                 $retval = str_replace("[{$key}]", $escape ? esc_html($value) : $value, $retval);
             }
         }
         // Parse [if_ordered_shippable_items]
         $open_tag = preg_quote("[if_ordered_shippable_items]", '#');
         $close_tag = preg_quote("[/if_ordered_shippable_items]", '#');
         $regex = "#{$open_tag}(.*?){$close_tag}#ms";
         if (preg_match_all($regex, $retval, $matches, PREG_SET_ORDER)) {
             foreach ($matches as $match) {
                 $replacement = $order->get_cart()->has_shippable_items() ? $match[1] : '';
                 $retval = str_replace($match[0], $replacement, $retval);
             }
         }
         // Parse [if_ordered_digital_downloads]
         $open_tag = preg_quote("[if_ordered_digital_downloads]", '#');
         $close_tag = preg_quote("[/if_ordered_digital_downloads]", '#');
         $regex = "#{$open_tag}(.*?){$close_tag}#ms";
         $show_downloads = FALSE;
         if ($order->get_cart()->has_digital_downloads() && $order->status == 'verified') {
             $show_downloads = TRUE;
         }
         if (preg_match_all($regex, $retval, $matches, PREG_SET_ORDER)) {
             foreach ($matches as $match) {
                 $replacement = $show_downloads ? $match[1] : '';
                 $retval = str_replace($match[0], $replacement, $retval);
             }
         }
         // Render cart
         if (strpos($retval, '[items]') !== FALSE) {
             $retval = str_replace('[items]', C_NextGen_Pro_Order_Controller::get_instance()->render($order->get_cart()), $retval);
         }
         $retval = apply_filters('ngg_order_details', $retval, $order);
         // Unset any variables on the order we may have set
         foreach ($other_values as $key => $value) {
             unset($order->{$key});
         }
     }
     return $retval;
 }