function eStore_co_member_log_in_requirement_check() { if (get_option('eStore_eMember_must_be_logged_to_checkout') == 1) { if (function_exists('wp_eMember_install')) { $emember_auth = Emember_Auth::getInstance(); $user_id = $emember_auth->getUserInfo('member_id'); if (empty($user_id)) { $redirection_url = get_option('eStore_eMember_redirection_url_when_not_logged'); if (empty($redirection_url)) { echo "Error Detected! If you want to use the 'Only Allow Logged In Members to Checkout' feature then you must specify a value in the 'Redirection URL for Anonymous Checkout' field also."; exit; } if (get_option('eStore_enable_fancy_redirection_on_checkout')) { ob_start(); wp_eStore_redirector_header(); wp_eStore_redirector_body(); $click_text = WP_ESTORE_CLICK_HERE; echo "<form id=\"gateway_form\" method=\"POST\" name=\"gateway_form\" action=\"" . $redirection_url . "\">"; echo "<input type=\"hidden\" name=\"wp_eStore_eMember_redirect\" value=\"1\"/>\n"; echo "<input type=\"submit\" value=\"{$click_text}\">"; echo "</form>"; wp_eStore_redirector_footer(); $eStore_redirector_output = ob_get_contents(); ob_end_clean(); echo $eStore_redirector_output; exit; } eStore_redirect_to_url($redirection_url); //header('Location: ' . $redirection_url); exit; } } else { echo "Error! You don't have the WP eMember plugin installed! You can only use the 'Only Allow Logged In Members to Checkout' feature with the WP eMember plugin."; exit; } } }
function wp_estore_product_management_menu() { echo '<div class="wrap"> <h2>' . __('Manage Products', 'wp_eStore') . '</h2>'; echo '<div id="poststuff"><div id="post-body">'; $eStore_products_per_page = get_option('eStore_products_per_page'); if (empty($eStore_products_per_page)) { echo '<div id="message" class="updated fade"><p>'; echo 'It appears that you have never saved your settings after installing the plugin! Please visit the settings page of this plugin and save it.'; echo '</p></div>'; } ?> <br /> <div class="postbox"> <h3><label for="title">Product Search</label></h3> <div class="inside"> <br /><strong>Search for a product by entering the full or partial product Name</strong> <br /><br /> <form method="post" action="<?php echo $_SERVER["REQUEST_URI"]; ?> "> <input type="hidden" name="info_update" id="info_update" value="true" /> <input name="eStore_product_search" type="text" size="40" value=""/> <div class="submit"> <input type="submit" name="info_update" class="button" value="Search »" /> </div> </form> </div></div> <?php if (isset($_POST['limit_update'])) { update_option('eStore_manage_products_limit2', (string) $_POST["eStore_manage_products_limit2"]); } $limit = get_option('eStore_manage_products_limit2'); if (empty($limit)) { update_option('eStore_manage_products_limit2', 50); $limit = 50; } if (isset($_REQUEST['deleted'])) { echo '<div id="message" class="updated fade"><p><strong>'; echo $_REQUEST['msg']; echo '</strong></p></div>'; } if (isset($_REQUEST['Delete'])) { $prod_id = $_REQUEST['prod_id']; if (wp_eStore_delete_product_data($prod_id)) { $message = "Product successfully deleted"; } else { $message = "An error occurded while trying to delete the entry"; } $redirect_url = 'admin.php?page=wp-cart-for-digital-products/wp_eStore1.php&deleted=1&msg=' . urlencode($message); eStore_redirect_to_url($redirect_url); } if (isset($_POST['info_update'])) { $search_term = (string) $_POST["eStore_product_search"]; update_option('eStore_product_search', (string) $_POST["eStore_product_search"]); eStore_display_searched_products($search_term); } else { eStore_display_products($limit); } ?> <form method="post" action="<?php echo $_SERVER["REQUEST_URI"]; ?> "> <input type="hidden" name="limit_update" id="limit_update" value="true" /> <br /> <strong>Product Display Limit Per Page : </strong> <input name="eStore_manage_products_limit2" type="text" size="6" value="<?php echo get_option('eStore_manage_products_limit2'); ?> "/> <input type="submit" name="limit_update" class="button" value="Update »" /> </form> <?php echo '</div></div>'; echo '</div>'; }
<?php include_once '../../../wp-load.php'; if (isset($_POST['eStore_manaul_gateway']) && $_POST['eStore_manaul_gateway'] == "process") { global $wp_eStore_config; $eStore_on_page_manual_checkout_page_url = $wp_eStore_config->getValue('eStore_on_page_manual_checkout_page_url'); if (empty($eStore_on_page_manual_checkout_page_url)) { include_once 'eStore_manual_gateway_functions.php'; eStore_manual_gateway_api(); } else { eStore_redirect_to_url($eStore_on_page_manual_checkout_page_url); } } else { exit; }
function wp_estore_discounts_menu() { echo '<div class="wrap"> <h2>' . __('Manage Coupons/Discounts', 'wp_eStore') . '</h2>'; echo '<div id="poststuff"><div id="post-body">'; global $wp_eStore_config, $wpdb; $currency_symbol = get_option('cart_currency_symbol'); $coupon_table_name = WP_ESTORE_COUPON_TABLE_NAME; if (isset($_POST['info_update'])) { update_option('eStore_use_coupon_system', $_POST['eStore_use_coupon_system'] == '1' ? '1' : ''); echo '<div id="message" class="updated fade"><p>Coupon Settings Updated</p></div>'; } if (isset($_POST['marketing_settings'])) { $tmp_offer_text = htmlentities(stripslashes($_POST['eStore_special_offer_text']), ENT_COMPAT, "UTF-8"); update_option('eStore_special_offer_text', $tmp_offer_text); echo '<div id="message" class="updated fade">Marketing Options Updated</div>'; } if (isset($_POST['auto_discount_settings'])) { update_option('eStore_use_auto_discount', $_POST['eStore_use_auto_discount'] == '1' ? '1' : ''); $wp_eStore_config->setValue('eStore_use_auto_discount', $_POST['eStore_use_auto_discount'] == '1' ? '1' : ''); update_option('eStore_amount_free_shipping_threshold', (string) $_POST["eStore_amount_free_shipping_threshold"]); $wp_eStore_config->setValue('eStore_amount_free_shipping_threshold', (string) $_POST["eStore_amount_free_shipping_threshold"]); update_option('eStore_qty_free_shipping_threshold', (string) $_POST["eStore_qty_free_shipping_threshold"]); $wp_eStore_config->setValue('eStore_qty_free_shipping_threshold', (string) $_POST["eStore_qty_free_shipping_threshold"]); update_option('eStore_amount_threshold_auto_coupon', (string) $_POST["eStore_amount_threshold_auto_coupon"]); $wp_eStore_config->setValue('eStore_amount_threshold_auto_coupon', (string) $_POST["eStore_amount_threshold_auto_coupon"]); update_option('eStore_amount_threshold_auto_coupon_code', (string) $_POST["eStore_amount_threshold_auto_coupon_code"]); $wp_eStore_config->setValue('eStore_amount_threshold_auto_coupon_code', (string) $_POST["eStore_amount_threshold_auto_coupon_code"]); update_option('eStore_qty_threshold_auto_coupon', (string) $_POST["eStore_qty_threshold_auto_coupon"]); $wp_eStore_config->setValue('eStore_qty_threshold_auto_coupon', (string) $_POST["eStore_qty_threshold_auto_coupon"]); update_option('eStore_qty_threshold_auto_coupon_code', (string) $_POST["eStore_qty_threshold_auto_coupon_code"]); $wp_eStore_config->setValue('eStore_qty_threshold_auto_coupon_code', (string) $_POST["eStore_qty_threshold_auto_coupon_code"]); $wp_eStore_config->saveConfig(); echo '<div id="message" class="updated fade">Auto Discount Settings Updated</div>'; } //If product is being edited, grab current product info if (isset($_GET['editproduct']) && $_GET['editproduct'] != '') { $theid = $_GET['editproduct']; $editingproduct = $wpdb->get_row("SELECT * FROM {$coupon_table_name} WHERE id = '{$theid}'", OBJECT); } if (isset($_POST['Submit'])) { //validate some of the entry fields $error_message = ""; if (!empty($_POST['expiry_date'])) { if (!wp_eStore_is_date_valid($_POST['expiry_date'])) { $error_message .= "<br />The expiry date is not in the valid form. Please enter the date in yyyy-mm-dd form. Example: 2011-12-25"; } } if (empty($_POST['coupon_code'])) { $error_message .= "<br />Error! Coupon code field cannot be empty."; } if (empty($_POST['discount_value'])) { $error_message .= "<br />Error! Discount value field cannot be empty."; } if (empty($error_message)) { if (!isset($_POST['editedproduct'])) { $_POST['editedproduct'] = ""; } //Get the post data $post_editedproduct = esc_sql($_POST['editedproduct']); $post_coupon_code = esc_sql($_POST['coupon_code']); $post_discount_value = esc_sql($_POST['discount_value']); $post_discount_type = esc_sql($_POST['discount_type']); $redemption_limit = esc_sql($_POST['redemption_limit']); if (empty($redemption_limit)) { if ($redemption_limit != '0') { $redemption_limit = '9999'; } } $redemption_count = esc_sql($_POST['redemption_count']); $post_coupon_active = esc_sql($_POST['coupon_active']); $post_property = esc_sql($_POST['property']); $post_logic = esc_sql($_POST['logic']); $post_value = esc_sql($_POST['value']); $curr_symbol = get_option('cart_currency_symbol'); if (!empty($post_value)) { $post_value = str_replace($curr_symbol, "", $post_value); } $start_date = esc_sql($_POST['start_date']); if (empty($start_date)) { $start_date = "0000-00-00"; } $expiry_date = esc_sql($_POST['expiry_date']); if (empty($expiry_date)) { $expiry_date = "0000-00-00"; } $dynamic = ""; if ($post_coupon_active == 1) { $post_coupon_active = 'Yes'; } else { $post_coupon_active = 'No'; } if ($post_editedproduct == '') { $updatedb = "INSERT INTO {$coupon_table_name} (coupon_code, discount_value, discount_type, active,redemption_limit,redemption_count,property,logic,value,expiry_date,dynamic,start_date) VALUES ('{$post_coupon_code}', '{$post_discount_value}','{$post_discount_type}','{$post_coupon_active}','{$redemption_limit}','{$redemption_count}','{$post_property}','{$post_logic}','{$post_value}','{$expiry_date}','{$dynamic}','{$start_date}')"; $results = $wpdb->query($updatedb); echo '<div id="message" class="updated fade"><p>Coupon "' . $post_coupon_code . '" created.</p></div>'; } else { $updatedb = "UPDATE {$coupon_table_name} SET coupon_code = '{$post_coupon_code}', discount_value = '{$post_discount_value}', discount_type = '{$post_discount_type}', active = '{$post_coupon_active}',redemption_limit='{$redemption_limit}',redemption_count='{$redemption_count}',property='{$post_property}',logic='{$post_logic}',value='{$post_value}',expiry_date='{$expiry_date}',dynamic='{$dynamic}',start_date='{$start_date}' WHERE id='{$post_editedproduct}'"; $results = $wpdb->query($updatedb); echo '<div id="message" class="updated fade"><p>' . __('Coupon', 'wp_eStore') . ' "' . $post_coupon_code . '" ' . __('updated.', 'wp_eStore') . '</p></div>'; } } else { echo '<div id="message" class="updated fade"><p>' . $error_message . '</p></div>'; } } //Delete from the coupons list if (isset($_REQUEST['delete_record']) && isset($_REQUEST['record_id'])) { $thecouponid = $_REQUEST['record_id']; $del_query = "DELETE FROM {$coupon_table_name} WHERE id='{$thecouponid}'"; $results = $wpdb->query($del_query); $redirect_url = 'admin.php?page=wp_eStore_discounts&msg=' . urlencode("Coupon deleted successfully!"); eStore_redirect_to_url($redirect_url); } if (isset($_REQUEST['msg'])) { echo '<div id="message" class="updated fade"><p>' . $_REQUEST['msg'] . '</p></div>'; } ?> <div class="postbox"> <h3><label for="title">Coupons Settings</label></h3> <div class="inside"> <form method="post" action="<?php echo $_SERVER["REQUEST_URI"]; ?> "> <input type="hidden" name="info_update" id="info_update" value="true" /> <br /><strong>Use Coupon System: </strong> <input name="eStore_use_coupon_system" type="checkbox"<?php if (get_option('eStore_use_coupon_system') != '') { echo ' checked="checked"'; } ?> value="1"/> <span class="description"> When checked your customers will be able to enter a coupon code in the shopping cart before checkout.</span> <div class="submit"> <input type="submit" class="button" name="info_update" value="Update »" /> </div> </form> </div></div> <div class="postbox"> <h3><label for="title">Automatic Discount Settings</label></h3> <div class="inside"> <form method="post" action="<?php echo $_SERVER["REQUEST_URI"]; ?> "> <input type="hidden" name="auto_discount_settings" id="auto_discount_settings" value="true" /> <table class="form-table"> <tr valign="top"> <th scope="row">Use Automatic Discount Feature</th> <td><input name="eStore_use_auto_discount" type="checkbox"<?php if (get_option('eStore_use_auto_discount') != '') { echo ' checked="checked"'; } ?> value="1"/> <span class="description">When checked your customers will automatically get discounts in their shopping cart according to the conditions specified below.</span> </td> </tr> <tr valign="top"> <th scope="row">Free Shipping for Sub-total Over</th> <td><?php echo $currency_symbol . " "; ?> <input name="eStore_amount_free_shipping_threshold" type="text" id="eStore_amount_free_shipping_threshold" value="<?php echo get_option('eStore_amount_free_shipping_threshold'); ?> " size="4" /> (Example: 50.00) <br/><p class="description">Customers who order more than this amount will get free shipping. Leave empty if you do not want to use it.</p></td> </tr> <tr valign="top"> <th scope="row">Free Shipping for Quantity Over</th> <td><input name="eStore_qty_free_shipping_threshold" type="text" id="eStore_qty_free_shipping_threshold" value="<?php echo get_option('eStore_qty_free_shipping_threshold'); ?> " size="4" /> (Example: 5) <br/><p class="description">Customers who order more than this quantity will get free shipping. Leave empty if you do not want to use it.</p></td> </tr> <tr valign="top"> <th scope="row">Apply Coupon Automatically for Sub-total Over</th> <td>Subtotal: <?php echo $currency_symbol . " "; ?> <input name="eStore_amount_threshold_auto_coupon" type="text" id="eStore_amount_threshold_auto_coupon" value="<?php echo get_option('eStore_amount_threshold_auto_coupon'); ?> " size="4" /> Coupon Code to Apply: <input name="eStore_amount_threshold_auto_coupon_code" type="text" id="eStore_amount_threshold_auto_coupon_code" value="<?php echo get_option('eStore_amount_threshold_auto_coupon_code'); ?> " size="20" /> <br/><p class="description">Customers who order more than this amount will automatically get the specified coupon applied to their cart. Leave empty if you do not want to use it.</p></td> </tr> <tr valign="top"> <th scope="row">Apply Coupon Automatically for Quantity Over</th> <td>Quantity: <input name="eStore_qty_threshold_auto_coupon" type="text" id="eStore_qty_threshold_auto_coupon" value="<?php echo get_option('eStore_qty_threshold_auto_coupon'); ?> " size="4" /> Coupon Code to Apply: <input name="eStore_qty_threshold_auto_coupon_code" type="text" id="eStore_qty_threshold_auto_coupon_code" value="<?php echo get_option('eStore_qty_threshold_auto_coupon_code'); ?> " size="20" /> <br/><p class="description">Customers who order more than this quantity will automatically get the specified coupon applied to their cart. Leave empty if you do not want to use it.</p></td> </tr> </table> <div class="submit"> <input type="submit" class="button" name="auto_discount_settings" value="Update »" /> </div> </form> </div></div> <div class="postbox"> <h3><label for="title">Add A Coupon</label></h3> <div class="inside"> <form method="post" action="admin.php?page=wp_eStore_discounts"> <table width="850"> <?php if (isset($_GET['editproduct']) && $_GET['editproduct'] != '') { echo '<input name="editedproduct" type="hidden" value="' . $_GET['editproduct'] . '" />'; } else { if (isset($editingproduct)) { //Copying an existing recored or this object is already loaded } else { //New record (initialize with empty data) $editingproduct = new stdClass(); $editingproduct->id = ""; $editingproduct->coupon_code = ""; $editingproduct->discount_value = ""; $editingproduct->discount_type = "0"; $editingproduct->redemption_limit = ""; $editingproduct->redemption_count = ""; $editingproduct->start_date = ""; $editingproduct->expiry_date = ""; $editingproduct->property = ""; $editingproduct->logic = ""; $editingproduct->value = ""; } } ?> <thead><tr> <th align="left"><strong>Coupon Code</strong></th> <th align="left"><strong>Discount Value</strong></th> <th align="left"><strong>Redemption Limit</strong></th> <th align="left"><strong>Redemption Count</strong></th> <th align="left"><strong>Start Date<br />(yyyy-mm-dd)</strong></th> <th align="left"><strong>Expiry Date<br />(yyyy-mm-dd)</strong></th> <th align="left"><strong>Active</strong></th> </tr></thead> <tbody> <tr> <td width="160"><input name="coupon_code" type="text" id="coupon_code" value="<?php echo $editingproduct->coupon_code; ?> " size="20" /></td> <td width="120"><input name="discount_value" type="text" id="discount_value" value="<?php echo $editingproduct->discount_value; ?> " size="5" /> <select name='discount_type'> <option value='0' <?php if ($editingproduct->discount_type == '0') { echo 'selected="selected"'; } ?> >%</option> <option value='1' <?php if ($editingproduct->discount_type == '1') { echo 'selected="selected"'; } ?> ><?php echo $currency_symbol; ?> </option> </select> </td> <td width="100"><input name="redemption_limit" type="text" id="redemption_limit" value="<?php echo $editingproduct->redemption_limit; ?> " size="4" /><br /></td> <td width="100"><input name="redemption_count" type="text" id="redemption_count" value="<?php echo $editingproduct->redemption_count; ?> " size="4" /></td> <td width="250"><input class="estore_date" name="start_date" type="text" id="start_date" value="<?php if ($editingproduct->start_date != "0000-00-00") { echo $editingproduct->start_date; } else { echo ""; } ?> " size="10" /></td> <td width="250"><input class="estore_date" name="expiry_date" type="text" id="expiry_date" value="<?php if ($editingproduct->expiry_date != "0000-00-00") { echo $editingproduct->expiry_date; } else { echo ""; } ?> " size="10" /></td> <td><input type='checkbox' value='1' checked='checked' name='coupon_active' /></td> <td> <p class="submit"><input type="submit" name="Submit" class="button-primary" value="Save Coupon" /></p> </td></tr> <tr> <th align="left"><strong>Conditions (Optional)</strong></th> </tr> <tr> <td> <select name='property'> <option value='1' <?php if ($editingproduct->property == '1') { echo 'selected="selected"'; } ?> >Individual Item Quantity</option> <option value='2' <?php if ($editingproduct->property == '2') { echo 'selected="selected"'; } ?> >Total Quantity</option> <option value='3' <?php if ($editingproduct->property == '3') { echo 'selected="selected"'; } ?> >Subtotal Amount</option> <option value='4' <?php if ($editingproduct->property == '4') { echo 'selected="selected"'; } ?> >Total Amount</option> <option value='5' <?php if ($editingproduct->property == '5') { echo 'selected="selected"'; } ?> >Item Name</option> <option value='6' <?php if ($editingproduct->property == '6') { echo 'selected="selected"'; } ?> >Item ID</option> <option value='7' <?php if ($editingproduct->property == '7') { echo 'selected="selected"'; } ?> >Free Shipping if total</option> <option value='8' <?php if ($editingproduct->property == '8') { echo 'selected="selected"'; } ?> >Product Category ID</option> </select> </td> <td> <select name='logic'> <option value='1' <?php if ($editingproduct->logic == '1') { echo 'selected="selected"'; } ?> >Is greater than</option> <option value='2' <?php if ($editingproduct->logic == '2') { echo 'selected="selected"'; } ?> >Is equal to</option> <option value='3' <?php if ($editingproduct->logic == '3') { echo 'selected="selected"'; } ?> >Contains</option> </select> </td> <td><input name="value" type="text" id="value" value="<?php echo $editingproduct->value; ?> " size="20" /></td> </tr> </tbody> </table> </form> </div></div> <?php //eStore_display_coupons_list($coupon_table_name); eStore_display_coupons_list_new(); echo '<br /><br />'; eStore_display_marketing_options(); echo '</div></div>'; //end of poststuff div echo '</div>'; //end of wrap div }
function eStore_gateway_specific_buy_now_submit_listener() { if (isset($_REQUEST['eStore_gs_buy_now_submit'])) { $wp_eStore_config = WP_eStore_Config::getInstance(); $cookie_domain = eStore_get_top_level_domain(); setcookie("cart_in_use", "true", time() + 21600, "/", $cookie_domain); if (function_exists('wp_cache_serve_cache_file')) { //WP Super cache workaround setcookie("comment_author_", "eStore", time() + 21600, "/", $cookie_domain); } unset($_SESSION['eStore_last_action_msg']); unset($_SESSION['eStore_last_action_msg_2']); unset($_SESSION['eStore_last_action_msg_3']); unset($_SESSION['eStore_gs_bn_co_error_msg']); if (isset($_SESSION['eStore_cart'])) { unset($_SESSION['eStore_cart']); } //sanitize data $_REQUEST['product'] = strip_tags($_REQUEST['product']); //for PHP5.2 use filter_var($_REQUEST['product'], FILTER_SANITIZE_STRING); $_REQUEST['add_qty'] = strip_tags($_REQUEST['add_qty']); $_REQUEST['item_number'] = strip_tags($_REQUEST['item_number']); if (isset($_REQUEST['custom_price'])) { $_REQUEST['custom_price'] = strip_tags($_REQUEST['custom_price']); } if (isset($_REQUEST['price'])) { $_REQUEST['price'] = strip_tags($_REQUEST['price']); } isset($_REQUEST['shipping']) ? $_REQUEST['shipping'] = strip_tags($_REQUEST['shipping']) : ($_REQUEST['shipping'] = ''); isset($_REQUEST['cartLink']) ? $_REQUEST['cartLink'] = strip_tags($_REQUEST['cartLink']) : ($_REQUEST['cartLink'] = ''); isset($_REQUEST['thumbnail_url']) ? $_REQUEST['thumbnail_url'] = strip_tags($_REQUEST['thumbnail_url']) : ($_REQUEST['thumbnail_url'] = ''); isset($_REQUEST['tax']) ? $_REQUEST['tax'] = strip_tags($_REQUEST['tax']) : ($_REQUEST['tax'] = ''); if (isset($_REQUEST['digital_flag'])) { $_REQUEST['digital_flag'] = strip_tags($_REQUEST['digital_flag']); } else { $_REQUEST['digital_flag'] = ''; } $gateway = strip_tags($_REQUEST['eStore_gsbn_gateway']); $products = array(); $eStore_gs_buy_now_checkout_error = false; $count = 1; if ($count == 1) { $item_addittion_permitted = true; $quantity_available = is_quantity_availabe($_REQUEST['item_number'], $_REQUEST['add_qty']); if (!$quantity_available) { //Requested qty not available $_REQUEST['add_qty'] = 1; //Add one by default $eStore_gs_buy_now_checkout_error = true; } if (isset($_SESSION['eStore_last_action_msg'])) { $_SESSION['eStore_gs_bn_co_error_msg'] = $_SESSION['eStore_last_action_msg']; } if ($item_addittion_permitted) { if (!empty($_REQUEST[$_REQUEST['product']])) { $price = $_REQUEST[$_REQUEST['product']]; } else { if (isset($_REQUEST['custom_price'])) { global $wpdb; $products_table_name = WP_ESTORE_PRODUCTS_TABLE_NAME; $id = $_REQUEST['item_number']; $retrieved_product = $wpdb->get_row("SELECT * FROM {$products_table_name} WHERE id = '{$id}'", OBJECT); if ($_REQUEST['custom_price'] < $retrieved_product->price) { $price = $retrieved_product->price; $currSymbol = get_option('cart_currency_symbol'); $eStore_gs_buy_now_checkout_error = true; $_SESSION['eStore_gs_bn_co_error_msg'] = '<p style="color: red;">' . WP_ESTORE_MINIMUM_PRICE_YOU_CAN_ENTER . $currSymbol . $retrieved_product->price . '</p>'; } else { $price = $_REQUEST['custom_price']; } } else { $price = $_REQUEST['price']; } } $product = array('name' => stripslashes($_REQUEST['product']), 'price' => $price, 'quantity' => $_REQUEST['add_qty'], 'shipping' => $_REQUEST['shipping'], 'item_number' => $_REQUEST['item_number'], 'cartLink' => $_REQUEST['cartLink'], 'thumbnail_url' => $_REQUEST['thumbnail_url'], 'tax' => $_REQUEST['tax'], 'digital_flag' => $_REQUEST['digital_flag']); array_push($products, $product); } } if (!$eStore_gs_buy_now_checkout_error) { $_SESSION['eStore_cart'] = $products; $_SESSION['eStore_url'] = WP_ESTORE_URL; $_SESSION['eStore_cart_sub_total'] = eStore_get_cart_total(); $_SESSION['eStore_cart_postage_cost'] = eStore_get_cart_shipping(); $_SESSION['eStore_cart_total_tax'] = eStore_calculate_total_cart_tax(); wp_eStore_check_cookie_flag_and_store_values(); if (WP_ESTORE_ENABLE_NEW_CHECKOUT_REDIRECTION === '1') { $redirect_page = WP_ESTORE_WP_SITE_URL . '/?eStore_checkout=process&eStore_gateway=' . $gateway; } else { $redirect_page = WP_ESTORE_URL . '/eStore_payment_submission.php?eStore_gateway=' . $gateway; } eStore_redirect_to_url($redirect_page); } } }
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_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); } }
function handle_payment_data($raw_data, $gateway) { eStore_payment_debug("Handling payment data from: " . $gateway, true); if ($gateway == "2co") { $mc_currency = $raw_data['list_currency']; if (empty($mc_currency)) { $mc_currency = $raw_data['currency_code']; } $uniqueOrderId = $raw_data['item_id_1']; if (empty($uniqueOrderId)) { //This is a tank you page post (not a background IPN post) $uniqueOrderId = $raw_data['cart_order_id']; } $cart_items = eStore_retrieve_order_details_from_db($uniqueOrderId, $gateway, $mc_currency); if (empty($raw_data['message_type'])) { //Normal Thank You page post $payment_data = extract_2co_general_payment_data_secondary($raw_data, $gateway, $cart_items); } else { //proper INS post $payment_data = extract_2co_general_payment_data($raw_data, $gateway, $cart_items); } if ($payment_data['txn_type'] == "ORDER_CREATED") { eStore_payment_debug("Order Received... verifying payment data.", true); eStore_do_post_payment_tasks($payment_data, $cart_items); } //Log the payment and cart data to the debug file foreach ($payment_data as $key => $value) { $text .= "{$key}={$value}, "; } foreach ($cart_items as $key => $value) { $text .= "{$key}={$value}, "; } eStore_payment_debug($text, true, true); } else { if ($gateway == "authorize") { $cart_items = eStore_retrieve_order_details_from_db($raw_data['x_cust_id'], $gateway); $payment_data = extract_authorize_general_payment_data($raw_data, $gateway, $cart_items); //print_r($cart_items); if (!empty($cart_items)) { eStore_payment_debug("Order Received... verifying payment data.", true); eStore_do_post_payment_tasks($payment_data, $cart_items); } else { eStore_payment_debug("Cart items empty! Could not retrieve items from the database.", false); } //Log the payment data to the debug file foreach ($payment_data as $key => $value) { $text .= "{$key}={$value}, "; } foreach ($cart_items as $key => $value) { $text .= "{$key}={$value}, "; } eStore_payment_debug($text, true, true); //The pending payment data can be deleted at this stage } } //file_put_contents('2co_process.txt', $text); reset_eStore_cart(); $post_payment_return_url = get_option('cart_return_from_paypal_url'); $post_payment_return_url = eStore_append_http_get_data_to_url($post_payment_return_url, "reset_eStore_cart", "1"); eStore_redirect_to_url($post_payment_return_url); }
function eStore_misc_loader_handlers() { if (isset($_REQUEST['estore_pagination_go'])) { //Pagination go request $target_page_no = sanitize_text_field($_REQUEST['estore_pagination_page_no']); $parameter_name = sanitize_text_field($_REQUEST['estore_pagination_parameter_name']); $page_url = esc_url($_REQUEST['estore_pagination_raw_url']); $target_page = eStore_append_http_get_data_to_url($page_url, $parameter_name, $target_page_no); eStore_redirect_to_url($target_page); } eStore_download_now_button_request_handler(); }