コード例 #1
0
function eStore_do_thank_you_page_display_tasks($payment_data, $cart_items)
{
    eStore_payment_debug('Executing eStore_do_thank_you_page_display_tasks()', true);
    $constructed_download_link = eStore_generate_download_links_for_cart_items($payment_data, $cart_items);
    $constructed_download_link = eStore_convert_text_download_links_into_html($constructed_download_link);
    eStore_save_trans_result_for_thank_you_page_display($payment_data, $constructed_download_link, $cart_items);
    global $wp_eStore_transaction_result_display_content;
    $wp_eStore_transaction_result_display_content = $_SESSION['eStore_tx_result'];
    eStore_payment_debug('Transaction result display value set', true);
}
コード例 #2
0
function eStore_process_PDT_payment_data($keyarray)
{
    setcookie("cart_in_use", "true", time() + 21600, "/");
    //TODO - refactor using eStore_do_thank_you_page_display_tasks()
    //TODO - do a multi-submission check
    eStore_payment_debug("Processing PayPal PDT...", true);
    global $tx_result_msg, $tx_result_error_msg;
    if (get_option('eStore_strict_email_check') != '') {
        $seller_paypal_email = get_option('cart_paypal_email');
        if ($seller_paypal_email != $keyarray['receiver_email']) {
            $tx_result_error_msg .= 'Invalid Seller Paypal Email Address Detected: ' . $keyarray['receiver_email'];
            eStore_payment_debug('Invalid Seller Paypal Email Address Detected: ' . $keyarray['receiver_email'], fales);
            return false;
        }
    }
    $payment_status = $keyarray['payment_status'];
    if ($payment_status != "Completed" && $payment_status != "Processed") {
        $tx_result_error_msg .= ESTORE_PENDING_PAYMENT_EMAIL_BODY;
        //'The Fund have not been cleared yet. Product will be delivered when the fund clears!';
        eStore_payment_debug("The fund did not clear. Product will be delivered via email when the fund clears! Payment Status: " . $payment_status, false);
        return false;
    }
    $custom = $keyarray['custom'];
    $delimiter = "&";
    $customvariables = array();
    $namevaluecombos = explode($delimiter, $custom);
    foreach ($namevaluecombos as $keyval_unparsed) {
        $equalsignposition = strpos($keyval_unparsed, '=');
        if ($equalsignposition === false) {
            $customvariables[$keyval_unparsed] = '';
            continue;
        }
        $key = substr($keyval_unparsed, 0, $equalsignposition);
        $value = substr($keyval_unparsed, $equalsignposition + 1);
        $customvariables[$key] = $value;
    }
    isset($customvariables['ngg_pid']) ? $pictureID = $customvariables['ngg_pid'] : ($pictureID = '');
    //$pictureID = $customvariables['ngg_pid'];
    //Fire the begin processing hook
    do_action('eStore_begin_paypal_pdt_processing', $keyarray['payer_email'], $customvariables['ip']);
    $transaction_type = $keyarray['txn_type'];
    $transaction_id = $keyarray['txn_id'];
    $transaction_subject = $keyarray['transaction_subject'];
    $gross_total = $keyarray['mc_gross'];
    if ($transaction_type == "cart") {
        // Cart Items
        $num_cart_items = $keyarray['num_cart_items'];
        $tx_result_msg .= 'Number of Cart Items: ' . $num_cart_items;
        $i = 1;
        $cart_items = array();
        while ($i < $num_cart_items + 1) {
            $item_number = $keyarray['item_number' . $i];
            $item_name = $keyarray['item_name' . $i];
            $quantity = $keyarray['quantity' . $i];
            $mc_gross = $keyarray['mc_gross_' . $i];
            $mc_currency = $keyarray['mc_currency'];
            $current_item = array('item_number' => $item_number, 'item_name' => $item_name, 'quantity' => $quantity, 'mc_gross' => $mc_gross, 'mc_currency' => $mc_currency);
            array_push($cart_items, $current_item);
            $i++;
        }
    } else {
        $cart_items = array();
        $tx_result_msg .= 'Transaction Type: Buy Now/Subscribe';
        $item_number = $keyarray['item_number'];
        $item_name = $keyarray['item_name'];
        $quantity = $keyarray['quantity'];
        $mc_gross = $keyarray['mc_gross'];
        $mc_currency = $keyarray['mc_currency'];
        $current_item = array('item_number' => $item_number, 'item_name' => $item_name, 'quantity' => $quantity, 'mc_gross' => $mc_gross, 'mc_currency' => $mc_currency);
        array_push($cart_items, $current_item);
    }
    $script_location = get_option('eStore_download_script');
    $random_key = get_option('eStore_random_code');
    global $wpdb;
    $products_table_name = $wpdb->prefix . "wp_eStore_tbl";
    $customer_table_name = $wpdb->prefix . "wp_eStore_customer_tbl";
    $sales_table_name = $wpdb->prefix . "wp_eStore_sales_tbl";
    $payment_currency = get_option('cart_payment_currency');
    $product_id_array = array();
    $product_name_array = array();
    $product_price_array = array();
    $product_qty_array = array();
    $download_link_array = array();
    $counter = 0;
    foreach ($cart_items as $current_cart_item) {
        $cart_item_data_num = $current_cart_item['item_number'];
        $key = $cart_item_data_num;
        $retrieved_product = $wpdb->get_row("SELECT * FROM {$products_table_name} WHERE id = '{$key}'", OBJECT);
        $cart_item_data_name = trim($current_cart_item['item_name']);
        //$retrieved_product->name;
        //$cart_item_data_name = mb_convert_encoding($cart_item_data_name, "UTF-8");
        $cart_item_data_quantity = $current_cart_item['quantity'];
        $cart_item_data_total = $current_cart_item['mc_gross'];
        $cart_item_data_currency = $current_cart_item['mc_currency'];
        $tx_result_msg .= '<br />Item Number: ' . $cart_item_data_num;
        $tx_result_msg .= '<br />Item Name: ' . $cart_item_data_name;
        $tx_result_msg .= '<br />Item Quantity: ' . $cart_item_data_quantity;
        $tx_result_msg .= '<br />Item Total: ' . $cart_item_data_total;
        $tx_result_msg .= '<br />Item Currency: ' . $cart_item_data_currency;
        // Compare the values with the values stored in the database
        isset($customvariables['coupon']) ? $coupon_code = $customvariables['coupon'] : ($coupon_code = '');
        //$coupon_code = $customvariables['coupon'];
        if (!empty($coupon_code)) {
            $tx_result_msg .= 'Coupon Code Used : ' . $coupon_code;
            $coupon_table_name = $wpdb->prefix . "wp_eStore_coupon_tbl";
            $ret_coupon = $wpdb->get_row("SELECT * FROM {$coupon_table_name} WHERE coupon_code = '{$coupon_code}'", OBJECT);
            if ($ret_coupon) {
                $discount_amount = $ret_coupon->discount_value;
                $discount_type = $ret_coupon->discount_type;
                if ($discount_type == 0) {
                    //apply % discount
                    $discount = $retrieved_product->price * $discount_amount / 100;
                    $true_product_price = $retrieved_product->price - $discount;
                } else {
                    // apply value discount
                    $true_product_price = $retrieved_product->price - $discount_amount;
                }
            }
        } else {
            $true_product_price = $retrieved_product->price * $cart_item_data_quantity;
        }
        $check_price = true;
        $msg = "";
        $msg = apply_filters('eStore_before_checking_price_filter', $msg, $current_cart_item);
        if (!empty($msg) && $msg == "currency-check-override") {
            $check_price = false;
            $tx_result_msg .= '<br />PDT check - Price and currency check override enabled by filter eStore_before_checking_price_filter';
        }
        if ($check_price) {
            $true_product_price = round($true_product_price, 2);
            if ($cart_item_data_total < $true_product_price) {
                $tx_result_error_msg .= 'Wrong Product Price Detected. Actual Product Price : ' . $true_product_price;
                $tx_result_error_msg .= 'Paid Product Price : ' . $cart_item_data_total;
                return false;
            }
            if (!empty($retrieved_product->currency_code)) {
                $payment_currency = $retrieved_product->currency_code;
            }
            if ($payment_currency != $cart_item_data_currency) {
                $tx_result_error_msg .= 'Invalid Product Currency : ' . $cart_item_data_currency;
                return false;
            }
        }
        //Check if nextgen gallery integration is being used
        $pid_check_value = eStore_is_ngg_pid_present($cart_item_data_name);
        if ($pid_check_value != -1) {
            $pictureID = $pid_check_value;
        }
        if (!empty($pictureID)) {
            $download_link = eStore_get_ngg_image_url_html($pictureID, $cart_item_data_name);
            $pictureID = "";
        } else {
            $eStore_auto_shorten_url = WP_ESTORE_AUTO_SHORTEN_DOWNLOAD_LINKS;
            $dl_link_target = 'target="_self"';
            if (WP_ESTORE_OPEN_IN_NEW_WINDOW_THANKU_DL_LINKS == '1') {
                $dl_link_target = 'target="_blank"';
            }
            $product_id = $retrieved_product->id;
            //check if it is a digital variation
            $is_digital_variation = false;
            if (!empty($retrieved_product->variation3) && eStore_check_if_string_contains_url($retrieved_product->variation3)) {
                $is_digital_variation = true;
            }
            if (empty($retrieved_product->product_download_url) && !$is_digital_variation) {
                $download_link = "<br /><strong>" . $cart_item_data_name . "</strong>" . WP_ESTORE_THIS_ITEM_DOES_NOT_HAVE_DOWNLOAD;
            } else {
                $payment_data = array();
                $payment_data['customer_name'] = $keyarray['first_name'] . " " . $keyarray['last_name'];
                $payment_data['payer_email'] = $keyarray['payer_email'];
                isset($keyarray['contact_phone']) ? $payment_data['contact_phone'] = $keyarray['contact_phone'] : ($payment_data['contact_phone'] = '');
                $payment_data['address'] = $keyarray['address_street'] . ", " . $keyarray['address_city'] . ", " . $keyarray['address_state'] . " " . $keyarray['address_zip'] . ", " . $keyarray['address_country'];
                $payment_data['txn_id'] = $keyarray['txn_id'];
                if (!empty($retrieved_product->variation3)) {
                    $download_link = get_download_for_variation_tx_result($cart_item_data_name, $retrieved_product, $script_location, $random_key, $payment_data);
                } else {
                    $download_url_field = $retrieved_product->product_download_url;
                    $product_ids = explode(',', $download_url_field);
                    $package_product = true;
                    $multi_parts = false;
                    foreach ($product_ids as $id) {
                        if (!is_numeric($id)) {
                            $package_product = false;
                        }
                    }
                    if (sizeof($product_ids) > 1 && !$package_product) {
                        $multi_parts = true;
                    }
                    if ($package_product) {
                        $tx_result_msg .= 'The product is a package product.';
                        foreach ($product_ids as $id) {
                            $id = trim($id);
                            $retrieved_product_for_id = $wpdb->get_row("SELECT * FROM {$products_table_name} WHERE id = '{$id}'", OBJECT);
                            $download_key = eStore_check_stamping_flag_and_generate_download_key($retrieved_product_for_id, $retrieved_product_for_id->id, '', $payment_data);
                            $download_url = eStore_construct_raw_encrypted_dl_url($download_key);
                            if (WP_ESTORE_USE_ANCHOR_FOR_THANKU_DL_LINKS === '1') {
                                $raw_download = '<a href="' . $download_url . '" ' . $dl_link_target . '>' . WP_ESTORE_CLICK_HERE_TO_DOWNLOAD . '</a>';
                            } else {
                                $raw_download = '<a href="' . $download_url . '" ' . $dl_link_target . '>' . $download_url . '</a>';
                            }
                            $download_link .= "<br /><strong>" . $retrieved_product_for_id->name . "</strong> - " . $raw_download . '<br />';
                            eStore_register_link_in_db('', $download_key, $download_url, '', '', '', 0, $payment_data['txn_id']);
                        }
                    } else {
                        if ($multi_parts) {
                            $tx_result_msg .= 'The product has multiple downloadable files.';
                            $count = 1;
                            $download_link .= "<br /><strong>" . $cart_item_data_name . "</strong> - ";
                            foreach ($product_ids as $id) {
                                $id = trim($id);
                                if (!empty($id)) {
                                    $download_key = eStore_check_stamping_flag_and_generate_download_key($retrieved_product, $product_id, $id, $payment_data);
                                    $download_url = eStore_construct_raw_encrypted_dl_url($download_key);
                                    if (WP_ESTORE_USE_ANCHOR_FOR_THANKU_DL_LINKS === '1') {
                                        $raw_download = '<a href="' . $download_url . '" ' . $dl_link_target . '>' . WP_ESTORE_CLICK_HERE_TO_DOWNLOAD . '</a>';
                                    } else {
                                        $raw_download = '<a href="' . $download_url . '" ' . $dl_link_target . '>' . $download_url . '</a>';
                                    }
                                    $download_link .= "<br />" . ESTORE_PART . " " . $count . " : " . $raw_download;
                                    eStore_register_link_in_db('', $download_key, $download_url, '', '', '', 0, $payment_data['txn_id']);
                                    $count++;
                                }
                            }
                        } else {
                            $download_key = eStore_check_stamping_flag_and_generate_download_key($retrieved_product, $product_id, '', $payment_data);
                            $download_url = eStore_construct_raw_encrypted_dl_url($download_key);
                            if (WP_ESTORE_USE_ANCHOR_FOR_THANKU_DL_LINKS === '1') {
                                $raw_download = '<a href="' . $download_url . '" ' . $dl_link_target . '>' . WP_ESTORE_CLICK_HERE_TO_DOWNLOAD . '</a>';
                            } else {
                                $raw_download = '<a href="' . $download_url . '" ' . $dl_link_target . '>' . $download_url . '</a>';
                            }
                            $download_link = "<br /><strong>" . stripslashes($cart_item_data_name) . "</strong> - " . $raw_download;
                            eStore_register_link_in_db('', $download_key, $download_url, '', '', '', 0, $payment_data['txn_id']);
                        }
                    }
                }
            }
        }
        $tx_result_msg .= 'Download Link : ' . $download_link;
        array_push($product_name_array, $cart_item_data_name);
        array_push($product_id_array, $product_id);
        array_push($product_price_array, $cart_item_data_total);
        array_push($product_qty_array, $cart_item_data_quantity);
        //array_push($attachments_array, $retrieved_product->product_download_url);
        array_push($download_link_array, $download_link);
        $counter++;
        $download_link = '';
    }
    // How long the download link remain valid (hours)
    $download_url_life = get_option('eStore_download_url_life');
    $email_body = get_option('eStore_buyer_email_body');
    // Send the product
    $constructed_products_name = "";
    $constructed_products_price = "";
    $constructed_products_id = "";
    $constructed_download_link = "";
    for ($i = 0; $i < sizeof($product_name_array); $i++) {
        $constructed_products_name .= $product_name_array[$i];
        $constructed_products_name .= ", ";
        $constructed_products_price .= $product_price_array[$i];
        $constructed_products_price .= ", ";
        $constructed_products_id .= $product_id_array[$i];
        $constructed_products_id .= ", ";
        $constructed_download_link .= "<br />";
        if (is_array($download_link_array[$i])) {
            $package_downloads = $download_link_array[$i];
            for ($j = 0; $j < sizeof($package_downloads); $j++) {
                $constructed_download_link .= $package_downloads[$j];
                $constructed_download_link .= "<br />";
            }
        } else {
            $constructed_download_link .= $download_link_array[$i];
        }
    }
    //Save transaction result for thank you page display
    eStore_payment_debug("Saving transaction data for thank you page display.", true);
    eStore_save_trans_result_for_thank_you_page_display($keyarray, $constructed_download_link, $cart_items);
    //Google Analytics e-commerce tracking (only do it if set in settings menu)
    if (get_option('eStore_enable_analytics_tracking')) {
        $mc_shipping = $keyarray['mc_shipping'];
        $mc_tax = $keyarray['tax'];
        $city = $keyarray['address_city'];
        $state = $keyarray['address_state'];
        $country = $keyarray['address_country'];
        $eStore_analytics_code = array();
        $eStore_analytics_code[] = "'_addTrans'," . "'" . $transaction_id . "','" . get_bloginfo('name') . "','" . $gross_total . "','" . $mc_tax . "','" . $mc_shipping . "','" . $city . "','" . $state . "','" . $country . "'";
        for ($j = 0; $j < sizeof($product_name_array); $j++) {
            $eStore_analytics_code[] = "'_addItem'," . "'" . $transaction_id . "','" . $product_id_array[$j] . "','" . $product_name_array[$j] . "','','" . $product_price_array[$j] . "','" . $product_qty_array[$j] . "'";
        }
        $eStore_analytics_code[] = "'_trackTrans'";
        $_SESSION['eStore_ga_code'] = $eStore_analytics_code;
        add_filter('yoast-ga-push-after-pageview', 'eStore_add_trans_to_ga_tracking');
    }
}
コード例 #3
0
function eStore_manual_gateway_form_processing_code()
{
    if (isset($_POST['submit_shipping'])) {
        if (eStore_get_total_cart_item_qty() < 1) {
            //Cart does not have any item
            echo '<div class="eStore_error_message">Error! Your shopping cart is empty. Please add items to your cart before checking out.</div>';
            return;
        }
        $input_verified = false;
        global $wpdb;
        $wp_eStore_config = WP_eStore_Config::getInstance();
        $err_msg = eStore_check_address_details();
        if (!empty($err_msg)) {
            $msg = '<div id="error">';
            $msg .= ESTORE_REQUIRED_FIELDS_MISSING;
            $msg .= $err_msg;
            $msg .= '</div>';
            echo $msg;
        } else {
            //Fire the begin processing hook
            $clientip = $_SERVER['REMOTE_ADDR'];
            $clientemail = $_POST['email'];
            do_action('eStore_begin_manual_co_processing', $clientemail, $clientip);
            $last_records_id = $wp_eStore_config->getValue('eStore_custom_receipt_counter');
            //get_option('eStore_custom_receipt_counter');
            if (empty($last_records_id)) {
                $last_records_id = 0;
            }
            $receipt_counter = $last_records_id + 1;
            $wp_eStore_config->setValue('eStore_custom_receipt_counter', $receipt_counter);
            $wp_eStore_config->saveConfig();
            $address = $_POST['address'] . ", " . $_POST['city'] . ", " . $_POST['state'] . " " . $_POST['postcode'] . " " . $_POST['country'];
            $payment_data = extract_manaul_co_general_payment_data($_POST['firstname'], $_POST['lastname'], $_POST['email'], $address, $_POST['phone']);
            $cart_items = extract_manual_item_data();
            $cust_direction = get_option('eStore_manual_co_cust_direction');
            $curr_symbol = get_option('cart_currency_symbol');
            if (!empty($cust_direction)) {
                $cust_direction_mod = eStore_apply_post_payment_dynamic_tags($cust_direction, $payment_data, $cart_items);
                $body .= "\n-------------------------------\n";
                $body .= $cust_direction_mod;
                $body .= "\n-------------------------------\n";
            }
            $count = 1;
            $constructed_download_link .= "<br />";
            $product_key_data = "";
            $show_tax_inc_price = $wp_eStore_config->getValue('eStore_show_tax_inclusive_price');
            foreach ($_SESSION['eStore_cart'] as $item) {
                $products_table_name = $wpdb->prefix . "wp_eStore_tbl";
                $key = $item['item_number'];
                $retrieved_product = $wpdb->get_row("SELECT * FROM {$products_table_name} WHERE id = '{$key}'", OBJECT);
                $rounded_price = round($item['price'], 2);
                $body .= "\n" . WP_ESTORE_DETAILS_OF_ORDERED_PRODUCT . ": " . $count;
                $body .= "\n-------------------------";
                $body .= "\n" . ESTORE_PRODUCT_ID . ": " . $item['item_number'];
                $body .= "\n" . ESTORE_PRODUCT_NAME . ": " . $item['name'];
                if ($show_tax_inc_price == '1') {
                    $rounded_price = eStore_get_tax_include_price_by_prod_id($item['item_number'], $rounded_price);
                }
                $formatted_price = print_digi_cart_payment_currency($rounded_price, $curr_symbol);
                $body .= "\n" . ESTORE_PRICE . ": " . $formatted_price;
                $body .= "\n" . ESTORE_QUANTITY . ": " . $item['quantity'] . "\n";
                if (get_option('eStore_manual_co_give_download_links') != '') {
                    $download_link = generate_download_link_for_product($item['item_number'], $item['name'], $payment_data);
                    $constructed_download_link .= $download_link . "<br />";
                    $body .= $download_link . "\n";
                    $product_key = eStore_post_sale_retrieve_serial_key_and_update($retrieved_product, $item['name'], $item['quantity']);
                    $product_key_data .= $product_key;
                    $body .= $product_key;
                    $product_specific_instructions = eStore_get_product_specific_instructions($retrieved_product);
                    $product_specific_instructions = eStore_apply_post_payment_dynamic_tags($product_specific_instructions, $payment_data, $cart_items);
                    $body .= $product_specific_instructions;
                }
                $count++;
                //Check and signup WishList or WP eMember user if needed
                //if(get_option('eStore_manual_co_auto_update_db')=='1')
                if ($wp_eStore_config->getValue('eStore_manual_co_auto_create_membership') == '1') {
                    $member_ref = $retrieved_product->ref_text;
                    eStore_payment_debug('Checking if membership inegration is being used. Reference Text Value: ' . $member_ref, true);
                    if (!empty($member_ref)) {
                        if (get_option('eStore_enable_wishlist_int')) {
                            eStore_payment_debug('WishList integration is being used... doing member account creation/upgrade task... see the "subscription_handle_debug.log" file for details', true);
                            wl_handle_subsc_signup($payment_data, $member_ref, $payment_data['txn_id']);
                        } else {
                            if (function_exists('wp_eMember_install')) {
                                $eMember_id = $payment_data['eMember_userid'];
                                eStore_payment_debug('eMember integration is being used... doing member account creation/upgrade task... see the "subscription_handle_debug.log" file for details', true);
                                eMember_handle_subsc_signup($payment_data, $member_ref, $payment_data['txn_id'], $eMember_id);
                            }
                        }
                    }
                }
                //=== End of membership handling code ===
            }
            $body .= "\n-------------------------------\n";
            if ($show_tax_inc_price != '1') {
                $body .= ESTORE_SUB_TOTAL . ": " . print_digi_cart_payment_currency($_SESSION['eStore_cart_sub_total'], $curr_symbol);
            }
            if (!empty($_SESSION['eStore_cart_postage_cost'])) {
                $body .= "\n" . ESTORE_SHIPPING . ": " . print_digi_cart_payment_currency($_SESSION['eStore_cart_postage_cost'], $curr_symbol);
            }
            if (!empty($_SESSION['eStore_cart_total_tax'])) {
                $body .= "\n" . WP_ESTORE_TAX . ": " . print_digi_cart_payment_currency($_SESSION['eStore_cart_total_tax'], $curr_symbol);
            }
            $total = $_SESSION['eStore_cart_sub_total'] + $_SESSION['eStore_cart_postage_cost'] + $_SESSION['eStore_cart_total_tax'];
            $body .= "\n" . ESTORE_TOTAL . ": " . print_digi_cart_payment_currency($total, $curr_symbol);
            $conversion_rate = get_option('eStore_secondary_currency_conversion_rate');
            if (!empty($conversion_rate)) {
                $secondary_curr_symbol = get_option('eStore_secondary_currency_symbol');
                $body .= "\n" . ESTORE_TOTAL . ' (' . get_option('eStore_secondary_currency_code') . '): ' . print_digi_cart_payment_currency($total * $conversion_rate, $secondary_curr_symbol);
            }
            if (isset($_SESSION['eStore_store_pickup_checked']) && $_SESSION['eStore_store_pickup_checked'] == '1') {
                $body .= "\nStore Pickup: Yes";
            }
            $total_items = $count - 1;
            $body .= "\n" . WP_ESTORE_TOTAL_ITEMS_ORDERED . ": " . $total_items;
            $body .= "\n" . ESTORE_TRANSACTION_ID . ": " . $payment_data['txn_id'];
            $body .= "\n\n" . WP_ESTORE_CUSTOMER_DETAILS;
            $body .= "\n-------------------------";
            $body .= "\n" . WP_ESTORE_NAME . ": " . $_POST['firstname'] . " " . $_POST['lastname'];
            $body .= "\n" . ESTORE_EMAIL . ": " . $_POST['email'];
            $body .= "\n" . ESTORE_PHONE . ": " . $_POST['phone'];
            $body .= "\n" . ESTORE_ADDRESS . ": " . $_POST['address'];
            $body .= "\n" . ESTORE_CITY . ": " . $_POST['city'];
            $body .= "\n" . ESTORE_STATE . ": " . $_POST['state'];
            $body .= "\n" . ESTORE_POSTCODE . ": " . $_POST['postcode'];
            $body .= "\n" . ESTORE_COUNTRY . ": " . $_POST['country'];
            $body .= "\n" . WP_ESTORE_ADDITIONAL_COMMENT . ": " . $_POST['additional_comment'];
            $notify_email = get_option('eStore_manual_notify_email');
            $buyer_email = $_POST['email'];
            if (empty($notify_email)) {
                $notify_email = get_bloginfo('admin_email');
            }
            // Get referrer
            if (!empty($_SESSION['ap_id'])) {
                $referrer = $_SESSION['ap_id'];
            } else {
                if (isset($_COOKIE['ap_id'])) {
                    $referrer = $_COOKIE['ap_id'];
                }
            }
            //Call the filter for email notification body
            eStore_payment_debug('Applying filter - eStore_notification_email_body_filter', true);
            $body = apply_filters('eStore_notification_email_body_filter', $body, $payment_data, $cart_items);
            $seller_email_body = $body . "\n\n" . WP_ESTORE_REFERRER . ": " . $referrer;
            $from_email_address = get_option('eStore_download_email_address');
            $headers = 'From: ' . $from_email_address . "\r\n";
            // Notify Seller
            $n_subject = $wp_eStore_config->getValue('seller_email_subject_manual_co');
            if (empty($n_subject)) {
                $n_subject = get_option('eStore_seller_email_subj');
            }
            wp_mail($notify_email, $n_subject, $seller_email_body, $headers);
            // Notify Buyer
            $buyer_email_subj = $wp_eStore_config->getValue('buyer_email_subject_manual_co');
            if (empty($buyer_email_subj)) {
                $buyer_email_subj = get_option('eStore_buyer_email_subj');
            }
            wp_mail($buyer_email, $buyer_email_subj, $body, $headers);
            if (!empty($product_key_data)) {
                //Lets add any serial key info to the data
                $payment_data['product_key_data'] = $product_key_data;
            }
            //Fire the manual checkout hook
            do_action('eStore_manual_checkout_form_data', $payment_data, $cart_items);
            //Add to the customer database if the option is enabled
            if (get_option('eStore_manual_co_auto_update_db') == '1') {
                record_sales_data($payment_data, $cart_items);
            }
            //Perform autoresponder signup
            if (get_option('eStore_manual_co_do_autoresponder_signup') == '1') {
                eStore_item_specific_autoresponder_signup($cart_items, $_POST['firstname'], $_POST['lastname'], $_POST['email']);
                eStore_global_autoresponder_signup($_POST['firstname'], $_POST['lastname'], $_POST['email']);
            }
            //Award Affiliate Commission
            eStore_award_commission_manual_co($payment_data, $cart_items);
            // Revenue sharing
            eStore_award_author_commission_manual_co($payment_data, $cart_items);
            //Create affiliate account if needed
            eStore_handle_auto_affiliate_account_creation($payment_data);
            //Post IPN data to external site if needed
            eStore_POST_IPN_data_to_url($payment_data, '', $cart_items);
            //Save transaction result for thank you page display
            if (get_option('eStore_manual_co_give_download_links') != '') {
                $constructed_download_link = wp_eStore_replace_url_in_string_with_link($constructed_download_link);
                eStore_save_trans_result_for_thank_you_page_display($payment_data, $constructed_download_link, $cart_items);
            }
            $return_url = get_option('eStore_manual_return_url');
            if (empty($return_url)) {
                $return_url = get_bloginfo('wpurl');
            }
            //Google analytics tracking
            if (get_option('eStore_enable_analytics_tracking') && get_option('eStore_manual_co_give_download_links') != '') {
                eStore_track_ga_ecommerce($payment_data, $cart_items);
                $return_url = eStore_append_http_get_data_to_url($return_url, "eStore_manual_co_track_ga", "1");
            }
            //Reset cart and redirect to Thank you page
            reset_eStore_cart();
            eStore_redirect_to_url($return_url);
        }
    }
}