/** * Get the legend for the main chart sidebar * * @return array */ public function get_chart_legend() { $legend = array(); $data = $this->get_report_data(); switch ($this->chart_groupby) { case 'hour': /** @noinspection PhpUndefinedFieldInspection */ $average_sales_title = sprintf(__('%s average sales per hour', 'jigoshop'), '<strong>' . jigoshop_price($data->average_sales) . '</strong>'); break; case 'day': /** @noinspection PhpUndefinedFieldInspection */ $average_sales_title = sprintf(__('%s average daily sales', 'jigoshop'), '<strong>' . jigoshop_price($data->average_sales) . '</strong>'); break; case 'month': default: /** @noinspection PhpUndefinedFieldInspection */ $average_sales_title = sprintf(__('%s average monthly sales', 'jigoshop'), '<strong>' . jigoshop_price($data->average_sales) . '</strong>'); break; } /** @noinspection PhpUndefinedFieldInspection */ $legend[] = array('title' => sprintf(__('%s gross sales in this period', 'jigoshop'), '<strong>' . jigoshop_price($data->total_sales) . '</strong>'), 'placeholder' => __('This is the sum of the order totals including shipping and taxes.', 'jigoshop'), 'color' => $this->chart_colours['sales_amount'], 'highlight_series' => 5); /** @noinspection PhpUndefinedFieldInspection */ $legend[] = array('title' => sprintf(__('%s net sales in this period', 'jigoshop'), '<strong>' . jigoshop_price($data->net_sales) . '</strong>'), 'placeholder' => __('This is the sum of the order totals excluding shipping and taxes.', 'jigoshop'), 'color' => $this->chart_colours['net_sales_amount'], 'highlight_series' => 6); $legend[] = array('title' => $average_sales_title, 'color' => $this->chart_colours['average'], 'highlight_series' => 2); /** @noinspection PhpUndefinedFieldInspection */ $legend[] = array('title' => sprintf(__('%s orders placed', 'jigoshop'), '<strong>' . $data->total_orders . '</strong>'), 'color' => $this->chart_colours['order_count'], 'highlight_series' => 1); /** @noinspection PhpUndefinedFieldInspection */ $legend[] = array('title' => sprintf(__('%s items purchased', 'jigoshop'), '<strong>' . $data->total_items . '</strong>'), 'color' => $this->chart_colours['item_count'], 'highlight_series' => 0); /** @noinspection PhpUndefinedFieldInspection */ $legend[] = array('title' => sprintf(__('%s charged for shipping', 'jigoshop'), '<strong>' . jigoshop_price($data->total_shipping) . '</strong>'), 'color' => $this->chart_colours['shipping_amount'], 'highlight_series' => 4); /** @noinspection PhpUndefinedFieldInspection */ $legend[] = array('title' => sprintf(__('%s worth of coupons used', 'jigoshop'), '<strong>' . jigoshop_price($data->total_coupons) . '</strong>'), 'color' => $this->chart_colours['coupon_amount'], 'highlight_series' => 3); return $legend; }
/** * Widget * Display the widget in the sidebar * Save output to the cache if empty * * @param array sidebar arguments * @param array instance */ public function widget($args, $instance) { // Hide widget if page is the cart or checkout if (is_cart() || is_checkout()) { return false; } extract($args); // Set the widget title $title = apply_filters('widget_title', $instance['title'] ? $instance['title'] : __('Cart', 'jigoshop'), $instance, $this->id_base); // Print the widget wrapper & title echo $before_widget; if ($title) { echo $before_title . $title . $after_title; } // Get the contents of the cart $cart_contents = jigoshop_cart::$cart_contents; // If there are items in the cart print out a list of products if (!empty($cart_contents)) { // Open the list echo '<ul class="cart_list">'; foreach ($cart_contents as $key => $value) { // Get product instance $_product = $value['data']; if ($_product->exists() && $value['quantity'] > 0) { echo '<li>'; // Print the product image & title with a link to the permalink echo '<a href="' . esc_attr(get_permalink($_product->id)) . '" title="' . esc_attr($_product->get_title()) . '">'; // Print the product thumbnail image if exists else display placeholder echo has_post_thumbnail($_product->id) ? get_the_post_thumbnail($_product->id, 'shop_tiny') : jigoshop_get_image_placeholder('shop_tiny'); // Print the product title echo '<span class="js_widget_product_title">' . $_product->get_title() . '</span>'; echo '</a>'; // Displays variations and cart item meta echo jigoshop_cart::get_item_data($value); // Print the quantity & price per product echo '<span class="js_widget_product_price">' . $value['quantity'] . ' × ' . $_product->get_price_html() . '</span>'; echo '</li>'; } } echo '</ul>'; // Close the list // Print the cart total echo '<p class="total"><strong>'; echo __('Subtotal', 'jigoshop'); echo ':</strong> ' . jigoshop_price($this->total_cart_items()); echo '</p>'; do_action('jigoshop_widget_cart_before_buttons'); // Print view cart & checkout buttons $view_cart_button_label = isset($instance['view_cart_button']) ? $instance['view_cart_button'] : __('View Cart →', 'jigoshop'); $checkout_button_label = isset($instance['checkout_button']) ? $instance['checkout_button'] : __('Checkout →', 'jigoshop'); echo '<p class="buttons">'; echo '<a href="' . esc_attr(jigoshop_cart::get_cart_url()) . '" class="button">' . __($view_cart_button_label, 'jigoshop') . '</a>'; echo '<a href="' . esc_attr(jigoshop_cart::get_checkout_url()) . '" class="button checkout">' . __($checkout_button_label, 'jigoshop') . '</a>'; echo '</p>'; } else { echo '<span class="empty">' . __('No products in the cart.', 'jigoshop') . '</span>'; } // Print closing widget wrapper echo $after_widget; }
public function menu_item() { $total = 0; if (!empty(jigoshop_cart::$cart_contents)) { foreach (jigoshop_cart::$cart_contents as $cart_item_key => $values) { $product = $values['data']; $total += $product->get_price() * $values['quantity']; } } $total = jigoshop_price($total); $menu_item = array('cart_url' => jigoshop_cart::get_cart_url(), 'shop_page_url' => get_permalink(jigoshop_get_page_id('shop')), 'cart_contents_count' => jigoshop_cart::$cart_contents_count, 'cart_total' => $total); return $menu_item; }
function get_order_email_arguments($order_id) { $options = Jigoshop_Base::get_options(); $order = new jigoshop_order($order_id); $inc_tax = $options->get('jigoshop_calc_taxes') == 'no' || $options->get('jigoshop_prices_include_tax') == 'yes'; $can_show_links = $order->status == 'completed' || $order->status == 'processing'; $statuses = $order->get_order_statuses_and_names(); $variables = array('blog_name' => get_bloginfo('name'), 'order_number' => $order->get_order_number(), 'order_date' => date_i18n(get_option('date_format')), 'order_status' => $statuses[$order->status], 'shop_name' => $options->get('jigoshop_company_name'), 'shop_address_1' => $options->get('jigoshop_address_1'), 'shop_address_2' => $options->get('jigoshop_address_2'), 'shop_tax_number' => $options->get('jigoshop_tax_number'), 'shop_phone' => $options->get('jigoshop_company_phone'), 'shop_email' => $options->get('jigoshop_company_email'), 'customer_note' => $order->customer_note, 'order_items_table' => jigoshop_get_order_items_table($order, $can_show_links, true, $inc_tax), 'order_items' => $order->email_order_items_list($can_show_links, true, $inc_tax), 'order_taxes' => jigoshop_get_order_taxes_list($order), 'subtotal' => $order->get_subtotal_to_display(), 'shipping' => $order->get_shipping_to_display(), 'shipping_cost' => jigoshop_price($order->order_shipping), 'shipping_method' => $order->shipping_service, 'discount' => jigoshop_price($order->order_discount), 'applied_coupons' => jigoshop_get_order_coupon_list($order), 'total_tax' => jigoshop_price($order->get_total_tax()), 'total' => jigoshop_price($order->order_total), 'is_local_pickup' => $order->shipping_method == 'local_pickup' ? true : null, 'checkout_url' => $order->status == 'pending' ? $order->get_checkout_payment_url() : null, 'payment_method' => $order->payment_method_title, 'is_bank_transfer' => $order->payment_method == 'bank_transfer' ? true : null, 'is_cash_on_delivery' => $order->payment_method == 'cod' ? true : null, 'is_cheque' => $order->payment_method == 'cheque' ? true : null, 'bank_info' => str_replace(PHP_EOL, '', jigoshop_bank_transfer::get_bank_details()), 'cheque_info' => str_replace(PHP_EOL, '', $options->get('jigoshop_cheque_description')), 'billing_first_name' => $order->billing_first_name, 'billing_last_name' => $order->billing_last_name, 'billing_company' => $order->billing_company, 'billing_euvatno' => $order->billing_euvatno, 'billing_address_1' => $order->billing_address_1, 'billing_address_2' => $order->billing_address_2, 'billing_postcode' => $order->billing_postcode, 'billing_city' => $order->billing_city, 'billing_country' => jigoshop_countries::get_country($order->billing_country), 'billing_state' => strlen($order->billing_state) == 2 ? jigoshop_countries::get_state($order->billing_country, $order->billing_state) : $order->billing_state, 'billing_country_raw' => $order->billing_country, 'billing state_raw' => $order->billing_state, 'billing_email' => $order->billing_email, 'billing_phone' => $order->billing_phone, 'shipping_first_name' => $order->shipping_first_name, 'shipping_last_name' => $order->shipping_last_name, 'shipping_company' => $order->shipping_company, 'shipping_address_1' => $order->shipping_address_1, 'shipping_address_2' => $order->shipping_address_2, 'shipping_postcode' => $order->shipping_postcode, 'shipping_city' => $order->shipping_city, 'shipping_country' => jigoshop_countries::get_country($order->shipping_country), 'shipping_state' => strlen($order->shipping_state) == 2 ? jigoshop_countries::get_state($order->shipping_country, $order->shipping_state) : $order->shipping_state, 'shipping_country_raw' => $order->shipping_country, 'shipping_state_raw' => $order->shipping_state); if ($options->get('jigoshop_calc_taxes') == 'yes') { $variables['all_tax_classes'] = $variables['order_taxes']; } else { unset($variables['order_taxes']); } return apply_filters('jigoshop_order_email_variables', $variables, $order_id); }
/** @see WP_Widget::widget */ function widget($args, $instance) { if (is_cart()) { return; } extract($args); if (!empty($instance['title'])) { $title = $instance['title']; } else { $title = __('Cart', 'jigoshop'); } $title = apply_filters('widget_title', $title, $instance, $this->id_base); echo $before_widget; if ($title) { echo $before_title . $title . $after_title; } echo '<ul class="cart_list">'; if (sizeof(jigoshop_cart::$cart_contents) > 0) { foreach (jigoshop_cart::$cart_contents as $item_id => $values) { $_product = $values['data']; if ($_product->exists() && $values['quantity'] > 0) { echo '<li><a href="' . get_permalink($item_id) . '">'; if (has_post_thumbnail($item_id)) { echo get_the_post_thumbnail($item_id, 'shop_tiny'); } else { echo '<img src="' . jigoshop::plugin_url() . '/assets/images/placeholder.png" alt="Placeholder" width="' . jigoshop::get_var('shop_tiny_w') . '" height="' . jigoshop::get_var('shop_tiny_h') . '" />'; } echo apply_filters('jigoshop_cart_widget_product_title', $_product->get_title(), $_product) . '</a> ' . $values['quantity'] . ' × ' . jigoshop_price($_product->get_price()) . '</li>'; } } } else { echo '<li class="empty">' . __('No products in the cart.', 'jigoshop') . '</li>'; } echo '</ul>'; if (sizeof(jigoshop_cart::$cart_contents) > 0) { echo '<p class="total"><strong>'; if (get_option('js_prices_include_tax') == 'yes') { _e('Total', 'jigoshop'); } else { _e('Subtotal', 'jigoshop'); } echo ':</strong> ' . jigoshop_cart::get_cart_total(); echo '</p>'; do_action('jigoshop_widget_shopping_cart_before_buttons'); echo '<p class="buttons"><a href="' . jigoshop_cart::get_cart_url() . '" class="button">' . __('View Cart →', 'jigoshop') . '</a> <a href="' . jigoshop_cart::get_checkout_url() . '" class="button checkout">' . __('Checkout →', 'jigoshop') . '</a></p>'; } echo $after_widget; }
/** * Outputs the thankyou page **/ function jigoshop_thankyou() { _e('<p>Thank you. Your order has been processed successfully.</p>', 'jigoshop'); // Pay for order after checkout step if (isset($_GET['order'])) $order_id = $_GET['order']; else $order_id = 0; if (isset($_GET['key'])) $order_key = $_GET['key']; else $order_key = ''; if ($order_id > 0) : $order = &new jigoshop_order( $order_id ); if ($order->order_key == $order_key) : ?> <ul class="order_details"> <li class="order"> <?php _e('Order:', 'jigoshop'); ?> <strong># <?php echo $order->id; ?></strong> </li> <li class="date"> <?php _e('Date:', 'jigoshop'); ?> <strong><?php echo date(get_option('date_format'), strtotime($order->order_date)); ?></strong> </li> <li class="total"> <?php _e('Total:', 'jigoshop'); ?> <strong><?php echo jigoshop_price($order->order_total); ?></strong> </li> <li class="method"> <?php _e('Payment method:', 'jigoshop'); ?> <strong><?php $gateways = jigoshop_payment_gateways::payment_gateways(); if (isset($gateways[$order->payment_method])) echo $gateways[$order->payment_method]->title; else echo $order->payment_method; ?></strong> </li> </ul> <div class="clear"></div> <?php do_action( 'thankyou_' . $order->payment_method, $order_id ); endif; endif; }
/** * Prepares a sparkline to show sales in the last X days * * @param int|string $id ID of the product to show. Blank to get all orders. * @param int $days Days of stats to get. * @param string $type Type of sparkline to get. Ignored if ID is not set. * @return string */ public function sales_sparkline($id = '', $days = 7, $type = 'sales') { if ($id) { $meta_key = $type == 'sales' ? '_line_total' : '_qty'; $data = $this->get_order_report_data(array('data' => array('_product_id' => array('type' => 'order_item_meta', 'order_item_type' => 'line_item', 'function' => '', 'name' => 'product_id'), $meta_key => array('type' => 'order_item_meta', 'order_item_type' => 'line_item', 'function' => 'SUM', 'name' => 'sparkline_value'), 'post_date' => array('type' => 'post_data', 'function' => '', 'name' => 'post_date')), 'where' => array(array('key' => 'post_date', 'value' => date('Y-m-d', strtotime('midnight -' . ($days - 1) . ' days', current_time('timestamp'))), 'operator' => '>'), array('key' => 'ID', 'value' => $id, 'operator' => '=')), 'group_by' => 'YEAR(posts.post_date), MONTH(posts.post_date), DAY(posts.post_date)', 'query_type' => 'get_results', 'filter_range' => false)); } else { $data = $this->get_order_report_data(array('data' => array('_order_total' => array('type' => 'meta', 'function' => 'SUM', 'name' => 'sparkline_value'), 'post_date' => array('type' => 'post_data', 'function' => '', 'name' => 'post_date')), 'where' => array(array('key' => 'post_date', 'value' => date('Y-m-d', strtotime('midnight -' . ($days - 1) . ' days', current_time('timestamp'))), 'operator' => '>')), 'group_by' => 'YEAR(posts.post_date), MONTH(posts.post_date), DAY(posts.post_date)', 'query_type' => 'get_results', 'filter_range' => false)); } $total = 0; foreach ($data as $d) { $total += $d->sparkline_value; } if ($type == 'sales') { $tooltip = sprintf(__('Sold %s worth in the last %d days', 'jigoshop'), strip_tags(jigoshop_price($total)), $days); } else { $tooltip = sprintf(_n('Sold 1 item in the last %d days', 'Sold %d items in the last %d days', $total, 'jigoshop'), $total, $days); } $sparkline_data = array_values($this->prepare_chart_data($data, 'post_date', 'sparkline_value', $days - 1, strtotime('midnight -' . ($days - 1) . ' days', current_time('timestamp')), 'day')); return '<span class="jigoshop_sparkline ' . ($type == 'sales' ? 'lines' : 'bars') . ' tips" data-color="#777" data-tip="' . esc_attr($tooltip) . '" data-barwidth="' . 60 * 60 * 16 * 1000 . '" data-sparkline="' . esc_attr(json_encode($sparkline_data)) . '"></span>'; }
/** * Get the legend for the main chart sidebar * * @return array */ public function get_chart_legend() { if (!$this->show_categories) { return array(); } $legend = array(); $index = 0; foreach ($this->show_categories as $category) { $category = get_term($category, 'product_cat'); $total = 0; $product_ids = $this->get_products_in_category($category->term_id); foreach ($product_ids as $id) { if (isset($this->item_sales[$id])) { $total += $this->item_sales[$id]; } } $legend[] = array('title' => sprintf(__('%s sales in %s', 'jigoshop'), '<strong>' . jigoshop_price($total) . '</strong>', $category->name), 'color' => isset($this->chart_colours[$index]) ? $this->chart_colours[$index] : $this->chart_colours[0], 'highlight_series' => $index); $index++; } return $legend; }
if ($options->get('jigoshop_calc_shipping') == 'yes') { ?> <td><address> <?php if ($order->formatted_shipping_address) { echo $order->formatted_shipping_address; } else { echo '–'; } ?> </address></td> <?php } ?> <td><?php echo apply_filters('jigoshop_display_order_total', jigoshop_price($order->order_total), $order); ?> </td> <td class="nobr"><?php _e($order->status, 'jigoshop'); ?> </td> <td class="nobr alignright"> <?php if ($order->status == 'pending') { ?> <a href="<?php echo esc_url($order->get_checkout_payment_url()); ?> " class="button pay"><?php _e('Pay', 'jigoshop');
public function coupons_widget() { ?> <h4 class="section_title"><span><?php _e('Filter by coupon', 'jigoshop'); ?> </span></h4> <div class="section"> <form method="GET"> <div> <?php $data = $this->get_report_data(); $used_coupons = array(); foreach ($data as $coupons) { foreach ($coupons->coupons as $coupon) { if (!empty($coupon)) { if (!isset($used_coupons[$coupon['code']])) { $used_coupons[$coupon['code']] = $coupon; $used_coupons[$coupon['code']]['usage'] = 0; } $used_coupons[$coupon['code']]['usage'] += $coupons->usage[$coupon['code']]; } } } if ($used_coupons) { ?> <select id="coupon_codes" name="coupon_codes" class="wc-enhanced-select" data-placeholder="<?php _e('Choose coupons…', 'jigoshop'); ?> " style="width:100%;"> <option value=""><?php _e('All coupons', 'jigoshop'); ?> </option> <?php foreach ($used_coupons as $coupon) { echo '<option value="' . esc_attr($coupon['code']) . '" ' . selected(in_array($coupon['code'], $this->coupon_codes), true, false) . '>' . $coupon['code'] . '</option>'; } ?> </select> <input type="submit" class="submit button" value="<?php _e('Show', 'jigoshop'); ?> " /> <input type="hidden" name="range" value="<?php if (!empty($_GET['range'])) { echo esc_attr($_GET['range']); } ?> " /> <input type="hidden" name="start_date" value="<?php if (!empty($_GET['start_date'])) { echo esc_attr($_GET['start_date']); } ?> " /> <input type="hidden" name="end_date" value="<?php if (!empty($_GET['end_date'])) { echo esc_attr($_GET['end_date']); } ?> " /> <input type="hidden" name="page" value="<?php if (!empty($_GET['page'])) { echo esc_attr($_GET['page']); } ?> " /> <input type="hidden" name="tab" value="<?php if (!empty($_GET['tab'])) { echo esc_attr($_GET['tab']); } ?> " /> <input type="hidden" name="report" value="<?php if (!empty($_GET['report'])) { echo esc_attr($_GET['report']); } ?> " /> <?php } else { ?> <span><?php _e('No used coupons found', 'jigoshop'); ?> </span> <?php } ?> </div> </form> </div> <h4 class="section_title"><span><?php _e('Most Popular', 'jigoshop'); ?> </span></h4> <div class="section"> <table cellspacing="0"> <?php $most_popular = $used_coupons; usort($most_popular, function ($a, $b) { return $b['usage'] - $a['usage']; }); $most_popular = array_slice($most_popular, 0, 12); if ($most_popular) { foreach ($most_popular as $coupon) { echo '<tr class="' . (in_array($coupon['code'], $this->coupon_codes) ? 'active' : '') . '"> <td class="count" width="1%">' . $coupon['usage'] . '</td> <td class="name"><a href="' . esc_url(add_query_arg('coupon_codes', $coupon['code'])) . '">' . $coupon['code'] . '</a></td> </tr>'; } } else { echo '<tr><td colspan="2">' . __('No coupons found in range', 'jigoshop') . '</td></tr>'; } ?> </table> </div> <h4 class="section_title"><span><?php _e('Most Discount', 'jigoshop'); ?> </span></h4> <div class="section"> <table cellspacing="0"> <?php $most_discount = $used_coupons; usort($most_discount, function ($a, $b) { return $b['amount'] * $b['usage'] - $a['amount'] * $a['usage']; }); $most_discount = array_slice($most_discount, 0, 12); if ($most_discount) { foreach ($most_discount as $coupon) { echo '<tr class="' . (in_array($coupon['code'], $this->coupon_codes) ? 'active' : '') . '"> <td class="count" width="1%">' . jigoshop_price($coupon['amount'] * $coupon['usage']) . '</td> <td class="name"><a href="' . esc_url(add_query_arg('coupon_codes', $coupon['code'])) . '">' . $coupon['code'] . '</a></td> </tr>'; } } else { echo '<tr><td colspan="3">' . __('No coupons found in range', 'jigoshop') . '</td></tr>'; } ?> </table> </div> <script type="text/javascript"> jQuery(function($){ $('.section_title').click(function(){ var next_section = $(this).next('.section'); if($(next_section).is(':visible')) return false; $('.section:visible').slideUp(); $('.section_title').removeClass('open'); $(this).addClass('open').next('.section').slideDown(); return false; }); $('.section').slideUp(100, function(){ <?php if (empty($this->coupon_codes)) { ?> $('.section_title:eq(1)').click(); <?php } else { ?> $('.section_title:eq(0)').click(); <?php } ?> }); }); </script> <?php }
/** Output items for display in emails */ function email_order_items_list( $show_download_links = false, $show_sku = false ) { $return = ''; foreach($this->items as $item) : $_product = &new jigoshop_product( $item['id'] ); $return .= $item['qty'] . ' x ' . apply_filters('jigoshop_order_product_title', $item['name'], $_product); if ($show_sku) : $return .= ' (#' . $_product->sku . ')'; endif; $return .= ' - ' . strip_tags(jigoshop_price( $item['cost']*$item['qty'], array('ex_tax_label' => 1 ))); if ($show_download_links) : if ($_product->exists) : if ($_product->is_type('downloadable')) : $return .= PHP_EOL . ' - ' . $this->get_downloadable_file_url( $item['id'] ) . ''; endif; endif; endif; $return .= PHP_EOL; endforeach; return $return; }
/** * Function for showing the dashboard * * The dashboard shows widget for things such as: * - Products * - Sales * - Recent reviews * * @since 1.0 * @usedby jigoshop_admin_menu() */ function jigoshop_dashboard() { ?> <div class="wrap jigoshop"> <div class="icon32 jigoshop_icon"><br/></div> <h2><?php _e('Jigoshop Dashboard','jigoshop'); ?></h2> <div id="jigoshop_dashboard"> <div id="dashboard-widgets" class="metabox-holder"> <div class="postbox-container" style="width:49%;"> <div id="jigoshop_right_now" class="jigoshop_right_now postbox"> <h3><?php _e('Right Now', 'jigoshop') ?></h3> <div class="inside"> <div class="table table_content"> <p class="sub"><?php _e('Shop Content', 'jigoshop'); ?></p> <table> <tbody> <tr class="first"> <td class="first b"><a href="edit.php?post_type=product"><?php $num_posts = wp_count_posts( 'product' ); $num = number_format_i18n( $num_posts->publish ); echo $num; ?></a></td> <td class="t"><a href="edit.php?post_type=product"><?php _e('Products', 'jigoshop'); ?></a></td> </tr> <tr> <td class="first b"><a href="edit-tags.php?taxonomy=product_cat&post_type=product"><?php echo wp_count_terms('product_cat'); ?></a></td> <td class="t"><a href="edit-tags.php?taxonomy=product_cat&post_type=product"><?php _e('Product Categories', 'jigoshop'); ?></a></td> </tr> <tr> <td class="first b"><a href="edit-tags.php?taxonomy=product_tag&post_type=product"><?php echo wp_count_terms('product_tag'); ?></a></td> <td class="t"><a href="edit-tags.php?taxonomy=product_tag&post_type=product"><?php _e('Product Tag', 'jigoshop'); ?></a></td> </tr> <tr> <td class="first b"><a href="admin.php?page=attributes"><?php echo sizeof(jigoshop::$attribute_taxonomies); ?></a></td> <td class="t"><a href="admin.php?page=attributes"><?php _e('Attribute taxonomies', 'jigoshop'); ?></a></td> </tr> </tbody> </table> </div> <div class="table table_discussion"> <p class="sub"><?php _e('Orders', 'jigoshop'); ?></p> <table> <tbody> <?php $jigoshop_orders = &new jigoshop_orders(); ?> <tr class="first"> <td class="b"><a href="edit.php?post_type=shop_order&shop_order_status=pending"><span class="total-count"><?php echo $jigoshop_orders->pending_count; ?></span></a></td> <td class="last t"><a class="pending" href="edit.php?post_type=shop_order&shop_order_status=pending"><?php _e('Pending', 'jigoshop'); ?></a></td> </tr> <tr> <td class="b"><a href="edit.php?post_type=shop_order&shop_order_status=on-hold"><span class="total-count"><?php echo $jigoshop_orders->on_hold_count; ?></span></a></td> <td class="last t"><a class="onhold" href="edit.php?post_type=shop_order&shop_order_status=on-hold"><?php _e('On-Hold', 'jigoshop'); ?></a></td> </tr> <tr> <td class="b"><a href="edit.php?post_type=shop_order&shop_order_status=processing"><span class="total-count"><?php echo $jigoshop_orders->processing_count; ?></span></a></td> <td class="last t"><a class="processing" href="edit.php?post_type=shop_order&shop_order_status=processing"><?php _e('Processing', 'jigoshop'); ?></a></td> </tr> <tr> <td class="b"><a href="edit.php?post_type=shop_order&shop_order_status=completed"><span class="total-count"><?php echo $jigoshop_orders->completed_count; ?></span></a></td> <td class="last t"><a class="complete" href="edit.php?post_type=shop_order&shop_order_status=completed"><?php _e('Completed', 'jigoshop'); ?></a></td> </tr> </tbody> </table> </div> <div class="versions"> <p id="wp-version-message"><?php _e('You are using', 'jigoshop'); ?> <strong>JigoShop <?php echo JIGOSHOP_VERSION; ?>.</strong></p> </div> <div class="clear"></div> </div> </div><!-- postbox end --> <div class="postbox"> <h3 class="hndle" id="poststuff"><span><?php _e('Recent Orders', 'jigoshop') ?></span></h3> <div class="inside"> <?php $args = array( 'numberposts' => 10, 'orderby' => 'post_date', 'order' => 'DESC', 'post_type' => 'shop_order', 'post_status' => 'publish' ); $orders = get_posts( $args ); if ($orders) : echo '<ul class="recent-orders">'; foreach ($orders as $order) : $this_order = &new jigoshop_order( $order->ID ); echo ' <li> <span class="order-status '.sanitize_title($this_order->status).'">'.ucwords($this_order->status).'</span> <a href="'.admin_url('post.php?post='.$order->ID).'&action=edit">'.date_i18n('l jS \of F Y h:i:s A', strtotime($this_order->order_date)).'</a><br /> <small>'.sizeof($this_order->items).' '._n('item', 'items', sizeof($this_order->items), 'jigoshop').' <span class="order-cost">'.__('Total: ', 'jigoshop').jigoshop_price($this_order->order_total).'</span></small> </li>'; endforeach; echo '</ul>'; endif; ?> </div> </div><!-- postbox end --> <?php if (get_option('jigoshop_manage_stock')=='yes') : ?> <div class="postbox jigoshop_right_now"> <h3 class="hndle" id="poststuff"><span><?php _e('Stock Report', 'jigoshop') ?></span></h3> <div class="inside"> <?php $lowstockamount = get_option('jigoshop_notify_low_stock_amount'); if (!$lowstockamount) $lowstockamount = 1; $nostockamount = get_option('jigoshop_notify_no_stock_amount'); if (!$nostockamount) $nostockamount = 1; $outofstock = array(); $lowinstock = array(); $args = array( 'post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => -1 ); $my_query = new WP_Query($args); if ($my_query->have_posts()) : while ($my_query->have_posts()) : $my_query->the_post(); $_product = &new jigoshop_product( $my_query->post->ID ); if (!$_product->managing_stock()) continue; $thisitem = '<tr class="first"> <td class="first b"><a href="post.php?post='.$my_query->post->ID.'&action=edit">'.$_product->stock.'</a></td> <td class="t"><a href="post.php?post='.$my_query->post->ID.'&action=edit">'.$my_query->post->post_title.'</a></td> </tr>'; if ($_product->stock<=$nostockamount) : $outofstock[] = $thisitem; continue; endif; if ($_product->stock<=$lowstockamount) $lowinstock[] = $thisitem; endwhile; endif; wp_reset_query(); if (sizeof($lowinstock)==0) : $lowinstock[] = '<tr><td colspan="2">'.__('No products are low in stock.', 'jigoshop').'</td></tr>'; endif; if (sizeof($outofstock)==0) : $outofstock[] = '<tr><td colspan="2">'.__('No products are out of stock.', 'jigoshop').'</td></tr>'; endif; ?> <div class="table table_content"> <p class="sub"><?php _e('Low Stock', 'jigoshop'); ?></p> <table> <tbody> <?php echo implode('', $lowinstock); ?> </tbody> </table> </div> <div class="table table_discussion"> <p class="sub"><?php _e('Out of Stock/Backorders', 'jigoshop'); ?></p> <table> <tbody> <?php echo implode('', $outofstock); ?> </tbody> </table> </div> <div class="clear"></div> </div> </div><!-- postbox end --> <?php endif; ?> </div> <div class="postbox-container" style="width:49%; float:right;"> <?php global $current_month_offset; $current_month_offset = (int) date('m'); if (isset($_GET['month'])) $current_month_offset = (int) $_GET['month']; ?> <div class="postbox stats" id="jigoshop-stats"> <h3 class="hndle" id="poststuff"> <?php if ($current_month_offset!=date('m')) : ?><a href="admin.php?page=jigoshop&month=<?php echo $current_month_offset+1; ?>" class="next">Next Month →</a><?php endif; ?> <a href="admin.php?page=jigoshop&month=<?php echo $current_month_offset-1; ?>" class="previous">← Previous Month</a> <span><?php _e('Monthly Sales', 'jigoshop') ?></span></h3> <div class="inside"> <div id="placeholder" style="width:100%; height:300px; position:relative;"></div> <script type="text/javascript"> /* <![CDATA[ */ jQuery(function(){ function weekendAreas(axes) { var markings = []; var d = new Date(axes.xaxis.min); // go to the first Saturday d.setUTCDate(d.getUTCDate() - ((d.getUTCDay() + 1) % 7)) d.setUTCSeconds(0); d.setUTCMinutes(0); d.setUTCHours(0); var i = d.getTime(); do { // when we don't set yaxis, the rectangle automatically // extends to infinity upwards and downwards markings.push({ xaxis: { from: i, to: i + 2 * 24 * 60 * 60 * 1000 } }); i += 7 * 24 * 60 * 60 * 1000; } while (i < axes.xaxis.max); return markings; } <?php function orders_this_month( $where = '' ) { global $current_month_offset; $month = $current_month_offset; $year = (int) date('Y'); $first_day = strtotime("{$year}-{$month}-01"); $last_day = strtotime('-1 second', strtotime('+1 month', $first_day)); $after = date('Y-m-d', $first_day); $before = date('Y-m-d', $last_day); $where .= " AND post_date > '$after'"; $where .= " AND post_date < '$before'"; return $where; } add_filter( 'posts_where', 'orders_this_month' ); $args = array( 'numberposts' => -1, 'orderby' => 'post_date', 'order' => 'DESC', 'post_type' => 'shop_order', 'post_status' => 'publish' , 'suppress_filters' => false ); $orders = get_posts( $args ); $order_counts = array(); $order_amounts = array(); // Blank date ranges to begin $month = $current_month_offset; $year = (int) date('Y'); $first_day = strtotime("{$year}-{$month}-01"); $last_day = strtotime('-1 second', strtotime('+1 month', $first_day)); if ((date('m') - $current_month_offset)==0) : $up_to = date('d', strtotime('NOW')); else : $up_to = date('d', $last_day); endif; $count = 0; while ($count < $up_to) : $time = strtotime(date('Ymd', strtotime('+ '.$count.' DAY', $first_day))).'000'; $order_counts[$time] = 0; $order_amounts[$time] = 0; $count++; endwhile; if ($orders) : foreach ($orders as $order) : $order_data = &new jigoshop_order($order->ID); if ($order_data->status=='cancelled' || $order_data->status=='refunded') continue; $time = strtotime(date('Ymd', strtotime($order->post_date))).'000'; if (isset($order_counts[$time])) : $order_counts[$time]++; else : $order_counts[$time] = 1; endif; if (isset($order_amounts[$time])) : $order_amounts[$time] = $order_amounts[$time] + $order_data->order_total; else : $order_amounts[$time] = (float) $order_data->order_total; endif; endforeach; endif; remove_filter( 'posts_where', 'orders_this_month' ); ?> var d = [ <?php $values = array(); foreach ($order_counts as $key => $value) $values[] = "[$key, $value]"; echo implode(',', $values); ?> ]; for (var i = 0; i < d.length; ++i) d[i][0] += 60 * 60 * 1000; var d2 = [ <?php $values = array(); foreach ($order_amounts as $key => $value) $values[] = "[$key, $value]"; echo implode(',', $values); ?> ]; for (var i = 0; i < d2.length; ++i) d2[i][0] += 60 * 60 * 1000; var plot = jQuery.plot(jQuery("#placeholder"), [ { label: "Number of sales", data: d }, { label: "Sales amount", data: d2, yaxis: 2 } ], { series: { lines: { show: true }, points: { show: true } }, grid: { show: true, aboveData: false, color: '#ccc', backgroundColor: '#fff', borderWidth: 2, borderColor: '#ccc', clickable: false, hoverable: true, markings: weekendAreas }, xaxis: { mode: "time", timeformat: "%d %b", tickLength: 1, minTickSize: [1, "day"] }, yaxes: [ { min: 0, tickSize: 1, tickDecimals: 0 }, { position: "right", min: 0, tickDecimals: 2 } ], colors: ["#21759B", "#ed8432"] }); function showTooltip(x, y, contents) { jQuery('<div id="tooltip">' + contents + '</div>').css( { position: 'absolute', display: 'none', top: y + 5, left: x + 5, border: '1px solid #fdd', padding: '2px', 'background-color': '#fee', opacity: 0.80 }).appendTo("body").fadeIn(200); } var previousPoint = null; jQuery("#placeholder").bind("plothover", function (event, pos, item) { if (item) { if (previousPoint != item.dataIndex) { previousPoint = item.dataIndex; jQuery("#tooltip").remove(); if (item.series.label=="Number of sales") { var y = item.datapoint[1]; showTooltip(item.pageX, item.pageY, item.series.label + " - " + y); } else { var y = item.datapoint[1].toFixed(2); showTooltip(item.pageX, item.pageY, item.series.label + " - <?php echo get_jigoshop_currency_symbol(); ?>" + y); } } } else { jQuery("#tooltip").remove(); previousPoint = null; } }); }); /* ]]> */ </script> </div> </div><!-- postbox end --> <div class="postbox"> <h3 class="hndle" id="poststuff"><span><?php _e('Recent Product Reviews', 'jigoshop') ?></span></h3> <div class="inside jigoshop-reviews-widget"> <?php global $wpdb; $comments = $wpdb->get_results("SELECT *, SUBSTRING(comment_content,1,100) AS comment_excerpt FROM $wpdb->comments LEFT JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID) WHERE comment_approved = '1' AND comment_type = '' AND post_password = '' AND post_type = 'product' ORDER BY comment_date_gmt DESC LIMIT 5" ); if ($comments) : echo '<ul>'; foreach ($comments as $comment) : echo '<li>'; echo get_avatar($comment->comment_author, '32'); $rating = get_comment_meta( $comment->comment_ID, 'rating', true ); echo '<div class="star-rating" title="'.$rating.'"> <span style="width:'.($rating*16).'px">'.$rating.' '.__('out of 5', 'jigoshop').'</span></div>'; echo '<h4 class="meta"><a href="'.get_permalink($comment->ID).'#comment-'.$comment->comment_ID .'">'.$comment->post_title.'</a> reviewed by ' .strip_tags($comment->comment_author) .'</h4>'; echo '<blockquote>'.strip_tags($comment->comment_excerpt).' [...]</blockquote></li>'; endforeach; echo '</ul>'; else : echo '<p>'.__('There are no product reviews yet.', 'jigoshop').'</p>'; endif; ?> </div> </div><!-- postbox end --> <div class="postbox"> <h3 class="hndle" id="poststuff"><span><?php _e('Latest News', 'jigoshop') ?></span></h3> <div class="inside jigoshop-rss-widget"> <?php if (file_exists(ABSPATH.WPINC.'/class-simplepie.php')) { include_once(ABSPATH.WPINC.'/class-simplepie.php'); $rss = fetch_feed('http://jigoshop.com/feed'); if (!is_wp_error( $rss ) ) : $maxitems = $rss->get_item_quantity(5); $rss_items = $rss->get_items(0, $maxitems); if ( $maxitems > 0 ) : echo '<ul>'; foreach ( $rss_items as $item ) : $title = wptexturize($item->get_title(), ENT_QUOTES, "UTF-8"); $link = $item->get_permalink(); $date = $item->get_date('U'); if ( ( abs( time() - $date) ) < 86400 ) : // 1 Day $human_date = sprintf(__('%s ago','jigoshop'), human_time_diff($date)); else : $human_date = date(__('F jS Y','jigoshop'), $date); endif; echo '<li><a href="'.$link.'">'.$title.'</a> – <span class="rss-date">'.$human_date.'</span></li>'; endforeach; echo '</ul>'; else : echo '<ul><li>'.__('No items found.','jigoshop').'</li></ul>'; endif; else : echo '<ul><li>'.__('No items found.','jigoshop').'</li></ul>'; endif; } ?> </div> </div><!-- postbox end --> <div class="postbox"> <h3 class="hndle" id="poststuff"><span><?php _e('Useful Links', 'jigoshop') ?></span></h3> <div class="inside jigoshop-links-widget"> <ul class="links"> <li><a href="http://jigoshop.com/"><?php _e('Jigoshop', 'jigoshop'); ?></a> – <?php _e('Learn more about the Jigoshop plugin', 'jigoshop'); ?></li> <li><a href="http://jigoshop.com/tour/"><?php _e('Tour', 'jigoshop'); ?></a> – <?php _e('Take a tour of the plugin', 'jigoshop'); ?></li> <li><a href="http://jigoshop.com/user-guide/"><?php _e('Documentation', 'jigoshop'); ?></a> – <?php _e('Stuck? Read the plugin\'s documentation.', 'jigoshop'); ?></li> <li><a href="http://jigoshop.com/forums/"><?php _e('Forums', 'jigoshop'); ?></a> – <?php _e('Help from the community or our dedicated support team.', 'jigoshop'); ?></li> <li><a href="http://jigoshop.com/extend/extensions/"><?php _e('Jigoshop Extensions', 'jigoshop'); ?></a> – <?php _e('Extend Jigoshop with extra plugins and modules.', 'jigoshop'); ?></li> <li><a href="http://jigoshop.com/extend/themes/"><?php _e('Jigoshop Themes', 'jigoshop'); ?></a> – <?php _e('Extend Jigoshop with themes.', 'jigoshop'); ?></li> <li><a href="http://twitter.com/#!/jigoshop"><?php _e('@Jigoshop', 'jigoshop'); ?></a> – <?php _e('Follow us on Twitter.', 'jigoshop'); ?></li> <li><a href="https://github.com/jigoshop/Jigoshop"><?php _e('Jigoshop on Github', 'jigoshop'); ?></a> – <?php _e('Help extend Jigoshop.', 'jigoshop'); ?></li> <li><a href="http://wordpress.org/extend/plugins/jigoshop/"><?php _e('Jigoshop on WordPress.org', 'jigoshop'); ?></a> – <?php _e('Leave us a rating!', 'jigoshop'); ?></li> </ul> <div class="social"> <h4 class="first"><?php _e('Jigoshop Project', 'jigoshop') ?></h4> <p><?php _e('Join our growing developer community today, contribute to the jigoshop project via GitHub.') ?></p> <p><a href="https://github.com/jigoshop/Jigoshop" class="gitforked-button gitforked-forks gitforked-watchers">Fork</a></p> <script src="http://gitforked.com/api/1.1/button.js" type="text/javascript"></script> <h4><?php _e('Jigoshop Social', 'jigoshop'); ?></h4> <div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="http://jigoshop.com" send="true" layout="button_count" width="250" show_faces="true" action="like" font="arial"></fb:like> <p><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://jigoshop.com/" data-text="Jigoshop: A WordPress eCommerce solution that works" data-count="horizontal" data-via="jigoshop" data-related="Jigowatt:Creators">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></p> <p><g:plusone size="medium" href="http://jigoshop.com/"></g:plusone><script type="text/javascript" src="https://apis.google.com/js/plusone.js">{lang: 'en-GB'}</script></p> <h4><?php _e('Brought to you by', 'jigoshop'); ?></h4> <p><a href="http://jigowatt.co.uk/" title="Jigoshop is brought to you by Jigowatt"><img src="<?php echo jigoshop::plugin_url(); ?>/assets/images/jigowatt.png" alt="Jigowatt" /></a></p> <p><?php _e('From design to deployment Jigowatt delivers expert solutions to enterprise customers using Magento & WordPress open source platforms.') ?></p> </div> <div class="clear"></div> </div> </div><!-- postbox end --> </div> </div> </div> </div> <?php } ?>
function jigoshop_custom_order_columns($column) { global $post; $jigoshop_options = Jigoshop_Base::get_options(); $order = new jigoshop_order($post->ID); switch ($column) { case "order_status": echo sprintf('<mark class="%s">%s</mark>', sanitize_title($order->status), __($order->status, 'jigoshop')); break; case "order_title": echo '<a href="' . admin_url('post.php?post=' . $post->ID . '&action=edit') . '">' . sprintf(__('Order %s', 'jigoshop'), $order->get_order_number()) . '</a>'; echo '<time title="' . date_i18n(_x('c', 'date', 'jigoshop'), strtotime($post->post_date)) . '">' . date_i18n(__('F j, Y, g:i a', 'jigoshop'), strtotime($post->post_date)) . '</time>'; break; case "customer": if ($order->user_id) { $user_info = get_userdata($order->user_id); } ?> <dl> <dt><?php _e('User:'******'jigoshop'); ?> </dt> <dd><?php if (isset($user_info) && $user_info) { echo '<a href="user-edit.php?user_id=' . $user_info->ID . '">#' . $user_info->ID . ' – <strong>'; if ($user_info->first_name || $user_info->last_name) { echo $user_info->first_name . ' ' . $user_info->last_name; } else { echo $user_info->display_name; } echo '</strong></a>'; } else { _e('Guest', 'jigoshop'); } ?> </dd> <?php if ($order->billing_email) { ?> <dt><?php _e('Billing Email:', 'jigoshop'); ?> </dt> <dd><a href="mailto:<?php echo $order->billing_email; ?> "><?php echo $order->billing_email; ?> </a></dd><?php } ?> <?php if ($order->billing_phone) { ?> <dt><?php _e('Billing Phone:', 'jigoshop'); ?> </dt> <dd><?php echo $order->billing_phone; ?> </dd><?php } ?> </dl> <?php break; case "billing_address": echo '<strong>' . $order->billing_first_name . ' ' . $order->billing_last_name; if ($order->billing_company) { echo ', ' . $order->billing_company; } echo '</strong><br/>'; echo '<a target="_blank" href="http://maps.google.co.uk/maps?&q=' . urlencode($order->formatted_billing_address) . '&z=16">' . $order->formatted_billing_address . '</a>'; break; case "shipping_address": if ($order->formatted_shipping_address) { echo '<strong>' . $order->shipping_first_name . ' ' . $order->shipping_last_name; if ($order->shipping_company) { echo ', ' . $order->shipping_company; } echo '</strong><br/>'; echo '<a target="_blank" href="http://maps.google.co.uk/maps?&q=' . urlencode($order->formatted_shipping_address) . '&z=16">' . $order->formatted_shipping_address . '</a>'; } else { echo '–'; } break; case "billing_and_shipping": ?> <dl> <?php if ($order->payment_method_title) { ?> <dt><?php _e('Payment:', 'jigoshop'); ?> </dt> <dd><?php echo $order->payment_method_title; ?> </dd> <?php } ?> <?php if ($order->shipping_service) { ?> <dt><?php _e('Shipping:', 'jigoshop'); ?> </dt> <dd><?php echo sprintf(__('%s', 'jigoshop'), $order->shipping_service); ?> </dd> <?php } ?> </dl> <?php break; case "total_cost": ?> <table cellpadding="0" cellspacing="0" class="cost"> <tr> <?php if ($jigoshop_options->get('jigoshop_calc_taxes') == 'yes' && $order->has_compound_tax() || $jigoshop_options->get('jigoshop_tax_after_coupon') == 'yes' && $order->order_discount > 0) { ?> <th><?php _e('Retail Price', 'jigoshop'); ?> </th> <?php } else { ?> <th><?php _e('Subtotal', 'jigoshop'); ?> </th> <?php } ?> <td><?php echo jigoshop_price($order->order_subtotal); ?> </td> </tr> <?php if ($order->order_shipping > 0) { ?> <tr> <th><?php _e('Shipping', 'jigoshop'); ?> </th> <td><?php echo jigoshop_price($order->order_shipping); ?> </td> </tr> <?php } do_action('jigoshop_processing_fee_after_shipping'); if ($jigoshop_options->get('jigoshop_tax_after_coupon') == 'yes' && $order->order_discount > 0) { ?> <tr> <th><?php _e('Discount', 'jigoshop'); ?> </th> <td>-<?php echo jigoshop_price($order->order_discount); ?> </td> </tr> <?php } if ($jigoshop_options->get('jigoshop_calc_taxes') == 'yes' && $order->has_compound_tax() || $jigoshop_options->get('jigoshop_tax_after_coupon') == 'yes' && $order->order_discount > 0) { ?> <tr> <th><?php _e('Subtotal', 'jigoshop'); ?> </th> <td><?php echo jigoshop_price($order->order_discount_subtotal); ?> </td> </tr> <?php } if ($jigoshop_options->get('jigoshop_calc_taxes') == 'yes') { foreach ($order->get_tax_classes() as $tax_class) { if ($order->show_tax_entry($tax_class)) { ?> <tr> <th><?php echo $order->get_tax_class_for_display($tax_class) . ' (' . (double) $order->get_tax_rate($tax_class) . '%):'; ?> </th> <td><?php echo $order->get_tax_amount($tax_class); ?> </td> </tr> <?php } } } if ($jigoshop_options->get('jigoshop_tax_after_coupon') == 'no' && $order->order_discount > 0) { ?> <tr> <th><?php _e('Discount', 'jigoshop'); ?> </th> <td>-<?php echo jigoshop_price($order->order_discount); ?> </td> </tr><?php } ?> <tr> <th><?php _e('Total', 'jigoshop'); ?> </th> <td><?php echo jigoshop_price($order->order_total); ?> </td> </tr> </table> <?php break; case 'order_coupons': if (!empty($order->order_discount_coupons)) { foreach ($order->order_discount_coupons as $used_coupon) { ?> <p class="order_coupon"><?php echo '#' . $used_coupon['id'] . ' - ' . $used_coupon['code']; ?> </p> <?php } } break; } }
function jigoshop_custom_order_columns($column) { global $post; $order = &new jigoshop_order( $post->ID ); switch ($column) { case "order_status" : echo sprintf( __('<mark class="%s">%s</mark>', 'jigoshop'), sanitize_title($order->status), $order->status ); break; case "order_title" : echo '<a href="'.admin_url('post.php?post='.$post->ID.'&action=edit').'">'.sprintf( __('Order #%s', 'jigoshop'), $post->ID ).'</a>'; echo '<time title="'.date_i18n('c', strtotime($post->post_date)).'">'.date_i18n('F j, Y, g:i a', strtotime($post->post_date)).'</time>'; break; case "customer" : if ($order->user_id) $user_info = get_userdata($order->user_id); ?> <dl> <dt><?php _e('User:'******'jigoshop'); ?></dt> <dd><?php if (isset($user_info) && $user_info) : echo '<a href="user-edit.php?user_id='.$user_info->ID.'">#'.$user_info->ID.' – <strong>'; if ($user_info->first_name || $user_info->last_name) echo $user_info->first_name.' '.$user_info->last_name; else echo $user_info->display_name; echo '</strong></a>'; else : _e('Guest', 'jigoshop'); endif; ?></dd> <?php if ($order->billing_email) : ?><dt><?php _e('Billing Email:', 'jigoshop'); ?></dt> <dd><a href="mailto:<?php echo $order->billing_email; ?>"><?php echo $order->billing_email; ?></a></dd><?php endif; ?> <?php if ($order->billing_phone) : ?><dt><?php _e('Billing Tel:', 'jigoshop'); ?></dt> <dd><?php echo $order->billing_phone; ?></dd><?php endif; ?> </dl> <?php break; case "billing_address" : echo '<strong>'.$order->billing_first_name . ' ' . $order->billing_last_name; if ($order->billing_company) echo ', '.$order->billing_company; echo '</strong><br/>'; echo '<a target="_blank" href="http://maps.google.co.uk/maps?&q='.urlencode($order->formatted_billing_address).'&z=16">'.$order->formatted_billing_address.'</a>'; break; case "shipping_address" : if ($order->formatted_shipping_address) : echo '<strong>'.$order->shipping_first_name . ' ' . $order->shipping_last_name; if ($order->shipping_company) : echo ', '.$order->shipping_company; endif; echo '</strong><br/>'; echo '<a target="_blank" href="http://maps.google.co.uk/maps?&q='.urlencode($order->formatted_shipping_address).'&z=16">'.$order->formatted_shipping_address.'</a>'; else : echo '–'; endif; break; case "billing_and_shipping" : ?> <dl> <dt><?php _e('Payment:', 'jigoshop'); ?></dt> <dd><?php echo $order->payment_method; ?></dd> <dt><?php _e('Shipping:', 'jigoshop'); ?></dt> <dd><?php echo $order->shipping_method; ?></dd> </dl> <?php break; case "total_cost" : ?> <table cellpadding="0" cellspacing="0" class="cost"> <tr> <th><?php _e('Subtotal', 'jigoshop'); ?></th> <td><?php echo jigoshop_price($order->order_subtotal); ?></td> </tr> <?php if ($order->order_shipping>0) : ?><tr> <th><?php _e('Shipping', 'jigoshop'); ?></th> <td><?php echo jigoshop_price($order->order_shipping); ?></td> </tr><?php endif; ?> <?php if ($order->get_total_tax()>0) : ?><tr> <th><?php _e('Tax', 'jigoshop'); ?></th> <td><?php echo jigoshop_price($order->get_total_tax()); ?></td> </tr><?php endif; ?> <?php if ($order->order_discount>0) : ?><tr> <th><?php _e('Discount', 'jigoshop'); ?></th> <td><?php echo jigoshop_price($order->order_discount); ?></td> </tr><?php endif; ?> <tr> <th><?php _e('Total', 'jigoshop'); ?></th> <td><?php echo jigoshop_price($order->order_total); ?></td> </tr> </table> <?php break; } }
<tr> <td colspan="2"><strong><?php _e('Grand Total', 'jigoshop'); ?></strong></td> <td><strong><?php echo jigoshop_cart::get_total(); ?></strong></td> </tr> </tfoot> <tbody> <?php if (sizeof(jigoshop_cart::$cart_contents)>0) : foreach (jigoshop_cart::$cart_contents as $item_id => $values) : $_product = $values['data']; if ($_product->exists() && $values['quantity']>0) : echo ' <tr> <td>'.$_product->get_title().'</td> <td>'.$values['quantity'].'</td> <td>'.jigoshop_price($_product->get_price_excluding_tax()*$values['quantity'], array('ex_tax_label' => 1)).'</td> </tr>'; endif; endforeach; endif; ?> </tbody> </table> <div id="payment"> <?php if (jigoshop_cart::needs_payment()) : ?> <ul class="payment_methods methods"> <?php $available_gateways = jigoshop_payment_gateways::get_available_payment_gateways(); if ($available_gateways) : // Chosen Method
/** * Outputs the pay page - payment gateways can hook in here to show payment forms etc **/ function jigoshop_pay() { if (isset($_GET['pay_for_order']) && isset($_GET['order']) && isset($_GET['order_id'])) { // Pay for existing order $order_key = urldecode($_GET['order']); $order_id = (int) $_GET['order_id']; $order = new jigoshop_order($order_id); jigoshop::show_messages(); if ($order->id == $order_id && $order->order_key == $order_key && $order->status == 'pending') { jigoshop_pay_for_existing_order($order); } } else { // Pay for order after checkout step if (isset($_GET['order'])) { $order_id = $_GET['order']; } else { $order_id = 0; } if (isset($_GET['key'])) { $order_key = $_GET['key']; } else { $order_key = ''; } if ($order_id > 0) { $order = new jigoshop_order($order_id); if ($order->order_key == $order_key && $order->status == 'pending') { jigoshop::show_messages(); ?> <ul class="order_details"> <li class="order"> <?php _e('Order:', 'jigoshop'); ?> <strong><?php echo $order->get_order_number(); ?> </strong> </li> <li class="date"> <?php _e('Date:', 'jigoshop'); ?> <strong><?php echo date_i18n(get_option('date_format') . ' ' . get_option('time_format'), strtotime($order->order_date)); ?> </strong> </li> <li class="total"> <?php _e('Total:', 'jigoshop'); ?> <strong><?php echo jigoshop_price($order->order_total); ?> </strong> </li> <li class="method"> <?php _e('Payment method:', 'jigoshop'); ?> <strong><?php $gateways = jigoshop_payment_gateways::payment_gateways(); if (isset($gateways[$order->payment_method])) { echo $gateways[$order->payment_method]->title; } else { echo $order->payment_method; } ?> </strong> </li> </ul> <?php do_action('receipt_' . $order->payment_method, $order_id); ?> <div class="clear"></div> <?php } } } }
/** * Outputs the pay page - payment gateways can hook in here to show payment forms etc **/ function jigoshop_pay() { if ( isset($_GET['pay_for_order']) && isset($_GET['order']) && isset($_GET['order_id']) ) : // Pay for existing order $order_key = urldecode( $_GET['order'] ); $order_id = (int) $_GET['order_id']; $order = &new jigoshop_order( $order_id ); if ($order->id == $order_id && $order->order_key == $order_key && $order->status=='pending') : // Set customer location to order location if ($order->billing_country) jigoshop_customer::set_country( $order->billing_country ); if ($order->billing_state) jigoshop_customer::set_state( $order->billing_state ); if ($order->billing_postcode) jigoshop_customer::set_postcode( $order->billing_postcode ); // Pay form was posted - process payment if (isset($_POST['pay']) && jigoshop::verify_nonce('pay')) : // Update payment method if ($order->order_total > 0 ) : $payment_method = jigowatt_clean($_POST['payment_method']); $data = (array) maybe_unserialize( get_post_meta( $order_id, 'order_data', true ) ); $data['payment_method'] = $payment_method; update_post_meta( $order_id, 'order_data', $data ); $available_gateways = jigoshop_payment_gateways::get_available_payment_gateways(); $result = $available_gateways[$payment_method]->process_payment( $order_id ); // Redirect to success/confirmation/payment page if ($result['result']=='success') : wp_safe_redirect( $result['redirect'] ); exit; endif; else : // No payment was required for order $order->payment_complete(); wp_safe_redirect( get_permalink(get_option('jigoshop_thanks_page_id')) ); exit; endif; endif; // Show messages jigoshop::show_messages(); // Show form jigoshop_pay_for_existing_order( $order ); elseif ($order->status!='pending') : jigoshop::add_error( __('Your order has already been paid for. Please contact us if you need assistance.', 'jigoshop') ); jigoshop::show_messages(); else : jigoshop::add_error( __('Invalid order.', 'jigoshop') ); jigoshop::show_messages(); endif; else : // Pay for order after checkout step if (isset($_GET['order'])) $order_id = $_GET['order']; else $order_id = 0; if (isset($_GET['key'])) $order_key = $_GET['key']; else $order_key = ''; if ($order_id > 0) : $order = &new jigoshop_order( $order_id ); if ($order->order_key == $order_key && $order->status=='pending') : ?> <ul class="order_details"> <li class="order"> <?php _e('Order:', 'jigoshop'); ?> <strong># <?php echo $order->id; ?></strong> </li> <li class="date"> <?php _e('Date:', 'jigoshop'); ?> <strong><?php echo date(get_option('date_format'), strtotime($order->order_date)); ?></strong> </li> <li class="total"> <?php _e('Total:', 'jigoshop'); ?> <strong><?php echo jigoshop_price($order->order_total); ?></strong> </li> <li class="method"> <?php _e('Payment method:', 'jigoshop'); ?> <strong><?php $gateways = jigoshop_payment_gateways::payment_gateways(); if (isset($gateways[$order->payment_method])) echo $gateways[$order->payment_method]->title; else echo $order->payment_method; ?></strong> </li> </ul> <?php do_action( 'receipt_' . $order->payment_method, $order_id ); ?> <div class="clear"></div> <?php else : wp_safe_redirect( get_permalink(get_option('jigoshop_myaccount_page_id')) ); exit; endif; else : wp_safe_redirect( get_permalink(get_option('jigoshop_myaccount_page_id')) ); exit; endif; endif; }
function jigoshop_ajax_update_item_quantity() { /** @var jigoshop_cart $cart */ $cart = jigoshop_cart::instance(); $cart->set_quantity($_POST['item'], (int) $_POST['qty']); $items = $cart->get_cart(); $price = -1; if (isset($items[$_POST['item']])) { $item = $items[$_POST['item']]; /** @var jigoshop_product $product */ $product = $item['data']; $price = apply_filters('jigoshop_product_subtotal_display_in_cart', jigoshop_price($product->get_defined_price() * $item['quantity']), $item['product_id'], $item); } if (jigoshop_cart::show_retail_price()) { $subtotal = jigoshop_cart::get_cart_subtotal(true, false, true); } else { if (jigoshop_cart::show_retail_price() && Jigoshop_Base::get_options()->get('jigoshop_prices_include_tax') == 'no') { $subtotal = jigoshop_cart::get_cart_subtotal(true, true); } else { $subtotal = jigoshop_cart::$cart_contents_total_ex_tax; $subtotal = jigoshop_price($subtotal, array('ex_tax_label' => 1)); } } $tax = array(); foreach (jigoshop_cart::get_applied_tax_classes() as $tax_class) { if (jigoshop_cart::get_tax_for_display($tax_class)) { $tax[$tax_class] = jigoshop_cart::get_tax_amount($tax_class); } } $shipping = jigoshop_cart::get_cart_shipping_total(true, true) . '<small>' . jigoshop_cart::get_cart_shipping_title() . '</small>'; $discount = '-' . jigoshop_cart::get_total_discount(); $total = jigoshop_cart::get_total(); echo json_encode(array('success' => true, 'item_price' => $price, 'subtotal' => $subtotal, 'shipping' => $shipping, 'discount' => $discount, 'tax' => $tax, 'total' => $total)); exit; }
</dd> </dl> <?php } ?> </td> <td><span class="label"><?php _e('Qty', 'jigoshop'); ?> </span><?php echo $values['quantity']; ?> </td> <td><?php echo jigoshop_price($_product->get_price_excluding_tax($values['quantity']), array('ex_tax_label' => $_product->is_taxable())); ?> </td> </tr> <?php } } } ?> </tbody> </table> <?php $coupons = JS_Coupons::get_coupons(); if (!empty($coupons)) {
/** * Returns the products sale value, either with or without a percentage * * @return string HTML price of product (with sales) */ public function get_calculated_sale_price_html() { if ($this->is_on_sale()) { if (strstr($this->sale_price, '%')) { return '<del>' . jigoshop_price($this->regular_price) . '</del> <ins>' . jigoshop_price($this->get_price()) . '</ins><br/> <span class="discount">' . sprintf(__('%s off!', 'jigoshop'), $this->sale_price) . '</span>'; } else { return '<del>' . jigoshop_price($this->regular_price) . '</del> <ins>' . jigoshop_price($this->sale_price) . '</ins>'; } } return ''; }
function column_default($user, $column_name) { switch ($column_name) { case 'customer_name': if ($user->last_name && $user->first_name) { return $user->last_name . ', ' . $user->first_name; } else { return '-'; } case 'username': return $user->user_login; case 'location': $state_code = get_user_meta($user->ID, 'billing_state', true); $country_code = get_user_meta($user->ID, 'billing_country', true); $state = jigoshop_countries::has_state($country_code, $state_code) ? jigoshop_countries::get_state($country_code, $state_code) : $state_code; $country = jigoshop_countries::has_country($country_code) ? jigoshop_countries::get_country($country_code) : $country_code; $value = ''; if ($state) { $value .= $state . ', '; } $value .= $country; if ($value) { return $value; } else { return '-'; } case 'email': return '<a href="mailto:' . $user->user_email . '">' . $user->user_email . '</a>'; case 'spent': return jigoshop_price(jigoshop_get_customer_total_spent($user->ID)); case 'orders': return jigoshop_get_customer_order_count($user->ID); case 'last_order': $order_ids = get_posts(array('posts_per_page' => 1, 'post_type' => 'shop_order', 'post_status' => array('publish'), 'orderby' => 'date', 'order' => 'desc', 'meta_query' => array(array('key' => 'customer_user', 'value' => $user->ID)), 'fields' => 'ids')); if ($order_ids) { $order = new jigoshop_order($order_ids[0]); return '<a href="' . admin_url('post.php?post=' . $order->id . '&action=edit') . '">' . $order->get_order_number() . '</a> – ' . date_i18n(get_option('date_format'), strtotime($order->order_date)); } else { return '-'; } break; case 'user_actions': ob_start(); ?> <p> <?php do_action('jigoshop_admin_user_actions_start', $user); $actions = array(); $actions['refresh'] = array('url' => wp_nonce_url(add_query_arg('refresh', $user->ID), 'refresh'), 'name' => __('Refresh stats', 'jigoshop'), 'action' => 'refresh'); $actions['edit'] = array('url' => admin_url('user-edit.php?user_id=' . $user->ID), 'name' => __('Edit', 'jigoshop'), 'action' => 'edit'); $order_ids = $this->get_guest_orders(); $order_ids = array_map(function ($order) { return $order->ID; }, array_filter($order_ids, function ($order) use($user) { return $order->data['billing_email'] == $user->user_email; })); if ($order_ids) { $actions['link'] = array('url' => wp_nonce_url(add_query_arg('link_orders', $user->ID), 'link_orders'), 'name' => __('Link previous orders', 'jigoshop'), 'action' => 'link'); } $actions = apply_filters('jigoshop_admin_user_actions', $actions, $user); foreach ($actions as $action) { printf('<a class="button tips %s" href="%s" data-tip="%s">%s</a>', esc_attr($action['action']), esc_url($action['url']), esc_attr($action['name']), esc_attr($action['name'])); } do_action('jigoshop_admin_user_actions_end', $user); ?> </p><?php $user_actions = ob_get_contents(); ob_end_clean(); return $user_actions; } return ''; }
/** Returns the total discount amount. * * @param bool $with_price * @return bool|mixed|void */ public static function get_total_discount($with_price = true) { if (empty(self::$discount_total)) { return false; } return $with_price ? jigoshop_price(self::$discount_total) : self::$discount_total; }
<td><?php echo $item['qty']; ?> </td> <td> <?php if ($use_inc_tax && $item['cost_inc_tax'] >= 0) { ?> <?php echo jigoshop_price($item['cost_inc_tax'] * $item['qty'], array('ex_tax_label' => 0)); ?> <?php } else { ?> <?php echo jigoshop_price($item['cost'], array('ex_tax_label' => 1)); ?> <?php } ?> </td> </tr> <?php if ($show_links && $product->is_type('downloadable') && $product->exists()) { $product_id = (bool) $item['variation_id'] ? $product->variation_id : $product->id; $url = apply_filters('downloadable_file_url', $order->get_downloadable_file_url($product_id), $product, $order); if (!empty($url)) { ?> <tr> <td><?php _ex('Download link:', 'emails', 'jigoshop');
function jigoshop_shipping_calculator() { if (jigoshop_shipping::show_shipping_calculator()) { ?> <form class="shipping_calculator" action="<?php echo esc_url(jigoshop_cart::get_cart_url()); ?> " method="post"> <h2><a href="#" class="shipping-calculator-button"><?php _e('Calculate Shipping', 'jigoshop'); ?> <span>↓</span></a></h2> <section class="shipping-calculator-form"> <p class="form-row"> <select name="calc_shipping_country" id="calc_shipping_country" class="country_to_state" rel="calc_shipping_state"> <?php foreach (jigoshop_countries::get_allowed_countries() as $key => $value) { ?> <option value="<?php echo esc_attr($key); ?> " <?php selected(jigoshop_customer::get_shipping_country(), $key); ?> ><?php echo $value; ?> </option> <?php } ?> </select> </p> <div class="col2-set"> <p class="form-row col-1"> <?php $current_cc = jigoshop_customer::get_shipping_country(); $current_r = jigoshop_customer::get_shipping_state(); $states = jigoshop_countries::$states; if (jigoshop_countries::country_has_states($current_cc)) { // Dropdown ?> <span> <select name="calc_shipping_state" id="calc_shipping_state"> <option value=""><?php _e('Select a state…', 'jigoshop'); ?> </option><?php foreach ($states[$current_cc] as $key => $value) { echo '<option value="' . esc_attr($key) . '"'; if ($current_r == $key) { echo 'selected="selected"'; } echo '>' . $value . '</option>'; } ?> </select> </span> <?php } else { // Input ?> <input type="text" class="input-text" value="<?php echo esc_attr($current_r); ?> " placeholder="<?php _e('state', 'jigoshop'); ?> " name="calc_shipping_state" id="calc_shipping_state" /> <?php } ?> </p> <p class="form-row col-2"> <input type="text" class="input-text" value="<?php echo esc_attr(jigoshop_customer::get_shipping_postcode()); ?> " placeholder="<?php _e('Postcode/Zip', 'jigoshop'); ?> " title="<?php _e('Postcode', 'jigoshop'); ?> " name="calc_shipping_postcode" id="calc_shipping_postcode" /> </p> <?php do_action('jigoshop_after_shipping_calculator_fields'); ?> </div> <p> <button type="submit" name="calc_shipping" value="1" class="button"><?php _e('Update Totals', 'jigoshop'); ?> </button> </p> <p> <?php $available_methods = jigoshop_shipping::get_available_shipping_methods(); foreach ($available_methods as $method) { for ($i = 0; $i < $method->get_rates_amount(); $i++) { ?> <div class="col2-set"> <p class="form-row col-1"> <?php echo '<input type="radio" name="shipping_rates" value="' . esc_attr($method->id . ':' . $i) . '"' . ' class="shipping_select"'; if ($method->get_cheapest_service() == $method->get_selected_service($i) && $method->is_chosen()) { echo ' checked>'; } else { echo '>'; } echo $method->get_selected_service($i); ?> <p class="form-row col-2"><?php if ($method->get_selected_price($i) > 0) { echo jigoshop_price($method->get_selected_price($i)); echo __(' (ex. tax)', 'jigoshop'); } else { echo __('Free', 'jigoshop'); } ?> </div> <?php } } ?> <input type="hidden" name="cart-url" value="<?php echo esc_attr(jigoshop_cart::get_cart_url()); ?> "> <?php jigoshop::nonce_field('cart'); ?> </section> </form> <?php } }
</strong></td> <td><strong><?php echo jigoshop_price($order->order_total); ?> </strong></td> </tr> </tfoot> <tbody> <?php if (sizeof($order->items) > 0) { foreach ($order->items as $item) { echo ' <tr> <td>' . $item['name'] . '</td> <td>' . $item['qty'] . '</td> <td>' . jigoshop_price($item['cost']) . '</td> </tr>'; } } ?> </tbody> </table> <div id="payment"> <?php if ($order->order_total > 0) { ?> <ul class="payment_methods methods"> <?php $available_gateways = jigoshop_payment_gateways::get_available_payment_gateways(); if ($available_gateways) {
/** * Outputs the thankyou page **/ function jigoshop_thankyou() { $thankyou_message = __('<p>Thank you. Your order has been processed successfully.</p>', 'jigoshop'); echo apply_filters('jigoshop_thankyou_message', $thankyou_message); // Pay for order after checkout step if (isset($_GET['order'])) { $order_id = $_GET['order']; } else { $order_id = 0; } if (isset($_GET['key'])) { $order_key = $_GET['key']; } else { $order_key = ''; } if ($order_id > 0) { $order = new jigoshop_order($order_id); if ($order->order_key == $order_key) { ?> <?php do_action('jigoshop_thankyou_before_order_details', $order->id); ?> <ul class="order_details"> <li class="order"> <?php _e('Order:', 'jigoshop'); ?> <strong><?php echo $order->get_order_number(); ?> </strong> </li> <li class="date"> <?php _e('Date:', 'jigoshop'); ?> <strong><?php echo date_i18n(get_option('date_format') . ' ' . get_option('time_format'), strtotime($order->order_date)); ?> </strong> </li> <li class="total"> <?php _e('Total:', 'jigoshop'); ?> <strong><?php echo jigoshop_price($order->order_total); ?> </strong> </li> <li class="method"> <?php _e('Payment method:', 'jigoshop'); ?> <strong><?php $gateways = jigoshop_payment_gateways::payment_gateways(); if (isset($gateways[$order->payment_method])) { echo $gateways[$order->payment_method]->title; } else { echo $order->payment_method; } ?> </strong> </li> </ul> <div class="clear"></div> <?php do_action('thankyou_' . $order->payment_method, $order_id); do_action('jigoshop_thankyou', $order->id); } } echo '<p><a class="button" href="' . esc_url(jigoshop_cart::get_shop_url()) . '">' . __('← Continue Shopping', 'jigoshop') . '</a></p>'; }
/** * Pay for order notification email template - this one includes a payment link **/ function jigoshop_pay_for_order_customer_notification( $order_id ) { $order = &new jigoshop_order( $order_id ); $subject = '[' . get_bloginfo('name') . '] ' . __('Pay for Order','jigoshop'); $customer_message = sprintf( __("An order has been created for you on “%s”. To pay for this order please use the following link: %s",'jigoshop') . PHP_EOL . PHP_EOL, get_bloginfo('name'), $order->get_checkout_payment_url() ); $message = '=====================================================================' . PHP_EOL; $message .= __('ORDER #: ','jigoshop') . $order->id . '' . PHP_EOL; $message .= '=====================================================================' . PHP_EOL; $message .= $order->email_order_items_list(); if ($order->customer_note) : $message .= PHP_EOL . __('Note:','jigoshop') .$order->customer_note . PHP_EOL; endif; $message .= PHP_EOL . __('Subtotal:','jigoshop') . "\t\t\t" . $order->get_subtotal_to_display() . PHP_EOL; if ($order->order_shipping > 0) $message .= __('Shipping:','jigoshop') . "\t\t\t" . $order->get_shipping_to_display() . PHP_EOL; if ($order->order_discount > 0) $message .= __('Discount:','jigoshop') . "\t\t\t" . jigoshop_price($order->order_discount) . PHP_EOL; if ($order->get_total_tax() > 0) $message .= __('Tax:','jigoshop') . "\t\t\t\t\t" . jigoshop_price($order->get_total_tax()) . PHP_EOL; $message .= __('Total:','jigoshop') . "\t\t\t\t" . jigoshop_price($order->order_total) . ' - via ' . ucwords($order->payment_method) . PHP_EOL . PHP_EOL; $customer_message = html_entity_decode( strip_tags( $customer_message.$message ) ); wp_mail( $order->billing_email, $subject, $customer_message ); }
<?php echo $custom; ?> </dd> </dl> <?php } ?> </td> <td><?php echo $values['quantity']; ?> </td> <td> <?php echo jigoshop_price($product->get_defined_price() * $values['quantity'], array('ex_tax_label' => Jigoshop_Base::get_options()->get('jigoshop_show_prices_with_tax') == 'yes' ? 2 : 1)); ?> </td> </tr> <?php } } ?> </tbody> </table> <?php $coupons = jigoshop_cart::get_coupons(); ?> <table> <tr>
function jigoshop_order_tracking( $atts ) { extract(shortcode_atts(array( ), $atts)); global $post; if ($_POST) : $order = &new jigoshop_order(); if (isset($_POST['orderid']) && $_POST['orderid'] > 0) $order->id = (int) $_POST['orderid']; else $order->id = 0; if (isset($_POST['order_email']) && $_POST['order_email']) $order_email = trim($_POST['order_email']); else $order_email = ''; if ( !jigoshop::verify_nonce('order_tracking') ): echo '<p>'.__('You have taken too long. Please refresh the page and retry.', 'jigoshop').'</p>'; elseif ($order->id && $order_email && $order->get_order( $order->id )) : if ($order->billing_email == $order_email) : echo '<p>'.sprintf( __('Order #%s which was made %s has the status “%s”', 'jigoshop'), $order->id, human_time_diff(strtotime($order->order_date), current_time('timestamp')).__(' ago', 'jigoshop'), $order->status ); if ($order->status == 'completed') echo __(' and was completed ', 'jigoshop').human_time_diff(strtotime($order->completed_date), current_time('timestamp')).__(' ago', 'jigoshop'); echo '.</p>'; ?> <h2><?php _e('Order Details', 'jigoshop'); ?></h2> <table class="shop_table"> <thead> <tr> <th><?php _e('Title', 'jigoshop'); ?></th> <th><?php _e('SKU', 'jigoshop'); ?></th> <th><?php _e('Price', 'jigoshop'); ?></th> <th><?php _e('Quantity', 'jigoshop'); ?></th> </tr> </thead> <tfoot> <tr> <td colspan="3"><?php _e('Subtotal', 'jigoshop'); ?></td> <td><?php echo $order->get_subtotal_to_display(); ?></td> </tr> <?php if ($order->order_shipping>0) : ?><tr> <td colspan="3"><?php _e('Shipping', 'jigoshop'); ?></td> <td><?php echo $order->get_shipping_to_display(); ?></small></td> </tr><?php endif; ?> <?php if ($order->get_total_tax()>0) : ?><tr> <td colspan="3"><?php _e('Tax', 'jigoshop'); ?></td> <td><?php echo jigoshop_price($order->get_total_tax()); ?></td> </tr><?php endif; ?> <?php if ($order->order_discount>0) : ?><tr class="discount"> <td colspan="3"><?php _e('Discount', 'jigoshop'); ?></td> <td>-<?php echo jigoshop_price($order->order_discount); ?></td> </tr><?php endif; ?> <tr> <td colspan="3"><strong><?php _e('Grand Total', 'jigoshop'); ?></strong></td> <td><strong><?php echo jigoshop_price($order->order_total); ?></strong></td> </tr> </tfoot> <tbody> <?php foreach($order->items as $order_item) : $_product = &new jigoshop_product( $order_item['id'] ); echo '<tr>'; echo '<td>'.$_product->get_title().'</td>'; echo '<td>'.$_product->sku.'</td>'; echo '<td>'.jigoshop_price($_product->get_price()).'</td>'; echo '<td>'.$order_item['qty'].'</td>'; echo '</tr>'; endforeach; ?> </tbody> </table> <div style="width: 49%; float:left;"> <h2><?php _e('Billing Address', 'jigoshop'); ?></h2> <p><?php $address = $order->billing_first_name.' '.$order->billing_last_name.'<br/>'; if ($order->billing_company) $address .= $order->billing_company.'<br/>'; $address .= $order->formatted_billing_address; echo $address; ?></p> </div> <div style="width: 49%; float:right;"> <h2><?php _e('Shipping Address', 'jigoshop'); ?></h2> <p><?php $address = $order->shipping_first_name.' '.$order->shipping_last_name.'<br/>'; if ($order->shipping_company) $address .= $order->shipping_company.'<br/>'; $address .= $order->formatted_shipping_address; echo $address; ?></p> </div> <div class="clear"></div> <?php else : echo '<p>'.__('Sorry, we could not find that order id in our database. <a href="'.get_permalink($post->ID).'">Want to retry?</a>', 'jigoshop').'</p>'; endif; else : echo '<p>'.__('Sorry, we could not find that order id in our database. <a href="'.get_permalink($post->ID).'">Want to retry?</a>', 'jigoshop').'</p>'; endif; else : ?> <form action="<?php echo get_permalink($post->ID); ?>" method="post" class="track_order"> <p><?php _e('To track your order please enter your Order ID in the box below and press return. This was given to you on your receipt and in the confirmation email you should have received.', 'jigoshop'); ?></p> <p class="form-row form-row-first"><label for="orderid"><?php _e('Order ID', 'jigoshop'); ?></label> <input class="input-text" type="text" name="orderid" id="orderid" placeholder="<?php _e('Found in your order confirmation email.', 'jigoshop'); ?>" /></p> <p class="form-row form-row-last"><label for="order_email"><?php _e('Billing Email', 'jigoshop'); ?></label> <input class="input-text" type="text" name="order_email" id="order_email" placeholder="<?php _e('Email you used during checkout.', 'jigoshop'); ?>" /></p> <div class="clear"></div> <p class="form-row"><input type="submit" class="button" name="track" value="<?php _e('Track"', 'jigoshop'); ?>" /></p> <?php jigoshop::nonce_field('order_tracking') ?> </form> <?php endif; }
/** gets the total discount amount */ function get_total_discount() { if (self::$discount_total) return jigoshop_price(self::$discount_total); else return false; }