Beispiel #1
0
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;
}
Beispiel #2
0
function taxCalculateTaxByClass($taxClassID, $shippingAddressID, $billingAddressID)
{
    $shippingAddress = regGetAddress($shippingAddressID);
    $billingAddress = regGetAddress($billingAddressID);
    return taxCalculateTaxByClass2($taxClassID, $shippingAddress, $billingAddress);
}