function eStore_calculate_cart_shipping_if_not_zero() { $postage_cost = 0; if (isset($_SESSION['eStore_cart_postage_cost']) && $_SESSION['eStore_cart_postage_cost'] == 0) { //Maybe free shipping discount was applied return $postage_cost; } else { $postage_cost = eStore_get_cart_shipping(); return $postage_cost; } }
function eStore_action_after_cart_items_details_handler() { if (isset($_POST['eStore_store_pickup_data_submitted'])) { if (WP_ESTORE_DO_NOT_APPLY_SHIPPING_FOR_STORE_PICKUP != '0') { if (!empty($_POST['eStore_store_pickup_chkbx_data'])) { //Store pickup toggled to unhcecked/off $_SESSION['eStore_cart_postage_cost'] = eStore_get_cart_shipping(); unset($_SESSION['eStore_store_pickup_checked']); unset($_SESSION['eStore_last_action_msg']); } else { //remove shipping from the shopping cart as the user has selected to do store pickup $_SESSION['eStore_cart_postage_cost'] = 0; $_SESSION['eStore_store_pickup_checked'] = '1'; $_SESSION['eStore_last_action_msg'] = '<p style="color: green;">' . WP_ESTORE_STORE_PICKUP_SELECTED . '</p>'; } } } }
function eStore_handle_total_discount($ret_coupon, $flag = "total") { $products = $_SESSION['eStore_cart']; $total = eStore_get_cart_total(); //$_SESSION['eStore_cart_sub_total']; $shipping = eStore_get_cart_shipping(); //$_SESSION['eStore_cart_postage_cost']; if ($flag == "total") { $total = $total + $shipping; } if ($ret_coupon->logic == "1") { if ($total > $ret_coupon->value) { $products = eStore_apply_discount_on_products($ret_coupon, $products); } } else { if ($ret_coupon->logic == "2") { if ($total == $ret_coupon->value) { $products = eStore_apply_discount_on_products($ret_coupon, $products); } } } sort($products); $_SESSION['eStore_cart'] = $products; }
function wp_eStore_save_session_values_to_cookie() { $domain_url = $_SERVER['SERVER_NAME']; $cookie_domain = str_replace("www", "", $domain_url); $cookie_life_time = time() + 86400; $serialized_string = base64_encode(serialize($_SESSION['eStore_cart'])); setcookie('eStore_cart', $serialized_string, $cookie_life_time, "/", $cookie_domain); $_SESSION['eStore_cart_sub_total'] = eStore_get_cart_total(); setcookie('eStore_cart_sub_total', $_SESSION['eStore_cart_sub_total'], $cookie_life_time, "/", $cookie_domain); $_SESSION['eStore_cart_postage_cost'] = eStore_get_cart_shipping(); setcookie('eStore_cart_postage_cost', $_SESSION['eStore_cart_postage_cost'], $cookie_life_time, "/", $cookie_domain); $_SESSION['eStore_cart_total_tax'] = eStore_get_cart_tax(); setcookie('eStore_cart_total_tax', $_SESSION['eStore_cart_total_tax'], $cookie_life_time, "/", $cookie_domain); setcookie('eStore_custom_values', $_SESSION['eStore_custom_values'], $cookie_life_time, "/", $cookie_domain); setcookie('eStore_coupon_code', $_SESSION['eStore_coupon_code'], $cookie_life_time, "/", $cookie_domain); setcookie('eStore_selected_shipping_option', $_SESSION['eStore_selected_shipping_option'], $cookie_life_time, "/", $cookie_domain); }
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); } } }