Exemple #1
0
 function onListRates(&$d)
 {
     $shippinghelper = new shipping();
     $shippingrate = array();
     $rate = 0;
     $shipping = $shippinghelper->getShippingMethodByClass($this->classname);
     $shippingArr = $shippinghelper->getShopperGroupDefaultShipping();
     if (!empty($shippingArr)) {
         $shopper_shipping = $shippingArr['shipping_rate'];
         $shippingVatRate = $shippingArr['shipping_vat'];
         $default_shipping = JText::_('COM_REDSHOP_DEFAULT_SHOPPER_GROUP_SHIPPING');
         $shopper_shipping_id = $shippinghelper->encryptShipping(__CLASS__ . "|" . $shipping->name . "|" . $default_shipping . "|" . number_format($shopper_shipping, 2, '.', '') . "|" . $default_shipping . "|single|" . $shippingVatRate . "|0|1");
         $shippingrate[$rate]->text = $default_shipping;
         $shippingrate[$rate]->value = $shopper_shipping_id;
         $shippingrate[$rate]->rate = $shopper_shipping;
         $rate++;
     }
     $ratelist = $shippinghelper->listshippingrates($shipping->element, $d['users_info_id'], $d);
     for ($i = 0; $i < count($ratelist); $i++) {
         $rs = $ratelist[$i];
         $shippingRate = $rs->shipping_rate_value;
         $rs->shipping_rate_value = $shippinghelper->applyVatOnShippingRate($rs, $d['user_id']);
         $shippingVatRate = $rs->shipping_rate_value - $shippingRate;
         $economic_displaynumber = $rs->economic_displaynumber;
         $shipping_rate_id = $shippinghelper->encryptShipping(__CLASS__ . "|" . $shipping->name . "|" . $rs->shipping_rate_name . "|" . number_format($rs->shipping_rate_value, 2, '.', '') . "|" . $rs->shipping_rate_id . "|single|" . $shippingVatRate . '|' . $economic_displaynumber . '|' . $rs->deliver_type);
         $shippingrate[$rate] = new stdClass();
         $shippingrate[$rate]->text = $rs->shipping_rate_name;
         $shippingrate[$rate]->value = $shipping_rate_id;
         $shippingrate[$rate]->rate = $rs->shipping_rate_value;
         $shippingrate[$rate]->vat = $shippingVatRate;
         $rate++;
     }
     return $shippingrate;
 }
 function displayMoney($value)
 {
     $config = shipping::getConfig();
     if ($config['rightAlignCurency'] == '1') {
         $formatted = number_format($value, $config['decs'], $config['dsep'], $config['tsep']) . ' ' . $config['currency'];
     } else {
         $formatted = $config['currency'] . " " . number_format($value, $config['decs'], $config['dsep'], $config['tsep']);
     }
     return $formatted;
 }
Exemple #3
0
 public function display($tpl = null)
 {
     $context = 'shipping_rate';
     $uri = JFactory::getURI();
     $app = JFactory::getApplication();
     $document = JFactory::getDocument();
     $shippinghelper = new shipping();
     $lists['order'] = $app->getUserStateFromRequest($context . 'filter_order', 'filter_order', 'shipping_rate_id');
     $lists['order_Dir'] = $app->getUserStateFromRequest($context . 'filter_order_Dir', 'filter_order_Dir', '');
     $id = $app->getUserStateFromRequest($context . 'extension_id', 'extension_id', '0');
     if ((int) $id == 0) {
         JError::raiseError(500, "Direct Access not allowed, go to <a href='index.php?option=com_redshop&view=shipping'>" . JText::_('COM_REDSHOP_SHIPPING') . "</a>");
         return false;
     }
     $shipping = $shippinghelper->getShippingMethodById($id);
     $shipping_rates = $this->get('Data');
     $total = $this->get('Total');
     $pagination = $this->get('Pagination');
     $shippingpath = JPATH_ROOT . '/plugins/' . $shipping->folder . '/' . $shipping->element . '.xml';
     $myparams = new JRegistry($shipping->params, $shippingpath);
     $is_shipper = $myparams->get('is_shipper');
     $shipper_location = $myparams->get('shipper_location');
     $jtitle = $shipper_location ? JText::_('COM_REDSHOP_SHIPPING_LOCATION') : JText::_('COM_REDSHOP_SHIPPING_RATE');
     JToolBarHelper::title($jtitle . ' <small><small>[ ' . $shipping->name . ' ]</small></small>', 'redshop_shipping_rates48');
     JToolBarHelper::addNewX();
     JToolBarHelper::editListX();
     if ($is_shipper) {
         JToolBarHelper::customX('copy', 'copy.png', 'copy_f2.png', JText::_('COM_REDSHOP_TOOLBAR_COPY'), true);
     }
     JToolBarHelper::deleteList();
     JToolBarHelper::cancel('cancel', JText::_('JTOOLBAR_CLOSE'));
     $this->lists = $lists;
     $this->shipping_rates = $shipping_rates;
     $this->shipping = $shipping;
     $this->pagination = $pagination;
     $this->is_shipper = $is_shipper;
     $this->shipper_location = $shipper_location;
     $this->request_url = $uri->toString();
     parent::display($tpl);
 }
// Required for some shipping methods (ie. USPS).
require_once 'includes/classes/http_client.php';
// Set up the order address.
$country = 'US';
$city = 'Miami';
$region = 'FL';
$postal_code = '33102';
$row = tep_db_fetch_array(tep_db_query("select * from " . TABLE_COUNTRIES . " where countries_iso_code_2 = '" . $country . "'"));
$order->delivery['country'] = array('id' => $row['countries_id'], 'title' => $row['countries_name'], 'iso_code_2' => $country, 'iso_code_3' => $row['countries_iso_code_3']);
$order->delivery['country_id'] = $row['countries_id'];
$order->delivery['format_id'] = $row['address_format_id'];
$row = tep_db_fetch_array(tep_db_query("select * from " . TABLE_ZONES . " where zone_code = '" . $region . "'"));
$order->delivery['zone_id'] = $row['zone_id'];
$order->delivery['state'] = $row['zone_name'];
$order->delivery['city'] = $city;
$order->delivery['postcode'] = $postal_code;
$shipping_modules = new shipping();
foreach ($shippers as $shipper) {
    list($start_m, $start_s) = explode(' ', microtime());
    $start = $start_m + $start_s;
    $quotes = $shipping_modules->quote('', $shipper);
    list($end_m, $end_s) = explode(' ', microtime());
    $end = $end_m + $end_s;
    echo $shipper . " took " . number_format($end - $start, 5) . " Secs\n";
}
list($start_m, $start_s) = explode(' ', microtime());
$start = $start_m + $start_s;
$quotes = $shipping_modules->quote();
list($end_m, $end_s) = explode(' ', microtime());
$end = $end_m + $end_s;
echo "All quotes took " . number_format($end - $start, 5) . " Secs\n";
Exemple #5
0
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $shippinghelper = new shipping();
     $order_functions = new order_functions();
     $params = $app->getParams('com_redshop');
     $option = JRequest::getVar('option');
     $Itemid = JRequest::getInt('Itemid');
     $issplit = JRequest::getBool('issplit');
     $ccinfo = JRequest::getInt('ccinfo');
     $task = JRequest::getCmd('task');
     $model = $this->getModel('checkout');
     $session = JFactory::getSession();
     if ($issplit != '') {
         $session->set('issplit', $issplit);
     }
     $payment_method_id = JRequest::getCmd('payment_method_id');
     $users_info_id = JRequest::getInt('users_info_id');
     $auth = $session->get('auth');
     if (empty($users_info_id)) {
         $users_info_id = $auth['users_info_id'];
     }
     $shipping_rate_id = JRequest::getString('shipping_rate_id');
     $shippingdetail = explode("|", $shippinghelper->decryptShipping(str_replace(" ", "+", $shipping_rate_id)));
     if (count($shippingdetail) < 4) {
         $shipping_rate_id = "";
     }
     $cart = $session->get('cart');
     if ($cart['idx'] < 1) {
         $msg = JText::_('COM_REDSHOP_EMPTY_CART');
         $app->Redirect('index.php?option=' . $option . '&Itemid=' . $Itemid, $msg);
     }
     if (SHIPPING_METHOD_ENABLE) {
         if ($users_info_id < 1) {
             $msg = JText::_('COM_REDSHOP_SELECT_SHIP_ADDRESS');
             $link = 'index.php?option=' . $option . '&view=checkout&Itemid=' . $Itemid . '&users_info_id=' . $users_info_id . '&shipping_rate_id=' . $shipping_rate_id . '&payment_method_id=' . $payment_method_id;
             $app->Redirect($link, $msg);
         }
         if ($shipping_rate_id == '' && $cart['free_shipping'] != 1) {
             $msg = JText::_('COM_REDSHOP_SELECT_SHIP_METHOD');
             $link = 'index.php?option=' . $option . '&view=checkout&Itemid=' . $Itemid . '&users_info_id=' . $users_info_id . '&shipping_rate_id=' . $shipping_rate_id . '&payment_method_id=' . $payment_method_id;
             $app->Redirect($link, $msg);
         }
     }
     if ($payment_method_id == '') {
         $msg = JText::_('COM_REDSHOP_SELECT_PAYMENT_METHOD');
         $link = 'index.php?option=' . $option . '&view=checkout&Itemid=' . $Itemid . '&users_info_id=' . $users_info_id . '&shipping_rate_id=' . $shipping_rate_id . '&payment_method_id=' . $payment_method_id;
         $app->Redirect($link, $msg);
     }
     $paymentinfo = $order_functions->getPaymentMethodInfo($payment_method_id);
     $paymentinfo = $paymentinfo[0];
     $paymentpath = JPATH_SITE . '/plugins/redshop_payment/' . $paymentinfo->element . '/' . $paymentinfo->element . '.xml';
     $paymentparams = new JRegistry($paymentinfo->params);
     $is_creditcard = $paymentparams->get('is_creditcard', '');
     $is_subscription = $paymentparams->get('is_subscription', 0);
     if (@$is_creditcard == 1) {
         $document = JFactory::getDocument();
         JHTML::Script('credit_card.js', 'components/com_redshop/assets/js/', false);
     }
     if ($is_subscription) {
         $subscription_id = $session->set('subscription_id', $subscription_id);
     }
     $this->cart = $cart;
     $this->users_info_id = $users_info_id;
     $this->shipping_rate_id = $shipping_rate_id;
     $this->payment_method_id = $payment_method_id;
     $this->is_creditcard = $is_creditcard;
     if ($task != '') {
         $tpl = $task;
     }
     parent::display($tpl);
 }
 /**
  * Determine the appropriate shipping method if applicable
  * By default, selects the lowest-cost quote
  */
 function setShippingMethod()
 {
     global $total_count, $total_weight;
     // ensure that cart contents is calculated properly for weight and value
     if (!isset($total_weight)) {
         $total_weight = $_SESSION['cart']->show_weight();
     }
     if (!isset($total_count)) {
         $total_count = $_SESSION['cart']->count_contents();
     }
     // set the shipping method if one is not already set
     // defaults to the cheapest shipping method
     if (!$_SESSION['shipping'] || $_SESSION['shipping'] && $_SESSION['shipping'] == false && zen_count_shipping_modules() > 1) {
         require_once DIR_WS_CLASSES . 'http_client.php';
         require_once DIR_WS_CLASSES . 'shipping.php';
         $shipping_Obj = new shipping();
         // generate the quotes
         $shipping_Obj->quote();
         // set the cheapest one
         $_SESSION['shipping'] = $shipping_Obj->cheapest();
     }
 }
