コード例 #1
0
ファイル: module_function.php プロジェクト: gblok/rsc
function modGetAllInstalledModuleObjs($_ModuleType = 0)
{
    $ModuleObjs = array();
    $sql = 'select module_id FROM ' . MODULES_TABLE . ' ORDER BY module_name ASC, module_id ASC';
    $Result = db_query($sql);
    while ($_Row = db_fetch_row($Result)) {
        $_TObj = modGetModuleObj($_Row['module_id'], $_ModuleType);
        if ($_TObj && $_TObj->get_id() && $_TObj->is_installed()) {
            $ModuleObjs[] = $_TObj;
        }
    }
    return $ModuleObjs;
}
コード例 #2
0
ファイル: order2_shipping_quick.php プロジェクト: gblok/rsc
 function _getShippingCosts($shipping_methods, $order, $moduleFiles)
 {
     if (!isset($_SESSION["receiver_countryID"]) || !isset($_SESSION["receiver_zoneID"])) {
         return NULL;
     }
     $shipping_modules = modGetModules($moduleFiles);
     $shippingAddressID = 0;
     $shipping_costs = array();
     $res = cartGetCartContent();
     $sh_address = array("countryID" => $_SESSION["receiver_countryID"], "zoneID" => $_SESSION["receiver_zoneID"]);
     $addresses = array($sh_address, $sh_address);
     $j = 0;
     foreach ($shipping_methods as $shipping_method) {
         $_ShippingModule = modGetModuleObj($shipping_method["module_id"], SHIPPING_RATE_MODULE);
         if ($_ShippingModule) {
             if ($_ShippingModule->allow_shipping_to_address($sh_address)) {
                 $shipping_costs[$j] = oaGetShippingCostTakingIntoTax($res, $shipping_method["SID"], $addresses, $order);
             } else {
                 $shipping_costs[$j] = array(array('rate' => -1));
             }
         } else {
             $shipping_costs[$j] = oaGetShippingCostTakingIntoTax($res, $shipping_method["SID"], $addresses, $order);
         }
         $j++;
     }
     $_i = count($shipping_costs) - 1;
     for (; $_i >= 0; $_i--) {
         $_t = count($shipping_costs[$_i]) - 1;
         for (; $_t >= 0; $_t--) {
             if ($shipping_costs[$_i][$_t]['rate'] > 0) {
                 $shipping_costs[$_i][$_t]['rate'] = show_price($shipping_costs[$_i][$_t]['rate']);
             } else {
                 if (count($shipping_costs[$_i]) == 1 && $shipping_costs[$_i][$_t]['rate'] < 0) {
                     $shipping_costs[$_i] = 'n/a';
                 } else {
                     $shipping_costs[$_i][$_t]['rate'] = '';
                 }
             }
         }
     }
     return $shipping_costs;
 }
