Esempio n. 1
0
function draw()
{
    global $_CONF, $_TABLES, $LANG_ECOM;
    $display = "";
    $cart = get_cart_information();
    $sales_tax = $_SESSION['orderAmount'] - ($cart['total'] + $_SESSION['shipping_price']);
    $T = new Template($_CONF['path'] . 'plugins/ecommerce/templates/payment_processor');
    $T->set_file(array('cybersource_receipt' => 'cybersource_receipt.thtml', 'cybersource_receipt_cart_row' => 'cybersource_receipt_cart_row.thtml'));
    $T->set_var('order_number', $_SESSION['orderNumber']);
    $T->set_var('b_first_name', $_SESSION['billTo_firstName']);
    $T->set_var('b_last_name', $_SESSION['billTo_lastName']);
    $T->set_var('b_address_line_1', $_SESSION['billTo_street1']);
    $T->set_var('b_city', $_SESSION['billTo_city']);
    $T->set_var('b_state', $_SESSION['billTo_state']);
    $T->set_var('b_zip', $_SESSION['billTo_postalCode']);
    $T->set_var('b_country', strtoupper($_SESSION['billTo_country']));
    $T->set_var('s_full_name', $_SESSION['full_name']);
    $T->set_var('s_address_line_1', $_SESSION['address_line1']);
    $T->set_var('s_address_line_2', $_SESSION['address_line2']);
    $T->set_var('s_city', $_SESSION['city']);
    $T->set_var('s_state', $_SESSION['state']);
    $T->set_var('s_zip', $_SESSION['zip']);
    $T->set_var('s_country', strtoupper($_SESSION['country']));
    $T->set_var('msg_193', $LANG_ECOM[193]);
    $T->set_var('msg_194', $LANG_ECOM[194]);
    $T->set_var('msg_195', $LANG_ECOM[195]);
    #######
    foreach ($cart['items'] as $item) {
        $total = $item['price'] * $item['quantity'];
        $T->set_var('name', $item['name']);
        $T->set_var('price', number_format($item['price'], 2));
        $T->set_var('quantity', $item['quantity']);
        $T->set_var('item_total', number_format($total, 2));
        $T->parse('cybersource_receipt_cart_row', 'cybersource_receipt_cart_row');
    }
    $T->set_var('sub_total', number_format($cart['total'], 2));
    $T->set_var('shipping_details', $_SESSION['shipping_description']);
    $T->set_var('shipping_total', number_format($_SESSION['shipping_price'], 2));
    $T->set_var('sales_tax', number_format($sales_tax, 2));
    $T->set_var('grand_total', number_format($_SESSION['orderAmount'], 2));
    $T->set_var('b_email_address', $_SESSION['billTo_email']);
    //If Credit Card
    if ($_SESSION['card_accountNumber'] != "") {
        $T->set_var('credit_card', true);
        $T->set_var('card_number', $_SESSION['card_accountNumber']);
        $T->set_var('card_exp_month', $_SESSION['card_expirationMonth']);
        $T->set_var('card_exp_year', $_SESSION['card_expirationYear']);
    } else {
        $T->set_var('credit_card', false);
        //Fill in check fields as needed
    }
    $T->set_var('msg_38', $LANG_ECOM[38]);
    $T->set_var('msg_163', $LANG_ECOM[163]);
    $T->set_var('msg_180', $LANG_ECOM[180]);
    $T->set_var('msg_183', $LANG_ECOM[183]);
    $T->set_var('msg_184', $LANG_ECOM[184]);
    $T->set_var('msg_196', $LANG_ECOM[196]);
    $T->set_var('msg_197', $LANG_ECOM[197]);
    $T->parse('output', 'cybersource_receipt');
    echo $T->finish($T->get_var('output'));
    ####
    //Send email
    $res = DB_query("SELECT email, email_from FROM {$_TABLES['ecom_config']}");
    $row = DB_fetchArray($res);
    $headers = 'MIME-Version: 1.0' . "\r\n";
    //REquired for HTML
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $headers .= 'From: ' . $row['email_from'] . "\r\n";
    //send receipt to user
    mail($_SESSION['billTo_email'], "Order Number: " . $_SESSION['orderNumber'] . "", $display, $headers);
    //send duplicate receipt to address specified
    mail($row['email'], "Order Number: " . $_SESSION['orderNumber'] . "", $display, $headers);
    //Add transactions to database
    if ($_SESSION['uid'] == 0) {
        $uid = 1;
    } else {
        $uid = $_SESSION['uid'];
    }
    add_transactions($cart['items'], $_SESSION['orderNumber'], $uid, $_SESSION['shipping_price'], $sales_tax);
}
Esempio n. 2
0
$headers = 'MIME-Version: 1.0' . "\r\n";
//REquired for HTML
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: ' . $row['email_from'] . "\r\n";
//send receipt to user
mail($user_email['email'], "Order Number: " . $resArray['TRANSACTIONID'] . "", $display, $headers);
//send duplicate receipt to address specified
mail($row['email'], "Order Number: " . $resArray['TRANSACTIONID'] . "", $display, $headers);
echo COM_siteFooter(0);
//Add transactions to database
if ($_SESSION['uid'] == 0) {
    $uid = 1;
} else {
    $uid = $_SESSION['uid'];
}
add_transactions($cart['items'], $resArray['TRANSACTIONID'], $uid, $_SESSION['shipping_price'], $sales_tax);
session_destroy();
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^GET_CART_INFORMATION^^
# Get information from cart and total up the price and quantity of items purchase
# for display on receipt
#________________________________________________________________________________________________________
function get_cart_information()
{
    global $_TABLES, $_CONF;
    require_once $_CONF['path'] . "/plugins/ecommerce/shopping_cart.class.php";
    $c = new shopping_cart($_SESSION['cart']);
    //List each item in cart. Add up sub total.
    $cart_total = 0;
    $arr_items = $c->get_item_array();
    require_once '../shared_functions.php';
    update_quantity($arr_items);