Example #1
0
function add_order($card_type, $card_number, $card_cvv, $card_expires)
{
    global $db;
    $customer_id = $_SESSION['user']['customerID'];
    $billing_id = $_SESSION['user']['billingAddressID'];
    $shipping_id = $_SESSION['user']['shipAddressID'];
    $shipping_cost = shipping_cost();
    $tax = tax_amount(cart_subtotal());
    $order_date = date("Y-m-d H:i:s");
    $query = '
         INSERT INTO orders (customerID, orderDate, shipAmount, taxAmount,
                             shipAddressID, cardType, cardNumber,
                             cardExpires, billingAddressID)
         VALUES (:customer_id, :order_date, :ship_amount, :tax_amount,
                 :shipping_id, :card_type, :card_number,
                 :card_expires, :billing_id)';
    $statement = $db->prepare($query);
    $statement->bindValue(':customer_id', $customer_id);
    $statement->bindValue(':order_date', $order_date);
    $statement->bindValue(':ship_amount', $shipping_cost);
    $statement->bindValue(':tax_amount', $tax);
    $statement->bindValue(':shipping_id', $shipping_id);
    $statement->bindValue(':card_type', $card_type);
    $statement->bindValue(':card_number', $card_number);
    $statement->bindValue(':card_expires', $card_expires);
    $statement->bindValue(':billing_id', $billing_id);
    $statement->execute();
    $order_id = $db->lastInsertId();
    $statement->closeCursor();
    return $order_id;
}
Example #2
0
function add_order($card_type, $card_number, $card_cvv, $card_expires)
{
    global $db;
    $customer_id = $_SESSION['user']['idkhachhang'];
    $billing_id = $_SESSION['user']['iddiachithanhtoan'];
    $shipping_id = $_SESSION['user']['iddiachigiaohang'];
    $shipping_cost = shipping_cost();
    $tax = tax_amount(cart_subtotal());
    $order_date = date("Y-m-d H:i:s");
    $query = '
         INSERT INTO donhang (idkhachhang, ngaydathang, phigiaohang, thue,
                             iddiachigiaohang, loaithe, mathe,
                             hansudungthe, iddiachithanhtoan)
         VALUES (:idkhachhang, :ngaydathang, :phigiaohang, :thue,
                 :iddiachigiaohang, :loaithe, :mathe,
                 :hansudungthe, :iddiachithanhtoan)';
    $statement = $db->prepare($query);
    $statement->bindValue(':idkhachhang', $customer_id);
    $statement->bindValue(':ngaydathang', $order_date);
    $statement->bindValue(':phigiaohang', $shipping_cost);
    $statement->bindValue(':thue', $tax);
    $statement->bindValue(':iddiachigiaohang', $shipping_id);
    $statement->bindValue(':loaithe', $card_type);
    $statement->bindValue(':mathe', $card_number);
    $statement->bindValue(':hansudungthe', $card_expires);
    $statement->bindValue(':iddiachithanhtoan', $billing_id);
    $statement->execute();
    $order_id = $db->lastInsertId();
    $statement->closeCursor();
    return $order_id;
}
Example #3
0
    exit;
}
$action = filter_input(INPUT_POST, 'action');
if ($action == NULL) {
    $action = filter_input(INPUT_GET, 'action');
    if ($action == NULL) {
        $action = 'confirm';
    }
}
switch ($action) {
    case 'confirm':
        $cart = cart_get_items();
        if (cart_product_count() == 0) {
            redirect('../cart');
        }
        $subtotal = cart_subtotal();
        $item_count = cart_item_count();
        $item_shipping = 5;
        $shipping_cost = shipping_cost();
        $shipping_address = get_address($_SESSION['user']['shipAddressID']);
        $state = $shipping_address['state'];
        $tax = tax_amount($subtotal);
        // function from order_db.php file
        $total = $subtotal + $tax + $shipping_cost;
        include 'checkout_confirm.php';
        break;
    case 'payment':
        if (cart_product_count() == 0) {
            redirect($app_path . 'cart');
        }
        $card_number = '';
Example #4
0
">
                </td>
                <td class="right">
                    <?php 
        echo sprintf('$%.2f', $item['line_price']);
        ?>
                </td>
            </tr>
            <?php 
    }
    ?>
            <tr id="cart_footer" >
                <td colspan="3" class="right" ><b>Subtotal</b></td>
                <td class="right">
                    <?php 
    echo sprintf('$%.2f', cart_subtotal());
    ?>
                </td>
            </tr>
            <tr>
                <td colspan="4" class="right">
                    <input type="submit" value="Update Cart">
                </td>
            </tr>
            </table>
        </form>
        
    <?php 
}
?>
Example #5
0
" />
                </td>
                <td class="right">
                    <?php 
        echo sprintf($item['line_price']);
        ?>
                </td>
            </tr>
            <?php 
    }
    ?>
            <tr id="cart_footer" >
                <td colspan="3" class="right" ><b>Tổng cộng</b></td>
                <td class="right">
                    <?php 
    echo sprintf(cart_subtotal());
    ?>
                </td>
            </tr>
            <tr>
                <td colspan="4" class="right">
                    <input type="submit" value="Cập nhập giỏ hàng" />
                </td>
            </tr>
            </table>
        </form>
        
    <?php 
}
?>