Exemple #1
0
         if ($summary['discount_type'] == 'pp') {
             $summary['percent'] = number_format($summary['discount'] / ($summary['subtotal'] + $summary['discount']) * 100) . '%';
         }
     }
     $format = array('discount', 'shipping', 'subtotal', 'total_tax', 'total');
     foreach ($format as $field) {
         if (isset($summary[$field])) {
             $summary[$field] = Tax::getInstance()->priceFormat($summary[$field]);
         }
     }
     $summary['state_d'] = is_numeric($summary['state_d']) ? getStateFormat($summary['state_d']) : $summary['state_d'];
     $summary['state'] = is_numeric($summary['state']) ? getStateFormat($summary['state']) : $summary['state'];
     $summary['country'] = getCountryFormat($summary['country']);
     $summary['country_d'] = getCountryFormat($summary['country_d']);
     $summary['order_date'] = formatTime($summary['order_date'], false, true);
     $summary['ship_date'] = (int) str_replace('-', '', $summary['ship_date']) > 0 ? formatDispatchDate($summary['ship_date']) : '';
     if (($notes = $GLOBALS['db']->select('CubeCart_order_notes', false, array('cart_order_id' => $summary['cart_order_id']))) !== false) {
         foreach ($notes as $key => $note) {
             $summary['notes'][] = $note['content'] . '<br />';
         }
     }
     $smarty_data['list_orders'][] = $summary;
     unset($summary, $address);
 }
 $GLOBALS['smarty']->assign('ORDER_LIST', $smarty_data['list_orders']);
 $store_logo = $GLOBALS['gui']->getLogo(true, 'invoices');
 $GLOBALS['smarty']->assign('STORE_LOGO', $store_logo);
 $GLOBALS['smarty']->assign('STORE', array('name' => $GLOBALS['config']->get('config', 'store_name'), 'address' => $GLOBALS['config']->get('config', 'store_address'), 'county' => getStateFormat($GLOBALS['config']->get('config', 'store_zone')), 'country' => getCountryFormat($GLOBALS['config']->get('config', 'store_country')), 'postcode' => $GLOBALS['config']->get('config', 'store_postcode')));
 foreach ($GLOBALS['hooks']->load('admin.order.index.print') as $hook) {
     include $hook;
 }
