function eStore_create_cart_items_data_from_txn_id($txn_id) { $cart_items = array(); $cond = " txn_id = '{$txn_id}'"; $resultset = WP_eStore_Db_Access::findAll(WP_ESTORE_CUSTOMER_TABLE_NAME, $cond); if ($resultset) { foreach ($resultset as $item) { $current_item = array('item_number' => $item->purchased_product_id, 'item_name' => $item->product_name, 'quantity' => $item->purchase_qty, 'mc_gross' => $item->sale_amount, 'mc_currency' => ''); array_push($cart_items, $current_item); } //wp_eStore_write_debug_array($cart_items,true); } return $cart_items; }
function eStore_item_specific_autoresponder_signup($cart_items, $firstname, $lastname, $emailaddress) { eStore_payment_debug('Performing item specific autoresponder signup if specified.', true); global $wp_eStore_config; $wp_eStore_config = WP_eStore_Config::getInstance(); foreach ($cart_items as $current_cart_item) { $cart_item_data_num = $current_cart_item['item_number']; $item_name = $current_cart_item['item_name']; $cond = " id = '{$cart_item_data_num}'"; $retrieved_product = WP_eStore_Db_Access::find(WP_ESTORE_DB_PRODUCTS_TABLE_NAME, $cond); $list_name = $retrieved_product->aweber_list; // Autoresponder Sign up if (!empty($retrieved_product->aweber_list)) { if (get_option('eStore_use_mailchimp')) { eStore_payment_debug('MailChimp integration is being used.', true); $api = eStore_get_chimp_api_new(); $retval = eStore_mailchimp_subscribe($api, $list_name, $firstname, $lastname, $emailaddress); eStore_payment_debug('MailChimp item specific signup operation performed. Return value is: ' . $retval, true); } else { if (get_option('eStore_use_getResponse')) { eStore_payment_debug('GetResponse integration is being used.', true); $campaign_name = $retrieved_product->aweber_list; eStore_payment_debug('GetResponse campaign to signup to:' . $campaign_name, true); $retval = eStore_getResponse_subscribe($campaign_name, $firstname, $lastname, $emailaddress); eStore_payment_debug('GetResponse item specific signup operation performed. Return value is: ' . $retval, true); } else { if ($wp_eStore_config->getValue('eStore_use_generic_autoresponder_integration') == '1') { eStore_payment_debug('Generic autoresponder integration is being used.', true); $list_email_address = $retrieved_product->aweber_list; $result = eStore_generic_autoresponder_signup($firstname, $lastname, $emailaddress, $list_email_address); eStore_payment_debug('Generic autoresponder signup result: ' . $result, true); } else { if ($wp_eStore_config->getValue('eStore_use_new_aweber_integration') == '1') { //AWeber integration is enabled eStore_payment_debug('Using AWeber integraiton option to signup to the list: ' . $list_name, true); eStore_aweber_new_signup_user($list_name, $firstname, $lastname, $emailaddress); } } } } // API call for plugins extending the item specific autoresponder signup $signup_data = array('firstname' => $firstname, 'lastname' => $lastname, 'email' => $emailaddress, 'list_name' => $retrieved_product->aweber_list, 'item_id' => $cart_item_data_num, 'item_name' => $item_name); do_action('eStore_item_specific_autoresponder_signup', $signup_data); } } }
function eStore_register_link_in_db($creation_time = '', $download_key = '', $download_item = '', $download_limit_count, $download_limit_time, $download_limit_ip = '', $access_count = 0, $txn_id = '') { if (empty($creation_time)) { $creation_time = date("Y-m-d H:i:s"); //current_time('mysql'); } if (empty($download_key)) { //Download key cannot be empty return false; } if (empty($download_limit_count)) { $download_limit_count = get_option('eStore_download_url_limit_count'); if (empty($download_limit_count)) { $download_limit_count = 999; } } if (empty($download_limit_time)) { $download_limit_time = get_option('eStore_download_url_life'); } if (empty($download_limit_ip)) { $download_limit_ip = $_SERVER['REMOTE_ADDR']; } //Add to the download link to the database global $wpdb; $download_key = rawurldecode($download_key); //str_replace('%2B','+', $download_key ); $fields = array(); $fields['creation_time'] = $creation_time; $fields['download_key'] = $download_key; $fields['download_item'] = esc_sql($download_item); $fields['download_limit_count'] = $download_limit_count; $fields['download_limit_time'] = $download_limit_time; $fields['download_limit_ip'] = $download_limit_ip; $fields['access_count'] = $access_count; $fields['txn_id'] = $txn_id; $updated = WP_eStore_Db_Access::insert(WP_ESTORE_DOWNLOAD_LINKS_TABLE_NAME, $fields); return true; }
function eStore_check_and_retrieve_action_data($payment_data, $cart_items) { eStore_payment_debug('Checking if additional action data needs to be displayed on the Thank You page.', true); $output = ""; $customer_email = $payment_data['payer_email']; $txn_id = $payment_data['txn_id']; $member_rego_data_needed = false; $product_key_data_needed = false; foreach ($cart_items as $current_cart_item) { $id = $current_cart_item['item_number']; $retrieved_product = WP_eStore_Db_Access::find(WP_ESTORE_PRODUCTS_TABLE_NAME, " id = '{$id}'"); if (!empty($retrieved_product->ref_text)) { $member_rego_data_needed = true; } $retrieved_meta = WP_eStore_Db_Access::find(WP_ESTORE_PRODUCTS_META_TABLE_NAME, " prod_id = '{$id}' AND meta_key='available_key_codes'"); if (!empty($retrieved_meta->meta_value)) { $product_key_data_needed = true; } } if ($member_rego_data_needed && WP_ESTORE_SHOW_REGO_COMPLETION_LINK_ON_TY_PAGE === '1') { $cond = " meta_key2='txn_id' AND meta_value2='{$txn_id}' ORDER by meta_id DESC"; //TODO - add condition to find "reg_url" column so it doesn't get record from other rows with txn_id column $result = WP_eStore_Db_Access::find(WP_ESTORE_GLOBAL_META_TABLE_NAME, $cond); // if(!$result){//TODO - Failsafe: try with the email address and find the last entry and then check with members DB to see if incomplete rego exists // $cond = " meta_key1='member_email' AND meta_value1='$customer_email' ORDER by meta_id DESC"; // $result = WP_eStore_Db_Access::find(WP_ESTORE_GLOBAL_META_TABLE_NAME, $cond); // } if ($result) { //We have a result $rego_completion_link = '<a href="' . $result->meta_value3 . '" target="_blank">' . WP_ESTORE_CLICK_HERE_TO_COMPLETE_REGO . '</a>'; $output .= '<div class="eStore_thank_you_rego_link">' . $rego_completion_link . '</div>'; } else { $output .= WP_ESTORE_REGO_URL_IS_YET_TO_BE_CREATED; } } $product_key_data_found = false; if ($product_key_data_needed) { if (!empty($payment_data['product_key_data'])) { //product key data is already available $output .= $payment_data['product_key_data']; $product_key_data_found = true; } else { $retrieved_cust = WP_eStore_Db_Access::find(WP_ESTORE_CUSTOMER_TABLE_NAME, " txn_id = '{$txn_id}'"); //$retrieved_cust = WP_eStore_Db_Access::findAllArray(WP_ESTORE_CUSTOMER_TABLE_NAME, " email_address = '$customer_email' AND txn_id = '$txn_id'", "date ASC"); if ($retrieved_cust) { $output .= '<div class="eStore_thank_you_serial_key">' . $retrieved_cust->serial_number . '</div>'; $product_key_data_found = true; } } if (!$product_key_data_found) { //TODO - IPN hasn't been processed yet. Add a marker to do the ajax query later maybe $output .= WP_ESTORE_SERIAL_KEY_IS_YET_TO_BE_CREATED; } } return $output; }
$search_result = eStore_is_valid_url_if_not_empty($file_to_find); if ($search_result) { $eStore_debug_manager->downloads("Found a backup copy of the file. Preparing to serve this copy of the file ...", ESTORE_LEVEL_STATUS); $file_path = $file_to_find; $file_name = basename($file_path); } $file_name = eStore_perform_save_as_file_name_massaging($file_name); $eStore_debug_manager->downloads("Save as file name: " . $file_name, ESTORE_LEVEL_STATUS); } if (WP_ESTORE_STAMP_PDF_FILE_AT_DOWNLOAD_TIME === '1') { //Check if file should be stamped at download time $eStore_debug_manager->downloads('PDF File stamping at download time feature is enabled. Checking if file need to be stamped. File Key: ' . $file_key, ESTORE_LEVEL_SUCCESS); if ($retrieved_product->use_pdf_stamper == 1) { $eStore_debug_manager->downloads('PDF stamping is enabled for this product. Preparing to stamp the file.', ESTORE_LEVEL_SUCCESS); $cond = " download_key = '{$file_key}'"; $resultset = WP_eStore_Db_Access::find(WP_ESTORE_DOWNLOAD_LINKS_TABLE_NAME, $cond); if ($resultset) { $transaction_id = $resultset->txn_id; $eStore_debug_manager->downloads('Retrieved the transaction ID of the corresponding transaction. Txn ID: ' . $transaction_id, ESTORE_LEVEL_SUCCESS); $customer_table_name = WP_ESTORE_CUSTOMER_TABLE_NAME; $customer_data_rs = $wpdb->get_row("SELECT * FROM {$customer_table_name} WHERE txn_id = '{$transaction_id}'", OBJECT); if ($customer_data_rs) { $eStore_debug_manager->downloads('Retrieved the customer data for this transaction. Customer email ' . $customer_data->email_address, ESTORE_LEVEL_SUCCESS); $payment_data = eSore_create_payment_data_from_customer_resultset($customer_data_rs); $src_file = $file_path; //$retrieved_product->product_download_url; $stamped_file_url = eStore_stamp_pdf_file($payment_data, $src_file); if ($stamped_file_url === 'Error!') { $stamping_error = 'PDF Stamping did not finish correctly! Perform a manual stamping from PDF stamper admin menu and make sure the PDF stamper is working on your server.'; $eStore_debug_manager->downloads($stamping_error, ESTORE_LEVEL_FAILURE); eStore_dlvs::error($stamping_error);
function eStore_show_product_details($id, $info) { if ($id == 'no id') { return '<div class="eStore_error_message">You did not specify a Product ID. Please enter a Product ID with this shortcode</div>'; } if (empty($info)) { return '<div class="eStore_error_message">You did not specify which information of the product you want to show (the "info" parameter is empty). Please check the shortcode documentation to learn the usage of this shortcode.</div>'; } $condition = " id='" . $id . "'"; $product_details = WP_eStore_Db_Access::find(WP_ESTORE_PRODUCTS_TABLE_NAME, $condition); //var_dump($product_details); if ($info == 'all') { var_dump($product_details); return ""; } if ($info == "description") { $description = html_entity_decode($product_details->{$info}, ENT_COMPAT, "UTF-8"); $description = do_shortcode($description); return $description; } if (isset($product_details->{$info})) { return $product_details->{$info}; } else { if ($info === "price_formatted") { $item_price = $product_details->price; $defaultSymbol = WP_ESTORE_CURRENCY_SYMBOL; $price_formatted = print_digi_cart_payment_currency($item_price, $defaultSymbol); return $price_formatted; } else { if ($info === "price_tax_inclusive") { if (!empty($product_details->tax)) { $tax_rate = $product_details->tax; } else { $global_store_tax_rate = get_option('eStore_global_tax_rate'); $tax_rate = $global_store_tax_rate; } $tax_inc_price = eStore_calculate_tax_included_price_without_qty($product_details->price, $tax_rate); $tax_inc_price = number_format($tax_inc_price, 2, '.', ''); return $tax_inc_price; } else { return '<div class="eStore_error_message">The value you specified for the "info" parameter does not exist in the eStore product database. Please check the shortcode documentation to learn the usage of this shortcode.</div>'; } } } }
function eStore_save_membership_signup_rego_url($email, $rego_url, $ipn_data) { debug_log_subsc("Saving membership signup rego URL data for: " . $email, true); $fields = array(); $fields['date_time'] = date("Y-m-d H:i:s"); //current_time('mysql'); $fields['meta_key1'] = "member_email"; //Email address key $fields['meta_value1'] = $email; //Email address value $fields['meta_key2'] = "txn_id"; //Txn ID key $fields['meta_value2'] = $ipn_data['txn_id']; //Txn ID value $fields['meta_key3'] = "rego_url"; //Rego url key $fields['meta_value3'] = $rego_url; //Rego url value //Save ip address too maybe $updated = WP_eStore_Db_Access::insert(WP_ESTORE_GLOBAL_META_TABLE_NAME, $fields); debug_log_subsc("Membership signup rego URL data saved.", true); }