$billInfo = $invoice->getBillDetails($billID); // Get the bill info using the passed bill ID $invoiceInfo = $invoice->getInvoiceDetailsViaBillDBID($billInfo['bill_id']); // Get invoice details // xxxxxx Check if this is a membership and if so then check to see if tax needs to be added $parms['noDefault'] = true; // Do not allow defaults just in case $cartInfo['orderNumber'] = $invoiceInfo['invoice_number']; $uniqueOrderID = "bill-{$billID}"; $cartTotals['subtotalMinusDiscounts'] = $invoiceInfo['total'] * 1; // Round it $cartTotals['taxTotal'] = 0; $cartTotals['shippingTotal'] = 0; $cartTotals['cartGrandTotal'] = $invoiceInfo['total'] * 1; // Round it $cartTotals['billGrandTotalLocal'] = getCorrectedPrice($cartTotals['cartGrandTotal'], $parms); $memberAddress['country'] = $_SESSION['member']['primaryAddress']['country']; $memberAddress['state'] = $_SESSION['member']['primaryAddress']['state']; $memberAddress['countryID'] = $_SESSION['member']['primaryAddress']['countryID']; $memberAddress['name'] = $_SESSION['member']['f_name'] . " " . $_SESSION['member']['l_name']; $memberAddress['firstName'] = $_SESSION['member']['f_name']; $memberAddress['lastName'] = $_SESSION['member']['l_name']; $memberAddress['address'] = $_SESSION['member']['primaryAddress']['address']; $memberAddress['address2'] = $_SESSION['member']['primaryAddress']['address2']; $memberAddress['city'] = $_SESSION['member']['primaryAddress']['city']; $memberAddress['stateID'] = $_SESSION['member']['primaryAddress']['stateID']; $memberAddress['postalCode'] = $_SESSION['member']['primaryAddress']['postal_code']; $memberAddress['email'] = $_SESSION['member']['email']; $memberAddress['phone'] = $_SESSION['member']['phone']; $shippingAddress = $memberAddress; $billingAddress = $memberAddress;
$billTotal = new number_formatting(); // Used to make sure the bills are showing in the admins currency $billTotal->set_custom_cur_defaults($config['settings']['defaultcur']); $parms['noDefault'] = true; $billResult = mysqli_query($db, "\r\n\t\t\tSELECT *\r\n\t\t\tFROM {$dbinfo[pre]}billings\r\n\t\t\tLEFT JOIN {$dbinfo[pre]}invoices \r\n\t\t\tON {$dbinfo[pre]}billings.bill_id = {$dbinfo[pre]}invoices.bill_id\r\n\t\t\tWHERE {$dbinfo[pre]}billings.member_id = {$memberID}\r\n\t\t\tAND {$dbinfo[pre]}billings.deleted = 0\r\n\t\t\tORDER BY {$dbinfo[pre]}invoices.invoice_date DESC\r\n\t\t\t"); if ($returnRows = mysqli_num_rows($billResult)) { while ($bill = mysqli_fetch_assoc($billResult)) { $billsArray[$bill['bill_id']] = $bill; $billsArray[$bill['bill_id']]['invoice_date_display'] = $customDate->showdate($bill['invoice_date'], 0); $billsArray[$bill['bill_id']]['due_date_display'] = $customDate->showdate($bill['due_date'], 0); if ($bill['payment_status'] != 2) { $cleanTotal['display'] = $billTotal->currency_display($bill['total'], 1); $cleanTotal['raw'] = round($price, 2); $billsArray[$bill['bill_id']]['total'] = $cleanTotal; } else { $billsArray[$bill['bill_id']]['total'] = getCorrectedPrice($bill['total'], $parms); } // Unpaid invoice can show in the members currency $billsArray[$bill['bill_id']]['payment_status_lang'] = billStatusNumToText($bill['payment_status']); if ($nowGMT > $bill['due_date'] and ($bill['payment_status'] == 2 or $bill['payment_status'] == 4)) { $billsArray[$bill['bill_id']]['past_due'] = true; } // See if the bill is past due } $smarty->assign('notice', $notice); $smarty->assign('billsArray', $billsArray); $smarty->assign('billRows', $returnRows); } $smarty->display('bills.tpl'); } catch (Exception $e) { echo $e->getMessage();
// Add updated tax a to session $_SESSION['cartTotalsSession']['taxB'] = $recalcTaxB; // Add updated tax b to session $_SESSION['cartTotalsSession']['taxC'] = $recalcTaxC; // Add updated tax c to session $_SESSION['cartTotalsSession']['taxTotal'] = $_SESSION['cartTotalsSession']['clearTax'] ? 0 : $recalcTaxTotal; // Add updated tax total to session $_SESSION['cartTotalsSession']['taxALocal'] = getCorrectedPrice($recalcTaxA, $parms); // Add updated local tax a to session $_SESSION['cartTotalsSession']['taxBLocal'] = getCorrectedPrice($recalcTaxB, $parms); // Add updated local tax b to session $_SESSION['cartTotalsSession']['taxCLocal'] = getCorrectedPrice($recalcTaxC, $parms); // Add updated local tax c to session $_SESSION['cartTotalsSession']['shippingTotal'] = $shippingDetails['total']; // Add shipping total to cartTotalsSession $_SESSION['cartTotalsSession']['cartGrandTotalLocal'] = getCorrectedPrice($cartGrandTotal, $parms); $_SESSION['cartTotalsSession']['shippingTotalLocal']['display'] = $shippingDetails['price']['display']; //$_SESSION['cartTotalsSession']['shippingTotalLocal'] = getCorrectedPrice($shippingDetails['price']['raw'],$parms); //echo $shippingDetails['price']['display']; if ($_SESSION['cartTotalsSession']['shippingRequired']) { // Create step numbers depending on if shipping is needed or not $stepNumber = array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4); } else { $stepNumber = array('a' => 1, 'b' => 0, 'c' => 2, 'd' => 3); } $currency = getCurrencyInfo($_SESSION['selectedCurrencySession']); // Get the details of the currently selected currency //echo 'name: '.$_SESSION['shippingAddressSession']['name']; exit; // Update invoice with shipping and billing info if known mysqli_query($db, "\r\n\t\tUPDATE {$dbinfo[pre]}invoices SET \r\n\t\tinvoice_mem_id='{$_SESSION[member][mem_id]}',\r\n\t\texchange_rate='{$currency[exchange_rate]}',\r\n\t\ttotal='{$cartGrandTotal}',\r\n\t\tsubtotal='{$_SESSION[cartTotalsSession][priceSubTotal]}',\r\n\t\ttaxa_cost='{$recalcTaxA}',\r\n\t\ttaxb_cost='{$recalcTaxB}',\r\n\t\ttaxc_cost='{$recalcTaxC}',\r\n\t\ttax_ratea='{$_SESSION[tax][tax_a_default]}',\r\n\t\ttax_rateb='{$_SESSION[tax][tax_b_default]}',\r\n\t\ttax_ratec='{$_SESSION[tax][tax_c_default]}',\r\n\t\tship_id='{$_SESSION[cartInfoSession][selectedShippingMethodID]}',\r\n\t\tshipping_cost='{$shippingDetails[total]}',\r\n\t\tship_name='{$_SESSION[shippingAddressSession][name]}',\r\n\t\tship_address='{$_SESSION[shippingAddressSession][address]}',\r\n\t\tship_address2='{$_SESSION[shippingAddressSession][address2]}',\r\n\t\tship_city='{$_SESSION[shippingAddressSession][city]}',\r\n\t\tship_state='{$_SESSION[shippingAddressSession][stateID]}',\r\n\t\tship_country='{$_SESSION[shippingAddressSession][countryID]}',\r\n\t\tship_zip='{$_SESSION[shippingAddressSession][postalCode]}',\r\n\t\tship_phone='{$_SESSION[shippingAddressSession][phone]}',\r\n\t\tship_email='{$_SESSION[shippingAddressSession][email]}',\r\n\t\tbill_name='{$_SESSION[billingAddressSession][name]}',\r\n\t\tbill_address='{$_SESSION[billingAddressSession][address]}',\r\n\t\tbill_address2='{$_SESSION[billingAddressSession][address2]}',\r\n\t\tbill_city='{$_SESSION[billingAddressSession][city]}',\r\n\t\tbill_state='{$_SESSION[billingAddressSession][stateID]}',\r\n\t\tbill_country='{$_SESSION[billingAddressSession][countryID]}',\r\n\t\tbill_zip='{$_SESSION[billingAddressSession][postalCode]}',\r\n\t\tbill_phone='{$_SESSION[billingAddressSession][phone]}',\r\n\t\tbill_email='{$_SESSION[billingAddressSession][email]}',\r\n\t\tshippable='{$_SESSION[cartTotalsSession][shippingRequired]}',\r\n\t\tshipping_summary='{$_SESSION[cartTotalsSession][shippingSummary]}'\r\n\t\tWHERE invoice_id = '{$_SESSION[cartInfoSession][invoiceID]}'\r\n\t"); mysqli_query($db, "UPDATE {$dbinfo[pre]}orders SET member_id='{$_SESSION[member][mem_id]}',checkout_lang='{$_SESSION[member][language]}' WHERE uorder_id = '{$_SESSION[uniqueOrderID]}'");
function shippingMethodsList($shipping) { global $shipPercentage, $config, $dbinfo, $selectedLanguage, $db; $shippableTotal = $_SESSION['cartTotalsSession']['shippableTotal']; $shippableCount = $_SESSION['cartTotalsSession']['shippableCount']; $shippableWeight = $_SESSION['cartTotalsSession']['shippableWeight']; //echo $shipping['calc_type']."<br>"; switch ($shipping['calc_type']) { case 1: // Weight $rangeResult = mysqli_query($db, "SELECT * FROM {$dbinfo[pre]}shipping_ranges WHERE ship_id = '{$shipping[ship_id]}' AND fromrange <= '{$shippableWeight}' AND torange >= '{$shippableWeight}'"); $rangeRows = mysqli_num_rows($rangeResult); //echo $shipping['cost_type']; if ($rangeRows) { $range = mysqli_fetch_array($rangeResult); if ($shipping['cost_type'] == 1) { // Fixed amount $shippingPrice = $range['price'] * $shipPercentage; } else { // Percentage $shippingPrice = $shippableTotal * ($range['price'] / 100) * $shipPercentage; } } else { // No range found $shipping['price']['raw'] = 0; } $shippingSummary2 = "<shipping>\r\n\t\t\t\t</shipping>\r\n\t\t\t\t"; break; case 2: // Subtotal $rangeResult = mysqli_query($db, "SELECT * FROM {$dbinfo[pre]}shipping_ranges WHERE ship_id = '{$shipping[ship_id]}' AND fromrange <= '{$shippableTotal}' AND torange >= '{$shippableTotal}'"); $rangeRows = mysqli_num_rows($rangeResult); if ($rangeRows) { $range = mysqli_fetch_array($rangeResult); if ($shipping['cost_type'] == 1) { // Fixed amount $shippingPrice = $range['price'] * $shipPercentage; } else { $shippingPrice = $shippableTotal * ($range['price'] / 100) * $shipPercentage; $shippingPrice = round($shippingPrice, 2); // Round the shipping down to 2 decimals just in case } } else { // No range found $shippingPrice = 0; } //echo "rr: {$rangeRows}: ship price: {$shippingPrice}"; $shippingSummary2 = "<shipping>\r\n\t\t\t\t</shipping>\r\n\t\t\t\t"; break; case 3: // Flat Rate if ($shipping['cost_type'] == 1) { // Fixed amount $shippingPrice = $shipping['flat_rate'] * $shipPercentage; } else { $shippingPrice = $shippableTotal * ($shipping['flat_rate'] / 100) * $shipPercentage; $shippingPrice = round($shippingPrice, 2); // Round the shipping down to 2 decimals just in case } //echo "ship cost type: " . $shipping['flat_rate']; $shippingSummary2 = "<shipping>\r\n\t\t\t\t</shipping>\r\n\t\t\t\t"; break; case 4: // Quantity $rangeResult = mysqli_query($db, "SELECT * FROM {$dbinfo[pre]}shipping_ranges WHERE ship_id = '{$shipping[ship_id]}' AND fromrange <= '{$shippableCount}' AND torange >= '{$shippableCount}'"); $rangeRows = mysqli_num_rows($rangeResult); //echo 'sc'.$shippableCount; if ($rangeRows) { $range = mysqli_fetch_array($rangeResult); if ($shipping['cost_type'] == 1) { // Fixed amount $shippingPrice = $range['price'] * $shipPercentage; } else { $shippingPrice = $shippableTotal * ($range['price'] / 100) * $shipPercentage; $shippingPrice = round($shippingPrice, 2); // Round the shipping down to 2 decimals just in case } } else { // No range found $shippingPrice = 0; } $shippingSummary2 = "<shipping>\r\n\t\t\t\t</shipping>\r\n\t\t\t\t"; break; } if ($_SESSION['cartTotalsSession']['additionalShipping']) { // Add any additional shipping from prints, products, packages $shippingPrice += $_SESSION['cartTotalsSession']['additionalShipping']; } $shipping['total'] = $_SESSION['cartTotalsSession']['clearShipping'] ? 0 : $shippingPrice; // Clear the shipping? $shipping['title'] = $shipping['title_' . $selectedLanguage] ? $shipping['title_' . $selectedLanguage] : $shipping['title']; // Choose the correct language $shipping['description'] = $shipping['description_' . $selectedLanguage] ? $shipping['description_' . $selectedLanguage] : $shipping['description']; // Choose the correct language if ($_SESSION['tax']['tax_inc'] and $_SESSION['tax']['tax_shipping'] and $shipping['taxable']) { $priceParms['taxInc'] = true; $shipping['taxInc'] = true; } $priceParms['noDefault'] = true; $shipping['price'] = getCorrectedPrice($shippingPrice, $priceParms); return $shipping; }
$cartTotals['totalCreditsDiscounts'] = $discountOnCreditsSubTotal; $cartTotals['totalDiscounts'] = $discountOnPhysicalTotal + $discountOnDigitalTotal; $cartTotals['totalPhysicalDiscounts'] = $discountOnPhysicalTotal; $cartTotals['totalDigitalDiscounts'] = $discountOnDigitalTotal; // xxx make sure to make this a session also just in case someone tries to change the input values on the cart page $creditsAvailableAtCheckout = $_SESSION['member']['credits'] + $creditsInCart; $cartTotals['creditsAvailableAtCheckout'] = $creditsAvailableAtCheckout ? $creditsAvailableAtCheckout : 0; // Check how many credits the member has at checkout - include those in the current cart // Set display totals $cartTotals['totalDiscountsLocal'] = getCorrectedPrice($cartTotals['totalDiscounts'], $parms); // For display $cartTotals['subTotalLocal'] = getCorrectedPrice($cartTotals['priceSubTotal'], $parms); // For display $cartTotals['totalLocal'] = getCorrectedPrice($cartTotals['total'], $parms); // For display $cartTotals['priceSubTotalPreview'] = getCorrectedPrice($cartTotals['priceSubTotal'], $parms); // For preview $cartTotals['creditsSubTotalPreview'] = $cartTotals['creditsSubTotal'] <= 0 ? 0 : $cartTotals['creditsSubTotal']; // Do extra check for no credits - default to 0 $smarty->assign('cartItemRows', $cartItemRows); // Assign a count of the number of items in the cart // Assign the entire array unless we are asking for only the last item if ($onlyLastAdded) { $smarty->assign('cartItems', array_slice($cartItemsArray, 0, 1)); } else { $smarty->assign('cartItems', $cartItemsArray); } $_SESSION['cartItemsSession'] = $cartItemsArray; // Put the cart items into a session to use them later $cartTotals['itemsInCart'] = $cartItemRows; //$_SESSION['itemsInCart'] = $cartItemRows;
$invoice['taxc_cost'] = $taxcTemp['display']; $paymentTemp = getCorrectedPrice(0, $parms); // Unpaid invoice can show in the members currency $invoice['payment'] = $paymentTemp['display']; $invoice['balance'] = $invoice['total']; $shippingTemp = getCorrectedPrice($invoice['shipping_cost'], $parms); // Unpaid invoice can show in the members currency $invoice['shipping_cost'] = $shippingTemp['display']; } if ($billInfo['bill_type'] == 1) { foreach ($invoiceItems as $invoiceItemKey => $invoiceItem) { if ($invoice['payment_status'] != 2) { $invoiceItems[$invoiceItemKey]['price_total'] = $billTotal->currency_display($invoiceItems[$invoiceItemKey]['price_total'], 1); $invoiceItems[$invoiceItemKey]['cost_value'] = $billTotal->currency_display($invoiceItems[$invoiceItemKey]['price_total'], 1); } else { $priceTotal = getCorrectedPrice($invoiceItems[$invoiceItemKey]['price_total'], $parms); // Unpaid invoice can show in the members currency $invoiceItems[$invoiceItemKey]['price_total'] = $priceTotal['display']; $invoiceItems[$invoiceItemKey]['cost_value'] = $priceTotal['display']; } $invoiceItems[$invoiceItemKey]['name'] = $invoiceItems[$invoiceItemKey]['description']; // Set the quantity to 1 $invoiceItems[$invoiceItemKey]['quantity'] = 1; // Set the quantity to 1 } } if ($invoice['bill_type'] == 2) { /* $itemsResult = mysqli_query($db, " SELECT * FROM {$dbinfo[pre]}orders