Example #1
0
 /**
  * Add product to order line items
  *
  * @param array $item
  * @param string $hash
  * @return array/false
  */
 private function _orderAddProduct($item, $hash = '')
 {
     // Add an item to the order - fetch the details from the database
     if (is_array($item)) {
         if (isset($item['certificate'])) {
             $gc = $GLOBALS['config']->get('gift_certs');
             $product = array('name' => $GLOBALS['language']->catalogue['gift_certificate'], 'price' => $item['certificate']['value'], 'product_code' => $gc['product_code'], 'digital' => (bool) $item['digital'], 'coupon_id' => $this->_createCertificate($item['certificate']['value']), 'custom' => serialize($item['certificate']), 'hash' => $hash);
         } else {
             $product = $GLOBALS['catalogue']->getProductData($item['id'], 1, false, 10, 1, false, $item['options_identifier']);
         }
         $record = array('cart_order_id' => $this->_order_id, 'product_id' => (int) $item['id'], 'quantity' => $item['quantity'], 'price' => !isset($item['certificate']) ? $item['total_price_each'] : $item['certificate']['value'], 'product_code' => !empty($product['product_code']) ? $product['product_code'] : $item['product_code'], 'name' => !empty($product['name']) ? $product['name'] : $item['name'], 'digital' => !empty($product['digital']) || !empty($product['digital_path']) ? 1 : 0, 'custom' => isset($product['custom']) ? $product['custom'] : null, 'coupon_id' => isset($product['coupon_id']) ? $product['coupon_id'] : 0, 'hash' => $hash, 'options_identifier' => $item['options_identifier'], 'options_array' => serialize($item['options']), 'product_options' => $this->serializeOptions($item['options'], $item['id']));
         foreach ($GLOBALS['hooks']->load('class.order.products.add.pre') as $hook) {
             include $hook;
         }
         $insert_id = $GLOBALS['db']->insert('CubeCart_order_inventory', $record);
         // Taxes
         $tax_on = $GLOBALS['config']->get('config', 'basket_tax_by_delivery') ? 'delivery_address' : 'billing_address';
         $tax_state_id = is_numeric($this->_basket[$tax_on]['state_id']) ? $this->_basket[$tax_on]['state_id'] : getStateFormat($this->_basket[$tax_on]['state_id'], 'name', 'id');
         $tax_amount = $record['price'] * $record['quantity'];
         // By this stage product prices will always be excluding tax!
         if (isset($tax_state_id)) {
             Tax::getInstance()->productTax($tax_amount, (int) $product['tax_type'], false, $tax_state_id);
         } else {
             Tax::getInstance()->productTax($tax_amount, (int) $product['tax_type'], false);
         }
         if ($record['digital'] && !isset($item['certificate'])) {
             // If digital, create a download code
             $this->_createDownload($item['id'], (int) $insert_id);
         }
         return $product;
     }
     return false;
 }
