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]}'");
// Upade orders db
try {
    $invoice = new invoiceTools();
    $invoice->setInvoiceID($_SESSION['cartInfoSession']['invoiceID']);
    $invoiceItemsCount = $invoice->queryInvoiceItems();
    // Number of invoice items total
    $digitalInvoiceItems = $invoice->getDigitalItems();
    $physicalInvoiceItems = $invoice->getPhysicalItems();
} catch (Exception $e) {
    echo $e->getMessage();
}
try {
    $smarty->assign('invoiceItemsCount', $invoiceItemsCount);
    // Number
    $smarty->assign('digitalInvoiceItems', $digitalInvoiceItems);
    // Digital invoice items
    $smarty->assign('physicalInvoiceItems', $physicalInvoiceItems);
    // Physical invoice items
    $smarty->assign('stepNumber', $stepNumber);