/** * 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', 'fflcommerce'), '<strong>' . fflcommerce_price($data->average_sales) . '</strong>'); break; case 'day': /** @noinspection PhpUndefinedFieldInspection */ $average_sales_title = sprintf(__('%s average daily sales', 'fflcommerce'), '<strong>' . fflcommerce_price($data->average_sales) . '</strong>'); break; case 'month': default: /** @noinspection PhpUndefinedFieldInspection */ $average_sales_title = sprintf(__('%s average monthly sales', 'fflcommerce'), '<strong>' . fflcommerce_price($data->average_sales) . '</strong>'); break; } /** @noinspection PhpUndefinedFieldInspection */ $legend[] = array('title' => sprintf(__('%s gross sales in this period', 'fflcommerce'), '<strong>' . fflcommerce_price($data->total_sales) . '</strong>'), 'placeholder' => __('This is the sum of the order totals including shipping and taxes.', 'fflcommerce'), 'color' => $this->chart_colours['sales_amount'], 'highlight_series' => 5); /** @noinspection PhpUndefinedFieldInspection */ $legend[] = array('title' => sprintf(__('%s net sales in this period', 'fflcommerce'), '<strong>' . fflcommerce_price($data->net_sales) . '</strong>'), 'placeholder' => __('This is the sum of the order totals excluding shipping and taxes.', 'fflcommerce'), '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', 'fflcommerce'), '<strong>' . $data->total_orders . '</strong>'), 'color' => $this->chart_colours['order_count'], 'highlight_series' => 1); /** @noinspection PhpUndefinedFieldInspection */ $legend[] = array('title' => sprintf(__('%s items purchased', 'fflcommerce'), '<strong>' . $data->total_items . '</strong>'), 'color' => $this->chart_colours['item_count'], 'highlight_series' => 0); /** @noinspection PhpUndefinedFieldInspection */ $legend[] = array('title' => sprintf(__('%s charged for shipping', 'fflcommerce'), '<strong>' . fflcommerce_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', 'fflcommerce'), '<strong>' . fflcommerce_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', 'fflcommerce'), $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 = fflcommerce_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') : fflcommerce_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 fflcommerce_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', 'fflcommerce'); echo ':</strong> ' . fflcommerce_price($this->total_cart_items()); echo '</p>'; do_action('fflcommerce_widget_cart_before_buttons'); // Print view cart & checkout buttons $view_cart_button_label = isset($instance['view_cart_button']) ? $instance['view_cart_button'] : __('View Cart →', 'fflcommerce'); $checkout_button_label = isset($instance['checkout_button']) ? $instance['checkout_button'] : __('Checkout →', 'fflcommerce'); echo '<p class="buttons">'; echo '<a href="' . esc_attr(fflcommerce_cart::get_cart_url()) . '" class="button">' . __($view_cart_button_label, 'fflcommerce') . '</a>'; echo '<a href="' . esc_attr(fflcommerce_cart::get_checkout_url()) . '" class="button checkout">' . __($checkout_button_label, 'fflcommerce') . '</a>'; echo '</p>'; } else { echo '<span class="empty">' . __('No products in the cart.', 'fflcommerce') . '</span>'; } // Print closing widget wrapper echo $after_widget; }
function get_order_email_arguments($order_id) { $options = FFLCommerce_Base::get_options(); $order = new fflcommerce_order($order_id); $inc_tax = $options->get('fflcommerce_calc_taxes') == 'no' || $options->get('fflcommerce_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('fflcommerce_company_name'), 'shop_address_1' => $options->get('fflcommerce_address_1'), 'shop_address_2' => $options->get('fflcommerce_address_2'), 'shop_tax_number' => $options->get('fflcommerce_tax_number'), 'shop_phone' => $options->get('fflcommerce_company_phone'), 'shop_email' => $options->get('fflcommerce_company_email'), 'customer_note' => $order->customer_note, 'order_items_table' => fflcommerce_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' => fflcommerce_get_order_taxes_list($order), 'subtotal' => $order->get_subtotal_to_display(), 'shipping' => $order->get_shipping_to_display(), 'shipping_cost' => fflcommerce_price($order->order_shipping), 'shipping_method' => $order->shipping_service, 'discount' => fflcommerce_price($order->order_discount), 'total_tax' => fflcommerce_price($order->get_total_tax()), 'total' => fflcommerce_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, '', fflcommerce_bank_transfer::get_bank_details()), 'cheque_info' => str_replace(PHP_EOL, '', $options->get('fflcommerce_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' => fflcommerce_countries::get_country($order->billing_country), 'billing_state' => strlen($order->billing_state) == 2 ? fflcommerce_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' => fflcommerce_countries::get_country($order->shipping_country), 'shipping_state' => strlen($order->shipping_state) == 2 ? fflcommerce_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('fflcommerce_calc_taxes') == 'yes') { $variables['all_tax_classes'] = $variables['order_taxes']; } else { unset($variables['order_taxes']); } return apply_filters('fflcommerce_order_email_variables', $variables, $order_id); }
/** * 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', 'fflcommerce'), strip_tags(fflcommerce_price($total)), $days); } else { $tooltip = sprintf(_n('Sold 1 item in the last %d days', 'Sold %d items in the last %d days', $total, 'fflcommerce'), $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="fflcommerce_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', 'fflcommerce'), '<strong>' . fflcommerce_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; }
<td class="cart-row-subtotal"><?php echo fflcommerce_cart::get_cart_subtotal(true, true); ?> </td> </tr> <?php } elseif (fflcommerce_cart::show_retail_price()) { ?> <tr> <th class="cart-row-subtotal-title"><?php _e('Subtotal', 'fflcommerce'); ?> </th> <?php $price = fflcommerce_cart::$cart_contents_total_ex_tax + fflcommerce_cart::$shipping_total; $price = FFLCommerce_Base::get_options()->get('fflcommerce_show_prices_with_tax') == 'yes' ? fflcommerce_price($price, array('ex_tax_label' => 1)) : fflcommerce_price($price); ?> <td class="cart-row-subtotal"><?php echo $price; ?> </td> </tr> <?php } ?> <?php if (fflcommerce_cart::tax_after_coupon()) { ?> <tr class="discount"> <th class="cart-row-discount-title"><?php _e('Discount', 'fflcommerce');
function fflcommerce_custom_order_columns($column) { global $post; $fflcommerce_options = FFLCommerce_Base::get_options(); $order = new fflcommerce_order($post->ID); switch ($column) { case "order_status": echo sprintf('<mark class="%s">%s</mark>', sanitize_title($order->status), __($order->status, 'fflcommerce')); break; case "order_title": echo '<a href="' . admin_url('post.php?post=' . $post->ID . '&action=edit') . '">' . sprintf(__('Order %s', 'fflcommerce'), $order->get_order_number()) . '</a>'; echo '<time title="' . date_i18n(_x('c', 'date', 'fflcommerce'), strtotime($post->post_date)) . '">' . date_i18n(__('F j, Y, g:i a', 'fflcommerce'), strtotime($post->post_date)) . '</time>'; break; case "customer": if ($order->user_id) { $user_info = get_userdata($order->user_id); } ?> <dl> <dt><?php _e('User:'******'fflcommerce'); ?> </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', 'fflcommerce'); } ?> </dd> <?php if ($order->billing_email) { ?> <dt><?php _e('Billing Email:', 'fflcommerce'); ?> </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:', 'fflcommerce'); ?> </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:', 'fflcommerce'); ?> </dt> <dd><?php echo $order->payment_method_title; ?> </dd> <?php } ?> <?php if ($order->shipping_service) { ?> <dt><?php _e('Shipping:', 'fflcommerce'); ?> </dt> <dd><?php echo sprintf(__('%s', 'fflcommerce'), $order->shipping_service); ?> </dd> <?php } ?> </dl> <?php break; case "total_cost": ?> <table cellpadding="0" cellspacing="0" class="cost"> <tr> <?php if ($fflcommerce_options->get('fflcommerce_calc_taxes') == 'yes' && $order->has_compound_tax() || $fflcommerce_options->get('fflcommerce_tax_after_coupon') == 'yes' && $order->order_discount > 0) { ?> <th><?php _e('Retail Price', 'fflcommerce'); ?> </th> <?php } else { ?> <th><?php _e('Subtotal', 'fflcommerce'); ?> </th> <?php } ?> <td><?php echo fflcommerce_price($order->order_subtotal); ?> </td> </tr> <?php if ($order->order_shipping > 0) { ?> <tr> <th><?php _e('Shipping', 'fflcommerce'); ?> </th> <td><?php echo fflcommerce_price($order->order_shipping); ?> </td> </tr> <?php } do_action('fflcommerce_processing_fee_after_shipping'); if ($fflcommerce_options->get('fflcommerce_tax_after_coupon') == 'yes' && $order->order_discount > 0) { ?> <tr> <th><?php _e('Discount', 'fflcommerce'); ?> </th> <td>-<?php echo fflcommerce_price($order->order_discount); ?> </td> </tr> <?php } if ($fflcommerce_options->get('fflcommerce_calc_taxes') == 'yes' && $order->has_compound_tax() || $fflcommerce_options->get('fflcommerce_tax_after_coupon') == 'yes' && $order->order_discount > 0) { ?> <tr> <th><?php _e('Subtotal', 'fflcommerce'); ?> </th> <td><?php echo fflcommerce_price($order->order_discount_subtotal); ?> </td> </tr> <?php } if ($fflcommerce_options->get('fflcommerce_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 ($fflcommerce_options->get('fflcommerce_tax_after_coupon') == 'no' && $order->order_discount > 0) { ?> <tr> <th><?php _e('Discount', 'fflcommerce'); ?> </th> <td>-<?php echo fflcommerce_price($order->order_discount); ?> </td> </tr><?php } ?> <tr> <th><?php _e('Total', 'fflcommerce'); ?> </th> <td><?php echo fflcommerce_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; } }
$service = $method->get_selected_service($i); $price = $method->get_selected_price($i); $is_taxed = fflcommerce_cart::$shipping_tax_total > 0; ?> <option value="<?php echo esc_attr($method->id . ':' . $service . ':' . $i); ?> " <?php selected($method->is_rate_selected($i)); ?> > <?php echo $service; ?> – <?php echo $price > 0 ? fflcommerce_price($price, array('ex_tax_label' => (int) $is_taxed)) : __('Free', 'fflcommerce'); ?> </option> <?php } ?> <?php } ?> </select> <?php } else { ?> <p><?php echo __(fflcommerce_shipping::get_shipping_error_message(), 'fflcommerce'); ?>
function fflcommerce_order_tracking($atts) { extract(shortcode_atts(array(), $atts)); global $post; $fflcommerce_options = FFLCommerce_Base::get_options(); if ($_POST) { $order = new fflcommerce_order(); $order->id = !empty($_POST['orderid']) ? $_POST['orderid'] : 0; if (isset($_POST['order_email']) && $_POST['order_email']) { $order_email = trim($_POST['order_email']); } else { $order_email = ''; } if (!fflcommerce::verify_nonce('order_tracking')) { echo '<p>' . __('You have taken too long. Please refresh the page and retry.', 'fflcommerce') . '</p>'; } elseif ($order->id && $order_email && $order->get_order(apply_filters('fflcommerce_shortcode_order_tracking_order_id', $order->id))) { if ($order->billing_email == $order_email) { echo '<p>' . sprintf(__('Order %s which was made %s ago and has the status "%s"', 'fflcommerce'), $order->get_order_number(), human_time_diff(strtotime($order->order_date), current_time('timestamp')), __($order->status, 'fflcommerce')); if ($order->status == 'completed') { $completed = (array) get_post_meta($order->id, '_js_completed_date', true); if (!empty($completed)) { $completed = $completed[0]; } else { $completed = ''; } // shouldn't happen, reset to be sure echo sprintf(__(' was completed %s ago', 'fflcommerce'), human_time_diff(strtotime($completed), current_time('timestamp'))); } echo '.</p>'; do_action('fflcommerce_tracking_details_info', $order); ?> <?php do_action('fflcommerce_before_track_order_details', $order->id); ?> <h2><?php _e('Order Details', 'fflcommerce'); ?> </h2> <table class="shop_table"> <thead> <tr> <th><?php _e('ID/SKU', 'fflcommerce'); ?> </th> <th><?php _e('Title', 'fflcommerce'); ?> </th> <th><?php _e('Price', 'fflcommerce'); ?> </th> <th><?php _e('Quantity', 'fflcommerce'); ?> </th> </tr> </thead> <tfoot> <tr> <?php if ($fflcommerce_options->get('fflcommerce_calc_taxes') == 'yes' && $order->has_compound_tax() || $fflcommerce_options->get('fflcommerce_tax_after_coupon') == 'yes' && $order->order_discount > 0) { ?> <td colspan="3"><?php _e('Retail Price', 'fflcommerce'); ?> </td> <?php } else { ?> <td colspan="3"><?php _e('Subtotal', 'fflcommerce'); ?> </td> <?php } ?> <td><?php echo $order->get_subtotal_to_display(); ?> </td> </tr> <?php if ($order->order_shipping > 0) { ?> <tr> <td colspan="3"><?php _e('Shipping', 'fflcommerce'); ?> </td> <td><?php echo $order->get_shipping_to_display(); ?> </td> </tr> <?php } do_action('fflcommerce_processing_fee_after_shipping'); if ($fflcommerce_options->get('fflcommerce_tax_after_coupon') == 'yes' && $order->order_discount > 0) { ?> <tr class="discount"> <td colspan="3"><?php _e('Discount', 'fflcommerce'); ?> </td> <td>-<?php echo fflcommerce_price($order->order_discount); ?> </td> </tr> <?php } if ($fflcommerce_options->get('fflcommerce_calc_taxes') == 'yes' && $order->has_compound_tax() || $fflcommerce_options->get('fflcommerce_tax_after_coupon') == 'yes' && $order->order_discount > 0) { ?> <tr> <td colspan="3"><?php _e('Subtotal', 'fflcommerce'); ?> </td> <td><?php echo fflcommerce_price($order->order_discount_subtotal); ?> </td> </tr> <?php } if ($fflcommerce_options->get('fflcommerce_calc_taxes') == 'yes') { foreach ($order->get_tax_classes() as $tax_class) { if ($order->show_tax_entry($tax_class)) { ?> <tr> <td colspan="3"><?php echo $order->get_tax_class_for_display($tax_class) . ' (' . (double) $order->get_tax_rate($tax_class) . '%):'; ?> </td> <td><?php echo $order->get_tax_amount($tax_class); ?> </td> </tr> <?php } } } ?> <?php if ($fflcommerce_options->get('fflcommerce_tax_after_coupon') == 'no' && $order->order_discount > 0) { ?> <tr class="discount"> <td colspan="3"><?php _e('Discount', 'fflcommerce'); ?> </td> <td>-<?php echo fflcommerce_price($order->order_discount); ?> </td> </tr><?php } ?> <tr> <td colspan="3"><strong><?php _e('Grand Total', 'fflcommerce'); ?> </strong></td> <td><strong><?php echo fflcommerce_price($order->order_total); ?> </strong></td> </tr> </tfoot> <tbody> <?php foreach ($order->items as $order_item) { if (isset($order_item['variation_id']) && $order_item['variation_id'] > 0) { $_product = new fflcommerce_product_variation($order_item['variation_id']); } else { $_product = new fflcommerce_product($order_item['id']); } echo '<tr>'; echo '<td>' . $_product->sku . '</td>'; echo '<td class="product-name">' . $_product->get_title(); if ($_product instanceof fflcommerce_product_variation) { echo fflcommerce_get_formatted_variation($_product, $order_item['variation']); } do_action('fflcommerce_display_item_meta_data', $order_item); echo '</td>'; echo '<td>' . fflcommerce_price($order_item['cost']) . '</td>'; echo '<td>' . $order_item['qty'] . '</td>'; echo '</tr>'; } ?> </tbody> </table> <?php do_action('fflcommerce_after_track_order_details', $order->id); ?> <div style="width: 49%; float:left;"> <h2><?php _e('Billing Address', 'fflcommerce'); ?> </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', 'fflcommerce'); ?> </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>', 'fflcommerce') . '</p>'; } } else { echo '<p>' . sprintf(__('Sorry, we could not find that order id in our database. <a href="%s">Want to retry?</a></p>', 'fflcommerce'), get_permalink($post->ID)); } } else { ?> <form action="<?php echo esc_url(get_permalink($post->ID)); ?> " method="post" class="track_order"> <p><?php _e('To track your order please enter your Order ID and email address in the boxes below and press return. This was given to you on your receipt and in the confirmation email you should have received.', 'fflcommerce'); ?> </p> <p class="form-row form-row-first"><label for="orderid"><?php _e('Order ID', 'fflcommerce'); ?> </label> <input class="input-text" type="text" name="orderid" id="orderid" placeholder="<?php _e('Found in your order confirmation email.', 'fflcommerce'); ?> " /></p> <p class="form-row form-row-last"><label for="order_email"><?php _e('Billing Email', 'fflcommerce'); ?> </label> <input class="input-text" type="text" name="order_email" id="order_email" placeholder="<?php _e('Email you used during checkout.', 'fflcommerce'); ?> " /></p> <div class="clear"></div> <p class="form-row"><input type="submit" class="button" name="track" value="<?php _e('Track"', 'fflcommerce'); ?> " /></p> <?php fflcommerce::nonce_field('order_tracking'); ?> </form> <?php } }
if ($options->get('fflcommerce_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('fflcommerce_display_order_total', fflcommerce_price($order->order_total), $order); ?> </td> <td class="nobr"><?php _e($order->status, 'fflcommerce'); ?> </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', 'fflcommerce');
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 = fflcommerce_countries::has_state($country_code, $state_code) ? fflcommerce_countries::get_state($country_code, $state_code) : $state_code; $country = fflcommerce_countries::has_country($country_code) ? fflcommerce_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 fflcommerce_price(fflcommerce_get_customer_total_spent($user->ID)); case 'orders': return fflcommerce_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 fflcommerce_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('fflcommerce_admin_user_actions_start', $user); $actions = array(); $actions['refresh'] = array('url' => wp_nonce_url(add_query_arg('refresh', $user->ID), 'refresh'), 'name' => __('Refresh stats', 'fflcommerce'), 'action' => 'refresh'); $actions['edit'] = array('url' => admin_url('user-edit.php?user_id=' . $user->ID), 'name' => __('Edit', 'fflcommerce'), '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', 'fflcommerce'), 'action' => 'link'); } $actions = apply_filters('fflcommerce_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('fflcommerce_admin_user_actions_end', $user); ?> </p><?php $user_actions = ob_get_contents(); ob_end_clean(); return $user_actions; } return ''; }
/** * Outputs the thankyou page **/ function fflcommerce_thankyou() { $thankyou_message = __('<p>Thank you. Your order has been processed successfully.</p>', 'fflcommerce'); echo apply_filters('fflcommerce_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 fflcommerce_order($order_id); if ($order->order_key == $order_key) { ?> <?php do_action('fflcommerce_thankyou_before_order_details', $order->id); ?> <ul class="order_details"> <li class="order"> <?php _e('Order:', 'fflcommerce'); ?> <strong><?php echo $order->get_order_number(); ?> </strong> </li> <li class="date"> <?php _e('Date:', 'fflcommerce'); ?> <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:', 'fflcommerce'); ?> <strong><?php echo fflcommerce_price($order->order_total); ?> </strong> </li> <li class="method"> <?php _e('Payment method:', 'fflcommerce'); ?> <strong><?php $gateways = fflcommerce_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('fflcommerce_thankyou', $order->id); } } echo '<p><a class="button" href="' . esc_url(fflcommerce_cart::get_shop_url()) . '">' . __('← Continue Shopping', 'fflcommerce') . '</a></p>'; }
/** Output items for display in emails */ public function email_order_items_list($show_download_links = false, $show_sku = false, $price_inc_tax = false) { $return = ''; // validate if any item has cost less than 0. If that's the case, we can't use price including tax $use_inc_tax = $price_inc_tax; if ($price_inc_tax) { foreach ($this->items as $item) { $use_inc_tax = $item['cost_inc_tax'] >= 0; if (!$use_inc_tax) { break; } } } foreach ($this->items as $item) { $_product = $this->get_product_from_item($item); $return .= $item['qty'] . ' x ' . html_entity_decode(apply_filters('fflcommerce_order_product_title', $item['name'], $_product, $item), ENT_QUOTES, 'UTF-8'); if ($show_sku && self::get_options()->get('fflcommerce_enable_sku') == 'yes') { $return .= ' (#' . $_product->sku . ')'; } if ($use_inc_tax && $item['cost_inc_tax'] >= 0) { $return .= ' - ' . html_entity_decode(strip_tags(fflcommerce_price($item['cost_inc_tax'] * $item['qty'], array('ex_tax_label' => 0))), ENT_COMPAT, 'UTF-8'); } else { $return .= ' - ' . html_entity_decode(strip_tags(fflcommerce_price($item['cost'], array('ex_tax_label' => 1))), ENT_COMPAT, 'UTF-8'); } if ($_product instanceof fflcommerce_product_variation) { $return .= PHP_EOL . fflcommerce_get_formatted_variation($_product, $item['variation'], true); } // Very hacky, used for GFORMS ADDONS -Rob if (!isset($_product->variation_data) && isset($item['variation'])) { if (!empty($item['variation'])) { foreach ($item['variation'] as $variation) { $return .= PHP_EOL . $variation['name'] . ': ' . $variation['value']; } } } // Check that this filter supplied by OptArt is in use before applying it. // This filter in FFL Commerce 1.3 is only used by FFL Commerce Product Addons and should be revised because // if that plugin is not active, emails will have a line item with 'Array' on each product description. // TODO: FFLCommerce never intends to use $item like this, a filter is incorrect. -JAP- global $wp_filter; if (isset($wp_filter['fflcommerce_display_item_meta_data_email'])) { $meta_data = apply_filters('fflcommerce_display_item_meta_data_email', $item); if ($meta_data != '') { $return .= PHP_EOL . $meta_data; } } if (!empty($item['customization'])) { $return .= PHP_EOL . apply_filters('fflcommerce_customized_product_label', __(' Personal: ', 'fflcommerce')) . PHP_EOL . $item['customization']; } if ($show_download_links) { if ($_product->exists()) { if ($_product->is_type('downloadable')) { if ((bool) $item['variation_id']) { $product_id = $_product->variation_id; } else { $product_id = $_product->ID; } if ($this->get_downloadable_file_url($product_id)) { $return .= PHP_EOL . __('Your download link for this file is:', 'fflcommerce'); $return .= PHP_EOL . ' - ' . apply_filters('downloadable_file_url', $this->get_downloadable_file_url($product_id), $_product, $this) . ''; } } } } $return .= PHP_EOL; } return $return; }
/** * Outputs the pay page - payment gateways can hook in here to show payment forms etc **/ function fflcommerce_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 fflcommerce_order($order_id); fflcommerce::show_messages(); if ($order->id == $order_id && $order->order_key == $order_key && $order->status == 'pending') { fflcommerce_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 fflcommerce_order($order_id); if ($order->order_key == $order_key && $order->status == 'pending') { fflcommerce::show_messages(); ?> <ul class="order_details"> <li class="order"> <?php _e('Order:', 'fflcommerce'); ?> <strong><?php echo $order->get_order_number(); ?> </strong> </li> <li class="date"> <?php _e('Date:', 'fflcommerce'); ?> <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:', 'fflcommerce'); ?> <strong><?php echo fflcommerce_price($order->order_total); ?> </strong> </li> <li class="method"> <?php _e('Payment method:', 'fflcommerce'); ?> <strong><?php $gateways = fflcommerce_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 } } } }
public function coupons_widget() { ?> <h4 class="section_title"><span><?php _e('Filter by coupon', 'fflcommerce'); ?> </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…', 'fflcommerce'); ?> " style="width:100%;"> <option value=""><?php _e('All coupons', 'fflcommerce'); ?> </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', 'fflcommerce'); ?> " /> <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', 'fflcommerce'); ?> </span> <?php } ?> </div> </form> </div> <h4 class="section_title"><span><?php _e('Most Popular', 'fflcommerce'); ?> </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', 'fflcommerce') . '</td></tr>'; } ?> </table> </div> <h4 class="section_title"><span><?php _e('Most Discount', 'fflcommerce'); ?> </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%">' . fflcommerce_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', 'fflcommerce') . '</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 }
<?php echo $custom; ?> </dd> </dl> <?php } ?> </td> <td><?php echo $values['quantity']; ?> </td> <td> <?php echo fflcommerce_price($product->get_defined_price() * $values['quantity'], array('ex_tax_label' => Jigoshop_Base::get_options()->get('fflcommerce_show_prices_with_tax') == 'yes' ? 2 : 1)); ?> </td> </tr> <?php } } ?> </tbody> </table> <?php $coupons = fflcommerce_cart::get_coupons(); ?> <table> <tr>
<?php echo fflcommerce_get_formatted_variation($product, $item['variation']); ?> <?php } ?> <?php do_action('fflcommerce_display_item_meta_data', $item); ?> </td> <td><?php echo $item['qty']; ?> </td> <td><?php echo fflcommerce_price($item['cost'], array('ex_tax_label' => 1)); ?> </td> </tr> <?php } ?> <?php } ?> </tbody> </table> <?php do_action('fflcommerce_before_order_customer_details', $order->id); ?>
/** 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 ? fflcommerce_price(self::$discount_total) : self::$discount_total; }
/** * Product selection */ public function products_widget() { ?> <h4 class="section_title"><span><?php _e('Product Search', 'fflcommerce'); ?> </span></h4> <div class="section"> <form method="GET"> <div> <input type="hidden" class="fflcommerce-product-search" style="width:203px;" name="product_ids[]" data-placeholder="<?php _e('Search for a product…', 'fflcommerce'); ?> " data-action="fflcommerce_json_search_products_and_variations" /> <input type="submit" class="submit button" value="<?php _e('Show', 'fflcommerce'); ?> " /> <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']); } ?> " /> </div> </form> </div> <h4 class="section_title"><span><?php _e('Top Sellers', 'fflcommerce'); ?> </span></h4> <div class="section"> <table cellspacing="0"> <?php $top_sellers = $this->get_order_report_data(array('data' => array('order_items' => array('type' => 'meta', 'name' => 'top_products', 'process' => true, 'limit' => 12, 'order' => 'most_sold')), 'order_types' => array('shop_order'), 'query_type' => 'get_results', 'filter_range' => true)); if ($top_sellers) { foreach ($top_sellers as $product) { echo '<tr class="' . (in_array($product->product_id, $this->product_ids) ? 'active' : '') . '"> <td class="count">' . $product->order_item_qty . '</td> <td class="name"><a href="' . esc_url(add_query_arg('product_ids', $product->product_id)) . '">' . get_the_title($product->product_id) . '</a></td> <td class="sparkline">' . $this->sales_sparkline($product->product_id, 7, 'count') . '</td> </tr>'; } } else { echo '<tr><td colspan="3">' . __('No products found in range', 'fflcommerce') . '</td></tr>'; } ?> </table> </div> <h4 class="section_title"><span><?php _e('Top Freebies', 'fflcommerce'); ?> </span></h4> <div class="section"> <table cellspacing="0"> <?php $top_freebies = $this->get_order_report_data(array('data' => array('order_items' => array('type' => 'meta', 'name' => 'top_products', 'process' => true, 'where' => array('type' => 'comparison', 'key' => 'cost', 'value' => '0', 'operator' => '0'))), 'order_types' => array('shop_order'), 'query_type' => 'get_results', 'limit' => 12, 'nocache' => true)); if ($top_freebies) { foreach ($top_freebies as $product) { echo '<tr class="' . (in_array($product->product_id, $this->product_ids) ? 'active' : '') . '"> <td class="count">' . $product->order_item_qty . '</td> <td class="name"><a href="' . esc_url(add_query_arg('product_ids', $product->product_id)) . '">' . get_the_title($product->product_id) . '</a></td> <td class="sparkline">' . $this->sales_sparkline($product->product_id, 7, 'count') . '</td> </tr>'; } } else { echo '<tr><td colspan="3">' . __('No products found in range', 'fflcommerce') . '</td></tr>'; } ?> </table> </div> <h4 class="section_title"><span><?php _e('Top Earners', 'fflcommerce'); ?> </span></h4> <div class="section"> <table cellspacing="0"> <?php $top_earners = $this->get_order_report_data(array('data' => array('order_items' => array('type' => 'meta', 'name' => 'top_products', 'process' => true, 'limit' => 12, 'order' => 'most_earned')), 'order_types' => array('shop_order'), 'query_type' => 'get_results', 'filter_range' => true)); if ($top_earners) { foreach ($top_earners as $product) { echo '<tr class="' . (in_array($product->product_id, $this->product_ids) ? 'active' : '') . '"> <td class="count">' . fflcommerce_price($product->order_item_total) . '</td> <td class="name"><a href="' . esc_url(add_query_arg('product_ids', $product->product_id)) . '">' . get_the_title($product->product_id) . '</a></td> <td class="sparkline">' . $this->sales_sparkline($product->product_id, 7, 'sales') . '</td> </tr>'; } } else { echo '<tr><td colspan="3">' . __('No products found in range', 'fflcommerce') . '</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->product_ids)) { ?> $('.section_title:eq(1)').click(); <?php } ?> }); }); </script> <?php }
function fflcommerce_ajax_update_item_quantity() { /** @var fflcommerce_cart $cart */ $cart = fflcommerce_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 fflcommerce_product $product */ $product = $item['data']; $price = apply_filters('fflcommerce_product_subtotal_display_in_cart', fflcommerce_price($product->get_defined_price() * $item['quantity']), $item['product_id'], $item); } if (fflcommerce_cart::show_retail_price()) { $subtotal = fflcommerce_cart::get_cart_subtotal(true, false, true); } else { if (fflcommerce_cart::show_retail_price() && FFLCommerce_Base::get_options()->get('fflcommerce_prices_include_tax') == 'no') { $subtotal = fflcommerce_cart::get_cart_subtotal(true, true); } else { $subtotal = fflcommerce_cart::$cart_contents_total_ex_tax + fflcommerce_cart::$shipping_total; $subtotal = fflcommerce_price($subtotal, array('ex_tax_label' => 1)); } } $tax = array(); foreach (fflcommerce_cart::get_applied_tax_classes() as $tax_class) { if (fflcommerce_cart::get_tax_for_display($tax_class)) { $tax[$tax_class] = fflcommerce_cart::get_tax_amount($tax_class); } } $shipping = fflcommerce_cart::get_cart_shipping_total(true, true) . '<small>' . fflcommerce_cart::get_cart_shipping_title() . '</small>'; $discount = '-' . fflcommerce_cart::get_total_discount(); $total = fflcommerce_cart::get_total(); echo json_encode(array('success' => true, 'item_price' => $price, 'subtotal' => $subtotal, 'shipping' => $shipping, 'discount' => $discount, 'tax' => $tax, 'total' => $total)); exit; }
function fflcommerce_shipping_calculator() { if (fflcommerce_shipping::show_shipping_calculator()) { ?> <form class="shipping_calculator" action="<?php echo esc_url(fflcommerce_cart::get_cart_url()); ?> " method="post"> <h2><a href="#" class="shipping-calculator-button"><?php _e('Calculate Shipping', 'fflcommerce'); ?> <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 (fflcommerce_countries::get_allowed_countries() as $key => $value) { ?> <option value="<?php echo esc_attr($key); ?> " <?php selected(fflcommerce_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 = fflcommerce_customer::get_shipping_country(); $current_r = fflcommerce_customer::get_shipping_state(); $states = fflcommerce_countries::$states; if (fflcommerce_countries::country_has_states($current_cc)) { // Dropdown ?> <span> <select name="calc_shipping_state" id="calc_shipping_state"> <option value=""><?php _e('Select a state…', 'fflcommerce'); ?> </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', 'fflcommerce'); ?> " 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(fflcommerce_customer::get_shipping_postcode()); ?> " placeholder="<?php _e('Postcode/Zip', 'fflcommerce'); ?> " title="<?php _e('Postcode', 'fflcommerce'); ?> " name="calc_shipping_postcode" id="calc_shipping_postcode" /> </p> <?php do_action('fflcommerce_after_shipping_calculator_fields'); ?> </div> <p> <button type="submit" name="calc_shipping" value="1" class="button"><?php _e('Update Totals', 'fflcommerce'); ?> </button> </p> <p> <?php $available_methods = fflcommerce_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 fflcommerce_price($method->get_selected_price($i)); echo __(' (ex. tax)', 'fflcommerce'); } else { echo __('Free', 'fflcommerce'); } ?> </div> <?php } } ?> <input type="hidden" name="cart-url" value="<?php echo esc_attr(fflcommerce_cart::get_cart_url()); ?> "> <?php fflcommerce::nonce_field('cart'); ?> </section> </form> <?php } }
/** * Recent Orders */ function fflcommerce_dash_recent_orders() { $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 fflcommerce_order($order->ID); $user = get_userdata($this_order->user_id); if ($user) { $user = array('link' => get_edit_user_link($user->ID), 'name' => $user->display_name); } else { $user = array('link' => '', 'name' => __('guest', 'fflcommerce')); } $total_items = 0; foreach ($this_order->items as $index => $item) { $total_items += $item['qty']; } echo ' <li> <span class="order-status ' . sanitize_title($this_order->status) . '">' . ucwords(__($this_order->status, 'fflcommerce')) . '</span> <a href="' . admin_url('post.php?post=' . $order->ID) . '&action=edit">' . $this_order->get_order_number() . '</a> <span class="order-time">' . get_the_time(__('M d, Y', 'fflcommerce'), $order->ID) . '</span> <span class="order-customer"><a href="' . $user['link'] . '">' . $user['name'] . '</a></span> <small>' . sizeof($this_order->items) . ' ' . _n('Item', 'Items', sizeof($this_order->items), 'fflcommerce') . ', <span class="total-quantity">' . __('Total Quantity', 'fflcommerce') . ' ' . $total_items . '</span> <span class="order-cost">' . fflcommerce_price($this_order->order_total) . '</span></small> </li>'; } echo '</ul>'; } }
</strong></td> <td><strong><?php echo fflcommerce_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>' . fflcommerce_price($item['cost']) . '</td> </tr>'; } } ?> </tbody> </table> <div id="payment"> <?php if ($order->order_total > 0) { ?> <ul class="payment_methods methods"> <?php $available_gateways = fflcommerce_payment_gateways::get_available_payment_gateways(); if ($available_gateways) {
/** * 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>' . fflcommerce_price($this->regular_price) . '</del> <ins>' . fflcommerce_price($this->get_price()) . '</ins><br/> <span class="discount">' . sprintf(__('%s off!', 'fflcommerce'), $this->sale_price) . '</span>'; } else { return '<del>' . fflcommerce_price($this->regular_price) . '</del> <ins>' . fflcommerce_price($this->sale_price) . '</ins>'; } } return ''; }