示例#1
0
     if ($siteHasVouchers === -1) {
         $siteHasVouchers = dbOne('select count(id) ids from online_store_vouchers', 'ids');
         Core_cacheSave('online-store', 'site-has-vouchers', $siteHasVouchers);
     }
     if ($siteHasVouchers) {
         $c .= '<tr class="os_basket_totals online-store-vouchers">' . '<td class="voucher" style="text-align: right;" colspan="4">' . OnlineStore_showVoucherInput() . '</td></tr>';
     }
 }
 if ($group_discount && $discountableTotal) {
     // group discount
     $discount_amount = $discountableTotal * ($group_discount / 100);
     $c .= '<tr class="os_basket_totals">' . '<td class="group-discount" style="text-align:right;" colspan="3">' . '<span>' . __('Group Discount', 'core') . '</span> (' . $group_discount . '%)</td><td class="totals">-' . OnlineStore_numToPrice($discount_amount) . '</td></tr>';
     $grandTotal -= $discount_amount;
 }
 // { postage
 $postage = OnlineStore_getPostageAndPackaging($deliveryTotal, @$_REQUEST['Country'], 0);
 if ($postage['total']) {
     $grandTotal += $postage['total'];
     $c .= '<tr class="os_basket_totals postage"><td class="p_and_p __" lang-context="core" ' . 'style="text-align: right;" colspan="3">' . __('Postage and Packaging', 'core') . '</td><td class="totals">' . OnlineStore_numToPrice($postage['total']) . '</td></tr>';
 }
 // }
 if ($vattable && $_SESSION['onlinestore_vat_percent']) {
     $c .= '<tr class="os_basket_totals vat">' . '<td style="text-align:right" class="vat" colspan="3">' . '<span>' . __('VAT', 'core') . '</span> ( ' . $_SESSION['onlinestore_vat_percent'] . ' % ' . __('on', 'core') . OnlineStore_numToPrice($vattable) . ' )</td><td class="totals">';
     $vat = $vattable * ($_SESSION['onlinestore_vat_percent'] / 100);
     $c .= OnlineStore_numToPrice($vat) . '</td></tr>';
     $grandTotal += $vat;
 }
 $c .= '<tr class="os_basket_totals total-due"><td style="text-align: right;" colspa' . 'n="3">' . __('Total Due', 'core') . '</td>' . '<td class="totals">' . OnlineStore_numToPrice($grandTotal) . '</td></tr>' . '</table>';
 if ($has_vatfree) {
     $c .= '<div><sup>1</sup><span>' . __('VAT-free item', 'core') . '</span></div>';
 }
示例#2
0
/**
 * return the grand total in the checkout
 *
 * @return float
 */
function OnlineStore_getFinalTotal()
{
    $grandTotal = 0;
    $deliveryTotal = 0;
    $discountableTotal = 0;
    $vattable = 0;
    $has_vatfree = false;
    $user_is_vat_free = 0;
    $group_discount = 0;
    if (@$_SESSION['userdata']['id']) {
        $user = User::getInstance($_SESSION['userdata']['id']);
        if ($user) {
            $user_is_vat_free = $user->isInGroup('_vatfree');
            $group_discount = $user->getGroupHighest('discount');
        }
    }
    if (!isset($_SESSION['online-store']['items'])) {
        $_SESSION['online-store']['items'] = array();
    }
    foreach ($_SESSION['online-store']['items'] as $md5 => $item) {
        $totalItemCost = $item['cost'] * $item['amt'];
        $grandTotal += $totalItemCost;
        if ($item['vat']) {
            $vattable += $totalItemCost;
        }
        if (!isset($item['delivery_free']) || !$item['delivery_free']) {
            $deliveryTotal += $totalItemCost;
        }
        if (!isset($item['not_discountable']) || !$item['not_discountable']) {
            $discountableTotal += $totalItemCost;
        }
    }
    if (@$_REQUEST['os_voucher']) {
        require_once SCRIPTBASE . 'ww.plugins/online-store/frontend/voucher-libs.php';
        $email = @$_REQUEST['Email'];
        $code = $_REQUEST['os_voucher'];
        $voucher_amount = OnlineStore_voucherAmount($code, $email, $grandTotal);
        if ($voucher_amount) {
            $grandTotal -= $voucher_amount;
        }
    }
    if ($group_discount && $discountableTotal) {
        // group discount
        $discount_amount = $discountableTotal * ($group_discount / 100);
        $grandTotal -= $discount_amount;
    }
    // { postage
    $postage = OnlineStore_getPostageAndPackaging($deliveryTotal, '', 0);
    if ($postage['total']) {
        $grandTotal += $postage['total'];
    }
    // }
    if ($vattable && !$user_is_vat_free) {
        $vat = $vattable * ($_SESSION['onlinestore_vat_percent'] / 100);
        $grandTotal += $vat;
    }
    return $grandTotal;
}