コード例 #3
0
ファイル: order_amount_functions.php プロジェクト: gblok/rsc
function oaGetShippingCostTakingIntoTax($cartContent, $shippingMethodID, $addresses, $orderDetails, $CALC_TAX = TRUE, $shServiceID = 0, $shServiceFull = FALSE)
{
    $Rates = array();
    $SimpleFormat = false;
    $shipping_method = shGetShippingMethodById($shippingMethodID);
    if ($shipping_method) {
        $shippingModule = modGetModuleObj($shipping_method["module_id"], SHIPPING_RATE_MODULE);
        if ($shippingModule) {
            //shipping address
            if (!is_array($addresses[0])) {
                $shippingAddress = regGetAddress($addresses[0]);
            } else {
                $shippingAddress = $addresses[0];
            }
            //order content
            $order = array("first_name" => $orderDetails["first_name"], "last_name" => $orderDetails["last_name"], "email" => $orderDetails["email"], "orderContent" => $cartContent, "order_amount" => $orderDetails["order_amount"]);
            $Rates = $shippingModule->calculate_shipping_rate($order, $shippingAddress, $shServiceID);
            if (!is_array($Rates)) {
                $Rates = array(array('name' => '', 'rate' => $Rates));
            }
        }
    }
    if (!count($Rates)) {
        $Rates[] = array('rate' => '0', 'name' => '');
    }
    foreach ($Rates as $_ind => $_Rate) {
        $Rates[$_ind]['rate'] += $cartContent["freight_cost"];
    }
    if ($CALC_TAX) {
        if (is_array($addresses[0])) {
            $rate = taxCalculateTaxByClass2(CONF_CALCULATE_TAX_ON_SHIPPING, $addresses[0], $addresses[1]);
        } else {
            $rate = taxCalculateTaxByClass(CONF_CALCULATE_TAX_ON_SHIPPING, $addresses[0], $addresses[1]);
        }
        foreach ($Rates as $_ind => $_Rate) {
            $Rates[$_ind]['rate'] += $Rates[$_ind]['rate'] / 100 * $rate;
        }
    }
    return $Rates;
}
コード例 #4
0
ファイル: order4_confirmation.php プロジェクト: gblok/rsc
             Redirect("index.php?product_removed=yes");
         }
     }
     $orderID = ordOrderProcessing($_GET["shippingMethodID"], $_GET["paymentMethodID"], $_GET["shippingAddressID"], $_GET["billingAddressID"], $shippingModuleFiles, $paymentModuleFiles, $_POST["order_comment"], $cc_number, $cc_holdername, $cc_expires, $cc_cvv, $_SESSION["log"], $smarty_mail, $shServiceID);
     $_SESSION["newoid"] = $orderID;
     cartClearCartContet();
     if (is_bool($orderID)) {
         RedirectProtected("index.php?order4_confirmation=yes" . "&shippingAddressID=" . $_GET["shippingAddressID"] . "&shippingMethodID=" . $_GET["shippingMethodID"] . "&billingAddressID=" . $_GET["billingAddressID"] . "&paymentMethodID=" . $_GET["paymentMethodID"] . "&payment_error=1");
     } else {
         RedirectProtected("index.php?order4_confirmation=yes" . "&order_success=yes&paymentMethodID=" . $_GET["paymentMethodID"] . "&orderID=" . $orderID);
     }
 }
 if (isset($_GET["order_success"])) {
     if (isset($_GET["orderID"]) && isset($_SESSION["newoid"]) && (int) $_SESSION["newoid"] == (int) $_GET["orderID"]) {
         $paymentMethod = payGetPaymentMethodById($_GET["paymentMethodID"]);
         $currentPaymentModule = modGetModuleObj($paymentMethod["module_id"], PAYMENT_MODULE);
         if ($currentPaymentModule != null) {
             $after_processing_html = $currentPaymentModule->after_processing_html($_GET["orderID"]);
         } else {
             $after_processing_html = "";
         }
         $smarty->assign("after_processing_html", $after_processing_html);
     }
     $smarty->assign("order_success", 1);
 } else {
     if (isset($_GET["payment_error"])) {
         if ($_GET["payment_error"] == 1) {
             $smarty->assign("payment_error", 1);
         } else {
             $smarty->assign("payment_error", base64_decode(str_replace(" ", "+", $_GET["payment_error"])));
         }
コード例 #5
0
ファイル: order_functions.php プロジェクト: gblok/rsc
function getOrderSummarize($shippingMethodID, $paymentMethodID, $shippingAddressID, $billingAddressID, $shippingModuleFiles, $paymentModulesFiles, $shServiceID = 0)
{
    // result this function
    $sumOrderContent = array();
    $q = db_query('select email_comments_text from ' . PAYMENT_TYPES_TABLE . ' where PID=' . (int) $paymentMethodID);
    $payment_email_comments_text = db_fetch_row($q);
    $payment_email_comments_text = $payment_email_comments_text[0];
    $q = db_query('select email_comments_text from ' . SHIPPING_METHODS_TABLE . ' where SID=' . (int) $shippingMethodID);
    $shipping_email_comments_text = db_fetch_row($q);
    $shipping_email_comments_text = $shipping_email_comments_text[0];
    $cartContent = cartGetCartContent();
    $pred_total = oaGetClearPrice($cartContent);
    if (isset($_SESSION['log'])) {
        $log = $_SESSION['log'];
    } else {
        $log = null;
    }
    $d = oaGetDiscountPercent($cartContent, $log);
    $discount = $pred_total / 100 * $d;
    // ordering with registration
    if ($shippingAddressID != 0 || isset($log)) {
        $addresses = array($shippingAddressID, $billingAddressID);
        $shipping_address = regGetAddressStr($shippingAddressID);
        $billing_address = regGetAddressStr($billingAddressID);
        $shaddr = regGetAddress($shippingAddressID);
        $sh_firstname = $shaddr['first_name'];
        $sh_lastname = $shaddr['last_name'];
    } else {
        if (!isset($_SESSION['receiver_countryID']) || !isset($_SESSION['receiver_zoneID'])) {
            return NULL;
        }
        $shippingAddress = array('countryID' => $_SESSION['receiver_countryID'], 'zoneID' => $_SESSION['receiver_zoneID']);
        $billingAddress = array('countryID' => $_SESSION['billing_countryID'], 'zoneID' => $_SESSION['billing_zoneID']);
        $addresses = array($shippingAddress, $billingAddress);
        $shipping_address = quickOrderGetReceiverAddressStr();
        $billing_address = quickOrderGetBillingAddressStr();
        $sh_firstname = $_SESSION['receiver_first_name'];
        $sh_lastname = $_SESSION['receiver_last_name'];
    }
    foreach ($cartContent['cart_content'] as $key => $cartItem) {
        // if conventional ordering
        if ($shippingAddressID != 0) {
            $productID = GetProductIdByItemId($cartItem['id']);
            $cartItem['tax'] = taxCalculateTax($productID, $addresses[0], $addresses[1]);
        } else {
            $productID = $cartItem['id'];
            $cartItem['tax'] = taxCalculateTax2($productID, $addresses[0], $addresses[1]);
        }
        if (!empty($cartItem['opt_margin']) && $paymentMethodID == 2) {
            $cost = $cartItem['costUC'];
            $margin = $cost / 100 * CONF_PERCENT_MARGIN;
            $cost += $margin;
            $costShow = show_price($cost * $cartItem['quantity']);
            $pred_total += $margin * $cartItem['quantity'];
            $cartContent['cart_content'][$key]['costUC'] = $cost;
            $cartContent['cart_content'][$key]['cost'] = $costShow;
            $cartItem['costUC'] = $cost;
            $cartItem['cost'] = $costShow;
        }
        $sumOrderContent[] = $cartItem;
    }
    $shipping_method = shGetShippingMethodById($shippingMethodID);
    if (!$shipping_method) {
        $shipping_name = '-';
    } else {
        $shipping_name = $shipping_method['Name'];
    }
    $payment_method = payGetPaymentMethodById($paymentMethodID);
    if (!$payment_method) {
        $payment_name = '-';
    } else {
        $payment_name = $payment_method['Name'];
    }
    //do not calculate tax for this payment type!
    if (isset($payment_method['calculate_tax']) && (int) $payment_method['calculate_tax'] == 0) {
        foreach ($sumOrderContent as $key => $val) {
            $sumOrderContent[$key]['tax'] = 0;
        }
        $orderDetails = array('first_name' => $sh_firstname, 'last_name' => $sh_lastname, 'email' => '', 'order_amount' => oaGetOrderAmountExShippingRate($cartContent, $addresses, $log, FALSE, $shServiceID));
        $tax = 0;
        $total = oaGetOrderAmount($cartContent, $addresses, $shippingMethodID, $log, $orderDetails, FALSE, $shServiceID);
        $shipping_cost = oaGetShippingCostTakingIntoTax($cartContent, $shippingMethodID, $addresses, $orderDetails, FALSE, $shServiceID);
    } else {
        $orderDetails = array('first_name' => $sh_firstname, 'last_name' => $sh_lastname, 'email' => '', 'order_amount' => oaGetOrderAmountExShippingRate($cartContent, $addresses, $log, FALSE));
        $tax = oaGetProductTax($cartContent, $d, $addresses);
        $total = oaGetOrderAmount($cartContent, $addresses, $shippingMethodID, $log, $orderDetails, TRUE, $shServiceID);
        $shipping_cost = oaGetShippingCostTakingIntoTax($cartContent, $shippingMethodID, $addresses, $orderDetails, TRUE, $shServiceID);
    }
    $tServiceInfo = null;
    if (is_array($shipping_cost)) {
        $_T = array_shift($shipping_cost);
        $tServiceInfo = $_T['name'];
        $shipping_cost = $_T['rate'];
    }
    $payment_form_html = '';
    $paymentModule = modGetModuleObj($payment_method['module_id'], PAYMENT_MODULE);
    if ($paymentModule) {
        $order = array();
        $address = array();
        if ($shippingAddressID != 0) {
            $payment_form_html = $paymentModule->payment_form_html(array('BillingAddressID' => $billingAddressID));
        } else {
            $payment_form_html = $paymentModule->payment_form_html(array('countryID' => $_SESSION['billing_countryID'], 'zoneID' => $_SESSION['billing_zoneID'], 'first_name' => $_SESSION['billing_first_name'], 'last_name' => $_SESSION['billing_last_name'], 'city' => $_SESSION['billing_city'], 'address' => $_SESSION['billing_address']));
        }
    }
    return array('sumOrderContent' => $sumOrderContent, 'discount' => $discount, 'discount_percent' => $d, 'discount_show' => show_price($discount), 'pred_total_disc' => show_price($pred_total * ((100 - $d) / 100)), 'pred_total' => show_price($pred_total), 'totalTax' => show_price($tax), 'totalTaxUC' => $tax, 'shipping_address' => $shipping_address, 'billing_address' => $billing_address, 'shipping_name' => $shipping_name, 'payment_name' => $payment_name, 'shipping_cost' => show_price($shipping_cost), 'shipping_costUC' => $shipping_cost, 'payment_form_html' => $payment_form_html, 'total' => show_price($total), 'totalUC' => $total, 'payment_email_comments_text' => $payment_email_comments_text, 'shipping_email_comments_text' => $shipping_email_comments_text, 'orderContentCartProductsCount' => count($sumOrderContent), 'shippingServiceInfo' => $tServiceInfo);
}
コード例 #6
0
ファイル: order2_shipping.php プロジェクト: gblok/rsc
 }
 $shippingAddressID = $_GET["shippingAddressID"];
 $order = _getOrder();
 $strAddress = regGetAddressStr($shippingAddressID);
 $moduleFiles = GetFilesInDirectory("core/modules/shipping", "php");
 foreach ($moduleFiles as $fileName) {
     include $fileName;
 }
 $shipping_methods = shGetAllShippingMethods(true);
 $shipping_costs = array();
 $res = cartGetCartContent();
 $sh_address = regGetAddress($shippingAddressID);
 $addresses = array($sh_address, $sh_address);
 $j = 0;
 foreach ($shipping_methods as $key => $shipping_method) {
     $_ShippingModule = modGetModuleObj($shipping_method["module_id"], SHIPPING_RATE_MODULE);
     if ($_ShippingModule) {
         if ($_ShippingModule->allow_shipping_to_address(regGetAddress($shippingAddressID))) {
             $shipping_costs[$j] = oaGetShippingCostTakingIntoTax($res, $shipping_method["SID"], $addresses, $order);
         } else {
             $shipping_costs[$j] = array(array('rate' => -1));
         }
     } else {
         $shipping_costs[$j] = oaGetShippingCostTakingIntoTax($res, $shipping_method["SID"], $addresses, $order);
     }
     $j++;
 }
 $_i = count($shipping_costs) - 1;
 for (; $_i >= 0; $_i--) {
     $_t = count($shipping_costs[$_i]) - 1;
     for (; $_t >= 0; $_t--) {
コード例 #7
0
ファイル: invoice_phys.php プロジェクト: gblok/rsc
    $sql = '
    SELECT count(*)
    FROM ' . ORDERS_TABLE . '
    WHERE orderID=' . $_GET['orderID'];
} else {
    if (!isset($_GET["orderID"]) || !isset($_GET["order_time"]) || !isset($_GET["customer_email"]) || !isset($_GET["moduleID"])) {
        die("Заказ не найден в базе данных");
    }
    $sql = '
    SELECT count(*)
    FROM ' . ORDERS_TABLE . '
    orderID=' . $_GET['orderID'] . '
    AND order_time="' . xEscSQL(base64_decode($_GET['order_time'])) . '"
    AND customer_email="' . xEscSQL(base64_decode($_GET['customer_email'])) . '"';
}
$InvoiceModule = modGetModuleObj((int) $_GET['moduleID'], PAYMENT_MODULE);
$_GET["orderID"] = (int) $_GET["orderID"];
$q = db_query($sql);
$row = db_fetch_row($q);
if ($row[0] == 1) {
    //заказ найден в базе данных
    $order = ordGetOrder($_GET["orderID"]);
    //define smarty vars
    $smarty->assign("billing_lastname", $order["customer_lastname"]);
    $smarty->assign("billing_firstname", $order["customer_firstname"]);
    $smarty->assign("billing_city", $order["billing_city"]);
    $smarty->assign("billing_address", $order["billing_address"]);
    if ($InvoiceModule->is_installed()) {
        $smarty->assign('InvoiceModule', $InvoiceModule);
        $smarty->assign("invoice_description", str_replace("[orderID]", (string) $_GET["orderID"], $InvoiceModule->_getSettingValue('CONF_PAYMENTMODULE_INVOICE_PHYS_DESCRIPTION')));
    } else {