if (isset($_SESSION['cartID']) && $_SESSION['cartID'] != $_SESSION['cart']->cartID && isset($_SESSION['shipping'])) {
    unset($_SESSION['shipping']);
}
$_SESSION['cartID'] = $_SESSION['cart']->cartID = $_SESSION['cart']->generate_cart_id();
// if the order contains only virtual products, forward the customer to the billing page as
// a shipping address is not needed
if ($order->content_type == 'virtual') {
    $_SESSION['shipping'] = false;
    $_SESSION['sendto'] = false;
    OSCOM::redirect('checkout_payment.php', '', 'SSL');
}
$total_weight = $_SESSION['cart']->show_weight();
$total_count = $_SESSION['cart']->count_contents();
// load all enabled shipping modules
require DIR_WS_CLASSES . 'shipping.php';
$shipping_modules = new shipping();
if (defined('MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING') && MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING == 'true') {
    $pass = false;
    switch (MODULE_ORDER_TOTAL_SHIPPING_DESTINATION) {
        case 'national':
            if ($order->delivery['country_id'] == STORE_COUNTRY) {
                $pass = true;
            }
            break;
        case 'international':
            if ($order->delivery['country_id'] != STORE_COUNTRY) {
                $pass = true;
            }
            break;
        case 'both':
            $pass = true;
Exemple #8
0
<?php

/**
 * @package     RedSHOP.Backend
 * @subpackage  Template
 *
 * @copyright   Copyright (C) 2005 - 2013 redCOMPONENT.com. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */
require_once JPATH_COMPONENT_ADMINISTRATOR . '/helpers/shipping.php';
$shippinghelper = new shipping();
$option = JRequest::getVar('option');
$download = JRequest::getVar('download');
if ($download) {
    $oid = JRequest::getInt('oid');
    $baseURL = JURI::root();
    $name = 'label_' . $oid . '.pdf';
    $tmp_name = JPATH_COMPONENT_ADMINISTRATOR . '/assets/lables/' . $name;
    $tmp_type = strtolower(JFile::getExt($name));
    switch ($tmp_type) {
        case "pdf":
            $ctype = "application/pdf";
            break;
        default:
            $ctype = "application/force-download";
    }
    header("Pragma: public");
    header('Expires: 0');
    header("Content-Type: {$ctype}");
    header('Content-Length: ' . filesize($tmp_name));
    header('Content-Disposition: attachment; filename=' . basename($name));
    $order->delivery['country']['title'] = $delivery_zone['countries_name'];
    $order->delivery['country']['id'] = $delivery_zone['countries_id'];
    $order->delivery['country_id'] = $delivery_zone['countries_id'];
    $order->delivery['zone_id'] = 0;
}
if (!isset($order->info['total'])) {
    $order->info['total'] = $_SESSION['cart']->show_total();
}
$_SESSION['delivery_zone'] = $order->delivery['country']['iso_code_2'];
//suppot downloads and gifts
if ($order->content_type == 'virtual' || $order->content_type == 'virtual_weight' || $_SESSION['cart']->count_contents_virtual() == 0) {
    $shipping_content = array();
    $shipping_content[] = array('NAME' => _SHIPPING_FREE);
} else {
    require DIR_WS_CLASSES . 'shipping.php';
    $shipping = new shipping();
    $free_shipping = $free_shipping_freeamount = $has_freeamount = false;
    require DIR_WS_MODULES . 'order_total/ot_shipping.php';
    include DIR_WS_LANGUAGES . $_SESSION['language'] . '/modules/order_total/ot_shipping.php';
    $ot_shipping = new ot_shipping();
    $ot_shipping->process();
    // load all enabled shipping modules
    $quotes = $shipping->quote();
    foreach ($quotes as $quote) {
        if ($quote['id'] == 'freeamount') {
            $has_freeamount = true;
            if (isset($quote['methods'])) {
                $free_shipping_freeamount = true;
                break;
            }
        }
Exemple #10
0
 public function replaceMessage($message, $orderData, $paymentName)
 {
     $shippinghelper = new shipping();
     $shipping_method = '';
     $details = explode("|", $shippinghelper->decryptShipping(str_replace(" ", "+", $orderData->ship_method_id)));
     if (count($details) > 1) {
         $ext = "";
         if (array_key_exists(2, $details)) {
             $ext = " (" . $details[2] . ")";
         }
         $shipping_method = $details[1] . $ext;
     }
     $producthelper = new producthelper();
     $userData = $producthelper->getUserInformation($orderData->user_id);
     $message = str_replace('{order_id}', $orderData->order_id, $message);
     $message = str_replace('{order_status}', $orderData->order_status, $message);
     $message = str_replace('{customer_name}', $userData->firstname, $message);
     $message = str_replace('{payment_status}', $orderData->order_payment_status, $message);
     $message = str_replace('{order_comment}', $orderData->customer_note, $message);
     $message = str_replace('{shipping_method}', $shipping_method, $message);
     $message = str_replace('{payment_method}', $paymentName, $message);
     return $message;
 }
 public function store($postdata)
 {
     $redshopMail = new redshopMail();
     $order_functions = new order_functions();
     $helper = new redhelper();
     $producthelper = new producthelper();
     $rsCarthelper = new rsCarthelper();
     $shippinghelper = new shipping();
     $adminproducthelper = new adminproducthelper();
     $stockroomhelper = new rsstockroomhelper();
     // For barcode generation
     $barcode_code = $order_functions->barcode_randon_number(12, 0);
     $postdata['barcode'] = $barcode_code;
     $row = $this->getTable('order_detail');
     if (!$row->bind($postdata)) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     if (!$row->store()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     $iscrm = $helper->isredCRM();
     if ($iscrm) {
         $postdata['order_id'] = $row->order_id;
         $postdata['debitor_id'] = $postdata['user_info_id'];
         JTable::addIncludePath(REDCRM_ADMIN . '/tables');
         $crmorder =& $this->getTable('crm_order');
         if (!$crmorder->bind($postdata)) {
             $this->setError($this->_db->getErrorMsg());
             return false;
         }
         if (!$crmorder->store()) {
             $this->setError($this->_db->getErrorMsg());
             return false;
         }
         // Update rma table entry
         if (ENABLE_RMA && isset($postdata['rmanotes'])) {
             $rmaInfo = $this->getTable('rma_orders');
             $rmaInfo->rma_number = $postdata['rma_number'];
             $rmaInfo->original_order_id = $postdata['main_order_id'];
             $rmaInfo->credit_note_order_id = $row->order_id;
             $rmaInfo->rma_note = $postdata['rmanotes'];
             $rmaInfo->store();
         }
         JTable::addIncludePath(REDSHOP_ADMIN . '/tables');
     }
     $order_shipping = explode("|", $shippinghelper->decryptShipping(str_replace(" ", "+", $row->ship_method_id)));
     $rowOrderStatus =& $this->getTable('order_status_log');
     $rowOrderStatus->order_id = $row->order_id;
     $rowOrderStatus->order_status = $row->order_status;
     $rowOrderStatus->date_changed = time();
     $rowOrderStatus->customer_note = $row->customer_note;
     $rowOrderStatus->store();
     $billingaddresses = $order_functions->getBillingAddress($row->user_id);
     if (isset($postdata['billisship']) && $postdata['billisship'] == 1) {
         $shippingaddresses = $billingaddresses;
     } else {
         $key = 0;
         $shippingaddresses = $order_functions->getShippingAddress($row->user_id);
         $shipp_users_info_id = isset($postdata['shipp_users_info_id']) && $postdata['shipp_users_info_id'] != 0 ? $postdata['shipp_users_info_id'] : 0;
         if ($shipp_users_info_id != 0) {
             for ($o = 0; $o < count($shippingaddresses); $o++) {
                 if ($shippingaddresses[$o]->users_info_id == $shipp_users_info_id) {
                     $key = $o;
                     break;
                 }
             }
         }
         $shippingaddresses = $shippingaddresses[$key];
     }
     // ORDER DELIVERY TIME IS REMAINING
     $user_id = $row->user_id;
     $item = $postdata['order_item'];
     for ($i = 0; $i < count($item); $i++) {
         $product_id = $item[$i]->product_id;
         $quantity = $item[$i]->quantity;
         $product_excl_price = $item[$i]->prdexclprice;
         $product_price = $item[$i]->productprice;
         // Attribute price added
         $generateAttributeCart = $rsCarthelper->generateAttributeArray((array) $item[$i], $user_id);
         $retAttArr = $producthelper->makeAttributeCart($generateAttributeCart, $product_id, $user_id, 0, $quantity);
         $product_attribute = $retAttArr[0];
         // Accessory price
         $generateAccessoryCart = $rsCarthelper->generateAccessoryArray((array) $item[$i], $user_id);
         $retAccArr = $producthelper->makeAccessoryCart($generateAccessoryCart, $product_id, $user_id);
         $product_accessory = $retAccArr[0];
         $accessory_total_price = $retAccArr[1];
         $accessory_vat_price = $retAccArr[2];
         $wrapper_price = 0;
         $wrapper_vat = 0;
         if ($item[$i]->wrapper_data != 0 && $item[$i]->wrapper_data != '') {
             $wrapper = $producthelper->getWrapper($product_id, $item[$i]->wrapper_data);
             if (count($wrapper) > 0) {
                 if ($wrapper[0]->wrapper_price > 0) {
                     $wrapper_vat = $producthelper->getProducttax($product_id, $wrapper[0]->wrapper_price, $user_id);
                 }
                 $wrapper_price = $wrapper[0]->wrapper_price + $wrapper_vat;
             }
         }
         $product = $producthelper->getProductById($product_id);
         $rowitem =& $this->getTable('order_item_detail');
         if (!$rowitem->bind($postdata)) {
             $this->setError($this->_db->getErrorMsg());
             return false;
         }
         // STOCKROOM update
         $updatestock = $stockroomhelper->updateStockroomQuantity($product_id, $quantity);
         $stockroom_id_list = $updatestock['stockroom_list'];
         $stockroom_quantity_list = $updatestock['stockroom_quantity_list'];
         $rowitem->stockroom_id = $stockroom_id_list;
         $rowitem->stockroom_quantity = $stockroom_quantity_list;
         $rowitem->order_item_id = 0;
         $rowitem->order_id = $row->order_id;
         $rowitem->user_info_id = $row->user_info_id;
         $rowitem->supplier_id = $product->manufacturer_id;
         $rowitem->product_id = $product_id;
         $rowitem->order_item_sku = $product->product_number;
         $rowitem->order_item_name = $product->product_name;
         $rowitem->product_quantity = $quantity;
         $rowitem->product_item_price = $product_price;
         $rowitem->product_item_price_excl_vat = $product_excl_price;
         $rowitem->product_final_price = $product_price * $quantity;
         $rowitem->order_item_currency = REDCURRENCY_SYMBOL;
         $rowitem->order_status = $row->order_status;
         $rowitem->cdate = $row->cdate;
         $rowitem->mdate = $row->cdate;
         $rowitem->product_attribute = $product_attribute;
         $rowitem->product_accessory = $product_accessory;
         $rowitem->wrapper_id = $item[$i]->wrapper_data;
         $rowitem->wrapper_price = $wrapper_price;
         $rowitem->is_giftcard = 0;
         // RedCRM product purchase price
         if ($iscrm) {
             $crmProductHelper = new crmProductHelper();
             $crmproduct = $crmProductHelper->getProductById($product_id);
             $rowitem->product_purchase_price = $crmproduct->product_purchase_price > 0 ? $crmproduct->product_purchase_price : $crmproduct->product_price;
         }
         if ($producthelper->checkProductDownload($product_id)) {
             $medianame = $producthelper->getProductMediaName($product_id);
             for ($j = 0; $j < count($medianame); $j++) {
                 $product_serial_number = $producthelper->getProdcutSerialNumber($product_id);
                 $producthelper->insertProductDownload($product_id, $user_id, $rowitem->order_id, $medianame[$j]->media_name, $product_serial_number->serial_number);
             }
         }
         if (!$rowitem->store()) {
             $this->setError($this->_db->getErrorMsg());
             return false;
         }
         /** my accessory save in table start */
         if (count($generateAccessoryCart) > 0) {
             $attArr = $generateAccessoryCart;
             for ($a = 0; $a < count($attArr); $a++) {
                 $accessory_vat_price = 0;
                 $accessory_attribute = "";
                 $accessory_id = $attArr[$a]['accessory_id'];
                 $accessory_name = $attArr[$a]['accessory_name'];
                 $accessory_price = $attArr[$a]['accessory_price'];
                 $accessory_org_price = $accessory_price;
                 if ($accessory_price > 0) {
                     $accessory_vat_price = $producthelper->getProductTax($product_id, $accessory_price, $user_id);
                 }
                 $attchildArr = $attArr[$a]['accessory_childs'];
                 for ($j = 0; $j < count($attchildArr); $j++) {
                     $attribute_id = $attchildArr[$j]['attribute_id'];
                     $accessory_attribute .= urldecode($attchildArr[$j]['attribute_name']) . ":<br/>";
                     $rowattitem =& $this->getTable('order_attribute_item');
                     $rowattitem->order_att_item_id = 0;
                     $rowattitem->order_item_id = $rowitem->order_item_id;
                     $rowattitem->section_id = $attribute_id;
                     $rowattitem->section = "attribute";
                     $rowattitem->parent_section_id = $accessory_id;
                     $rowattitem->section_name = $attchildArr[$j]['attribute_name'];
                     $rowattitem->is_accessory_att = 1;
                     if ($attribute_id > 0) {
                         if (!$rowattitem->store()) {
                             $this->setError($this->_db->getErrorMsg());
                             return false;
                         }
                     }
                     $propArr = $attchildArr[$j]['attribute_childs'];
                     for ($k = 0; $k < count($propArr); $k++) {
                         $section_vat = 0;
                         if ($propArr[$k]['property_price'] > 0) {
                             $section_vat = $producthelper->getProducttax($product_id, $propArr[$k]['property_price'], $user_id);
                         }
                         $property_id = $propArr[$k]['property_id'];
                         $accessory_attribute .= urldecode($propArr[$k]['property_name']) . " (" . $propArr[$k]['property_oprand'] . $producthelper->getProductFormattedPrice($propArr[$k]['property_price'] + $section_vat) . ")<br/>";
                         $subpropArr = $propArr[$k]['property_childs'];
                         $rowattitem =& $this->getTable('order_attribute_item');
                         $rowattitem->order_att_item_id = 0;
                         $rowattitem->order_item_id = $rowitem->order_item_id;
                         $rowattitem->section_id = $property_id;
                         $rowattitem->section = "property";
                         $rowattitem->parent_section_id = $attribute_id;
                         $rowattitem->section_name = $propArr[$k]['property_name'];
                         $rowattitem->section_price = $propArr[$k]['property_price'];
                         $rowattitem->section_vat = $section_vat;
                         $rowattitem->section_oprand = $propArr[$k]['property_oprand'];
                         $rowattitem->is_accessory_att = 1;
                         if ($property_id > 0) {
                             if (!$rowattitem->store()) {
                                 $this->setError($this->_db->getErrorMsg());
                                 return false;
                             }
                         }
                         for ($l = 0; $l < count($subpropArr); $l++) {
                             $section_vat = 0;
                             if ($subpropArr[$l]['subproperty_price'] > 0) {
                                 $section_vat = $producthelper->getProducttax($rowitem->product_id, $subpropArr[$l]['subproperty_price'], $user_id);
                             }
                             $subproperty_id = $subpropArr[$l]['subproperty_id'];
                             $accessory_attribute .= urldecode($subpropArr[$l]['subproperty_name']) . " (" . $subpropArr[$l]['subproperty_oprand'] . $producthelper->getProductFormattedPrice($subpropArr[$l]['subproperty_price'] + $section_vat) . ")<br/>";
                             $rowattitem =& $this->getTable('order_attribute_item');
                             $rowattitem->order_att_item_id = 0;
                             $rowattitem->order_item_id = $rowitem->order_item_id;
                             $rowattitem->section_id = $subproperty_id;
                             $rowattitem->section = "subproperty";
                             $rowattitem->parent_section_id = $property_id;
                             $rowattitem->section_name = $subpropArr[$l]['subproperty_name'];
                             $rowattitem->section_price = $subpropArr[$l]['subproperty_price'];
                             $rowattitem->section_vat = $section_vat;
                             $rowattitem->section_oprand = $subpropArr[$l]['subproperty_oprand'];
                             $rowattitem->is_accessory_att = 1;
                             if ($subproperty_id > 0) {
                                 if (!$rowattitem->store()) {
                                     $this->setError($this->_db->getErrorMsg());
                                     return false;
                                 }
                             }
                         }
                     }
                 }
                 $accdata =& $this->getTable('accessory_detail');
                 if ($accessory_id > 0) {
                     $accdata->load($accessory_id);
                 }
                 $accProductinfo = $producthelper->getProductById($accdata->child_product_id);
                 $rowaccitem =& $this->getTable('order_acc_item');
                 $rowaccitem->order_item_acc_id = 0;
                 $rowaccitem->order_item_id = $rowitem->order_item_id;
                 $rowaccitem->product_id = $accessory_id;
                 $rowaccitem->order_acc_item_sku = $accProductinfo->product_number;
                 $rowaccitem->order_acc_item_name = $accessory_name;
                 $rowaccitem->order_acc_price = $accessory_org_price;
                 $rowaccitem->order_acc_vat = $accessory_vat_price;
                 $rowaccitem->product_quantity = $quantity;
                 $rowaccitem->product_acc_item_price = $accessory_price;
                 $rowaccitem->product_acc_final_price = $accessory_price * $quantity;
                 $rowaccitem->product_attribute = $accessory_attribute;
                 if ($accessory_id > 0) {
                     if (!$rowaccitem->store()) {
                         $this->setError($this->_db->getErrorMsg());
                         return false;
                     }
                 }
             }
         }
         /** my attribute save in table start */
         if (count($generateAttributeCart) > 0) {
             $attArr = $generateAttributeCart;
             for ($j = 0; $j < count($attArr); $j++) {
                 $attribute_id = $attArr[$j]['attribute_id'];
                 $rowattitem =& $this->getTable('order_attribute_item');
                 $rowattitem->order_att_item_id = 0;
                 $rowattitem->order_item_id = $rowitem->order_item_id;
                 $rowattitem->section_id = $attribute_id;
                 $rowattitem->section = "attribute";
                 $rowattitem->parent_section_id = $rowitem->product_id;
                 $rowattitem->section_name = $attArr[$j]['attribute_name'];
                 $rowattitem->is_accessory_att = 0;
                 if ($attribute_id > 0) {
                     if (!$rowattitem->store()) {
                         $this->setError($this->_db->getErrorMsg());
                         return false;
                     }
                 }
                 $propArr = $attArr[$j]['attribute_childs'];
                 for ($k = 0; $k < count($propArr); $k++) {
                     $section_vat = 0;
                     if ($propArr[$k]['property_price'] > 0) {
                         $section_vat = $producthelper->getProducttax($rowitem->product_id, $propArr[$k]['property_price'], $user_id);
                     }
                     $property_id = $propArr[$k]['property_id'];
                     /** product property STOCKROOM update start */
                     $updatestock = $stockroomhelper->updateStockroomQuantity($property_id, $quantity, "property");
                     $rowattitem =& $this->getTable('order_attribute_item');
                     $rowattitem->order_att_item_id = 0;
                     $rowattitem->order_item_id = $rowitem->order_item_id;
                     $rowattitem->section_id = $property_id;
                     $rowattitem->section = "property";
                     $rowattitem->parent_section_id = $attribute_id;
                     $rowattitem->section_name = $propArr[$k]['property_name'];
                     $rowattitem->section_price = $propArr[$k]['property_price'];
                     $rowattitem->section_vat = $section_vat;
                     $rowattitem->section_oprand = $propArr[$k]['property_oprand'];
                     $rowattitem->is_accessory_att = 0;
                     if ($property_id > 0) {
                         if (!$rowattitem->store()) {
                             $this->setError($this->_db->getErrorMsg());
                             return false;
                         }
                     }
                     $subpropArr = $propArr[$k]['property_childs'];
                     for ($l = 0; $l < count($subpropArr); $l++) {
                         $section_vat = 0;
                         if ($subpropArr[$l]['subproperty_price'] > 0) {
                             $section_vat = $producthelper->getProducttax($product_id, $subpropArr[$l]['subproperty_price'], $user_id);
                         }
                         $subproperty_id = $subpropArr[$l]['subproperty_id'];
                         /** product subproperty STOCKROOM update start */
                         $updatestock = $stockroomhelper->updateStockroomQuantity($subproperty_id, $quantity, "subproperty");
                         $rowattitem =& $this->getTable('order_attribute_item');
                         $rowattitem->order_att_item_id = 0;
                         $rowattitem->order_item_id = $rowitem->order_item_id;
                         $rowattitem->section_id = $subproperty_id;
                         $rowattitem->section = "subproperty";
                         $rowattitem->parent_section_id = $property_id;
                         $rowattitem->section_name = $subpropArr[$l]['subproperty_name'];
                         $rowattitem->section_price = $subpropArr[$l]['subproperty_price'];
                         $rowattitem->section_vat = $section_vat;
                         $rowattitem->section_oprand = $subpropArr[$l]['subproperty_oprand'];
                         $rowattitem->is_accessory_att = 0;
                         if ($subproperty_id > 0) {
                             if (!$rowattitem->store()) {
                                 $this->setError($this->_db->getErrorMsg());
                                 return false;
                             }
                         }
                     }
                 }
             }
         }
         //			$producthelper->insertProdcutUserfield($i,$item,$rowitem->order_item_id,12);
         if (USE_CONTAINER) {
             $producthelper->updateContainerStock($product_id, $quantity, $rowitem->container_id);
         }
         // Store userfields
         $userfields = $item[$i]->extrafieldname;
         $userfields_id = $item[$i]->extrafieldId;
         for ($ui = 0; $ui < count($userfields); $ui++) {
             $adminproducthelper->admin_insertProdcutUserfield($userfields_id[$ui], $rowitem->order_item_id, 12, $userfields[$ui]);
         }
         // redCRM RMA Transaction Entry
         if ($iscrm) {
             if (ENABLE_RMA && $rowitem->product_final_price < 0) {
                 // RMA transation log
                 if (isset($item[$i]->reason)) {
                     $rmaTrans =& $this->getTable('rma_transaction');
                     $rmaTrans->rma_transaction_id = 0;
                     $rmaTrans->rma_number = $postdata['rma_number'];
                     $rmaTrans->order_item_return_id = $rowitem->order_item_id;
                     $rmaTrans->order_item_return_reason = $item[$i]->reason;
                     $rmaTrans->order_item_return_status = $item[$i]->deposition;
                     $rmaTrans->order_item_return_action = $item[$i]->action;
                     $rmaTrans->cdate = time();
                     $rmaTrans->store();
                     if (ENABLE_ITEM_TRACKING_SYSTEM) {
                         // Manage supplier order stock
                         $crmSupplierOrderHelper = new crmSupplierOrderHelper();
                         $senddata['main_order_number'] = $postdata['main_order_number'];
                         $senddata['order_status'] = $row->order_status;
                         $senddata['product_id'] = $rowitem->product_id;
                         $senddata['property_id'] = $property_id;
                         $senddata['subproperty_id'] = $subproperty_id;
                         $senddata['deposition'] = $item[$i]->deposition;
                         $itemqty = $rowitem->product_quantity;
                         for ($r = 0; $r < $itemqty; $r++) {
                             $crmSupplierOrderHelper->manageStockAffectedRMA($senddata);
                         }
                     }
                 }
             }
         }
     }
     $rowpayment =& $this->getTable('order_payment');
     if (!$rowpayment->bind($postdata)) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     $rowpayment->order_id = $row->order_id;
     $rowpayment->payment_method_id = $postdata['payment_method_class'];
     $rowpayment->order_payment_amount = $row->order_total;
     $rowpayment->order_payment_name = $postdata['order_payment_name'];
     $rowpayment->payment_method_class = $postdata['payment_method_class'];
     if (!$rowpayment->store()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     // Add billing Info
     $userrow =& $this->getTable('user_detail');
     $userrow->load($billingaddresses->users_info_id);
     $orderuserrow =& $this->getTable('order_user_detail');
     if (!$orderuserrow->bind($userrow)) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     $orderuserrow->order_id = $row->order_id;
     $orderuserrow->address_type = 'BT';
     if (!$orderuserrow->store()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     // Add shipping Info
     $userrow =& $this->getTable('user_detail');
     if (isset($shippingaddresses->users_info_id)) {
         $userrow->load($shippingaddresses->users_info_id);
     }
     $orderuserrow =& $this->getTable('order_user_detail');
     if (!$orderuserrow->bind($userrow)) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     $orderuserrow->order_id = $row->order_id;
     $orderuserrow->address_type = 'ST';
     if (!$orderuserrow->store()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     if ($row->order_status == CLICKATELL_ORDER_STATUS) {
         $helper->clickatellSMS($row->order_id);
     }
     // Maintan supplier order stck when item tracking system is enabled
     if ($helper->isredCRM()) {
         if (ENABLE_ITEM_TRACKING_SYSTEM) {
             // Supplier order helper object
             $crmSupplierOrderHelper = new crmSupplierOrderHelper();
             $getStatus = array();
             $getStatus['orderstatus'] = $row->order_status;
             $getStatus['paymentstatus'] = $row->order_payment_status;
             $crmSupplierOrderHelper->redSHOPOrderUpdate($row->order_id, $getStatus);
             unset($getStatus);
         }
     }
     $checkOrderStatus = 1;
     if ($postdata['payment_method_class'] == "rs_payment_banktransfer" || $postdata['payment_method_class'] == "rs_payment_banktransfer_discount" || $postdata['payment_method_class'] == "rs_payment_banktransfer2" || $postdata['payment_method_class'] == "rs_payment_banktransfer3" || $postdata['payment_method_class'] == "rs_payment_banktransfer4" || $postdata['payment_method_class'] == "rs_payment_banktransfer5") {
         $checkOrderStatus = 0;
     }
     // Economic Integration start for invoice generate and book current invoice
     if (ECONOMIC_INTEGRATION == 1 && ECONOMIC_INVOICE_DRAFT != 2) {
         $issplit = 0;
         $economic = new economic();
         if (isset($postdata['issplit']) && $postdata['issplit'] == 1) {
             $issplit = 1;
         }
         $economicdata['split_payment'] = $issplit;
         $economicdata['economic_payment_terms_id'] = $postdata['economic_payment_terms_id'];
         $economicdata['economic_design_layout'] = $postdata['economic_design_layout'];
         $economicdata['economic_is_creditcard'] = $postdata['economic_is_creditcard'];
         $payment_name = $postdata['payment_method_class'];
         $paymentArr = explode("rs_payment_", $postdata['payment_method_class']);
         if (count($paymentArr) > 0) {
             $payment_name = $paymentArr[1];
         }
         $economicdata['economic_payment_method'] = $payment_name;
         $invoiceHandle = $economic->createInvoiceInEconomic($row->order_id, $economicdata);
         if (ECONOMIC_INVOICE_DRAFT == 0) {
             $bookinvoicepdf = $economic->bookInvoiceInEconomic($row->order_id, $checkOrderStatus);
             if (is_file($bookinvoicepdf)) {
                 $ret = $redshopMail->sendEconomicBookInvoiceMail($row->order_id, $bookinvoicepdf);
             }
         }
     }
     // ORDER MAIL SEND
     if ($postdata['task'] != "save_without_sendmail") {
         $redshopMail->sendOrderMail($row->order_id);
     }
     return $row;
 }
    if (!smn_session_is_registered('shipping')) {
        smn_session_register('shipping');
    }
    /*Unregister the session shipping_store,By Cimi*/
    if (!smn_session_is_registered('shipping_store')) {
        smn_session_register('shipping_store');
    }
    $shipping = false;
    $sendto = false;
    smn_redirect(smn_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'NONSSL'));
}
$total_weight = $cart->show_weight($store_id);
$total_count = $cart->count_contents($store_id);
// load all enabled shipping modules
require DIR_WS_CLASSES . 'shipping.php';
$shipping_modules = new shipping();
if (defined('MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING') && MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING == 'true') {
    $pass = false;
    switch (MODULE_ORDER_TOTAL_SHIPPING_DESTINATION) {
        case 'national':
            if ($order->delivery['country_id'] == $store->get_store_country()) {
                $pass = true;
            }
            break;
        case 'international':
            if ($order->delivery['country_id'] != $store->get_store_country()) {
                $pass = true;
            }
            break;
        case 'both':
            $pass = true;
Exemple #13
0
 public function gbasefeed($data)
 {
     $producthelper = new producthelper();
     $stockroomhelper = new rsstockroomhelper();
     $shippinghelper = new shipping();
     $unpublished_data = $data['unpublished_data'];
     $cid = $data['cid'];
     $url = JURI::root();
     $currency = new CurrencyHelper();
     $product_img_url = $url . 'components/com_redshop/assets/images/product/';
     $file_path = JPATH_COMPONENT_SITE . "/assets/document/gbase";
     $file_name = $file_path . "/product.xml";
     if (count($cid)) {
         $cids = implode(',', $cid);
         if ($unpublished_data == 1) {
             $query = "SELECT p.*,m.manufacturer_name FROM " . $this->_table_prefix . "product AS p " . " LEFT JOIN " . $this->_table_prefix . "manufacturer AS m" . " ON p.manufacturer_id = m.manufacturer_id" . " WHERE p.product_id IN (" . $cids . ")";
         } else {
             $query = "SELECT p.*,m.manufacturer_name FROM " . $this->_table_prefix . "product AS p " . " LEFT JOIN " . $this->_table_prefix . "manufacturer AS m" . " ON p.manufacturer_id = m.manufacturer_id" . " WHERE p.product_id IN (" . $cids . ") and p.published =1";
         }
         $this->_db->setQuery($query);
         $rs = $this->_db->loadObjectlist();
         // For shipping information
         $shippingArr = $shippinghelper->getShopperGroupDefaultShipping();
         $default_shipping = 0.0;
         $shipping_rate = $currency->convert(number_format($shippingArr['shipping_rate'], PRICE_DECIMAL, PRICE_SEPERATOR, THOUSAND_SEPERATOR), '', CURRENCY_CODE);
         $default_shipping = count($shippingArr) > 0 ? $shipping_rate : number_format($default_shipping, PRICE_DECIMAL, PRICE_SEPERATOR, THOUSAND_SEPERATOR);
         $default_shipping_country = DEFAULT_SHIPPING_COUNTRY;
         $xml_code = '<?xml version="1.0" encoding="UTF-8" ';
         $xml_code .= '<rss version ="2.0" xmlns:g="http://base.google.com/ns/1.0" xmlns:c="http://base.google.com/cns/1.0">';
         $xml_code .= "<channel>";
         for ($i = 0; $i < count($rs); $i++) {
             // For additional images
             $additional_images = $producthelper->getAdditionMediaImage($rs[$i]->product_id, $section = "product", $mediaType = "images");
             $add_image = "";
             for ($ad = 0; $ad < 10; $ad++) {
                 if (trim($additional_images[$ad]->product_full_image) != trim($additional_images[$ad]->media_name) && trim($additional_images[$ad]->media_name) != "") {
                     $add_image .= "<g:additional_image_link>" . $product_img_url . htmlspecialchars($additional_images[$ad]->media_name, ENT_NOQUOTES, "UTF-8") . "</g:additional_image_link>";
                 }
             }
             // For getting product Category
             $category_name = $producthelper->getCategoryNameByProductId($rs[$i]->product_id);
             if (USE_STOCKROOM == 1) {
                 // For c**t attributes
                 $attributes_set = array();
                 if ($rs[$i]->attribute_set_id > 0) {
                     $attributes_set = $producthelper->getProductAttribute(0, $rs[$i]->attribute_set_id, 0, 1);
                 }
                 $attributes = $producthelper->getProductAttribute($rs[$i]->product_id);
                 $attributes = array_merge($attributes, $attributes_set);
                 $totalatt = count($attributes);
                 // Get stock details
                 $isStockExists = $stockroomhelper->isStockExists($rs[$i]->product_id);
                 if ($totalatt > 0 && !$isStockExists) {
                     $isStockExists = $stockroomhelper->isAttributeStockExists($product_id);
                 }
                 $isPreorderStockExists = $stockroomhelper->isPreorderStockExists($product_id);
                 if ($totalatt > 0 && !$isPreorderStockExists) {
                     $isPreorderStockExists = $stockroomhelper->isAttributePreorderStockExists($product_id);
                 }
                 if (!$isStockExists) {
                     $product_preorder = $rs[$i]->preorder;
                     if ($product_preorder == "global" && ALLOW_PRE_ORDER || $product_preorder == "yes" || $product_preorder == "" && ALLOW_PRE_ORDER) {
                         if (!$isPreorderStockExists) {
                             $product_status = JText::_('COM_REDSHOP_OUT_OF_STOCK');
                         } else {
                             $product_status = JText::_('COM_REDSHOP_PREORDER');
                         }
                     } else {
                         $product_status = JText::_('COM_REDSHOP_OUT_OF_STOCK');
                     }
                 } else {
                     $product_status = JText::_('COM_REDSHOP_AVAILABLE_FOR_ORDER');
                 }
             } else {
                 $product_status = JText::_('COM_REDSHOP_AVAILABLE_FOR_ORDER');
             }
             $product_on_sale = 0;
             if ($rs[$i]->product_on_sale == 1 && ($rs[$i]->discount_stratdate == 0 && $rs[$i]->discount_enddate == 0 || $rs[$i]->discount_stratdate <= time() && $rs[$i]->discount_enddate >= time())) {
                 $product_on_sale = 1;
             }
             // For price and vat settings
             $product_price = $rs[$i]->product_price;
             $discount_price = $rs[$i]->discount_price;
             $sale_price = $product_on_sale == 1 ? $discount_price : $product_price;
             $price_vat = $producthelper->getGoogleVatRates($rs[$i]->product_id, $product_price, USE_TAX_EXEMPT);
             $sale_price_vat = $producthelper->getGoogleVatRates($rs[$i]->product_id, $sale_price, USE_TAX_EXEMPT);
             if (DEFAULT_VAT_COUNTRY != "USA") {
                 $product_price = $rs[$i]->product_price + $price_vat;
                 $sale_price = $sale_price + $sale_price_vat;
             }
             $product_price = $currency->convert(number_format($product_price, PRICE_DECIMAL, PRICE_SEPERATOR, THOUSAND_SEPERATOR), '', CURRENCY_CODE);
             $discount_price = $currency->convert(number_format($discount_price, PRICE_DECIMAL, PRICE_SEPERATOR, THOUSAND_SEPERATOR), '', CURRENCY_CODE);
             $sale_price = $currency->convert(number_format($sale_price, PRICE_DECIMAL, PRICE_SEPERATOR, THOUSAND_SEPERATOR), '', CURRENCY_CODE);
             $price_vat = $currency->convert(number_format($price_vat, PRICE_DECIMAL, PRICE_SEPERATOR, THOUSAND_SEPERATOR), '', CURRENCY_CODE);
             $product_url = $url . "index.php?option=com_redshop&amp;view=product&amp;pid=" . $rs[$i]->product_id;
             $xml_code .= "\n<item>";
             $xml_code .= "\n<g:id>" . htmlspecialchars($rs[$i]->product_id, ENT_NOQUOTES, "UTF-8") . "</g:id>";
             $xml_code .= "\n<title>" . htmlspecialchars($rs[$i]->product_name, ENT_NOQUOTES, "UTF-8") . "</title>";
             $xml_code .= "\n<description>'" . htmlspecialchars($rs[$i]->product_s_desc, ENT_NOQUOTES, "UTF-8") . "'</description>";
             $xml_code .= "\n<g:product_type>'" . htmlspecialchars($category_name, ENT_NOQUOTES, "UTF-8") . "'</g:product_type>";
             $xml_code .= "\n<link>" . htmlspecialchars($product_url, ENT_NOQUOTES, "UTF-8") . "</link>";
             $xml_code .= "\n<g:image_link>" . $product_img_url . htmlspecialchars($rs[$i]->product_full_image, ENT_NOQUOTES, "UTF-8") . "</g:image_link>";
             $xml_code .= "\n<g:brand>" . htmlspecialchars($rs[$i]->manufacturer_name, ENT_NOQUOTES, "UTF-8") . "</g:brand>";
             $xml_code .= "\n<g:condition>New</g:condition>";
             $xml_code .= "\n<g:availability>" . $product_status . "</g:availability>";
             $xml_code .= "\n<g:price>" . $product_price . " " . CURRENCY_CODE . "</g:price>";
             $xml_code .= "\n<g:sale_price>" . $sale_price . " " . CURRENCY_CODE . "</g:sale_price>";
             if ($product_on_sale == 1) {
                 $discount_start_date = date("c", $rs[$i]->discount_stratdate);
                 $discount_end_date = date("c", $rs[$i]->discount_enddate);
                 $xml_code .= "\n<g:sale_price_effective_date>" . $discount_start_date . "/" . $discount_end_date . "</g:sale_price_effective_date>";
             }
             $xml_code .= "\n<g:mpn>" . htmlspecialchars($rs[$i]->product_number, ENT_NOQUOTES, "UTF-8") . "</g:mpn>";
             if (DEFAULT_VAT_COUNTRY == "USA" || DEFAULT_VAT_COUNTRY == "GBR") {
                 $xml_code .= "\n<g:delivery>\r\n\t\t\t\t\t\t<g:country>" . DEFAULT_SHIPPING_COUNTRY . "</g:country>\r\n\t\t\t\t\t    <g:price>" . $default_shipping . " " . CURRENCY_CODE . "</g:price>\r\n\t\t\t\t\t</g:delivery>";
                 if ($rs[$i]->weight != 0) {
                     $xml_code .= "\n<g:delivery_weight>" . $rs[$i]->weight . " " . DEFAULT_WEIGHT_UNIT . "</g:delivery_weight>";
                 }
             } else {
                 $xml_code .= "\n<g:shipping>\r\n\t\t\t\t\t\t<g:country>" . DEFAULT_SHIPPING_COUNTRY . "</g:country>\r\n\t\t\t\t\t    <g:price>" . $default_shipping . " " . CURRENCY_CODE . "</g:price>\r\n\t\t\t\t\t</g:shipping>";
                 if ($rs[$i]->weight != 0) {
                     $xml_code .= "\n<g:shipping_weight>" . $rs[$i]->weight . " " . DEFAULT_WEIGHT_UNIT . "</g:shipping_weight>";
                 }
             }
             if (DEFAULT_VAT_COUNTRY == "USA") {
                 $xml_code .= "\n<g:tax>\r\n\t\t\t\t\t\t\t\t   <g:country>US</g:country>\r\n\t\t\t\t\t\t\t\t   <g:rate>" . $price_vat . "</g:rate>\r\n\t\t\t\t\t\t\t  </g:tax>";
             }
             $xml_code .= "\n" . $add_image;
             $xml_code .= "\n</item>";
         }
         $xml_code .= '</channel>';
         $xml_code .= '</rss>';
         $fp = fopen($file_name, "w");
         fwrite($fp, $xml_code);
         fclose($fp);
         if (!file_exists($file_name)) {
             return false;
         } else {
             return true;
         }
     }
     return false;
 }
Exemple #14
0
 function osC_Checkout_Shipping()
 {
     global $osC_Database, $osC_Session, $osC_Customer, $osC_Services, $breadcrumb, $order, $cart, $total_weight, $total_count, $shipping_modules, $pass, $free_shipping, $quotes;
     if ($cart->count_contents() < 1) {
         tep_redirect(tep_href_link(FILENAME_CHECKOUT, '', 'SSL'));
     }
     if ($osC_Services->isStarted('breadcrumb')) {
         $breadcrumb->add(NAVBAR_TITLE_CHECKOUT_SHIPPING, tep_href_link(FILENAME_CHECKOUT, $this->_module, 'SSL'));
     }
     if ($osC_Customer->hasDefaultAddress() === false) {
         $this->page_contents = 'checkout_shipping_address.php';
     }
     // if no shipping destination address was selected, use the customers own address as default
     if ($osC_Session->exists('sendto') == false) {
         $osC_Session->set('sendto', $osC_Customer->default_address_id);
     } else {
         // verify the selected shipping address
         $Qcheck = $osC_Database->query('select count(*) as total from :table_address_book where customers_id = :customers_id and address_book_id = :address_book_id');
         $Qcheck->bindTable(':table_address_book', TABLE_ADDRESS_BOOK);
         $Qcheck->bindInt(':customers_id', $osC_Customer->id);
         $Qcheck->bindInt(':address_book_id', $osC_Session->value('sendto'));
         $Qcheck->execute();
         if ($Qcheck->valueInt('total') != 1) {
             $osC_Session->set('sendto', $osC_Customer->default_address_id);
             $osC_Session->remove('shipping');
         }
     }
     $order = new order();
     // register a random ID in the session to check throughout the checkout procedure
     // against alterations in the shopping cart contents
     $osC_Session->set('cartID', $cart->cartID);
     // if the order contains only virtual products, forward the customer to the billing page as
     // a shipping address is not needed
     if ($order->content_type == 'virtual') {
         $false = false;
         $osC_Session->set('shipping', $false);
         $osC_Session->set('sendto', $false);
         tep_redirect(tep_href_link(FILENAME_CHECKOUT, 'payment', 'SSL'));
     }
     $total_weight = $cart->show_weight();
     $total_count = $cart->count_contents();
     // load all enabled shipping modules
     require DIR_WS_CLASSES . 'shipping.php';
     $shipping_modules = new shipping();
     if (defined('MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING') && MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING == 'true') {
         $pass = false;
         switch (MODULE_ORDER_TOTAL_SHIPPING_DESTINATION) {
             case 'national':
                 if ($order->delivery['country_id'] == STORE_COUNTRY) {
                     $pass = true;
                 }
                 break;
             case 'international':
                 if ($order->delivery['country_id'] != STORE_COUNTRY) {
                     $pass = true;
                 }
                 break;
             case 'both':
                 $pass = true;
                 break;
         }
         $free_shipping = false;
         if ($pass == true && $order->info['total'] - $order->info['shipping_cost'] >= MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER) {
             $free_shipping = true;
             include DIR_WS_LANGUAGES . $osC_Session->value('language') . '/modules/order_total/ot_shipping.php';
         }
     } else {
         $free_shipping = false;
     }
     // get all available shipping quotes
     $quotes = $shipping_modules->quote();
     // if no shipping method has been selected, automatically select the cheapest method.
     // if the modules status was changed when none were available, to save on implementing
     // a javascript force-selection method, also automatically select the cheapest shipping
     // method if more than one module is now enabled
     if ($osC_Session->exists('shipping') == false || $osC_Session->exists('shipping') && $osC_Session->value('shipping') == false && tep_count_shipping_modules() > 1) {
         $osC_Session->set('shipping', $shipping_modules->cheapest());
     }
     if ($_GET[$this->_module] == 'process') {
         $this->_process();
     }
 }
Exemple #15
0
$jinput = JFactory::getApplication()->input;
$post = $jinput->getArray($_POST);
$shippingbox_template = $redTemplate->getTemplate("shipping_box");
if (count($shippingbox_template) > 0 && $shippingbox_template[0]->template_desc) {
    $box_template_desc = $shippingbox_template[0]->template_desc;
} else {
    $box_template_desc = "<fieldset class=\"adminform\"> <legend><strong>{shipping_box_heading}</strong></legend>\r\n<div>{shipping_box_list}</div>\r\n</fieldset>";
}
$shipping_template = $redTemplate->getTemplate("redshop_shipping");
if (count($shipping_template) > 0 && $shipping_template[0]->template_desc) {
    $template_desc = $shipping_template[0]->template_desc;
} else {
    $template_desc = "<fieldset class=\"adminform\"><legend><strong>{shipping_heading}</strong></legend>\r\n<div>{shipping_method_loop_start}\r\n<h3>{shipping_method_title}</h3>\r\n<div>{shipping_rate_loop_start}\r\n<div>{shipping_rate_name} {shipping_rate}</div>\r\n{shipping_rate_loop_end}</div>\r\n{shipping_method_loop_end}</div>\r\n</fieldset>";
}
if ($this->users_info_id > 0) {
    $shippinghelper = new shipping();
    $shippingBoxes = $shippinghelper->getShippingBox();
    $selshipping_box_post_id = 0;
    if (count($shippingBoxes) > 0) {
        $selshipping_box_post_id = $shippingBoxes[0]->shipping_box_id;
    }
    if (isset($post['shipping_box_id'])) {
        $shipping_box_post_id = $post['shipping_box_id'];
    } else {
        $shipping_box_post_id = $selshipping_box_post_id;
    }
    $box_template_desc = $carthelper->replaceShippingBoxTemplate($box_template_desc, $shipping_box_post_id);
    echo eval("?>" . $box_template_desc . "<?php ");
    $returnarr = $carthelper->replaceShippingTemplate($template_desc, $this->shipping_rate_id, $shipping_box_post_id, $user->id, $this->users_info_id, $this->ordertotal, $this->order_subtotal);
    $template_desc = $returnarr['template_desc'];
    $this->shipping_rate_id = $returnarr['shipping_rate_id'];
Exemple #16
0
function process_merchant_calculation_callback_single($Gresponse)
{
    global $googlepayment, $order, $db, $total_weight, $total_count;
    list($root, $data) = $Gresponse->GetParsedXML();
    $currencies = new currencies();
    $cart = $_SESSION['cart'];
    $methods_hash = $googlepayment->getMethods();
    require DIR_WS_CLASSES . 'order.php';
    $order = new order();
    // Register a random ID in the session to check throughout the checkout procedure
    // against alterations in the shopping cart contents.
    //  if (!tep_session_is_registered('cartID')) {
    //  tep_session_register('cartID');
    // }
    //  $cartID = $cart->cartID;
    $items = get_arr_result($data[$root]['shopping-cart']['items']['item']);
    $products = array();
    foreach ($items as $item) {
        if (isset($item['merchant-private-item-data']['item']['VALUE'])) {
            $products[] = unserialize(base64_decode($item['merchant-private-item-data']['item']['VALUE']));
        }
    }
    $order->products = $products;
    $total_weight = $cart->show_weight();
    $total_count = $cart->count_contents();
    // Create the results and send it
    $merchant_calc = new GoogleMerchantCalculations(DEFAULT_CURRENCY);
    // Loop through the list of address ids from the callback.
    $addresses = get_arr_result($data[$root]['calculate']['addresses']['anonymous-address']);
    // Get all the enabled shipping methods.
    require DIR_WS_CLASSES . 'shipping.php';
    // Required for some shipping methods (ie. USPS).
    require_once 'includes/classes/http_client.php';
    foreach ($addresses as $curr_address) {
        // Set up the order address.
        $curr_id = $curr_address['id'];
        $country = $curr_address['country-code']['VALUE'];
        $city = $curr_address['city']['VALUE'];
        $region = $curr_address['region']['VALUE'];
        $postal_code = $curr_address['postal-code']['VALUE'];
        $countr_query = $db->Execute("select * \n                     from " . TABLE_COUNTRIES . " \n                     where countries_iso_code_2 = '" . makeSqlString($country) . "'");
        $row = $countr_query->fields;
        $order->delivery['country'] = array('id' => $row['countries_id'], 'title' => $row['countries_name'], 'iso_code_2' => $country, 'iso_code_3' => $row['countries_iso_code_3']);
        $order->delivery['country_id'] = $row['countries_id'];
        $order->delivery['format_id'] = $row['address_format_id'];
        $zone_query = $db->Execute("select * \n        \t\t                               from " . TABLE_ZONES . "\n        \t\t                               where zone_code = '" . makeSqlString($region) . "'");
        $row = $zone_query->fields;
        $order->delivery['zone_id'] = $row['zone_id'];
        $order->delivery['state'] = $row['zone_name'];
        $order->delivery['city'] = $city;
        $order->delivery['postcode'] = $postal_code;
        $shipping_modules = new shipping();
        // Loop through each shipping method if merchant-calculated shipping
        // support is to be provided
        //print_r($data[$root]['calculate']['shipping']['method']);
        if (isset($data[$root]['calculate']['shipping']['method'])) {
            $shipping = get_arr_result($data[$root]['calculate']['shipping']['method']);
            //      if (MODULE_PAYMENT_GOOGLECHECKOUT_MULTISOCKET == 'True') {
            //        // Single
            //        // i get all the enabled shipping methods
            //        $name = $shipping[0]['name'];
            //        //            Compute the price for this shipping method and address id
            //        list ($a, $method_name) = explode(': ', $name);
            //        if ((($order->delivery['country']['id'] == SHIPPING_ORIGIN_COUNTRY)
            //              && ($methods_hash[$method_name][1] == 'domestic_types'))
            //           || (($order->delivery['country']['id'] != SHIPPING_ORIGIN_COUNTRY)
            //              && ($methods_hash[$method_name][1] == 'international_types'))) {
            //          //								reset the shipping class to set the new address
            //          if (class_exists($methods_hash[$method_name][2])) {
            //            $GLOBALS[$methods_hash[$method_name][2]] = new $methods_hash[$method_name][2];
            //          }
            //        }
            //        $quotes = $shipping_modules->quote('', $methods_hash[$method_name][2]);
            //      } else {
            // Standard
            foreach ($shipping as $curr_ship) {
                $name = $curr_ship['name'];
                //            Compute the price for this shipping method and address id
                list($a, $method_name) = explode(': ', $name, 2);
                if ($order->delivery['country']['id'] == SHIPPING_ORIGIN_COUNTRY && $methods_hash[$method_name][1] == 'domestic_types' || $order->delivery['country']['id'] != SHIPPING_ORIGIN_COUNTRY && $methods_hash[$method_name][1] == 'international_types') {
                    //								reset the shipping class to set the new address
                    if (class_exists($methods_hash[$method_name][2])) {
                        $GLOBALS[$methods_hash[$method_name][2]] = new $methods_hash[$method_name][2]();
                    }
                }
            }
            $quotes = $shipping_modules->quote();
            //      }
            reset($shipping);
            foreach ($shipping as $curr_ship) {
                $name = $curr_ship['name'];
                //            Compute the price for this shipping method and address id
                list($a, $method_name) = explode(': ', $name, 2);
                unset($quote_povider);
                unset($quote_method);
                if ($order->delivery['country']['id'] == SHIPPING_ORIGIN_COUNTRY && $methods_hash[$method_name][1] == 'domestic_types' || $order->delivery['country']['id'] != SHIPPING_ORIGIN_COUNTRY && $methods_hash[$method_name][1] == 'international_types') {
                    foreach ($quotes as $key_provider => $shipping_provider) {
                        // privider name (class)
                        if ($shipping_provider['id'] == $methods_hash[$method_name][2]) {
                            // method name
                            $quote_povider = $key_provider;
                            if (is_array($shipping_provider['methods'])) {
                                foreach ($shipping_provider['methods'] as $key_method => $shipping_method) {
                                    if ($shipping_method['id'] == $methods_hash[$method_name][0]) {
                                        $quote_method = $key_method;
                                        break;
                                    }
                                }
                            }
                            break;
                        }
                    }
                }
                //if there is a problem with the method, i mark it as non-shippable
                if (isset($quotes[$quote_povider]['error']) || !isset($quotes[$quote_povider]['methods'][$quote_method]['cost'])) {
                    $price = "9999.09";
                    $shippable = "false";
                } else {
                    $price = $quotes[$quote_povider]['methods'][$quote_method]['cost'];
                    $shippable = "true";
                }
                // fix for item shipping function bug if called more than once in a session.
                $price = $price >= 0 ? $price : 0;
                $merchant_result = new GoogleResult($curr_id);
                $merchant_result->SetShippingDetails($name, $currencies->get_value(DEFAULT_CURRENCY) * $price, $shippable);
                if ($data[$root]['calculate']['tax']['VALUE'] == "true") {
                    //Compute tax for this address id and shipping type
                    $amount = 15;
                    // Modify this to the actual tax value
                    $merchant_result->SetTaxDetails($currencies->get_value(DEFAULT_CURRENCY) * $amount);
                }
                ////							 start cupons and gift processing (working)
                //								// only one coupon per order is valid!
                //                $_POST['dc_redeem_code'] = 'ROPU';
                //
                ////                require(DIR_WS_CLASSES . 'order.php');
                ////                $order = new order;
                //                require_once(DIR_WS_CLASSES . 'order_total.php');
                //                $order_total_modules = new order_total;
                ////                $order_total_modules->collect_posts();
                ////                $order_total_modules->pre_confirmation_check();
                //
                ////                print_r($order_total_modules);
                //                   $order_totals = $order_total_modules->process();
                ////                print_r($order_totals);
                //
                calculate_coupons($Gresponse, $merchant_result, $price);
                // end cupons
                $merchant_calc->AddResult($merchant_result);
            }
        } else {
            $merchant_result = new GoogleResult($curr_id);
            if ($data[$root]['calculate']['tax']['VALUE'] == "true") {
                //Compute tax for this address id and shipping type
                $amount = 15;
                // Modify this to the actual tax value
                $merchant_result->SetTaxDetails($currencies->get_value(DEFAULT_CURRENCY) * $amount);
            }
            calculate_coupons($Gresponse, $merchant_result);
            $merchant_calc->AddResult($merchant_result);
        }
    }
    $Gresponse->ProcessMerchantCalculations($merchant_calc);
}
Exemple #17
0
 public function calculateGrandTotal()
 {
     // calulate promo codes and group discounts
     //we need to tally up the cart, apply discounts, TAX that TOTAL somehow (different tax clases come into play), then add shipping
     //grab our discounts
     $cartDiscounts = $this->getOrderDiscounts();
     //reset totals
     $this->total_discounts = 0;
     $this->shipping_total = 0;
     $this->shipping_total_before_discounts = 0;
     $this->shippingDiscount = 0;
     $this->surcharge_total = 0;
     $this->subtotal = 0;
     $this->total = 0;
     $this->grand_total = 0;
     $this->tax = 0;
     $validateDiscountMessage = '';
     //eDebug($this->surcharge_total);
     //hate doing double loops, but we need to have the subtotal figured out already for
     //doing the straight dollar disoount calculations below
     for ($i = 0; $i < count($this->orderitem); $i++) {
         // figure out the amount of the discount
         /*if (!empty($this->product_discounts)) {
               $discount_amount = ($this->orderitem[$i]->products_price * ($this->product_discounts * .01));
               // change the price of the orderitem..this is needed for when we calculate tax below.
               $this->orderitem[$i]->products_price = $this->orderitem[$i]->products_price - $discount_amount;
               // keep a tally  of the total amount being subtracted by this discount.
               $this->total_discounts += $discount_amount;                
           }*/
         //$this->orderitem[$i]->products_price = $this->orderitem[$i]->getPriceWithOptions(); // * $this->orderitem[$i]->quantity;
         $this->orderitem[$i]->products_price_adjusted = $this->orderitem[$i]->products_price;
         //$this->orderitem[$i]->products_price_original = $this->orderitem[$i]->product->getPrice();
         $this->subtotal += $this->orderitem[$i]->products_price * $this->orderitem[$i]->quantity;
         $this->surcharge_total += $this->orderitem[$i]->product->getSurcharge() * $this->orderitem[$i]->quantity;
     }
     for ($i = 0; $i < count($this->orderitem); $i++) {
         //only allowing one discount for now, but in future we'll need to process
         //multiple and accomdate the "weight" and 'allow other discounts' type settings
         //this foreach will only fire once as of now, and will only hit on one or the other
         //TODO: We need to use produce_price_adjusted in the loops to accomodate for more than one disocunt
         //otherwise it's just resetting them now instead of adding them
         foreach ($cartDiscounts as $od) {
             //do not calculate invalid discounts, but don't remove either
             $discount = new discounts($od->discounts_id);
             /*$validateDiscountMessage = $discount->validateDiscount();
               if($validateDiscountMessage != '') break;*/
             //percentage discount
             if ($discount->action_type == 3) {
                 $discount_amount = round($this->orderitem[$i]->products_price * ($discount->discount_percent / 100), 2);
                 // change the price of the orderitem..this is needed for when we calculate tax below.
                 $this->orderitem[$i]->products_price_adjusted = $this->orderitem[$i]->products_price - $discount_amount;
                 // keep a tally  of the total amount being subtracted by this discount.
                 $this->total_discounts += $discount_amount * $this->orderitem[$i]->quantity;
             }
             //straight $$ discount
             if ($discount->action_type == 4) {
                 $this->total_discounts = $discount->discount_amount;
                 //what % of the order is this product with all it's quantity
                 $percentOfTotalOrder = $this->orderitem[$i]->products_price * $this->orderitem[$i]->quantity / $this->subtotal;
                 //figoure out how much that'll be and what each quanityt piece will bare
                 $discountAmountPerItem = round($percentOfTotalOrder * $discount->discount_amount / $this->orderitem[$i]->quantity, 2);
                 //$discount_amount = $this->orderitem[$i]->products_price * ($discount->discount_percent / 100);
                 // change the price of the orderitem..this is needed for when we calculate tax below.
                 $this->orderitem[$i]->products_price_adjusted = $this->orderitem[$i]->products_price - $discountAmountPerItem;
                 // keep a tally  of the total amount being subtracted by this discount.
                 //$this->total_discounts += $discountAmountPerItem * $this->orderitem[$i]->quantity;                    //eDebug($discountAmountPerItem);
             }
         }
         // calculate the tax for this product
         $taxclass = new taxclass($this->orderitem[$i]->product->tax_class_id);
         $this->orderitem[$i]->products_tax = $taxclass->getProductTax($this->orderitem[$i]);
         $this->tax += $this->orderitem[$i]->products_tax * $this->orderitem[$i]->quantity;
         //save out the order item
         $this->orderitem[$i]->save();
     }
     // add the "cart discounts" - percentage for sure, but straight can work also should be added after the final total is calculated,
     //including tax but not shipping
     // $this->updateOrderDiscounts();
     /*foreach ($cartDiscounts as $od)
       {
           $discount = new discounts($od->discounts_id); 
           if ($discount->action_type == 4)
           {                       
                $this->total_discounts += $discount->discount_amount;                           
           }                 
       }   */
     // calculate the shipping costs - need to check shipping discounts here in the future
     $estimate_shipping = false;
     if ($this->shipping_required) {
         $shippingmethods = $this->getShippingMethods();
         if (count($shippingmethods) > 0) {
             foreach ($shippingmethods as $sm_id) {
                 $method = new shippingmethod($sm_id, true);
                 if ($method->requiresShipping($this)) {
                     /*
                                             //need to implement handling
                                             $shippingCalc = new shippingcalculator($method->shippingcalculator_id);
                                             $calc = new $shippingCalc->calculator_name($method->shippingcalculator_id);
                                             eDebug($calc,true);*/
                     $this->shipping_total += $method->shipping_cost;
                     // + $method->calculator->getHandling();
                 }
             }
         } else {
             $estimate_shipping = true;
         }
     }
     $this->shipping_total_before_discounts = $this->shipping_total;
     if (isset($cartDiscounts)) {
         foreach ($cartDiscounts as $od) {
             $discount = new discounts($od->discounts_id);
             $this->shipping_total = $discount->calculateShippingTotal($this->shipping_total);
         }
     }
     $this->shippingDiscount = $this->shipping_total_before_discounts - $this->shipping_total;
     //check here to make sure we don't discount ourselves into oblivion
     $orderTotalPreDiscounts = $this->subtotal + $this->tax + $this->shipping_total;
     if ($this->total_discounts > $orderTotalPreDiscounts) {
         $this->total_discounts = $orderTotalPreDiscounts;
     }
     $this->total = $this->subtotal - $this->total_discounts;
     if ($estimate_shipping) {
         $this->shipping_total = shipping::estimateShipping($this);
     }
     // figure out which tax zones apply to this order.
     $this->taxzones = taxclass::getCartTaxZones($this);
     $this->grand_total = $this->subtotal - $this->total_discounts + $this->tax + $this->shipping_total + $this->surcharge_total;
     //if($validateDiscountMessage != '') flash('message',$validateDiscountMessage);
     //eDebug($this, true);
 }
Exemple #18
0
<? echo form::open_fieldset(array('class' => 'overview3'));
echo form::legend(Kohana::lang('eshop.other')); ?>
<p><? echo kohana::lang('eshop.status_order'); ?>: <strong><? echo customer::order_status($data['status_order'])?></strong></p>
<p><? echo kohana::lang('eshop.payment'); ?>: <strong><? echo payment::get_name($data['payment']); ?> &ndash; <? echo customer::payment_status($data['status_payment'])?></strong>

<? if($data['status_payment'] == 'none' AND payment::get_type($data['payment']) == "post"){ ?>
	&ndash; <a href="/cart/payment/<? echo $data['id']; ?>"><? echo Kohana::lang('eshop.payment_info'); ?></a>
<? } ?>
<? if($data['status_payment'] == 'none' AND payment::get_type($data['payment']) == "pre"){ ?>
	&ndash; <a href="/cart/payment/<? echo $data['id']; ?>"><? echo Kohana::lang('eshop.pay_now'); ?></a>
<? } ?>
</p>
<? if(payment::get_type($data['payment']) == "post"){ ?>
	<p><? echo Kohana::lang('eshop.vsymbol2'); ?>: <? echo $data['id']; ?></p>
<? } ?>
<p><? echo kohana::lang('eshop.shipping'); ?>: <strong><? echo shipping::get_name($data['shipping']); ?></strong></p>
<p><? echo kohana::lang('eshop.last_change'); ?>: <strong><? echo $data['last_change']; ?></strong></p>
<? echo form::close_fieldset(); ?>

<? echo form::close();?>

<h4><?php 
echo Kohana::lang('eshop.ordered');
?>
</h4>

<table class="cart">
	<tr><th><?php 
echo Kohana::lang('eshop.item');
?>
</th><th><?php 
$_SESSION['cartID'] = $_SESSION['cart']->cartID;

// if the order contains only virtual products, forward the customer to the billing page as
// a shipping address is not needed
if (($oOrder->content_type == 'virtual') || ($_SESSION['cart']->show_total() == 0) ) {
    $_SESSION['shipping'] = false;
    $_SESSION['sendto'] = false;
    MyOOS_CoreApi::redirect(oos_href_link($aPages['checkout_payment'], '', 'SSL'));
}

$total_weight = $_SESSION['cart']->show_weight();
$total_count = $_SESSION['cart']->count_contents();

// load all enabled shipping modules
require 'includes/classes/class_shipping.php';
$oShippingModules = new shipping;

if ( defined('MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING') && (MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING == '1') ) {
    switch (MODULE_ORDER_TOTAL_SHIPPING_DESTINATION) {
      case 'national':
        if ($oOrder->delivery['country_id'] == STORE_COUNTRY) $pass = true; break;

      case 'international':
        if ($oOrder->delivery['country_id'] != STORE_COUNTRY) $pass = true; break;

      case 'both':
        $pass = true; break;

      default:
        $pass = false; break;
    }
Exemple #20
0
 public function business_gls_export($cid)
 {
     $app = JFactory::getApplication();
     $oids = implode(',', $cid);
     $where = "";
     $redhelper = new redhelper();
     $order_helper = new order_functions();
     $shipping = new shipping();
     $exportfilename = 'redshop_gls_order_export.csv';
     /* Start output to the browser */
     if (ereg('Opera(/| )([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT'])) {
         $UserBrowser = "Opera";
     } elseif (ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT'])) {
         $UserBrowser = "IE";
     } else {
         $UserBrowser = '';
     }
     $mime_type = $UserBrowser == 'IE' || $UserBrowser == 'Opera' ? 'application/octetstream' : 'application/octet-stream';
     /* Clean the buffer */
     while (@ob_end_clean()) {
     }
     header('Content-Type: ' . $mime_type);
     header('Content-Encoding: UTF-8');
     header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
     if ($UserBrowser == 'IE') {
         header('Content-Disposition: inline; filename="' . $exportfilename . '"');
         header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
         header('Pragma: public');
     } else {
         header('Content-Disposition: attachment; filename="' . $exportfilename . '"');
         header('Pragma: no-cache');
     }
     if ($cid[0] != 0) {
         $where = " WHERE order_id IN (" . $oids . ")";
     }
     $db = JFactory::getDbo();
     $q = "SELECT * FROM #__redshop_orders " . $where . " ORDER BY order_id asc";
     $db->setQuery($q);
     $gls_arr = $db->loadObjectList();
     echo "Order_number,Quantity,Create_date,total_weight,reciever_firstName,reciever_lastname,Customer_note";
     echo "\r\n";
     for ($i = 0; $i < count($gls_arr); $i++) {
         $details = explode("|", $shipping->decryptShipping(str_replace(" ", "+", $gls_arr[$i]->ship_method_id)));
         if ($details[0] == 'shipper') {
             $orderproducts = $order_helper->getOrderItemDetail($gls_arr[$i]->order_id);
             $shippingDetails = $order_helper->getOrderShippingUserInfo($gls_arr[$i]->order_id);
             $billingDetails = $order_helper->getOrderBillingUserInfo($gls_arr[$i]->order_id);
             $totalWeight = "";
             $qty = "";
             for ($c = 0; $c < count($orderproducts); $c++) {
                 $product_id[] = $orderproducts[$c]->product_id;
                 $qty += $orderproducts[$c]->product_quantity;
                 $content_products[] = $orderproducts[$c]->order_item_name;
                 $sql = "SELECT weight FROM #__redshop_product WHERE product_id ='" . $orderproducts[$c]->product_id . "'";
                 $db->setQuery($sql);
                 $weight = $db->loadResult();
                 $totalWeight += $weight * $orderproducts[$c]->product_quantity;
             }
             $userDetail = ',"' . $shippingDetails->firstname . ' ' . $shippingDetails->lastname . '","' . $gls_arr[$i]->customer_note;
             echo '"' . $gls_arr[$i]->order_number . '","' . $qty . '","' . date("d-m-Y", $gls_arr[$i]->cdate) . '","' . $totalWeight . '","' . $userDetail . '"';
             echo "\r\n";
         }
     }
     exit;
 }
/**
 * Process a <merchant-calculation-callback>.
 */
function process_merchant_calculation_callback_single($google_response)
{
    global $google_checkout, $order, $cart, $total_weight, $total_count;
    list($root, $gc_data) = $google_response->GetParsedXML();
    $currencies = new currencies();
    // Get a hash array with the description of each shipping method
    $shipping_methods = $google_checkout->getMethods();
    require DIR_WS_CLASSES . 'order.php';
    $order = new order();
    $items = gc_get_arr_result($gc_data[$root]['shopping-cart']['items']['item']);
    // Get Coustoms OT
    $custom_order_totals_total = 0;
    $custom_order_totals = array();
    $order->products = array();
    foreach ($items as $item) {
        if (isset($item['merchant-private-item-data']['item']['VALUE'])) {
            $order->products[] = unserialize(base64_decode($item['merchant-private-item-data']['item']['VALUE']));
        } else {
            if ($item['merchant-private-item-data']['order_total']['VALUE']) {
                $ot = unserialize(base64_decode($item['merchant-private-item-data']['order_total']['VALUE']));
                $custom_order_totals[] = $ot;
                $order_total_value = $ot['value'] * (strrpos($ot['text'], '-') === false ? 1 : -1);
                $custom_order_totals_total += $currencies->get_value($gc_data[$root]['order-total']['currency']) * $order_total_value;
            } else {
                // For invoices.
                $order->products[] = array('qty' => $item['quantity']['VALUE'], 'name' => $item['item-name']['VALUE'], 'model' => $item['item-description']['VALUE'], 'tax' => 0, 'tax_description' => @$item['tax-table-selector']['VALUE'], 'price' => $item['unit-price']['VALUE'], 'final_price' => $item['unit-price']['VALUE'], 'onetime_charges' => 0, 'weight' => 0, 'products_priced_by_attribute' => 0, 'product_is_free' => 0, 'products_discount_type' => 0, 'products_discount_type_from' => 0, 'id' => @$item['merchant-item-id']['VALUE']);
            }
        }
    }
    $ex_cart = $cart;
    $cart = new shoppingCart();
    $prod_attr = gc_get_prattr($order->products);
    foreach ($prod_attr as $product_id => $item_data) {
        //$products_id, $qty = '1', $attributes = '
        $cart->add_cart($product_id, $item_data['qty'], $item_data['attr']);
    }
    // Register a random ID in the session to check throughout the checkout procedure
    // against alterations in the shopping cart contents.
    // TODO(eddavisson): Why is this commented out?
    //if (!tep_session_is_registered('cartID')) {
    //  tep_session_register('cartID');
    //}
    //$cartID = $cart->cartID;
    $total_weight = $cart->show_weight();
    $total_count = $cart->count_contents();
    // Create the results and send it
    $merchant_calc = new GoogleMerchantCalculations(DEFAULT_CURRENCY);
    // Loop through the list of address ids from the callback.
    $addresses = gc_get_arr_result($gc_data[$root]['calculate']['addresses']['anonymous-address']);
    // Get all the enabled shipping methods.
    require_once DIR_WS_CLASSES . 'shipping.php';
    // Required for some shipping methods (ie. USPS).
    require_once 'includes/classes/http_client.php';
    foreach ($addresses as $curr_address) {
        // Set up the order address.
        $curr_id = $curr_address['id'];
        $country = $curr_address['country-code']['VALUE'];
        $city = $curr_address['city']['VALUE'];
        $region = $curr_address['region']['VALUE'];
        $postal_code = $curr_address['postal-code']['VALUE'];
        $row = tep_db_fetch_array(tep_db_query("select * from " . TABLE_COUNTRIES . " where countries_iso_code_2 = '" . gc_make_sql_string($country) . "'"));
        $order->delivery['country'] = array('id' => $row['countries_id'], 'title' => $row['countries_name'], 'iso_code_2' => $country, 'iso_code_3' => $row['countries_iso_code_3']);
        $order->delivery['country_id'] = $row['countries_id'];
        $order->delivery['format_id'] = $row['address_format_id'];
        $row = tep_db_fetch_array(tep_db_query("select * from " . TABLE_ZONES . " where zone_code = '" . gc_make_sql_string($region) . "'"));
        $order->delivery['zone_id'] = $row['zone_id'];
        $order->delivery['state'] = $row['zone_name'];
        $order->delivery['city'] = $city;
        $order->delivery['postcode'] = $postal_code;
        //print_r($order);
        $shipping_modules = new shipping();
        // Loop through each shipping method if merchant-calculated shipping
        // support is to be provided
        //print_r($gc_data[$root]['calculate']['shipping']['method']);
        if (isset($gc_data[$root]['calculate']['shipping'])) {
            $shipping = gc_get_arr_result($gc_data[$root]['calculate']['shipping']['method']);
            // TODO(eddavisson): If we reactivate this, need to move to new configuration system.
            if (MODULE_PAYMENT_GOOGLECHECKOUT_MULTISOCKET == 'True') {
                // Single.
                // Get all the enabled shipping methods.
                $name = $shipping[0]['name'];
                // Compute the price for this shipping method and address id
                list($a, $method_name) = explode(': ', $name);
                if ($order->delivery['country']['id'] == SHIPPING_ORIGIN_COUNTRY && $shipping_methods[$method_name][1] == 'domestic_types' || $order->delivery['country']['id'] != SHIPPING_ORIGIN_COUNTRY && $shipping_methods[$method_name][1] == 'international_types') {
                    // Reset the shipping class to set the new address
                    if (class_exists($shipping_methods[$method_name][2])) {
                        $GLOBALS[$shipping_methods[$method_name][2]] = new $shipping_methods[$method_name][2]();
                    }
                }
                $quotes = $shipping_modules->quote('', $shipping_methods[$method_name][2]);
            } else {
                // Standard
                foreach ($shipping as $curr_ship) {
                    $name = $curr_ship['name'];
                    // Compute the price for this shipping method and address id
                    list($a, $method_name) = explode(': ', $name);
                    if ($order->delivery['country']['id'] == SHIPPING_ORIGIN_COUNTRY && $shipping_methods[$method_name][1] == 'domestic_types' || $order->delivery['country']['id'] != SHIPPING_ORIGIN_COUNTRY && $shipping_methods[$method_name][1] == 'international_types') {
                        // Reset the shipping class to set the new address.
                        if (class_exists($shipping_methods[$method_name][2])) {
                            $GLOBALS[$shipping_methods[$method_name][2]] = new $shipping_methods[$method_name][2]();
                        }
                    }
                }
                $quotes = $shipping_modules->quote();
            }
            reset($shipping);
            foreach ($shipping as $curr_ship) {
                $name = $curr_ship['name'];
                // Compute the price for this shipping method and address id
                list($a, $method_name) = explode(': ', $name);
                unset($quote_provider);
                unset($quote_method);
                if ($order->delivery['country']['id'] == SHIPPING_ORIGIN_COUNTRY && $shipping_methods[$method_name][1] == 'domestic_types' || $order->delivery['country']['id'] != SHIPPING_ORIGIN_COUNTRY && $shipping_methods[$method_name][1] == 'international_types') {
                    foreach ($quotes as $key_provider => $shipping_provider) {
                        // privider name (class)
                        if ($shipping_provider['id'] == $shipping_methods[$method_name][2]) {
                            // method name
                            $quote_provider = $key_provider;
                            if (is_array($shipping_provider['methods'])) {
                                foreach ($shipping_provider['methods'] as $key_method => $shipping_method) {
                                    if ($shipping_method['id'] == $shipping_methods[$method_name][0]) {
                                        $quote_method = $key_method;
                                        break;
                                    }
                                }
                            }
                            break;
                        }
                    }
                }
                //if there is a problem with the method, i mark it as non-shippable
                if (isset($quotes[$quote_provider]['error']) || !isset($quotes[$quote_provider]['methods'][$quote_method]['cost'])) {
                    $price = "9999.09";
                    $shippable = "false";
                } else {
                    $price = $quotes[$quote_provider]['methods'][$quote_method]['cost'];
                    $shippable = "true";
                }
                $merchant_result = new GoogleResult($curr_id);
                $merchant_result->SetShippingDetails($name, $currencies->get_value(DEFAULT_CURRENCY) * $price, $shippable);
                if ($gc_data[$root]['calculate']['tax']['VALUE'] == "true") {
                    // Compute tax for this address id and shipping type
                    $amount = 15;
                    // Modify this to the actual tax value
                    $merchant_result->SetTaxDetails($currencies->get_value(DEFAULT_CURRENCY) * $amount);
                }
                if (isset($gc_data[$root]['calculate']['merchant-code-strings']['merchant-code-string'])) {
                    $codes = gc_get_arr_result($gc_data[$root]['calculate']['merchant-code-strings']['merchant-code-string']);
                    foreach ($codes as $curr_code) {
                        // Update this data as required to set whether the coupon is valid, the code and the amount
                        $coupons = new GoogleCoupons("true", $curr_code['code'], $currencies->get_value(DEFAULT_CURRENCY) * 5, "test2");
                        $merchant_result->AddCoupons($coupons);
                    }
                }
                $merchant_calc->AddResult($merchant_result);
            }
        } else {
            $merchant_result = new GoogleResult($curr_id);
            if ($gc_data[$root]['calculate']['tax']['VALUE'] == "true") {
                // Compute tax for this address id and shipping type
                $amount = 15;
                // Modify this to the actual tax value
                $merchant_result->SetTaxDetails($currencies->get_value(DEFAULT_CURRENCY) * $amount);
            }
            //calculate_coupons($google_response, $merchant_result);
            $merchant_calc->AddResult($merchant_result);
        }
    }
    $cart = $ex_cart;
    $google_response->ProcessMerchantCalculations($merchant_calc);
}
Exemple #22
0
    $check_address_query = "SELECT count(*) AS total FROM " . TABLE_ADDRESS_BOOK . "\r\n                          WHERE customers_id = :customersID\r\n                          AND address_book_id = :addressBookID";
    $check_address_query = $db->bindVars($check_address_query, ':customersID', $_SESSION['customer_id'], 'integer');
    $check_address_query = $db->bindVars($check_address_query, ':addressBookID', $_SESSION['billto'], 'integer');
    $check_address = $db->Execute($check_address_query);
    if ($check_address->fields['total'] != '1') {
        $_SESSION['billto'] = $_SESSION['customer_default_address_id'];
        $_SESSION['payment'] = '';
    }
}
$total_weight = $_SESSION['cart']->show_weight();
$total_count = $_SESSION['cart']->count_contents();
require DIR_WS_CLASSES . 'order.php';
$order = new order();
// Load the selected shipping module(needed to calculate tax correctly)
require DIR_WS_CLASSES . 'shipping.php';
$shipping_modules = new shipping();
require DIR_WS_CLASSES . 'order_total.php';
$order_total_modules = new order_total();
$order_total_modules->collect_posts();
$order_total_modules->pre_confirmation_check();
//4px
//require(DIR_WS_CLASSES . 'DSFShipping.php');
// $objDSFShipping = new DSFShipping();
//  $country_info = zen_get_countries($order->delivery['country_id'], true);
//var_dump($country_info, $total_weight);
//$dsf_shippings = $objDSFShipping->calculate($country_info['countries_iso_code_2'], $total_weight);
//4px end
// get all available shipping quotes
$quotes = $shipping_modules->quote();
//4px shipping
//$quotes = array_merge($dsf_shippings, $quotes);
 public function getShippingRate()
 {
     $shippinghelper = new shipping();
     $get = JRequest::get('get');
     $shipping = explode("|", $shippinghelper->decryptShipping(str_replace(" ", "+", $get['shipping_rate_id'])));
     $order_shipping = 0;
     $order_shipping_class = '';
     if (count($shipping) > 4) {
         $order_shipping = $shipping[3] - $shipping[6];
         $order_shipping_tax = $shipping[6];
         $order_shipping_class = $shipping[0];
     }
     echo "<div id='resultShippingClass'>" . $order_shipping_class . "</div>";
     echo "<div id='resultShipping'>" . $order_shipping . "</div>";
     echo "<div id='resultShippingVat'>" . $order_shipping_tax . "</div>";
     die;
 }
 function confirmation()
 {
     global $order, $smarty, $xtPrice, $main, $messageStack, $total_weight, $total_count, $free_shipping;
     if (isset($_GET['conditions_message'])) {
         $message_condition = str_replace('\\n', '', ERROR_CONDITIONS_NOT_ACCEPTED);
         $message_address = str_replace('\\n', '', ERROR_ADDRESS_NOT_ACCEPTED);
         switch ($_GET['conditions_message']) {
             case "1":
                 $messageStack->add('checkout_confirmation', $message_condition);
                 break;
             case "13":
                 $messageStack->add('checkout_confirmation', $message_condition);
                 $messageStack->add('checkout_confirmation', ERROR_CHECKOUT_SHIPPING_NO_METHOD);
                 break;
             case "2":
                 $messageStack->add('checkout_confirmation', $message_address);
                 break;
             case "23":
                 $messageStack->add('checkout_confirmation', $message_address);
                 $messageStack->add('checkout_confirmation', ERROR_CHECKOUT_SHIPPING_NO_METHOD);
                 break;
             case "12":
                 $messageStack->add('checkout_confirmation', $message_condition);
                 $messageStack->add('checkout_confirmation', $message_address);
                 break;
             case "123":
                 $messageStack->add('checkout_confirmation', $message_condition);
                 $messageStack->add('checkout_confirmation', $message_address);
                 $messageStack->add('checkout_confirmation', ERROR_CHECKOUT_SHIPPING_NO_METHOD);
                 break;
             case "3":
                 $messageStack->add('checkout_confirmation', ERROR_CHECKOUT_SHIPPING_NO_METHOD);
                 break;
         }
     }
     if ($order->delivery['country']['iso_code_2'] != '') {
         $_SESSION['delivery_zone'] = $order->delivery['country']['iso_code_2'];
     }
     $no_shipping = false;
     if ($order->content_type == 'virtual' || $order->content_type == 'virtual_weight' || $_SESSION['cart']->count_contents_virtual() == 0) {
         $no_shipping = true;
     }
     $total_weight = $_SESSION['cart']->show_weight();
     $total_count = $_SESSION['cart']->count_contents();
     // load all enabled shipping modules
     $shipping_modules = new shipping();
     // add unallowed payment / shipping
     if (defined('MODULE_EXCLUDE_PAYMENT_STATUS') && MODULE_EXCLUDE_PAYMENT_STATUS == 'True') {
         for ($i = 1; $i <= MODULE_EXCLUDE_PAYMENT_NUMBER; $i++) {
             $payment_exclude = explode(',', constant('MODULE_EXCLUDE_PAYMENT_PAYMENT_' . $i));
             if (in_array($this->code, $payment_exclude)) {
                 $shipping_exclude = explode(',', constant('MODULE_EXCLUDE_PAYMENT_SHIPPING_' . $i));
                 for ($i = 0, $n = count($shipping_modules->modules); $i < $n; $i++) {
                     if (in_array(substr($shipping_modules->modules[$i], 0, -4), $shipping_exclude)) {
                         unset($shipping_modules->modules[$i]);
                     }
                 }
             }
         }
     }
     $free_shipping = false;
     $ot_shipping = new ot_shipping();
     $ot_shipping->process();
     if ($no_shipping === true) {
         $_SESSION['shipping'] = false;
     }
     // get all available shipping quotes
     $quotes = $shipping_modules->quote();
     // if no shipping method has been selected, automatically select the cheapest method.
     // if the modules status was changed when none were available, to save on implementing
     // a javascript force-selection method, also automatically select the cheapest shipping
     // method if more than one module is now enabled
     if (!isset($_SESSION['shipping']) && CHECK_CHEAPEST_SHIPPING_MODUL == 'true' || isset($_SESSION['shipping']) && $_SESSION['shipping'] == false && xtc_count_shipping_modules() > 1) {
         $_SESSION['shipping'] = $shipping_modules->cheapest();
     }
     if ($no_shipping === true) {
         $_SESSION['shipping'] = false;
     }
     if (defined('SHOW_SELFPICKUP_FREE') && SHOW_SELFPICKUP_FREE == 'true') {
         if ($free_shipping == true) {
             $free_shipping = false;
             $quotes = array_merge($ot_shipping->quote(), $shipping_modules->quote('selfpickup', 'selfpickup'));
         }
     }
     $module_smarty = new Smarty();
     $shipping_block = '';
     if (xtc_count_shipping_modules() > 0) {
         $showtax = $_SESSION['customers_status']['customers_status_show_price_tax'];
         $module_smarty->assign('FREE_SHIPPING', $free_shipping);
         # free shipping or not...
         if ($free_shipping == true) {
             $module_smarty->assign('FREE_SHIPPING_TITLE', FREE_SHIPPING_TITLE);
             $module_smarty->assign('FREE_SHIPPING_DESCRIPTION', sprintf(FREE_SHIPPING_DESCRIPTION, $xtPrice->xtcFormat($free_shipping_value_over, true, 0, true)) . xtc_draw_hidden_field('shipping', 'free_free'));
             $module_smarty->assign('FREE_SHIPPING_ICON', $quotes[$i]['icon']);
         } else {
             $radio_buttons = 0;
             #loop through installed shipping methods...
             for ($i = 0, $n = sizeof($quotes); $i < $n; $i++) {
                 if (!isset($quotes[$i]['error'])) {
                     for ($j = 0, $n2 = sizeof($quotes[$i]['methods']); $j < $n2; $j++) {
                         # set the radio button to be checked if it is the method chosen
                         $quotes[$i]['methods'][$j]['radio_buttons'] = $radio_buttons;
                         $checked = isset($_SESSION['shipping']) && $quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id'] == $_SESSION['shipping']['id'] ? true : false;
                         if ($checked == true || $n == 1 && $n2 == 1) {
                             $quotes[$i]['methods'][$j]['checked'] = 1;
                         }
                         if ($n > 1 || $n2 > 1) {
                             if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0 || !isset($quotes[$i]['tax'])) {
                                 $quotes[$i]['tax'] = 0;
                             }
                             $quotes[$i]['methods'][$j]['price'] = $xtPrice->xtcFormat(xtc_add_tax($quotes[$i]['methods'][$j]['cost'], $quotes[$i]['tax']), true, 0, true);
                             $quotes[$i]['methods'][$j]['radio_field'] = xtc_draw_radio_field('shipping', $quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id'], $checked, 'id="rd-' . ($i + 1) . '" onChange="this.form.submit()"');
                         } else {
                             if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0) {
                                 $quotes[$i]['tax'] = 0;
                             }
                             $quotes[$i]['methods'][$j]['price'] = $xtPrice->xtcFormat(xtc_add_tax($quotes[$i]['methods'][$j]['cost'], isset($quotes[$i]['tax']) ? $quotes[$i]['tax'] : 0), true, 0, true) . xtc_draw_hidden_field('shipping', $quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id']);
                         }
                         $radio_buttons++;
                     }
                 }
             }
             $module_smarty->assign('module_content', $quotes);
         }
         $module_smarty->assign('language', $_SESSION['language']);
         $module_smarty->caching = 0;
         $shipping_block = $module_smarty->fetch(CURRENT_TEMPLATE . '/module/checkout_shipping_block.html');
     }
     if ($no_shipping === false) {
         $module_smarty->assign('FORM_SHIPPING_ACTION', xtc_draw_form('checkout_shipping', xtc_href_link(FILENAME_CHECKOUT_CONFIRMATION, xtc_get_all_get_params(), 'SSL')) . xtc_draw_hidden_field('action', 'process'));
         $shipping_found = false;
         for ($i = 0, $n = sizeof($quotes); $i < $n; $i++) {
             for ($j = 0, $n2 = sizeof($quotes[$i]['methods']); $j < $n2; $j++) {
                 if ($quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id'] == $_SESSION['shipping']['id']) {
                     $shipping_found = true;
                     break;
                 }
             }
         }
         if ($shipping_found === false) {
             $module_smarty->assign('shipping_message', ERROR_CHECKOUT_SHIPPING_NO_METHOD);
             /*
             if (xtc_count_shipping_modules() == 1) {
               $module_smarty->assign('BUTTON_CONTINUE', xtc_image_submit('button_confirm.gif', IMAGE_BUTTON_CONFIRM));
             }
             */
         }
         $module_smarty->assign('BUTTON_CONTINUE', xtc_image_submit('button_confirm.gif', IMAGE_BUTTON_CONFIRM));
         $module_smarty->assign('FORM_END', '</form>');
         if ($no_shipping === false) {
             $module_smarty->assign('SHIPPING_BLOCK', $shipping_block);
         }
         $module_smarty->assign('language', $_SESSION['language']);
         $module_smarty->caching = 0;
         $shipping_method = $module_smarty->fetch(DIR_FS_EXTERNAL . '/paypal/templates/shipping_block.html');
         $smarty->assign('SHIPPING_METHOD', $shipping_method);
     }
     $smarty->assign('SHIPPING_ADDRESS_EDIT', xtc_href_link(FILENAME_CHECKOUT_SHIPPING_ADDRESS, xtc_get_all_get_params(), 'SSL'));
     $smarty->assign('BILLING_ADDRESS_EDIT', xtc_href_link(FILENAME_CHECKOUT_PAYMENT_ADDRESS, xtc_get_all_get_params(), 'SSL'));
     $smarty->clear_assign('SHIPPING_EDIT');
     $smarty->clear_assign('PAYMENT_EDIT');
     //$smarty->clear_assign('PRODUCTS_EDIT');
 }
 function quickPay()
 {
     global $order, $user;
     if ($order->shipping_required) {
         redirect_to(array('controller' => 'cart', 'action' => 'checkout'));
     }
     if (empty($order->orderitem)) {
         flashAndFlow('error', 'There are no items in your cart.');
     }
     // if we made it here it means that the item was add to the cart.
     expHistory::set('viewable', $this->params);
     // call each products checkout() callback & calculate total
     foreach ($order->orderitem as $item) {
         $product = new $item->product_type($item->product_id);
         $product->checkout();
     }
     // setup the billing & shipping calculators info
     if ($product->requiresBilling) {
         $billing = new billing();
         assign_to_template(array('billing' => $billing));
     }
     if ($product->requiresShipping) {
         $shipping = new shipping();
         $shipping->pricelist = $shipping->listPrices();
         assign_to_template(array('shipping' => $shipping));
     }
     assign_to_template(array('product' => $product, 'user' => $user, 'order' => $order));
 }
                 if (count($tell_a_friend_email) < zen_get_configuration_key_value("MODULE_SHIPPING_TELL_A_FRIEND_NO_OF_EMAILS")) {
                     $tell_a_friend_email_error .= "Please fill all the email fields.<br>";
                     $bool = false;
                 }
                 if ($tell_a_friend_email_error != '') {
                     $messageStack->add_session('checkout_shipping', $tell_a_friend_email_error, 'error');
                     $_SESSION['shipping'] = $shipping_modules->cheapest();
                     zen_redirect(zen_href_link(FILENAME_CHECKOUT, '', 'SSL'));
                 }
                 if ($bool) {
                     $quote = $shipping_modules->quote($method, $module);
                 }
                 //eof tell a freand
             } else {
                 // avoid incorrect calculations during redirect
                 $shipping_modules = new shipping();
                 $quote = $shipping_modules->quote($method, $module);
                 //$debug_logger->log_event (__FILE__, __LINE__, $quote);
             }
         }
         if (isset($quote['error'])) {
             $_SESSION['shipping'] = '';
         } else {
             if (isset($quote[0]['methods'][0]['title']) && isset($quote[0]['methods'][0]['cost'])) {
                 $_SESSION['shipping'] = array('id' => $_SESSION['shipping'], 'title' => $free_shipping == true ? $quote[0]['methods'][0]['title'] : $quote[0]['module'] . ' (' . $quote[0]['methods'][0]['title'] . ')', 'cost' => $quote[0]['methods'][0]['cost']);
             }
         }
     } else {
         $_SESSION['shipping'] = false;
     }
 }
     } else {
         // first timer
         $_SESSION['cart_country_id'] = STORE_COUNTRY;
         $_SESSION['country_info'] = zen_get_countries(STORE_COUNTRY, true);
         $country_info = $_SESSION['country_info'];
         $order->delivery = array('country' => array('id' => STORE_COUNTRY, 'title' => $country_info['countries_name'], 'iso_code_2' => $country_info['countries_iso_code_2'], 'iso_code_3' => $country_info['countries_iso_code_3']), 'country_id' => STORE_COUNTRY, 'zone_id' => $state_zone_id, 'format_id' => zen_get_address_format_id($_POST['zone_country_id']));
     }
     // set the cost to be able to calculate free shipping
     $order->info = array('total' => $_SESSION['cart']->show_total(), 'currency' => $currency, 'currency_value' => $currencies->currencies[$currency]['value']);
 }
 // weight and count needed for shipping !
 $total_weight = $_SESSION['cart']->show_weight();
 $shipping_estimator_display_weight = $total_weight;
 $total_count = $_SESSION['cart']->count_contents();
 require DIR_WS_CLASSES . 'shipping.php';
 $shipping_modules = new shipping();
 $quotes = $shipping_modules->quote();
 // print_r($quotes);
 // die('here');
 $order->info['subtotal'] = $_SESSION['cart']->show_total();
 // set selections for displaying
 $selected_country = $order->delivery['country']['id'];
 $selected_address = $sendto;
 // }
 // eo shipping cost
 // check free shipping based on order $total
 if (defined('MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING') && MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING == 'true') {
     switch (MODULE_ORDER_TOTAL_SHIPPING_DESTINATION) {
         case 'national':
             if ($order->delivery['country_id'] == STORE_COUNTRY) {
                 $pass = true;
Exemple #28
0
 /**
  *  Get Shipping rate function
  *
  * @return shipping rate by Ajax
  */
 public function getShippingrate()
 {
     include_once JPATH_COMPONENT_ADMINISTRATOR . '/helpers/shipping.php';
     $shipping = new shipping();
     echo $shipping->getShippingrate_calc();
     exit;
 }
}
require DIR_WS_CLASSES . 'order.php';
$order = new order();
if ($order->delivery['country']['iso_code_2'] != '') {
    $_SESSION['delivery_zone'] = $order->delivery['country']['iso_code_2'];
}
$kein_versand = 0;
if ($order->content_type == 'virtual' || $order->content_type == 'virtual_weight' || $_SESSION['cart']->count_contents_virtual() == 0) {
    // GV Code added
    $kein_versand = 1;
}
$total_weight = $_SESSION['cart']->show_weight();
$total_count = $_SESSION['cart']->count_contents();
// load all enabled shipping modules
require DIR_WS_CLASSES . 'shipping.php';
$shipping_modules = new shipping();
if (defined('MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING') && MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING == 'true') {
    switch (MODULE_ORDER_TOTAL_SHIPPING_DESTINATION) {
        case 'national':
            if ($order->delivery['country_id'] == STORE_COUNTRY) {
                $pass = true;
            }
            break;
        case 'international':
            if ($order->delivery['country_id'] != STORE_COUNTRY) {
                $pass = true;
            }
            break;
        case 'both':
            $pass = true;
            break;
Exemple #30
0
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $context = 'shipping_rate';
     $shippinghelper = new shipping();
     $userhelper = new rsUserhelper();
     $uri = JFactory::getURI();
     $model = $this->getModel();
     $db = JFactory::getDbo();
     $id = $app->getUserStateFromRequest($context . 'extension_id', 'extension_id', '0');
     $shipping = $shippinghelper->getShippingMethodById($id);
     $option = JRequest::getVar('option');
     $document = JFactory::getDocument();
     $document->addScript('components/' . $option . '/assets/js/select_sort.js');
     $document->addStyleSheet('components/' . $option . '/assets/css/search.css');
     $document->addScript('components/' . $option . '/assets/js/search.js');
     $document->addScript('components/' . $option . '/assets/js/common.js');
     $shippingpath = JPATH_ROOT . '/plugins/' . $shipping->folder . '/' . $shipping->element . '.xml';
     $myparams = new JRegistry($shipping->params, $shippingpath);
     $is_shipper = $myparams->get('is_shipper');
     $shipper_location = $myparams->get('shipper_location');
     $jtitle = $shipper_location ? JText::_('COM_REDSHOP_SHIPPING_LOCATION') : JText::_('COM_REDSHOP_SHIPPING_RATE');
     $this->setLayout('default');
     $lists = array();
     $detail = $this->get('data');
     $isNew = $detail->shipping_rate_id < 1;
     $text = $isNew ? JText::_('COM_REDSHOP_NEW') : JText::_('COM_REDSHOP_EDIT');
     JToolBarHelper::title($jtitle . ': <small><small>[ ' . $shipping->name . ' : ' . $text . ' ]</small></small>', 'redshop_shipping_rates48');
     JToolBarHelper::save();
     JToolBarHelper::apply();
     if ($isNew) {
         JToolBarHelper::cancel();
     } else {
         JToolBarHelper::cancel('cancel', JText::_('JTOOLBAR_CLOSE'));
     }
     $q = "SELECT  country_3_code as value,country_name as text from #__" . TABLE_PREFIX . "_country ORDER BY country_name ASC";
     $db->setQuery($q);
     $countries[] = JHTML::_('select.option', '0', '- ' . JText::_('COM_REDSHOP_SELECT_COUNTRY') . ' -', 'value', 'text');
     $countries = array_merge($countries, $db->loadObjectList());
     $shipping_rate_state = array();
     if ($detail->shipping_rate_country) {
         $shipping_rate_state = $model->GetStateList($detail->shipping_rate_country);
     }
     $detail->shipping_rate_state = explode(',', $detail->shipping_rate_state);
     $tmp = new stdClass();
     $tmp = @array_merge($tmp, $detail->shipping_rate_state);
     $lists['shipping_rate_state'] = JHTML::_('select.genericlist', $shipping_rate_state, 'shipping_rate_state[]', 'class="inputbox" multiple="multiple"', 'value', 'text', $detail->shipping_rate_state);
     $detail->shipping_rate_country = explode(',', $detail->shipping_rate_country);
     $tmp = new stdClass();
     $tmp = @array_merge($tmp, $detail->shipping_rate_country);
     $lists['shipping_rate_country'] = JHTML::_('select.genericlist', $countries, 'shipping_rate_country[]', 'class="inputbox" multiple="multiple" onchange="getStateList()" ', 'value', 'text', $detail->shipping_rate_country);
     $detail->shipping_rate_on_category = explode(',', $detail->shipping_rate_on_category);
     $product_category = new product_category();
     $lists['shipping_rate_on_category'] = $product_category->list_all("shipping_rate_on_category[]", 0, $detail->shipping_rate_on_category, 10, false, true);
     $shoppergroup = $userhelper->getShopperGroupList();
     $detail->shipping_rate_on_shopper_group = explode(',', $detail->shipping_rate_on_shopper_group);
     $lists['shipping_rate_on_shopper_group'] = JHTML::_('select.genericlist', $shoppergroup, 'shipping_rate_on_shopper_group[]', 'class="inputbox" multiple="multiple" ', 'value', 'text', $detail->shipping_rate_on_shopper_group);
     $lists['deliver_type'] = JHTML::_('select.booleanlist', 'deliver_type', 'class="inputbox"', $detail->deliver_type, 'COM_REDSHOP_HOME', 'COM_REDSHOP_POSTOFFICE');
     $productData = array();
     $result_container = array();
     if ($detail->shipping_rate_on_product) {
         $result_container = $model->GetProductListshippingrate($detail->shipping_rate_on_product);
     }
     $lists['product_all'] = JHTML::_('select.genericlist', $productData, 'product_all[]', 'class="inputbox" multiple="multiple" ', 'value', 'text', $detail->shipping_rate_on_product);
     $lists['shipping_product'] = JHTML::_('select.genericlist', $result_container, 'container_product[]', 'class="inputbox" onmousewheel="mousewheel(this);" ondblclick="selectnone(this);" multiple="multiple"  size="15" style="width:200px;" ', 'value', 'text', 0);
     $field = new extra_field();
     // Extra field
     $list_field = $field->list_all_field(11, $detail->shipping_rate_id);
     $lists['extra_field'] = $list_field;
     $shippingVatGroup = $model->getVatGroup();
     $temps = array((object) array('value' => '', 'text' => JText::_('COM_REDSHOP_SELECT')));
     $shippingVatGroup = array_merge($temps, $shippingVatGroup);
     $shippingfor = array((object) array('value' => 0, 'text' => JText::_('COM_REDSHOP_BOTH')), (object) array('value' => 1, 'text' => JText::_('COM_REDSHOP_COMPANY_ONLY')), (object) array('value' => 2, 'text' => JText::_('COM_REDSHOP_PRIVATE')));
     $lists['company_only'] = JHTML::_('select.genericlist', $shippingfor, 'company_only', 'class="inputbox" size="1" ', 'value', 'text', $detail->company_only);
     $lists['shipping_tax_group_id'] = JHTML::_('select.genericlist', $shippingVatGroup, 'shipping_tax_group_id', 'class="inputbox" size="1" ', 'value', 'text', $detail->shipping_tax_group_id);
     $this->is_shipper = $is_shipper;
     $this->shipper_location = $shipper_location;
     $this->lists = $lists;
     $this->detail = $detail;
     $this->shipping = $shipping;
     $this->request_url = $uri->toString();
     parent::display($tpl);
 }