Example #2
0
         $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;
     }
     // Parse
     $template = $GLOBALS['smarty']->fetch('templates/orders.print.php');
     $print_hash = md5(implode('{@}', $summaries[0]));
     $cleanup = '<?php unlink(__FILE__); ?>';
     $filename = 'print.' . $print_hash . '.php';
     if (file_put_contents(CC_FILES_DIR . $filename, $template . $cleanup)) {
         httpredir($GLOBALS['storeURL'] . '/files/' . $filename);
     } else {
         $GLOBALS['main']->setACPWarning($lang['orders']['error_print_generate']);
         httpredir(currentPage(array('print')));
     }
 } else {
Example #3
0
 /**
  * Get the current basket
  *
  * @return basket/false
  */
 public function get()
 {
     if ($GLOBALS['session']->get('hide_prices')) {
         return false;
     }
     if (!empty($this->basket['contents']) && is_array($this->basket['contents'])) {
         $this->_discount = $this->_subtotal = $this->_total_tax_add = $this->_weight = 0;
         // Include inline shipping maths for Per Category Shipping
         $ship_by_cat = $GLOBALS['config']->get('Per_Category');
         $sbc_path = CC_ROOT_DIR . '/modules/shipping/Per_Category/line.inc.php';
         if (file_exists($sbc_path) && isset($ship_by_cat['status']) && $ship_by_cat['status']) {
             require_once $sbc_path;
             $line_shipping = new Per_Category_Line($ship_by_cat, $this->basket);
         } else {
             $ship_by_cat = array('status', false);
         }
         $tax_on = $GLOBALS['config']->get('config', 'basket_tax_by_delivery') ? 'delivery_address' : 'billing_address';
         $tax_country = 0;
         if (isset($this->basket[$tax_on])) {
             $tax_country = (int) $this->basket[$tax_on]['country_id'];
         }
         if (empty($tax_country)) {
             $tax_country = $GLOBALS['config']->get('config', 'store_country');
         }
         $GLOBALS['tax']->loadTaxes($tax_country);
         foreach ($this->basket['contents'] as $hash => $item) {
             if (empty($item) || !is_array($item)) {
                 ## Keep things tidy
                 unset($this->basket['contents'][$hash]);
                 continue;
             }
             // Basket Contents
             if (is_numeric($item['id'])) {
                 $item['options_identifier'] = isset($item['options_identifier']) ? $item['options_identifier'] : '';
                 $product = $GLOBALS['catalogue']->getProductData($item['id'], $item['quantity'], false, 10, 1, false, $item['options_identifier']);
                 if (!$product) {
                     // Warn that the product has been removed
                     if (!empty($item['name'])) {
                         $GLOBALS['gui']->setError(sprintf($GLOBALS['language']->checkout['error_item_not_available'], $item['name']));
                     }
                     unset($this->basket['contents'][$hash]);
                     continue;
                 }
                 $product['quantity'] = $item['quantity'];
                 if ($GLOBALS['tax']->salePrice($product['price'], $product['sale_price'])) {
                     $product['price'] = $product['sale_price'];
                 }
                 $product['price_display'] = $product['price'];
                 $product['base_price_display'] = $GLOBALS['tax']->priceFormat($product['price'], true);
                 $product['remove_options_tax'] = false;
                 if ($product['tax_inclusive']) {
                     // Remove tax from the items by default, everything internally should be sans-tax
                     $GLOBALS['tax']->inclusiveTaxRemove($product['price'], $product['tax_type']);
                     $product['tax_inclusive'] = false;
                     $product['remove_options_tax'] = true;
                 }
                 $product['option_line_price'] = $product['option_price_ignoring_tax'] = 0;
                 if (isset($item['options']) && is_array($item['options'])) {
                     foreach ($item['options'] as $option_id => $option_data) {
                         if (is_array($option_data)) {
                             // Text option
                             foreach ($option_data as $trash => $option_value) {
                                 if (($assign_id = $GLOBALS['db']->select('CubeCart_option_assign', false, array('product' => (int) $item['id'], 'option_id' => $option_id))) !== false) {
                                     $assign_id = $assign_id[0]['assign_id'];
                                 } else {
                                     $assign_id = 0;
                                 }
                                 $value = $GLOBALS['catalogue']->getOptionData((int) $option_id, $assign_id);
                                 if ($value) {
                                     Cart::updateProductDataWithOption($product, $value);
                                     $value['value_name'] = $option_value;
                                     $product['options'][] = $value;
                                 }
                             }
                         } else {
                             if (is_numeric($option_data)) {
                                 // Select option
                                 $value = $GLOBALS['catalogue']->getOptionData((int) $option_id, (int) $option_data);
                                 if ($value) {
                                     Cart::updateProductDataWithOption($product, $value);
                                     $product['options'][] = $value;
                                 }
                             }
                         }
                     }
                 } else {
                     $product['options'] = false;
                 }
                 $product['price'] = sprintf("%0.2F", $product['price']);
                 // Add the total product price inc options etc for payment gateways
                 $this->basket['contents'][$hash]['option_line_price'] = $product['option_line_price'];
                 $this->basket['contents'][$hash]['total_price_each'] = $product['price'];
                 $this->basket['contents'][$hash]['description'] = substr(strip_tags($product['description']), 0, 255);
                 $this->basket['contents'][$hash]['name'] = $product['name'];
                 $this->basket['contents'][$hash]['product_code'] = $product['product_code'];
                 $this->basket['contents'][$hash]['product_weight'] = $product['product_weight'];
             } else {
                 if (!isset($item['certificate'])) {
                     continue;
                 }
                 $gc = $GLOBALS['config']->get('gift_certs');
                 $product = array('quantity' => $item['quantity'], 'product_code' => $gc['product_code'], 'price' => $item['certificate']['value'], 'name' => sprintf('%s (%s)', $GLOBALS['language']->catalogue['gift_certificate'], $GLOBALS['tax']->priceFormat($item['certificate']['value'], true)), 'digital' => (bool) $item['digital'], 'tax_type' => $gc['taxType'], 'tax_inclusive' => true, 'options' => array(), 'option_price_ignoring_tax' => 0);
                 $product['price_display'] = $product['price'];
             }
             if ($product['digital']) {
                 $this->basket_digital = true;
             }
             if (!empty($product['absolute_price'])) {
                 $product['line_price_display'] = $product['option_price_ignoring_tax'];
                 $product['price_display'] = $product['option_price_ignoring_tax'] * $item['quantity'];
             } else {
                 $product['line_price_display'] = $product['price_display'] + $product['option_price_ignoring_tax'];
                 $product['price_display'] = ($product['price_display'] + $product['option_price_ignoring_tax']) * $item['quantity'];
             }
             ## Update Subtotals
             $product['line_price'] = $product['price'];
             $product['price'] = $product['price'] * $item['quantity'];
             $this->_subtotal += $product['price'];
             $this->_weight += $product['quantity'] * $product['product_weight'];
             $this->basket_data[$hash] = $product;
             // Calculate Taxes
             $tax_state_id = is_numeric($this->basket[$tax_on]['state_id']) ? $this->basket[$tax_on]['state_id'] : getStateFormat($this->basket[$tax_on]['state_id'], 'name', 'id');
             if (isset($tax_state_id)) {
                 $product_tax = $GLOBALS['tax']->productTax($product['price'], (int) $product['tax_type'], (bool) $product['tax_inclusive'], $tax_state_id);
             } else {
                 $product_tax = $GLOBALS['tax']->productTax($product['price'], (int) $product['tax_type'], (bool) $product['tax_inclusive']);
             }
             $this->basket['contents'][$hash]['tax_each'] = $product_tax;
             // Calculate Line Shipping Price if enabled
             if (isset($ship_by_cat['status']) && $ship_by_cat['status']) {
                 $assigned_categories = $GLOBALS['catalogue']->getCategoryStatusByProductID($product['product_id']);
                 foreach ($assigned_categories as $assigned_category) {
                     if ($assigned_category['primary']) {
                         $assigned_category_id = $assigned_category['cat_id'];
                         continue;
                     }
                 }
                 $category = $GLOBALS['catalogue']->getCategoryData($assigned_category_id);
                 $line_shipping->lineCalc($product, $category);
             }
         }
         // Put By_Cat shipping prices into basket for calc class
         if (isset($ship_by_cat['status']) && $ship_by_cat['status']) {
             $this->basket['By_Category_Shipping'] = $line_shipping->_lineShip + $line_shipping->_perShipPrice;
         }
         // Shipping
         $this->_shipping = isset($this->basket['shipping']) && !empty($this->basket['shipping']) ? $this->basket['shipping']['value'] : 0;
         if (isset($this->basket[$tax_on]['state_id']) && isset($this->basket['shipping'])) {
             $GLOBALS['tax']->productTax($this->_shipping, $this->basket['shipping']['tax_id'], false, $this->basket[$tax_on]['state_id'], 'shipping');
         }
         // Apply Discounts
         $this->_applyDiscounts();
         $this->basket['weight'] = sprintf('%.3F', $this->_weight);
         $this->basket['discount'] = sprintf('%.2F', $this->_discount);
         $this->basket['subtotal'] = sprintf('%.2F', $this->_subtotal);
         $taxes = $GLOBALS['tax']->fetchTaxAmounts();
         foreach ($GLOBALS['hooks']->load('class.cart.get.fetchtaxes') as $hook) {
             include $hook;
         }
         $this->basket['total_tax'] = sprintf('%.2F', $taxes['applied']);
         $this->_total = $this->_subtotal + $this->_shipping + $this->basket['total_tax'];
         // if we are using per-product coupon, the prices are already reduced, so the total is fine
         if (!$this->_item_discount) {
             $this->_total -= $this->_discount;
         }
         if ($this->_total < 0) {
             $this->_total = 0;
         }
         $this->basket['total'] = sprintf('%.2F', $this->_total);
         foreach ($GLOBALS['hooks']->load('class.cart.get') as $hook) {
             include $hook;
         }
         $this->save();
         return $this->basket_data;
     }
     return false;
 }
Example #4
0
 /**
  * Format address array
  *
  * @param array
  * @return array
  */
 public function formatAddress($address = array(), $user_defined = true, $estimate = false)
 {
     if (!$user_defined && !is_array($address)) {
         if ($GLOBALS['config']->get('config', 'disable_estimates') == '1') {
             $address = array('postcode' => '', 'country' => '', 'state' => '');
         } else {
             $address = array('postcode' => $GLOBALS['config']->get('config', 'store_postcode'), 'country' => $GLOBALS['config']->get('config', 'store_country'), 'state' => $GLOBALS['config']->get('config', 'store_zone'));
         }
     }
     $state_field = is_numeric($address['state']) ? 'id' : 'name';
     $address['state_id'] = getStateFormat($address['state'], $state_field, 'id');
     $address['country_id'] = $address['country'];
     $address['country'] = getCountryFormat($address['country_id']);
     $address['state_abbrev'] = getStateFormat($address['state'], $state_field, 'abbrev');
     $address['country_iso'] = getCountryFormat($address['country_id'], 'numcode', 'iso');
     $address['country_iso3'] = getCountryFormat($address['country_id'], 'numcode', 'iso3');
     $address['state'] = getStateFormat($address['state_id']);
     $address['user_defined'] = $user_defined;
     $address['estimate'] = $estimate;
     return $address;
 }
Example #5
0
if (($tax_classes = $GLOBALS['db']->select('CubeCart_tax_class')) !== false) {
    $GLOBALS['smarty']->assign('TAX_CLASSES', $tax_classes);
    foreach ($tax_classes as $class) {
        $tax_class[$class['id']] = $class['tax_name'];
    }
}
## Get Tax Details
if (($tax_details = $GLOBALS['db']->select('CubeCart_tax_details')) !== false) {
    foreach ($tax_details as $tax_detail) {
        if ($tax_detail['status']) {
            $tax_detail['enabled'] = 'selected="selected"';
        } else {
            $tax_detail['disabled'] = 'selected="selected"';
        }
        $tax_detail_array[$tax_detail['id']] = $tax_detail['name'];
        $smarty_data['tax_details'][] = $tax_detail;
    }
    $GLOBALS['smarty']->assign('TAX_DETAILS', $smarty_data['tax_details']);
}
## Get Tax Rules
if (($tax_rules = $GLOBALS['db']->select('CubeCart_tax_rates')) !== false) {
    foreach ($tax_rules as $rule) {
        $rule['country'] = getCountryFormat($rule['country_id']);
        $rule['state'] = $rule['county_id'] != 0 ? getStateFormat($rule['county_id']) : $lang['common']['regions_all'];
        $rule['class'] = $tax_class[$rule['type_id']];
        $rule['detail'] = $tax_detail_array[$rule['details_id']];
        $smarty_data['tax_rules'][] = $rule;
    }
    $GLOBALS['smarty']->assign('TAX_RULES', $smarty_data['tax_rules']);
}
$page_content = $GLOBALS['smarty']->fetch('templates/settings.tax.php');
Example #6
0
                 $jsonArray = array();
                 foreach ($counties as $state) {
                     $jsonArray[getCountryFormat($state['country_id'], 'id', 'numcode')][] = array('id' => $state['id'], 'name' => $state['name']);
                 }
                 $GLOBALS['smarty']->assign('JSON_STATE', json_encode($jsonArray));
             }
         }
         $GLOBALS['smarty']->assign('ADDRESS', $address[0]);
     }
     $GLOBALS['smarty']->assign('DISPLAY_ADDRESS_EDIT', true);
 } else {
     // Get Addresses
     if (($addresses = $GLOBALS['db']->select('CubeCart_addressbook', false, array('customer_id' => $customer_id))) !== false) {
         foreach ($addresses as $address) {
             $address['country_name'] = getCountryFormat($address['country']);
             $address['state_name'] = getStateFormat($address['state']);
             $address['edit'] = currentPage(null, array('address_id' => $address['address_id']));
             $address['delete'] = currentPage(null, array('delete_addr' => $address['address_id']));
             $address['json'] = json_encode($address);
             $smarty_data['list_address'][] = $address;
         }
         $GLOBALS['smarty']->assign('ADDRESS_LIST', $smarty_data['list_address']);
     }
     $GLOBALS['smarty']->assign('DISPLAY_ADDRESS_LIST', true);
 }
 // Get group memberships
 if (($memberships = $GLOBALS['db']->select('CubeCart_customer_membership', false, array('customer_id' => $customer_id))) !== false) {
     foreach ($GLOBALS['hooks']->load('admin.customer.group.get') as $hook) {
         include $hook;
     }
     foreach ($memberships as $membership) {
Example #7
0
 /**
  * Admin search function
  *
  * @param string $type
  * @param string $search_string
  * @return data/false
  */
 public static function search($type, $search_string)
 {
     $data = false;
     if (!empty($type) && !empty($search_string)) {
         switch (strtolower($type)) {
             case 'user':
                 if (($results = $GLOBALS['db']->select('CubeCart_customer', false, array('~' . $search_string => array('last_name', 'first_name', 'email')), false, false, false, false)) !== false) {
                     foreach ($results as $result) {
                         $data[] = array('value' => $result['customer_id'], 'display' => $result['first_name'] . ' ' . $result['last_name'], 'info' => $result['email'], 'data' => $result);
                     }
                 }
                 break;
             case 'address':
                 if (($results = $GLOBALS['db']->select('CubeCart_addressbook', false, array('customer_id' => (int) $search_string), false, false, false, false)) !== false) {
                     foreach ($results as $result) {
                         $result['state'] = getStateFormat($result['state']);
                         $result['country'] = getCountryFormat($result['country']);
                         $data[] = $result;
                     }
                 }
                 break;
             case 'product':
                 // Limited to a maximum of 15 results, in order to prevent it going mental
                 if (($results = $GLOBALS['db']->select('CubeCart_inventory', false, array('~' . $search_string => array('name', 'product_code')), false, 15, false, false)) !== false) {
                     foreach ($results as $result) {
                         $lower_price = Tax::getInstance()->salePrice($result['price'], $result['sale_price'], false);
                         if ($lower_price && $lower_price < $result['price']) {
                             $result['price'] = $lower_price;
                         }
                         $data[] = array('value' => $result['product_id'], 'display' => $result['name'], 'info' => Tax::getInstance()->priceFormat($result['price']), 'data' => $result);
                     }
                 }
                 break;
             case 'newsletter':
                 $newsletter = Newsletter::getInstance();
                 $status = $newsletter->sendNewsletter($_GET['q'], $_GET['page']);
                 if (is_array($status)) {
                     $data = $status;
                 } else {
                     $data = $status ? array('complete' => 'true', 'percent' => 100) : array('error' => 'true');
                 }
                 break;
             case 'files':
                 if ($_GET['dir'] == '/') {
                     $dir = false;
                 } elseif ($_GET['dir'] == '/') {
                     $dir = false;
                 } else {
                     $dir = $_GET['dir'];
                 }
                 $filemanager = new FileManager($_GET['group'], $dir);
                 // Directories
                 if (($dirs = $filemanager->findDirectories()) !== false) {
                     foreach ($dirs[$filemanager->formatPath($dir)] as $parent => $folder) {
                         $path = !empty($dir) ? '/' : '';
                         $json[] = array('type' => 'directory', 'path' => urldecode($dir . basename($folder) . '/'), 'name' => basename($folder));
                     }
                 }
                 if (($files = $filemanager->listFiles()) !== false) {
                     $catalogue = new Catalogue();
                     foreach ($files as $result) {
                         if ($filemanager->getMode() == FileManager::FM_FILETYPE_IMG) {
                             $fetch = $catalogue->imagePath($result['file_id'], 'medium');
                             $path = $name = $fetch;
                         } else {
                             $path = $result['filepath'];
                             $name = $result['filename'];
                         }
                         $json[] = array('type' => 'file', 'path' => dirname($path) . '/', 'file' => basename($result['filename']), 'name' => basename($name), 'id' => $result['file_id'], 'description' => $result['description'], 'mime' => $result['mimetype']);
                     }
                 }
                 $data = isset($json) && is_array($json) ? $json : false;
                 break;
             default:
                 return false;
                 break;
         }
         if (!$data) {
             $data = array();
         }
         return json_encode($data);
     }
     return false;
 }
Example #8
0
 /**
  * Receipt
  */
 private function _receipt()
 {
     if (isset($_GET['cart_order_id']) && $GLOBALS['user']->is()) {
         $customer_id = $GLOBALS['user']->getId();
         if (!$customer_id) {
             $customer_id = $GLOBALS['session']->get('ghost_customer_id');
         }
         $where = array('cart_order_id' => $_GET['cart_order_id'], 'customer_id' => $customer_id);
         if (($summaries = $GLOBALS['db']->select('CubeCart_order_summary', false, $where)) !== false) {
             $summary = $summaries[0];
             if (($products = $GLOBALS['db']->select('CubeCart_order_inventory', false, array('cart_order_id' => $_GET['cart_order_id']))) !== false) {
                 foreach ($products as $item) {
                     $item['price_total'] = $GLOBALS['tax']->priceFormat(sprintf('%.2F', $item['price'] * $item['quantity']), true);
                     $item['price'] = $GLOBALS['tax']->priceFormat($item['price'], true);
                     if (!empty($item['product_options'])) {
                         $options = ($array = unserialize($item['product_options'])) ? $array : explode("\n", $item['product_options']);
                         foreach ($options as $option) {
                             $value = trim($option);
                             if (empty($value)) {
                                 continue;
                             }
                             $item['options'][] = $option;
                         }
                     }
                     $summary['items'][] = $item;
                 }
             }
             // Price Formatting
             $format = array('discount', 'shipping', 'subtotal', 'total_tax', 'total');
             foreach ($format as $field) {
                 if (isset($summary[$field])) {
                     $summary[$field] = $GLOBALS['tax']->priceFormat($summary[$field]);
                 }
             }
             // Taxes
             if (($taxes = $GLOBALS['db']->select('CubeCart_order_tax', false, array('cart_order_id' => $summary['cart_order_id']))) !== false) {
                 $GLOBALS['tax']->loadTaxes($summary['country']);
                 foreach ($taxes as $vat) {
                     $detail = $GLOBALS['tax']->fetchTaxDetails($vat['tax_id']);
                     $summary['taxes'][] = array('name' => $detail['name'], 'value' => $GLOBALS['tax']->priceFormat($vat['amount'], true));
                 }
             } else {
                 $summary['taxes'][] = array('name' => $GLOBALS['language']->basket['total_tax'], 'value' => $GLOBALS['tax']->priceFormat($summary['total_tax']));
             }
             // Delivery Address
             $summary['state'] = getStateFormat($summary['state']);
             $summary['country'] = getCountryFormat($summary['country']);
             $summary['state_d'] = is_numeric($summary['state_d']) ? getStateFormat($summary['state_d']) : $summary['state_d'];
             $summary['country_d'] = getCountryFormat($summary['country_d']);
             $summary['order_status'] = $GLOBALS['language']->order_state['name_' . $summary['status']];
             $summary['vat_number'] = $GLOBALS['config']->get('config', 'tax_number');
             $summary['order_date'] = formatTime($summary['order_date'], '%d %B %Y', true);
             $var[] = $summary;
             $GLOBALS['smarty']->assign('LIST_ORDERS', $var);
             $GLOBALS['smarty']->assign('PAGE_TITLE', sprintf($GLOBALS['language']->orders['title_invoice_x'], $summary['cart_order_id']));
             $GLOBALS['smarty']->assign('STORE', array('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')));
             $GLOBALS['smarty']->assign('STORE_LOGO', $GLOBALS['gui']->getLogo(true, 'invoices'));
             foreach ($GLOBALS['hooks']->load('class.cubecart.print.receipt') as $hook) {
                 include $hook;
             }
             $GLOBALS['smarty']->display('templates/print.receipt.php');
         }
         $GLOBALS['debug']->supress();
         exit;
     } else {
         httpredir('?_a=login');
     }
 }
Example #9
0
 /**
  * Format address array
  *
  * @param array
  * @return array
  */
 public function formatAddress($address = array(), $user_defined = true, $estimate = false)
 {
     if (!$user_defined && !is_array($address)) {
         if ($GLOBALS['config']->get('config', 'disable_estimates') == '1') {
             $address = array('postcode' => '', 'country' => '', 'state' => '');
         } else {
             $address = array('postcode' => $GLOBALS['config']->get('config', 'store_postcode'), 'country' => $GLOBALS['config']->get('config', 'store_country'), 'state' => $GLOBALS['config']->get('config', 'store_zone'));
         }
     }
     $state_field = is_numeric($address['state']) ? 'id' : 'name';
     // Check state
     $country_id = getCountryFormat($address['country'], 'numcode', 'id');
     if ($user_defined && !CC_IN_ADMIN && $_GET['_a'] !== 'addressbook' && (empty($address['state']) && !empty($address['country']) || $GLOBALS['db']->select('CubeCart_geo_zone', false, array($state_field => $address['state'])) == false && $GLOBALS['db']->select('CubeCart_geo_zone', false, array('country_id' => $country_id)))) {
         $address_description = empty($address['description']) ? '' : ' (&quot;' . $address['description'] . '&quot;)';
         $GLOBALS['gui']->setError(sprintf($GLOBALS['language']->address['check_state'], $address_description));
         httpredir("?_a=addressbook&action=edit&address_id=" . $address['address_id']);
         return false;
     }
     $address['state_id'] = getStateFormat($address['state'], $state_field, 'id');
     $address['country_id'] = $address['country'];
     $address['country'] = getCountryFormat($address['country_id']);
     $address['state_abbrev'] = getStateFormat($address['state'], $state_field, 'abbrev');
     $address['country_iso'] = getCountryFormat($address['country_id'], 'numcode', 'iso');
     $address['country_iso3'] = getCountryFormat($address['country_id'], 'numcode', 'iso3');
     $address['state'] = getStateFormat($address['state_id']);
     $address['user_defined'] = $user_defined;
     $address['estimate'] = $estimate;
     return $address;
 }
Example #10
0
 foreach ($order_summary as $field => $value) {
     if (in_array($field, array('subtotal', 'discount', 'shipping', 'total_tax', 'total'))) {
         if (!isset($tally[$field])) {
             $tally[$field] = 0;
         }
         $tally[$field] += $value;
     }
 }
 ##MY ADDITION
 $order_summary['ship_date'] = sprintf('"=""%s"""', $order_summary['ship_date']);
 $order_summary['ship_tracking'] = sprintf('"=""%s"""', $order_summary['ship_tracking']);
 ## END MY ADDITION
 $order_summary['country'] = is_numeric($order_summary['country']) ? getCountryFormat($order_summary['country']) : $order_summary['country'];
 $order_summary['state'] = is_numeric($order_summary['state']) ? getStateFormat($order_summary['state']) : $order_summary['state'];
 $order_summary['country_d'] = is_numeric($order_summary['country_d']) ? getCountryFormat($order_summary['country_d']) : $order_summary['country_d'];
 $order_summary['state_d'] = is_numeric($order_summary['state_d']) ? getStateFormat($order_summary['state_d']) : $order_summary['state_d'];
 $order_summary['date'] = formatTime($order_summary['order_date'], false, true);
 ## Run line of external report data
 if (isset($external_report) && is_object($external_report)) {
     $external_report->report_order_data($order_summary);
 }
 unset($order_summary['order_date'], $values);
 foreach ($order_summary as $field => $value) {
     if ($i == 0) {
         $headers[] = $field;
     }
     $values[] = is_numeric($value) || !strpos($value, ',') ? $value : sprintf('"%s"', addslashes($value));
 }
 if ($i == 0 && $add_headers) {
     $data[] = implode(',', $headers);
 }