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); } } }
function eStore_process_squeeze_form_submission($name, $email, $prod_id, $ap_id, $clientip) { global $eStore_debug_manager; $eStore_debug_manager->squeeze_form("Processing free download request for squeeze form submission...", ESTORE_LEVEL_SUCCESS); if (empty($email) || empty($prod_id)) { $eStore_debug_manager->squeeze_form("Error! Email or Product ID value is missing. Cannot process this request.", ESTORE_LEVEL_FAILURE); } if (!is_numeric($prod_id)) { $eStore_debug_manager->squeeze_form("Decrypting product ID value: " . $prod_id, ESTORE_LEVEL_SUCCESS); $prod_id = base64_decode($prod_id); } $eStore_debug_manager->squeeze_form("Received Data...[Name:" . $name . "][Email:" . $email . "][Product ID:" . $prod_id . "][ap_id:" . $ap_id . "][IP Address:" . $clientip . "]", ESTORE_LEVEL_SUCCESS); //Check the email address validity if (!is_email($email)) { $eStore_debug_manager->squeeze_form("Email address (" . $email . ") is not valid. This request will not be processed.", ESTORE_LEVEL_FAILURE, true); exit; } global $wpdb; $wp_eStore_config = WP_eStore_Config::getInstance(); $products_table_name = WP_ESTORE_PRODUCTS_TABLE_NAME; $customer_table_name = $wpdb->prefix . "wp_eStore_customer_tbl"; $retrieved_product = $wpdb->get_row("SELECT * FROM {$products_table_name} WHERE id = '{$prod_id}'", OBJECT); //Perform verification if the the "Enforce Zero Price Checking on Free Product Download" option is enabled. if ($wp_eStore_config->getValue('eStore_product_price_must_be_zero_for_free_download') == '1') { if (!is_numeric($retrieved_product->price) || $retrieved_product->price > 0) { $error_msg = "Error! The admin of this site requires the product price to be set to 0.00 before it can be given as a free download!"; eStore_send_free_download1($name, $email, $error_msg); $eStore_debug_manager->squeeze_form($error_msg, ESTORE_LEVEL_FAILURE, true); exit; } } // These 2 lines of code ensure the Ajax version of the "squeeze form" now passes its data through to the PDF Stamper addon. // -- The Assurer, 2010-09-12. $payment_data = free_download_pseudo_payment_data($name, $email); // Populate the pseudo payment data. $cart_items = eStore_create_item_data($prod_id); // Populate the pseudo cart data. $download = generate_download_link_for_product($prod_id, '', $payment_data); // Generate the download link. //$download = generate_download_link_for_product($prod_id); if (eStore_send_free_download1($name, $email, $download, $payment_data, $cart_items)) { $eStore_debug_manager->squeeze_form("Email with the download link sent to: " . $email, ESTORE_LEVEL_SUCCESS); //$retrieved_product = $wpdb->get_row("SELECT * FROM $products_table_name WHERE id = '$prod_id'", OBJECT); $download_email = get_option('eStore_download_email_address'); $name_pieces = explode(' ', $name, 2); $firstname = $name_pieces[0]; if (!empty($name_pieces[1])) { $lastname = $name_pieces[1]; } $eStore_debug_manager->squeeze_form("Performing autoresponder signup if specified in the settings...", ESTORE_LEVEL_SUCCESS); eStore_item_specific_autoresponder_signup($cart_items, $firstname, $lastname, $email); eStore_global_autoresponder_signup($firstname, $lastname, $email); $eStore_debug_manager->squeeze_form("Updating the customers database with the visitor details...", ESTORE_LEVEL_SUCCESS); // Update the Customer and products table $cart_item_qty = 1; $new_available_copies = ''; if (is_numeric($retrieved_product->available_copies)) { $new_available_copies = $retrieved_product->available_copies - $cart_item_qty; } $new_sales_count = $retrieved_product->sales_count + $cart_item_qty; $current_product_id = $retrieved_product->id; $updatedb = "UPDATE {$products_table_name} SET available_copies = '{$new_available_copies}', sales_count = '{$new_sales_count}' WHERE id='{$current_product_id}'"; $results = $wpdb->query($updatedb); $emailaddress = $email; $clientdate = date("Y-m-d"); $txn_id = $payment_data['txn_id']; //"Free Download"; $sale_price = '0'; $coupon_code_used = ""; $eMember_username = ""; $product_name = $retrieved_product->name; $address = ""; $phone = ""; $subscr_id = ""; $cart_item_qty = "1"; $customer_ip = $clientip; $status = "FREE_DOWNLOAD"; $product_key_data = ""; $notes = ""; $ret_customer_db = $wpdb->get_row("SELECT email_address FROM {$customer_table_name} WHERE purchased_product_id = '{$prod_id}' and email_address='{$emailaddress}'", OBJECT); if (!$ret_customer_db) { $updatedb = "INSERT INTO {$customer_table_name} (first_name, last_name, email_address, purchased_product_id,txn_id,date,sale_amount,coupon_code_used,member_username,product_name,address,phone,subscr_id,purchase_qty,ipaddress,status,serial_number,notes) VALUES ('{$firstname}', '{$lastname}','{$emailaddress}','{$prod_id}','{$txn_id}','{$clientdate}','{$sale_price}','{$coupon_code_used}','{$eMember_username}','{$product_name}','{$address}','{$phone}','{$subscr_id}','{$cart_item_qty}','{$customer_ip}','{$status}','{$product_key_data}','{$notes}')"; $results = $wpdb->query($updatedb); } if (!empty($ap_id)) { $eStore_debug_manager->squeeze_form("Affiliate Referrer ID Value:" . $ap_id, ESTORE_LEVEL_SUCCESS, true); if (get_option('eStore_aff_enable_lead_capture_for_sqeeze_form') != '') { if (function_exists('wp_aff_record_remote_lead')) { if (empty($clientip)) { $clientip = ""; } wp_aff_record_remote_lead($ap_id, $email, $prod_id, $clientip); $eStore_debug_manager->squeeze_form("Affiliate lead captured", ESTORE_LEVEL_SUCCESS, true); } else { $eStore_debug_manager->squeeze_form("Affiliate platform plugin is not installed or it needs to be updated to use this feature!", ESTORE_LEVEL_FAILURE, true); } } } do_action('eStore_squeeze_form_processed', $payment_data, $cart_items); $eStore_debug_manager->squeeze_form("Squeeze form task complete.", ESTORE_LEVEL_SUCCESS, true); } }
function eStore_download_now_button_request_handler() { if (isset($_POST['eStore_download_now_button'])) { //sanitize data $_POST['product'] = strip_tags($_POST['product']); $_POST['download_now_product_id'] = strip_tags($_POST['download_now_product_id']); $product_id = base64_decode($_POST['download_now_product_id']); $product_name_with_var_text = $_POST['product']; //update the inventory count of this product global $wpdb, $wp_eStore_config; $products_table_name = WP_ESTORE_PRODUCTS_TABLE_NAME; $retrieved_product = $wpdb->get_row("SELECT * FROM {$products_table_name} WHERE id = '{$product_id}'", OBJECT); if ($wp_eStore_config->getValue('eStore_product_price_must_be_zero_for_free_download') == '1') { if (!is_numeric($retrieved_product->price) || $retrieved_product->price > 0) { echo '<div class="eStore_error_message">Error! The admin of this site requires the product price to be set to 0.00 before it can be given as a free download!</div>'; exit; } } $cart_item_qty = 1; if (is_numeric($retrieved_product->available_copies)) { $new_available_copies = $retrieved_product->available_copies - $cart_item_qty; } $new_sales_count = $retrieved_product->sales_count + $cart_item_qty; $current_product_id = $retrieved_product->id; $updatedb = "UPDATE {$products_table_name} SET available_copies = '{$new_available_copies}', sales_count = '{$new_sales_count}' WHERE id='{$current_product_id}'"; $results = $wpdb->query($updatedb); //generate download link $download_link = generate_download_link_for_product($product_id, $product_name_with_var_text); $pieces = explode("http", $download_link); $full_encrypted_url = 'http' . $pieces[1]; eStore_redirect_to_url($full_encrypted_url); } }