Exemple #2
0
 /**
  * Get order details (summary & line items)
  *
  * @param string $order_id
  * @return array
  */
 public function getOrderDetails($order_id)
 {
     $order_summary = $this->getSummary($order_id);
     $hide_prices = $GLOBALS['session']->has('hide_prices') ? $GLOBALS['session']->get('hide_prices') : false;
     $GLOBALS['session']->set('hide_prices', false);
     // Format prices etc for order emails...
     $order_summary['subtotal'] = Tax::getInstance()->priceFormat($order_summary['subtotal'], true);
     $order_summary['total'] = Tax::getInstance()->priceFormat($order_summary['total'], true);
     $order_summary['discount'] = Tax::getInstance()->priceFormat($order_summary['discount'], true);
     $order_summary['shipping'] = Tax::getInstance()->priceFormat($order_summary['shipping'], true);
     // Get taxes
     $order_taxes = $GLOBALS['db']->select('CubeCart_order_tax', array('tax_id', 'amount'), array('cart_order_id' => $order_id));
     // Put in items
     $vars = array();
     foreach ($this->_order_inventory as $item) {
         if ($item['product_id'] > 0) {
             $product = array_merge($GLOBALS['catalogue']->getProductData($item['product_id']), $item);
             $product['item_price'] = Tax::getInstance()->priceFormat($product['price']);
             $product['price'] = Tax::getInstance()->priceFormat($product['price'] * $product['quantity']);
             if (!empty($product['product_options'])) {
                 $product['product_options'] = implode(' ', unserialize($item['product_options']));
             }
             $vars['products'][] = $product;
         } else {
             $item['price'] = Tax::getInstance()->priceFormat($item['price']);
             $vars['products'][] = $item;
         }
     }
     // Put tax in
     if ($order_taxes) {
         foreach ($order_taxes as $order_tax) {
             $tax_data = Tax::getInstance()->fetchTaxDetails($order_tax['tax_id']);
             $tax['tax_name'] = $tax_data['name'];
             //$tax['tax_percent'] = sprintf('%.3F',$tax_data['tax_percent']);
             $tax['tax_percent'] = floatval($tax_data['tax_percent']);
             // get rid of zeroes
             $tax['tax_amount'] = Tax::getInstance()->priceFormat($order_tax['amount']);
             $vars['taxes'][] = $tax;
         }
     }
     $billing = array('first_name' => $order_summary['first_name'], 'last_name' => $order_summary['last_name'], 'company_name' => $order_summary['company_name'], 'line1' => $order_summary['line1'], 'line2' => $order_summary['line2'], 'town' => $order_summary['town'], 'state' => getStateFormat($order_summary['state']), 'postcode' => $order_summary['postcode'], 'country' => getCountryFormat($order_summary['country']), 'phone' => $order_summary['phone'], 'email' => $order_summary['email']);
     $shipping = array('first_name' => $order_summary['first_name_d'], 'last_name' => $order_summary['last_name_d'], 'company_name' => $order_summary['company_name_d'], 'line1' => $order_summary['line1_d'], 'line2' => $order_summary['line2_d'], 'town' => $order_summary['town_d'], 'state' => getStateFormat($order_summary['state_d']), 'postcode' => $order_summary['postcode_d'], 'country' => getCountryFormat($order_summary['country_d']));
     // Format data
     $order_summary['order_date'] = formatTime($order_summary['order_date'], false, true);
     $order_summary['ship_date'] = (int) str_replace('-', '', $order_summary['ship_date']) > 0 ? formatDispatchDate($order_summary['ship_date']) : "";
     $order_summary['gateway'] = str_replace('_', ' ', $order_summary['gateway']);
     $values['order_summary'] = $order_summary;
     $values['billing'] = $billing;
     $values['shipping'] = $shipping;
     $values['taxes'] = $vars['taxes'];
     $values['products'] = $vars['products'];
     foreach ($GLOBALS['hooks']->load('class.order.get_order_details') as $hook) {
         include $hook;
     }
     $GLOBALS['session']->set('hide_prices', $hide_prices);
     $this->_email_details = $values;
     return $this->_email_details;
 }
