/** * Echos the current store navigation links. * * @param bool $echo Optional, whether to echo. Defaults to true */ function mp_store_navigation($echo = true) { global $mp; //navigation if (!$mp->get_setting('disable_cart')) { $nav = '<ul class="mp_store_navigation"><li class="page_item"><a href="' . mp_products_link(false, true) . '" title="' . __('Products', 'mp') . '">' . __('Products', 'mp') . '</a></li>'; $nav .= '<li class="page_item"><a href="' . mp_cart_link(false, true) . '" title="' . __('Shopping Cart', 'mp') . '">' . __('Shopping Cart', 'mp') . '</a></li>'; $nav .= '<li class="page_item"><a href="' . mp_orderstatus_link(false, true) . '" title="' . __('Order Status', 'mp') . '">' . __('Order Status', 'mp') . '</a></li> </ul>'; } else { $nav = '<ul class="mp_store_navigation"> <li class="page_item"><a href="' . mp_products_link(false, true) . '" title="' . __('Products', 'mp') . '">' . __('Products', 'mp') . '</a></li> </ul>'; } $nav = apply_filters('mp_store_navigation', $nav); if ($echo) { echo $nav; } else { return $nav; } }
/** * Returns the current order status link. * @param bool url Optional, whether to return a link or url. Defaults to show link. * @param string link_text Optional, text to show in link. */ function mp_orderstatus_link_sc($atts) { extract(shortcode_atts(array('url' => false, 'link_text' => ''), $atts)); return mp_orderstatus_link(false, $url, $link_text); }
public static function cp_mp_order_notification_body($content, $order) { if ('3.0' === self::get_base() && !is_object($order) && !empty($order)) { $order = new MP_Order($order); } if (cp_get_order_course_id($order->ID)) { $course_id = cp_get_order_course_id($order->ID); $course = new Course($course_id); $tags = array('CUSTOMER_NAME', 'BLOG_NAME', 'LOGIN_ADDRESS', 'WEBSITE_ADDRESS', 'COURSE_ADDRESS', 'COURSE_TITLE', 'ORDER_ID', 'ORDER_STATUS_URL'); $course_title = ''; $course_address = ''; $order_name = ''; $tracking_url = ''; switch (self::get_base()) { case '3.0': $cart = $order->get_cart(); $items = $cart->get_items(); $order_post = get_post($order->ID); $course_title = ''; $course_address = ''; $order_name = $order->get_meta('mp_billing_info->first_name') . ' ' . $order->get_meta('mp_billing_info->last_name'); $counter = 0; foreach ($items as $product_id => $qty) { $counter += 1; $course_id = (int) get_post_meta($product_id, 'course_id', true); $course_title .= get_post_field('post_title', $course_id); $course_address .= get_permalink($course_id); if (count($items) > 0 && $counter !== count($items)) { $course_title .= ', '; $course_address .= ', '; } } $tracking_url = apply_filters('wpml_marketpress_tracking_url', mp_orderstatus_link(false, true) . $order_post->post_title . '/'); break; case '2.0': $order_name = $order->mp_shipping_info['name']; $course_address = $course->get_permalink(); $course_title = $course->details->post_title; $tracking_url = apply_filters('wpml_marketpress_tracking_url', mp_orderstatus_link(false, true) . $order->post_title . '/'); break; } $tags_replaces = array($order_name, get_bloginfo(), cp_student_login_address(), home_url(), $course_address, $course_title, $order->ID, $tracking_url); $message = coursepress_get_mp_order_content_email(); $message = str_replace($tags, $tags_replaces, $message); add_filter('wp_mail_from', 'my_mail_from_function', 99); if (!function_exists('my_mail_from_function')) { function my_mail_from_function($email) { return coursepress_get_mp_order_from_email(); } } add_filter('wp_mail_from_name', 'my_mail_from_name_function', 99); if (!function_exists('my_mail_from_name_function')) { function my_mail_from_name_function($name) { return coursepress_get_mp_order_from_name(); } } return $message; } else { return $content; } }
function filter_email($order, $text) { global $blog_id; $bid = is_multisite() ? $blog_id : 1; //// order info if (is_array($order->mp_cart_info) && count($order->mp_cart_info)) { $order_info = __('Items:', 'mp') . "\n"; foreach ($order->mp_cart_info as $product_id => $variations) { foreach ($variations as $variation => $data) { $order_info .= "\t" . $data['name'] . ': ' . number_format_i18n($data['quantity']) . ' * ' . number_format_i18n($data['price'], 2) . ' = ' . number_format_i18n($data['price'] * $data['quantity'], 2) . ' ' . $order->mp_payment_info['currency'] . "\n"; //show download link if set if ($order->post_status != 'order_received' && ($download_url = $this->get_download_url($product_id, $order->post_title))) { $order_info .= "\t\t" . __('Download: ', 'mp') . $download_url . "\n"; } // FPM: Product Custom Fields $cf_key = $bid . ':' . $product_id . ':' . $variation; if (isset($order->mp_shipping_info['mp_custom_fields'][$cf_key])) { $cf_items = $order->mp_shipping_info['mp_custom_fields'][$cf_key]; $mp_custom_field_label = get_post_meta($product_id, 'mp_custom_field_label', true); if (isset($mp_custom_field_label[$variation])) { $label_text = esc_attr($mp_custom_field_label[$variation]); } else { $label_text = __('Product Personalization: ', 'mp'); } $order_info .= "\t\t" . $label_text . "\n"; foreach ($cf_items as $idx => $cf_item) { $item_cnt = intval($idx) + 1; $order_info .= "\t\t\t" . $item_cnt . ". " . $cf_item . "\n"; } } $order_info .= "\n"; } } $order_info .= "\n"; } //coupon line if ($order->mp_discount_info) { $order_info .= "\n" . __('Coupon Discount:', 'mp') . ' ' . str_replace('%', __(' Percent', 'mp'), $order->mp_discount_info['discount']); //have to escape % sign so sprintf doesn't choke } //shipping line if ($order->mp_shipping_total) { $order_info .= "\n" . __('Shipping:', 'mp') . ' ' . number_format_i18n($order->mp_shipping_total, 2) . ' ' . $order->mp_payment_info['currency']; } //tax line if ($order->mp_tax_total) { $order_info .= "\n" . __('Taxes:', 'mp') . ' ' . number_format_i18n($order->mp_tax_total, 2) . ' ' . $order->mp_payment_info['currency']; } //total line $order_info .= "\n" . __('Order Total:', 'mp') . ' ' . number_format_i18n($order->mp_order_total, 2) . ' ' . $order->mp_payment_info['currency']; //// Shipping Info if (is_array($order->mp_cart_info) && $this->download_only_cart($order->mp_cart_info) || $this->get_setting('shipping->method') == 'none') { //if the cart is only digital products $shipping_info = __('No shipping required for this order.', 'mp'); } else { $shipping_info = __('Full Name:', 'mp') . ' ' . $order->mp_shipping_info['name']; $shipping_info .= "\n" . __('Address:', 'mp') . ' ' . $order->mp_shipping_info['address1']; if ($order->mp_shipping_info['address2']) { $shipping_info .= "\n" . __('Address 2:', 'mp') . ' ' . $order->mp_shipping_info['address2']; } $shipping_info .= "\n" . __('City:', 'mp') . ' ' . $order->mp_shipping_info['city']; if (!empty($order->mp_shipping_info['state'])) { $shipping_info .= "\n" . __('State/Province/Region:', 'mp') . ' ' . $order->mp_shipping_info['state']; } $shipping_info .= "\n" . __('Postal/Zip Code:', 'mp') . ' ' . $order->mp_shipping_info['zip']; $shipping_info .= "\n" . __('Country:', 'mp') . ' ' . $order->mp_shipping_info['country']; if (!empty($order->mp_shipping_info['phone'])) { $shipping_info .= "\n" . __('Phone Number:', 'mp') . ' ' . $order->mp_shipping_info['phone']; } // If actually shipped show method, else customer's shipping choice. if (isset($order->mp_shipping_info['method']) && $order->mp_shipping_info['method'] != 'other') { $shipping_info .= "\n" . __('Shipping Method:', 'mp') . ' ' . $order->mp_shipping_info['method']; } elseif (!empty($order->mp_shipping_info['shipping_option'])) { $shipping_info .= "\n" . __('Shipping Method:', 'mp') . ' ' . strtoupper($order->mp_shipping_info['shipping_option']) . ' ' . $order->mp_shipping_info['shipping_sub_option']; } if (!empty($order->mp_shipping_info['tracking_num'])) { $shipping_info .= "\n" . __('Tracking Number:', 'mp') . ' ' . $order->mp_shipping_info['tracking_num']; } } if (!empty($order->mp_shipping_info['special_instructions'])) { $shipping_info .= "\n" . __('Special Instructions:', 'mp') . ' ' . $order->mp_shipping_info['special_instructions']; } if (!empty($order->mp_order_notes)) { $order_notes = __('Order Notes:', 'mp') . "\n" . $order->mp_order_notes; } //// Payment Info $payment_info = __('Payment Method:', 'mp') . ' ' . $order->mp_payment_info['gateway_public_name']; if ($order->mp_payment_info['method']) { $payment_info .= "\n" . __('Payment Type:', 'mp') . ' ' . $order->mp_payment_info['method']; } if ($order->mp_payment_info['transaction_id']) { $payment_info .= "\n" . __('Transaction ID:', 'mp') . ' ' . $order->mp_payment_info['transaction_id']; } $payment_info .= "\n" . __('Payment Total:', 'mp') . ' ' . number_format_i18n($order->mp_payment_info['total'], 2) . ' ' . $order->mp_payment_info['currency']; $payment_info .= "\n\n"; if ($order->post_status == 'order_received') { $payment_info .= __('Your payment for this order is not yet complete. Here is the latest status:', 'mp') . "\n"; $statuses = $order->mp_payment_info['status']; krsort($statuses); //sort with latest status at the top $status = reset($statuses); $timestamp = key($statuses); $payment_info .= date_i18n(get_option('date_format') . ' - ' . get_option('time_format'), $timestamp) . ': ' . $status; } else { $payment_info .= __('Your payment for this order is complete.', 'mp'); } //total $order_total = number_format_i18n($order->mp_payment_info['total'], 2) . ' ' . $order->mp_payment_info['currency']; //tracking URL $tracking_url = apply_filters('wpml_marketpress_tracking_url', mp_orderstatus_link(false, true) . $order->post_title . '/'); //setup filters $search = array('CUSTOMERNAME', 'ORDERID', 'ORDERINFO', 'SHIPPINGINFO', 'PAYMENTINFO', 'TOTAL', 'TRACKINGURL', 'ORDERNOTES'); $replace = array($order->mp_shipping_info['name'], $order->post_title, $order_info, $shipping_info, $payment_info, $order_total, $tracking_url, $order_notes); //replace $text = str_replace($search, $replace, $text); return $text; }
/** * Echos the current store navigation links. * * @param bool $echo Optional, whether to echo. Defaults to true */ function mp_store_navigation($echo = true) { $settings = get_option('mp_settings'); //navigation if (!$settings['disable_cart']) { $nav = '<ul class="mp_store_navigation"><li class="page_item"><a href="' . mp_products_link(false, true) . '" title="' . __('Products', 'mp') . '">' . __('Products', 'mp') . '</a></li>'; $nav .= '<li class="page_item"><a href="' . mp_cart_link(false, true) . '" title="' . __('Shopping Cart', 'mp') . '">' . __('Shopping Cart', 'mp') . '</a></li>'; $nav .= '<li class="page_item"><a href="' . mp_orderstatus_link(false, true) . '" title="' . __('Order Status', 'mp') . '">' . __('Order Status', 'mp') . '</a></li> </ul>'; } else { $nav = '<ul class="mp_store_navigation"> <li class="page_item"><a href="' . mp_products_link(false, true) . '" title="' . __('Products', 'mp') . '">' . __('Products', 'mp') . '</a></li> </ul>'; } if ($echo) { echo $nav; } else { return $nav; } }
/** * Runs before page load incase you need to run any scripts before loading the success message page */ function order_confirmation($order) { global $mp; //check if created already by IPN if (!$order) { $result = $this->PaymentDetails($_SESSION['PAYKEY']); if ($result["responseEnvelope_ack"] == "Success" || $result["responseEnvelope_ack"] == "SuccessWithWarning") { //setup our payment details $payment_info['gateway_public_name'] = $this->public_name; $payment_info['gateway_private_name'] = $this->admin_name; $payment_info['method'] = __('PayPal balance, Credit Card, or Instant Transfer', 'mp'); $payment_info['transaction_id'] = $result["paymentInfoList_paymentInfo(0)_transactionId"]; $timestamp = time(); $order_id = $result["trackingId"]; //setup status switch ($result["paymentInfoList_paymentInfo(0)_transactionStatus"]) { case 'PARTIALLY_REFUNDED': $status = __('The payment has been partially refunded.', 'mp'); $create_order = true; $paid = true; break; case 'COMPLETED': $status = __('The payment has been completed, and the funds have been added successfully to your account balance.', 'mp'); $create_order = true; $paid = true; break; case 'PROCESSING': $status = __('The transaction is in progress.', 'mp'); $create_order = true; $paid = true; break; case 'REVERSED': $status = __('You refunded the payment.', 'mp'); $create_order = false; $paid = false; break; case 'DENIED': $status = __('The transaction was rejected by the receiver (you).', 'mp'); $create_order = false; $paid = false; break; case 'PENDING': $pending_str = array('ADDRESS_CONFIRMATION' => __('The payment is pending because your customer did not include a confirmed shipping address and your Payment Receiving Preferences is set such that you want to manually accept or deny each of these payments. To change your preference, go to the Preferences section of your Profile.', 'mp'), 'ECHECK' => __('The payment is pending because it was made by an eCheck that has not yet cleared.', 'mp'), 'INTERNATIONAL' => __('The payment is pending because you hold a non-U.S. account and do not have a withdrawal mechanism. You must manually accept or deny this payment from your Account Overview.', 'mp'), 'MULTI_CURRENCY' => __('You do not have a balance in the currency sent, and you do not have your Payment Receiving Preferences set to automatically convert and accept this payment. You must manually accept or deny this payment.', 'mp'), 'RISK' => __('The payment is pending while it is being reviewed by PayPal for risk.', 'mp'), 'UNILATERAL' => __('The payment is pending because it was made to an email address that is not yet registered or confirmed.', 'mp'), 'UPGRADE' => __('The payment is pending because it was made via credit card and you must upgrade your account to Business or Premier status in order to receive the funds. It can also mean that you have reached the monthly limit for transactions on your account.', 'mp'), 'VERIFY' => __('The payment is pending because you are not yet verified. You must verify your account before you can accept this payment.', 'mp'), 'OTHER' => __('The payment is pending for an unknown reason. For more information, contact PayPal customer service.', 'mp')); $status = __('The payment is pending.', 'mp'); $status .= '<br />' . $pending_str[$result["paymentInfoList_paymentInfo(0)_pendingReason"]]; $create_order = true; $paid = false; break; default: // case: various error cases $create_order = false; $paid = false; } $status = $result["paymentInfoList_paymentInfo(0)_transactionStatus"] . ': ' . $status; //status's are stored as an array with unix timestamp as key $payment_info['status'][$timestamp] = $status; $payment_info['total'] = $result["paymentInfoList_paymentInfo(0)_receiver_amount"]; $payment_info['currency'] = $result["currencyCode"]; //succesful payment, create our order now if ($create_order) { $cart = get_transient('mp_order_' . $order_id . '_cart'); $shipping_info = get_transient('mp_order_' . $order_id . '_shipping'); $order_id = $mp->create_order($result["trackingId"], $cart, $shipping_info, $payment_info, $paid); delete_transient('mp_order_' . $order_id . '_cart'); delete_transient('mp_order_' . $order_id . '_shipping'); delete_transient('mp_order_' . $order_id . '_shipping_total'); delete_transient('mp_order_' . $order_id . '_tax_total'); delete_transient('mp_order_' . $order_id . '_userid'); delete_transient('mp_order_' . $order_id . '_coupon'); } else { $mp->cart_checkout_error(sprintf(__('Sorry, your order was not completed. Please <a href="%s">go back and try again</a>.', 'mp'), mp_checkout_step_url('checkout'))); return; } } else { //whoops, error for ($i = 0; $i <= 5; $i++) { //print the first 5 errors if (isset($result["error({$i})_message"])) { $error .= "<li>{$result["error({$i})_errorId"]} - {$result["error({$i})_message"]}</li>"; } } $error = '<br /><ul>' . $error . '</ul>'; $mp->cart_checkout_error(sprintf(__('There was a problem connecting to PayPal to check the status of your purchase. Please <a href="%s">check the status of your order here »</a>', 'mp') . $error, mp_orderstatus_link(false, true))); return; } } else { $mp->set_cart_cookie(array()); } }
function mycred_market_parse_email($email) { if ($email['request']['ref'] == 'marketpress_payment') { $order = get_post((int) $email['request']['ref_id']); if (isset($order->id)) { $track_link = '<a href="' . mp_orderstatus_link(false, true) . $order_id . '/' . '">#' . $order->post_title . '/' . '</a>'; $content = str_replace('%order_id%', $order->post_title, $email['request']['entry']); $email['request']['entry'] = str_replace('%order_link%', $track_link, $content); } } return $email; }
function framemarket_mp_order_status() { global $mp, $wp_query; $settings = get_option('mp_settings'); echo $settings['msg']['order_status']; $order_id = $wp_query->query_vars['order_id'] ? $wp_query->query_vars['order_id'] : $_GET['order_id']; if (!empty($order_id)) { //get order $order = $mp->get_order($order_id); if ($order) { //valid order echo '<hr/><h2><em>' . sprintf(__('Order Details (%s):', 'mp'), htmlentities($order_id)) . '</em></h2>'; ?> <h3><?php _e('Current Status', 'mp'); ?> </h3> <ul> <?php //get times $received = date(get_option('date_format') . ' - ' . get_option('time_format'), $order->mp_received_time); if ($order->mp_paid_time) { $paid = date(get_option('date_format') . ' - ' . get_option('time_format'), $order->mp_paid_time); } if ($order->mp_shipped_time) { $shipped = date(get_option('date_format') . ' - ' . get_option('time_format'), $order->mp_shipped_time); } if ($order->post_status == 'order_received') { echo '<li>' . __('Received:', 'mp') . ' <strong>' . $received . '</strong></li>'; } else { if ($order->post_status == 'order_paid') { echo '<li>' . __('Paid:', 'mp') . ' <strong>' . $paid . '</strong></li>'; echo '<li>' . __('Received:', 'mp') . ' <strong>' . $received . '</strong></li>'; } else { if ($order->post_status == 'order_shipped' || $order->post_status == 'order_closed') { echo '<li>' . __('Shipped:', 'mp') . ' <strong>' . $shipped . '</strong></li>'; echo '<li>' . __('Paid:', 'mp') . ' <strong>' . $paid . '</strong></li>'; echo '<li>' . __('Received:', 'mp') . ' <strong>' . $received . '</strong></li>'; } } } $order_paid = $order->post_status != 'order_received'; $max_downloads = intval($settings['max_downloads']) ? intval($settings['max_downloads']) : 5; ?> </ul> <hr/> <h3><?php _e('Payment Information:', 'mp'); ?> </h3> <ul> <li> <?php _e('Payment Method:', 'mp'); ?> <strong><?php echo $order->mp_payment_info['gateway_public_name']; ?> </strong> </li> <li> <?php _e('Payment Type:', 'mp'); ?> <strong><?php echo $order->mp_payment_info['method']; ?> </strong> </li> <li> <?php _e('Transaction ID:', 'mp'); ?> <strong><?php echo $order->mp_payment_info['transaction_id']; ?> </strong> </li> <li> <?php _e('Payment Total:', 'mp'); ?> <strong><?php echo $mp->format_currency($order->mp_payment_info['currency'], $order->mp_payment_info['total']) . ' ' . $order->mp_payment_info['currency']; ?> </strong> </li> </ul> <hr/> <h3><?php _e('Order Information:', 'mp'); ?> </h3> <table id="mp-order-product-table" class="mp_cart_contents"> <thead><tr> <th class="mp_cart_col_thumb"> </th> <th class="mp_cart_col_product"><?php _e('Item', 'mp'); ?> </th> <th class="mp_cart_col_quant"><?php _e('Quantity', 'mp'); ?> </th> <th class="mp_cart_col_price"><?php _e('Price', 'mp'); ?> </th> <th class="mp_cart_col_subtotal"><?php _e('Subtotal', 'mp'); ?> </th> <th class="mp_cart_col_downloads"><?php _e('Download', 'mp'); ?> </th> </tr></thead> <tbody> <?php if (is_array($order->mp_cart_info) && count($order->mp_cart_info)) { foreach ($order->mp_cart_info as $product_id => $variations) { //for compatibility for old orders from MP 1.x if (isset($variations['name'])) { $data = $variations; echo '<tr>'; echo ' <td class="mp_cart_col_thumb">' . mp_product_image(false, 'widget', $product_id) . '</td>'; echo ' <td class="mp_cart_col_product"><a href="' . get_permalink($product_id) . '">' . esc_attr($data['name']) . '</a></td>'; echo ' <td class="mp_cart_col_quant">' . number_format_i18n($data['quantity']) . '</td>'; echo ' <td class="mp_cart_col_price">' . $mp->format_currency('', $data['price']) . '</td>'; echo ' <td class="mp_cart_col_subtotal">' . $mp->format_currency('', $data['price'] * $data['quantity']) . '</td>'; echo ' <td class="mp_cart_col_downloads"></td>'; echo '</tr>'; } else { foreach ($variations as $variation => $data) { echo '<tr>'; echo ' <td class="mp_cart_col_thumb">' . mp_product_image(false, 'widget', $product_id) . '</td>'; echo ' <td class="mp_cart_col_product"><a href="' . get_permalink($product_id) . '">' . esc_attr($data['name']) . '</a></td>'; echo ' <td class="mp_cart_col_quant">' . number_format_i18n($data['quantity']) . '</td>'; echo ' <td class="mp_cart_col_price">' . $mp->format_currency('', $data['price']) . '</td>'; echo ' <td class="mp_cart_col_subtotal">' . $mp->format_currency('', $data['price'] * $data['quantity']) . '</td>'; if (is_array($data['download']) && ($download_url = $mp->get_download_url($product_id, $order->post_title))) { if ($order_paid) { //check for too many downloads if (intval($data['download']['downloaded']) < $max_downloads) { echo ' <td class="mp_cart_col_downloads"><a href="' . $download_url . '">' . __('Download»', 'mp') . '</a></td>'; } else { echo ' <td class="mp_cart_col_downloads">' . __('Limit Reached', 'mp') . '</td>'; } } else { echo ' <td class="mp_cart_col_downloads">' . __('Awaiting Payment', 'mp') . '</td>'; } } else { echo ' <td class="mp_cart_col_downloads"></td>'; } echo '</tr>'; } } } } else { echo '<tr><td colspan="6">' . __('No products could be found for this order', 'mp') . '</td></tr>'; } ?> </tbody> </table> <ul> <?php //coupon line if ($order->mp_discount_info) { ?> <li><?php _e('Coupon Discount:', 'mp'); ?> <strong><?php echo $order->mp_discount_info['discount']; ?> </strong></li> <?php } ?> <?php //shipping line if ($order->mp_shipping_total) { ?> <li><?php _e('Shipping:', 'mp'); ?> <strong><?php echo $mp->format_currency('', $order->mp_shipping_total); ?> </strong></li> <?php } ?> <?php //tax line if ($order->mp_tax_total) { ?> <li><?php _e('Taxes:', 'mp'); ?> <strong><?php echo $mp->format_currency('', $order->mp_tax_total); ?> </strong></li> <?php } ?> <li><?php _e('Order Total:', 'mp'); ?> <strong><?php echo $mp->format_currency('', $order->mp_order_total); ?> </strong></li> </ul> <hr/> <h3><?php _e('Shipping Information:', 'mp'); ?> </h3> <table> <tr> <td align="right"><?php _e('Full Name:', 'mp'); ?> </td><td> <?php echo esc_attr($order->mp_shipping_info['name']); ?> </td> </tr> <tr> <td align="right"><?php _e('Address:', 'mp'); ?> </td> <td><?php echo esc_attr($order->mp_shipping_info['address1']); ?> </td> </tr> <?php if ($order->mp_shipping_info['address2']) { ?> <tr> <td align="right"><?php _e('Address 2:', 'mp'); ?> </td> <td><?php echo esc_attr($order->mp_shipping_info['address2']); ?> </td> </tr> <?php } ?> <tr> <td align="right"><?php _e('City:', 'mp'); ?> </td> <td><?php echo esc_attr($order->mp_shipping_info['city']); ?> </td> </tr> <?php if ($order->mp_shipping_info['state']) { ?> <tr> <td align="right"><?php _e('State/Province/Region:', 'mp'); ?> </td> <td><?php echo esc_attr($order->mp_shipping_info['state']); ?> </td> </tr> <?php } ?> <tr> <td align="right"><?php _e('Postal/Zip Code:', 'mp'); ?> </td> <td><?php echo esc_attr($order->mp_shipping_info['zip']); ?> </td> </tr> <tr> <td align="right"><?php _e('Country:', 'mp'); ?> </td> <td><?php echo $mp->countries[$order->mp_shipping_info['country']]; ?> </td> </tr> <?php if ($order->mp_shipping_info['phone']) { ?> <tr> <td align="right"><?php _e('Phone Number:', 'mp'); ?> </td> <td><?php echo esc_attr($order->mp_shipping_info['phone']); ?> </td> </tr> <?php } ?> </table> <?php mp_orderstatus_link(true, false, __('« Back', 'mp')); ?> <?php } else { //not valid order id echo '<hr/><h3>' . __('Invalid Order ID. Please try again:', 'mp') . '</h3>'; ?> <form action="<?php mp_orderstatus_link(true, true); ?> " method="get"> <label><?php _e('Enter your 12-digit Order ID number:', 'mp'); ?> <br /> <input type="text" name="order_id" id="order_id" class="input" value="" size="20" /></label> <input type="submit" id="order-id-submit" value="<?php _e('Look Up »', 'mp'); ?> " /> </form> <?php } } else { //get from usermeta $user_id = get_current_user_id(); if ($user_id) { if (is_multisite()) { global $blog_id; $meta_id = 'mp_order_history_' . $blog_id; } else { $meta_id = 'mp_order_history'; } $orders = get_user_meta($user_id, $meta_id, true); } else { //get from cookie if (is_multisite()) { global $blog_id; $cookie_id = 'mp_order_history_' . $blog_id . '_' . COOKIEHASH; } else { $cookie_id = 'mp_order_history_' . COOKIEHASH; } if (isset($_COOKIE[$cookie_id])) { $orders = unserialize($_COOKIE[$cookie_id]); } } if (is_array($orders) && count($orders)) { krsort($orders); //list orders echo '<hr/><h3>' . __('Your Recent Orders:', 'mp') . '</h3>'; echo '<ul id="mp-order-list">'; foreach ($orders as $timestamp => $order) { echo ' <li><strong>' . date(get_option('date_format') . ' - ' . get_option('time_format'), $timestamp) . ':</strong> <a href="./' . trailingslashit($order['id']) . '">' . $order['id'] . '</a> - ' . $mp->format_currency('', $order['total']) . '</li>'; } echo '</ul>'; ?> <form action="<?php mp_orderstatus_link(true, true); ?> " method="get"> <label><?php _e('Or enter your 12-digit Order ID number:', 'mp'); ?> <br /> <input type="text" name="order_id" id="order_id" class="input" value="" size="20" /></label> <input type="submit" id="order-id-submit" value="<?php _e('Look Up »', 'mp'); ?> " /> </form> <?php } else { if (!is_user_logged_in()) { ?> <table class="mp_cart_login"> <thead><tr> <th class="mp_cart_login" colspan="2"><?php _e('Have a User Account? Login To View Your Order History:', 'mp'); ?> </th> <th> </th> </tr></thead> <tbody> <tr> <td class="mp_cart_login"> <form name="loginform" id="loginform" action="<?php echo wp_login_url(); ?> " method="post"> <label><?php _e('Username', 'mp'); ?> <br /> <input type="text" name="log" id="user_login" class="input" value="" size="20" /></label> <br /> <label><?php _e('Password', 'mp'); ?> <br /> <input type="password" name="pwd" id="user_pass" class="input" value="" size="20" /></label> <br /> <input type="submit" name="wp-submit" id="mp_login_submit" value="<?php _e('Login »', 'mp'); ?> " /> <input type="hidden" name="redirect_to" value="<?php mp_orderstatus_link(true, true); ?> " /> </form> </td> <td class="mp_cart_or_label"><?php _e('or', 'mp'); ?> </td> <td class="mp_cart_checkout"> <form action="<?php mp_orderstatus_link(true, true); ?> " method="get"> <label><?php _e('Enter your 12-digit Order ID number:', 'mp'); ?> <br /> <input type="text" name="order_id" id="order_id" class="input" value="" size="20" /></label> <input type="submit" id="order-id-submit" value="<?php _e('Look Up »', 'mp'); ?> " /> </form> </td> </tr> </tbody> </table> <?php } else { ?> <form action="<?php mp_orderstatus_link(true, true); ?> " method="get"> <label><?php _e('Enter your 12-digit Order ID number:', 'mp'); ?> <br /> <input type="text" name="order_id" id="order_id" class="input" value="" size="20" /></label> <input type="submit" id="order-id-submit" value="<?php _e('Look Up »', 'mp'); ?> " /> </form> <?php } } } }
/** * Echos the order status page. Use in the mp_orderstatus.php template. * */ function flexmarket_order_status($btnclass = '') { global $mp, $wp_query, $blog_id; $bid = is_multisite() ? $blog_id : 1; // FPM: Used for Custom Field Processing echo do_shortcode($mp->get_setting('msg->order_status')); $order_id = isset($wp_query->query_vars['order_id']) ? $wp_query->query_vars['order_id'] : (isset($_GET['order_id']) ? $_GET['order_id'] : ''); if (!empty($order_id)) { //get order $order = $mp->get_order($order_id); if ($order) { //valid order echo '<h2 class="page-header"><em>' . sprintf(__('Order Details (%s):', 'mp'), htmlentities($order_id)) . '</em></h2>'; ?> <div class="row-fluid"> <div class="span6 well well-small well-shadow" style="min-height: 250px;"> <h3 class="page-header"><?php _e('Current Status', 'mp'); ?> </h3> <ul> <?php //get times $received = isset($order->mp_received_time) ? date_i18n(get_option('date_format') . ' - ' . get_option('time_format'), $order->mp_received_time) : ''; if (!empty($order->mp_paid_time)) { $paid = date_i18n(get_option('date_format') . ' - ' . get_option('time_format'), $order->mp_paid_time); } if (!empty($order->mp_shipped_time)) { $shipped = date_i18n(get_option('date_format') . ' - ' . get_option('time_format'), $order->mp_shipped_time); } if ($order->post_status == 'order_received') { echo '<li>' . __('Received:', 'mp') . ' <strong>' . $received . '</strong></li>'; } else { if ($order->post_status == 'order_paid') { echo '<li>' . __('Paid:', 'mp') . ' <strong>' . $paid . '</strong></li>'; echo '<li>' . __('Received:', 'mp') . ' <strong>' . $received . '</strong></li>'; } else { if ($order->post_status == 'order_shipped' || $order->post_status == 'order_closed') { echo '<li>' . __('Shipped:', 'mp') . ' <strong>' . $shipped . '</strong></li>'; echo '<li>' . __('Paid:', 'mp') . ' <strong>' . $paid . '</strong></li>'; echo '<li>' . __('Received:', 'mp') . ' <strong>' . $received . '</strong></li>'; } } } $order_paid = $order->post_status != 'order_received'; $max_downloads = $mp->get_setting('max_downloads', 5); ?> </ul> </div><!-- / span6 --> <div class="span6 well well-small well-shadow" style="min-height: 250px;"> <h3 class="page-header"><?php _e('Payment Information:', 'mp'); ?> </h3> <ul> <li> <?php _e('Payment Method:', 'mp'); ?> <strong><?php echo $order->mp_payment_info['gateway_public_name']; ?> </strong> </li> <li> <?php _e('Payment Type:', 'mp'); ?> <strong><?php echo $order->mp_payment_info['method']; ?> </strong> </li> <li> <?php _e('Transaction ID:', 'mp'); ?> <strong><?php echo $order->mp_payment_info['transaction_id']; ?> </strong> </li> <li> <?php _e('Payment Total:', 'mp'); ?> <strong><?php echo $mp->format_currency($order->mp_payment_info['currency'], $order->mp_payment_info['total']) . ' ' . $order->mp_payment_info['currency']; ?> </strong> </li> </ul> </div><!-- / span6 --> </div><!-- / row-fluid --> <div class="clear padding20"></div> <h3><?php _e('Order Information:', 'mp'); ?> </h3> <table id="mp-order-product-table" class="mp_cart_contents table table-striped table-bordered table-hover"> <thead><tr> <th class="mp_cart_col_thumb"> </th> <th class="mp_cart_col_product"><?php _e('Item', 'mp'); ?> </th> <th class="mp_cart_col_quant"><?php _e('Quantity', 'mp'); ?> </th> <th class="mp_cart_col_price"><?php _e('Price', 'mp'); ?> </th> <th class="mp_cart_col_subtotal"><?php _e('Subtotal', 'mp'); ?> </th> <th class="mp_cart_col_downloads"><?php _e('Download', 'mp'); ?> </th> </tr></thead> <tbody> <?php if (is_array($order->mp_cart_info) && count($order->mp_cart_info)) { foreach ($order->mp_cart_info as $product_id => $variations) { //for compatibility for old orders from MP 1.x if (isset($variations['name'])) { $data = $variations; echo '<tr>'; echo ' <td class="mp_cart_col_thumb">' . mp_product_image(false, 'widget', $product_id) . '</td>'; echo ' <td class="mp_cart_col_product"><a href="' . apply_filters('mp_product_url_display_in_cart', get_permalink($product_id), $product_id) . '">' . apply_filters('mp_product_name_display_in_cart', $data['name'], $product_id) . '</a>' . '</td>'; // Added WPML (This differs than other code) echo ' <td class="mp_cart_col_quant">' . number_format_i18n($data['quantity']) . '</td>'; echo ' <td class="mp_cart_col_price">' . $mp->format_currency('', $data['price']) . '</td>'; echo ' <td class="mp_cart_col_subtotal">' . $mp->format_currency('', $data['price'] * $data['quantity']) . '</td>'; echo ' <td class="mp_cart_col_downloads"></td>'; echo '</tr>'; } else { foreach ($variations as $variation => $data) { echo '<tr>'; echo ' <td class="mp_cart_col_thumb">' . mp_product_image(false, 'widget', $product_id) . '</td>'; echo ' <td class="mp_cart_col_product"><a href="' . apply_filters('mp_product_url_display_in_cart', get_permalink($product_id), $product_id) . '">' . apply_filters('mp_product_name_display_in_cart', $data['name'], $product_id) . '</a>'; // Output product custom field information $cf_key = $bid . ':' . $product_id . ':' . $variation; if (isset($order->mp_shipping_info['mp_custom_fields'][$cf_key])) { $cf_item = $order->mp_shipping_info['mp_custom_fields'][$cf_key]; $mp_custom_field_label = get_post_meta($product_id, 'mp_custom_field_label', true); if (isset($mp_custom_field_label[$variation])) { $label_text = $mp_custom_field_label[$variation]; } else { $label_text = __('Product Personalization:', 'mp'); } echo '<div class="mp_cart_custom_fields">' . $label_text . '<br />'; foreach ($cf_item as $item) { echo (!empty($item) ? '<i class="icon-minus opacity5"></i> ' : '') . $item . '<br/>'; } echo '</div>'; } echo '</td>'; // Added WPML (This differs than other code) echo ' <td class="mp_cart_col_quant">' . number_format_i18n($data['quantity']) . '</td>'; echo ' <td class="mp_cart_col_price">' . $mp->format_currency('', $data['price']) . '</td>'; echo ' <td class="mp_cart_col_subtotal">' . $mp->format_currency('', $data['price'] * $data['quantity']) . '</td>'; if (is_array($data['download']) && ($download_url = $mp->get_download_url($product_id, $order->post_title))) { if ($order_paid) { //check for too many downloads if (intval($data['download']['downloaded']) < $max_downloads) { echo ' <td class="mp_cart_col_downloads"><a href="' . $download_url . '">' . __('Download»', 'mp') . '</a></td>'; } else { echo ' <td class="mp_cart_col_downloads">' . __('Limit Reached', 'mp') . '</td>'; } } else { echo ' <td class="mp_cart_col_downloads">' . __('Awaiting Payment', 'mp') . '</td>'; } } else { echo ' <td class="mp_cart_col_downloads"></td>'; } echo '</tr>'; } } } } else { echo '<tr><td colspan="6">' . __('No products could be found for this order', 'mp') . '</td></tr>'; } ?> </tbody> </table> <div class="clear padding5"></div> <table class="table table-striped table-bordered table-hover"> <?php //coupon line if ($order->mp_discount_info) { ?> <tr> <td class="align-right span8"><?php _e('Coupon Discount:', 'mp'); ?> </td> <td class="span4"><strong><?php echo $order->mp_discount_info['discount']; ?> </strong></td> </tr> <?php } ?> <?php //shipping line if ($order->mp_shipping_total) { ?> <tr> <td class="align-right span8"><?php _e('Shipping:', 'mp'); ?> </td> <td class="span4"><strong><?php echo $mp->format_currency('', $order->mp_shipping_total); ?> </strong></td> </tr> <?php } ?> <?php //tax line if ($order->mp_tax_total) { ?> <tr> <td class="align-right span8"><?php _e('Taxes:', 'mp'); ?> </td> <td class="span4"><strong><?php echo $mp->format_currency('', $order->mp_tax_total); ?> </strong></td> </tr> <?php } ?> <tr> <td class="align-right span8"><?php _e('Order Total:', 'mp'); ?> </td> <td class="span4"><strong><?php echo $mp->format_currency('', $order->mp_order_total); ?> </strong></td> </tr> </table> <div class="clear padding10"></div> <?php if (!defined('MP_HIDE_ORDERSTATUS_SHIPPING')) { ?> <h3><?php _e('Shipping Information:', 'mp'); ?> </h3> <table class="table table-striped table-bordered table-hover"> <tr> <td class="span4 align-right" align="right"><?php _e('Full Name:', 'mp'); ?> </td><td> <?php echo esc_attr($order->mp_shipping_info['name']); ?> </td> </tr> <tr> <td class="span4 align-right" align="right"><?php _e('Address:', 'mp'); ?> </td> <td><?php echo esc_attr($order->mp_shipping_info['address1']); ?> </td> </tr> <?php if ($order->mp_shipping_info['address2']) { ?> <tr> <td class="span4 align-right" align="right"><?php _e('Address 2:', 'mp'); ?> </td> <td><?php echo esc_attr($order->mp_shipping_info['address2']); ?> </td> </tr> <?php } ?> <tr> <td class="span4 align-right" align="right"><?php _e('City:', 'mp'); ?> </td> <td><?php echo esc_attr($order->mp_shipping_info['city']); ?> </td> </tr> <?php if ($order->mp_shipping_info['state']) { ?> <tr> <td class="span4 align-right" align="right"><?php _e('State/Province/Region:', 'mp'); ?> </td> <td><?php echo esc_attr($order->mp_shipping_info['state']); ?> </td> </tr> <?php } ?> <tr> <td class="span4 align-right" align="right"><?php _e('Postal/Zip Code:', 'mp'); ?> </td> <td><?php echo esc_attr($order->mp_shipping_info['zip']); ?> </td> </tr> <tr> <td class="span4 align-right" align="right"><?php _e('Country:', 'mp'); ?> </td> <td><?php echo $mp->countries[$order->mp_shipping_info['country']]; ?> </td> </tr> <?php if ($order->mp_shipping_info['phone']) { ?> <tr> <td class="span4 align-right" align="right"><?php _e('Phone Number:', 'mp'); ?> </td> <td><?php echo esc_attr($order->mp_shipping_info['phone']); ?> </td> </tr> <?php } ?> <?php if (isset($order->mp_shipping_info['tracking_num'])) { ?> <tr> <td class="span4 align-right" align="right"><?php _e('Tracking Number:', 'mp'); ?> </td> <td><?php echo mp_tracking_link($order->mp_shipping_info['tracking_num'], $order->mp_shipping_info['method']); ?> </td> </tr> <?php } ?> </table> <?php } ?> <?php if (isset($order->mp_order_notes)) { ?> <h3><?php _e('Order Notes:', 'mp'); ?> </h3> <div class="well"> <?php echo wpautop($order->mp_order_notes); ?> </div> <?php } ?> <?php do_action('mp_order_status_output', $order); ?> <a class="btn btn-large<?php echo $btnclass; ?> " href="<?php mp_orderstatus_link(true, true); ?> " ><?php _e('« Back', 'mp'); ?> </a> <?php } else { //not valid order id echo '<h3>' . __('Invalid Order ID. Please try again:', 'mp') . '</h3>'; ?> <form action="<?php mp_orderstatus_link(true, true); ?> " method="get"> <label><?php _e('Enter your 12-digit Order ID number:', 'mp'); ?> <br /> <input type="text" name="order_id" id="order_id" class="input" value="" size="20" /></label> <input type="submit" class="btn<?php echo $btnclass; ?> " id="order-id-submit" value="<?php _e('Look Up »', 'mp'); ?> " /> </form> <?php } } else { //get from usermeta $user_id = get_current_user_id(); if ($user_id) { if (is_multisite()) { global $blog_id; $meta_id = 'mp_order_history_' . $blog_id; } else { $meta_id = 'mp_order_history'; } $orders = get_user_meta($user_id, $meta_id, true); } else { //get from cookie if (is_multisite()) { global $blog_id; $cookie_id = 'mp_order_history_' . $blog_id . '_' . COOKIEHASH; } else { $cookie_id = 'mp_order_history_' . COOKIEHASH; } if (isset($_COOKIE[$cookie_id])) { $orders = unserialize($_COOKIE[$cookie_id]); } } if (is_array($orders) && count($orders)) { krsort($orders); //list orders echo '<h3>' . __('Your Recent Orders:', 'mp') . '</h3>'; echo '<ul id="mp-order-list">'; foreach ($orders as $timestamp => $order) { echo ' <li><strong>' . date_i18n(get_option('date_format') . ' - ' . get_option('time_format'), $timestamp) . ':</strong> <a href="./' . trailingslashit($order['id']) . '">' . $order['id'] . '</a> - ' . $mp->format_currency('', $order['total']) . '</li>'; } echo '</ul>'; ?> <div class="clear padding20"></div> <form action="<?php mp_orderstatus_link(true, true); ?> " method="get"> <label><?php _e('Or enter your 12-digit Order ID number:', 'mp'); ?> <br /> <input type="text" name="order_id" id="order_id" class="input" value="" size="20" /></label> <input type="submit" id="order-id-submit" class="btn<?php echo $btnclass; ?> " value="<?php _e('Look Up »', 'mp'); ?> " /> </form> <?php } else { if (!is_user_logged_in()) { ?> <table class="mp_cart_login table table-striped"> <thead><tr> <th class="mp_cart_login" colspan="2"><?php _e('Have a User Account? Login To View Your Order History:', 'mp'); ?> </th> <th> </th> </tr></thead> <tbody> <tr> <td class="mp_cart_login"> <div class="padding20"></div> <form name="loginform" id="loginform" action="<?php echo wp_login_url(); ?> " method="post" class="form-inline"> <label><?php _e('Username', 'mp'); ?> <input type="text" name="log" id="user_login" class="input" value="" size="20" /></label> <label><?php _e('Password', 'mp'); ?> <input type="password" name="pwd" id="user_pass" class="input" value="" size="20" /></label> <input type="submit" name="wp-submit" class="btn<?php echo $btnclass; ?> " id="mp_login_submit" value="<?php _e('Login »', 'mp'); ?> " /> <input type="hidden" name="redirect_to" value="<?php mp_orderstatus_link(true, true); ?> " /> </form> </td> </tr> </tbody> </table> <div class="clear padding10"></div> <div class="mp_cart_checkout"> <form action="<?php mp_orderstatus_link(true, true); ?> " method="get"> <label><?php _e('Or, Enter your 12-digit Order ID number:', 'mp'); ?> <br /> <input type="text" name="order_id" id="order_id" class="input" value="" size="20" /></label> <input type="submit" id="order-id-submit" class="btn<?php echo $btnclass; ?> " value="<?php _e('Look Up »', 'mp'); ?> " /> </form> </div> <?php } else { ?> <form action="<?php mp_orderstatus_link(true, true); ?> " method="get"> <label><?php _e('Enter your 12-digit Order ID number:', 'mp'); ?> <br /> <input type="text" name="order_id" id="order_id" class="input" value="" size="20" /></label> <input type="submit" id="order-id-submit" class="btn<?php echo $btnclass; ?> " value="<?php _e('Look Up »', 'mp'); ?> " /> </form> <?php } } } }