Exemple #3
0
 /**
  * Orders
  */
 private function _orders()
 {
     // Order history
     $template = 'templates/content.orders.php';
     if ($GLOBALS['user']->is()) {
         $GLOBALS['gui']->addBreadcrumb($GLOBALS['language']->account['your_account'], 'index.php?_a=account');
         $GLOBALS['gui']->addBreadcrumb($GLOBALS['language']->account['your_orders'], currentPage(array('cart_order_id'), null, false));
         if (isset($_GET['cart_order_id']) && Order::validOrderId(trim($_GET['cart_order_id']))) {
             if (($orders = $GLOBALS['db']->select('CubeCart_order_summary', false, array('customer_id' => $GLOBALS['user']->get('customer_id'), 'cart_order_id' => $_GET['cart_order_id']))) !== false) {
                 $template = 'templates/content.receipt.php';
                 $order = $orders[0];
                 $GLOBALS['gui']->addBreadcrumb($order['cart_order_id'], currentPage());
                 if (($items = $GLOBALS['db']->select('CubeCart_order_inventory', false, array('cart_order_id' => $order['cart_order_id']))) !== false) {
                     foreach ($items as $item) {
                         // Do price formatting
                         $item['price_total'] = $GLOBALS['tax']->priceFormat($item['price'] * $item['quantity'], true);
                         $item['price'] = $GLOBALS['tax']->priceFormat($item['price']);
                         $item['options'] = unserialize($item['product_options']);
                         $vars['items'][] = $item;
                     }
                     $GLOBALS['smarty']->assign('ITEMS', $vars['items']);
                 }
                 // Taxes
                 if (($taxes = $GLOBALS['db']->select('CubeCart_order_tax', false, array('cart_order_id' => $order['cart_order_id']))) !== false) {
                     $GLOBALS['tax']->loadTaxes($GLOBALS['config']->get('config', 'basket_tax_by_delivery') ? $order['country'] : $order['country_d']);
                     foreach ($taxes as $vat) {
                         $detail = $GLOBALS['tax']->fetchTaxDetails($vat['tax_id']);
                         $vars['taxes'][] = array('name' => $detail['name'], 'value' => $GLOBALS['tax']->priceFormat($vat['amount'], true));
                     }
                 } else {
                     $vars['taxes'][] = array('name' => $GLOBALS['language']->basket['total_tax'], 'value' => $GLOBALS['tax']->priceFormat($order['total_tax']));
                 }
                 $GLOBALS['smarty']->assign('TAXES', $vars['taxes']);
                 $order['state'] = getStateFormat($order['state']);
                 $order['country'] = getCountryFormat($order['country']);
                 $order['state_d'] = is_numeric($order['state_d']) ? getStateFormat($order['state_d']) : $order['state_d'];
                 $order['country_d'] = getCountryFormat($order['country_d']);
                 if ($order['discount'] > 0) {
                     $GLOBALS['smarty']->assign('DISCOUNT', true);
                 }
                 // Loop through price values, and do the formatting
                 foreach (array('discount', 'shipping', 'subtotal', 'total', 'total_tax') as $key) {
                     $order[$key] = $GLOBALS['tax']->priceFormat($order[$key], true);
                 }
                 $order['order_status'] = $GLOBALS['language']->order_state['name_' . $order['status']];
                 $order['order_date_formatted'] = formatTime($order['order_date'], false, true);
                 foreach ($GLOBALS['hooks']->load('class.cubecart.order_summary') as $hook) {
                     include $hook;
                 }
                 $GLOBALS['smarty']->assign('SUM', $order);
                 $GLOBALS['smarty']->assign('ORDER', $order);
                 $GLOBALS['session']->delete('ghost_customer_id');
                 // Courier Tracking URLs
                 if (!empty($order['ship_method'])) {
                     // Load the module
                     $method = str_replace(' ', '_', $order['ship_method']);
                     $ship_class = CC_ROOT_DIR . '/modules/shipping/' . $method . '/' . 'shipping.class.php';
                     if (file_exists($ship_class)) {
                         include $ship_class;
                         if (class_exists($method) && method_exists((string) $method, 'tracking')) {
                             $shipping = new $method(false);
                             $url = $shipping->tracking($order['ship_tracking']);
                             $url = empty($url) && filter_var($order['ship_tracking'], FILTER_VALIDATE_URL) ? $order['ship_tracking'] : $url;
                             $delivery = array('url' => $url, 'method' => $order['ship_method'], 'product' => $order['ship_product'], 'tracking' => $order['ship_tracking'], 'date' => !empty($order['ship_date']) && $order['ship_date'] !== '0000-00-00' ? formatDispatchDate($order['ship_date']) : '');
                         }
                         unset($ship_class);
                     } else {
                         $delivery = array('url' => filter_var($order['ship_tracking'], FILTER_VALIDATE_URL) ? $order['ship_tracking'] : '', 'method' => $order['ship_method'], 'product' => $order['ship_product'], 'tracking' => $order['ship_tracking'], 'date' => !empty($order['ship_date']) && $order['ship_date'] !== '0000-00-00' ? formatDispatchDate($order['ship_date']) : '');
                     }
                     if (empty($delivery['date']) && empty($delivery['url']) && empty($delivery['tracking'])) {
                         $delivery = false;
                     }
                 } else {
                     $delivery = false;
                 }
                 $GLOBALS['smarty']->assign('DELIVERY', $delivery);
             } else {
                 httpredir(currentPage(array('cart_order_id')));
             }
         } else {
             if (isset($_GET['cancel']) && Order::validOrderId(trim($_GET['cancel']))) {
                 $order = Order::getInstance();
                 if ($order->orderStatus(Order::ORDER_CANCELLED, $_GET['cancel'])) {
                     // Specify order was cancelled by customer
                     $note = array('admin_id' => 0, 'cart_order_id' => $_GET['cancel'], 'content' => $GLOBALS['language']->orders['cancel_by_customer']);
                     $GLOBALS['db']->insert('CubeCart_order_notes', $note);
                     $GLOBALS['gui']->setError($GLOBALS['language']->orders['notify_order_cancelled']);
                 }
                 httpredir(currentPage(array('cancel')));
             } else {
                 if (isset($_GET['reorder']) && Order::validOrderId(trim($_GET['reorder']))) {
                     $basket = $GLOBALS['db']->select('CubeCart_order_summary', array('basket'), array('cart_order_id' => $_GET['reorder'], 'customer_id' => $GLOBALS['user']->get('customer_id')));
                     $past_data = unserialize($basket[0]['basket']);
                     $GLOBALS['cart']->basket['contents'] = $past_data['contents'];
                     $GLOBALS['cart']->save();
                     httpredir('?_a=basket');
                 }
             }
             $per_page = 15;
             $page = isset($_GET['page']) ? $_GET['page'] : 1;
             $order_count = $GLOBALS['db']->select('CubeCart_order_summary', false, array('customer_id' => $GLOBALS['user']->get('customer_id')));
             $order_count = count($order_count);
             if (($paginated_orders = $GLOBALS['db']->select('CubeCart_order_summary', array('cart_order_id', 'ship_tracking', 'order_date', 'status', 'total', 'basket'), array('customer_id' => $GLOBALS['user']->get('customer_id')), array('cart_order_id' => 'DESC'), $per_page, $page)) !== false) {
                 foreach ($paginated_orders as $i => $order) {
                     $order['time'] = formatTime($order['order_date']);
                     $status = $order['status'];
                     switch ((int) $order['status']) {
                         case 1:
                             # Pending
                             $icon = 'basket.png';
                             break;
                         case 2:
                             # Processing
                             $icon = 'clock.png';
                             break;
                         case 3:
                             # Complete & dispatched
                             $icon = 'lorry.png';
                             break;
                         case 4:
                             # Declined
                         # Declined
                         case 5:
                             # Fraud
                             $icon = 'error.png';
                             break;
                         case 6:
                             # Cancelled
                             $icon = 'bin.png';
                             break;
                     }
                     $order['total'] = $GLOBALS['tax']->priceFormat($order['total'], true);
                     $existing_transactions = $GLOBALS['db']->select('CubeCart_transactions', array('id'), array('order_id' => $order['cart_order_id']));
                     $order['make_payment'] = $order['status'] == 1 && !empty($order['basket']) && !$existing_transactions ? true : false;
                     $order['cancel'] = $order['status'] == 1 && !$existing_transactions ? true : false;
                     $order['status'] = array('icon' => $icon, 'text' => $GLOBALS['language']->order_state['name_' . (int) $order['status']]);
                     $vars['orders'][] = $order;
                 }
                 foreach ($GLOBALS['hooks']->load('class.cubecart.order_list') as $hook) {
                     include $hook;
                 }
                 $GLOBALS['smarty']->assign('ORDERS', $vars['orders']);
                 $GLOBALS['smarty']->assign('PAGINATION', $GLOBALS['db']->pagination($order_count, $per_page, $page));
             }
         }
     } else {
         // Order lookup for unregistered users
         if (isset($_REQUEST['cart_order_id']) && isset($_REQUEST['email']) && filter_var($_REQUEST['email'], FILTER_VALIDATE_EMAIL) && Order::validOrderId(trim($_REQUEST['cart_order_id']))) {
             $GLOBALS['gui']->addBreadcrumb($GLOBALS['language']->orders['my_order'], currentPage());
             if (($orders = $GLOBALS['db']->select('CubeCart_order_summary', false, array('email' => $_REQUEST['email'], 'cart_order_id' => $_REQUEST['cart_order_id']))) !== false) {
                 $template = 'templates/content.receipt.php';
                 $order = $orders[0];
                 $GLOBALS['user']->setGhostId($order['customer_id']);
                 if (($items = $GLOBALS['db']->select('CubeCart_order_inventory', false, array('cart_order_id' => $order['cart_order_id']))) !== false) {
                     foreach ($items as $item) {
                         // Do price formatting
                         $item['price_total'] = $GLOBALS['tax']->priceFormat($item['price'] * $item['quantity'], true);
                         $item['price'] = $GLOBALS['tax']->priceFormat($item['price']);
                         $item['options'] = unserialize($item['product_options']);
                         $vars['items'][] = $item;
                     }
                     $GLOBALS['smarty']->assign('ITEMS', $vars['items']);
                 }
                 if (($taxes = $GLOBALS['db']->select('CubeCart_order_tax', false, array('cart_order_id' => $order['cart_order_id']))) !== false) {
                     $GLOBALS['tax']->loadTaxes($GLOBALS['config']->get('config', 'basket_tax_by_delivery') ? $order['country'] : $order['country_d']);
                     foreach ($taxes as $vat) {
                         $detail = $GLOBALS['tax']->fetchTaxDetails($vat['tax_id']);
                         $vars['taxes'][] = array('name' => $detail['name'], 'value' => $GLOBALS['tax']->priceFormat($vat['amount'], true));
                     }
                 } else {
                     $vars['taxes'][] = array('name' => $GLOBALS['language']->basket['total_tax'], 'value' => $GLOBALS['tax']->priceFormat($order['total_tax']));
                 }
                 $GLOBALS['smarty']->assign('TAXES', $vars['taxes']);
                 $order['country'] = getCountryFormat($order['country']);
                 $order['country_d'] = getCountryFormat($order['country_d']);
                 $order['state'] = is_numeric($order['state']) ? getStateFormat($order['state']) : $order['state'];
                 $order['state_d'] = is_numeric($order['state_d']) ? getStateFormat($order['state_d']) : $order['state_d'];
                 // Loop through price values, and do the formatting
                 foreach (array('discount', 'shipping', 'subtotal', 'total', 'total_tax') as $key) {
                     $order[$key] = $GLOBALS['tax']->priceFormat($order[$key], true);
                 }
                 $order['order_status'] = $GLOBALS['language']->order_state['name_' . $order['status']];
                 $order['order_date_formatted'] = formatTime($order['order_date'], false, true);
                 foreach ($GLOBALS['hooks']->load('class.cubecart.order_summary') as $hook) {
                     include $hook;
                 }
                 $GLOBALS['smarty']->assign('SUM', $order);
                 $GLOBALS['smarty']->assign('ORDER', $order);
             } else {
                 $GLOBALS['gui']->setError($GLOBALS['language']->orders['error_search_result']);
             }
         } else {
             if (isset($_REQUEST['cart_order_id']) && isset($_REQUEST['email'])) {
                 $GLOBALS['gui']->setError($GLOBALS['language']->orders['error_search_result']);
             }
             // Display a search page
             $cart_order_id = Order::validOrderId(trim($_GET['cart_order_id'])) ? trim($_GET['cart_order_id']) : '';
             $GLOBALS['smarty']->assign('ORDER_NUMBER', $cart_order_id);
             $GLOBALS['gui']->addBreadcrumb($GLOBALS['language']->orders['search'], currentPage());
         }
     }
     $content = $GLOBALS['smarty']->fetch($template);
     $GLOBALS['smarty']->assign('PAGE_CONTENT', $content);
 }