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 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 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_cart_display_checkout_button_form_part() { $output = ""; global $wp_eStore_config; if (defined('WP_PAYMENT_GATEWAY_BUNDLE_VERSION')) { // Load payment gateway bundle config $wp_pg_bundle_config = WP_Payment_Gateway_Bundle_Config::getInstance(); } //Check if minimum and maximum cart checkout amount restriction apply if ($wp_eStore_config->getValue('eStore_enable_checkout_amt_limit') == '1') { $minimum_cart_co_amount = $wp_eStore_config->getValue('eStore_checkout_amt_limit_minimum'); if (!empty($minimum_cart_co_amount)) { $minimum_cart_co_amount = number_format((double) $minimum_cart_co_amount, 2); } $maximum_cart_co_amount = $wp_eStore_config->getValue('eStore_checkout_amt_limit_maximum'); if (!empty($maximum_cart_co_amount)) { $maximum_cart_co_amount = number_format((double) $maximum_cart_co_amount, 2); } $cart_sub_total = eStore_get_cart_total(); if (is_numeric($minimum_cart_co_amount) && $cart_sub_total < $minimum_cart_co_amount) { $output .= '<p class="eStore_error_message">'; $output .= ESTORE_CART_DOES_NOT_MEET_MIN_REQUIREMENT; $output .= ESTORE_CART_MINIMUM_CHECKOUT_AMOUNT_REQUIRED . WP_ESTORE_CURRENCY_SYMBOL . $minimum_cart_co_amount; $output .= '</p>'; return $output; } if (is_numeric($maximum_cart_co_amount) && $cart_sub_total > $maximum_cart_co_amount) { $output .= '<p class="eStore_error_message">'; $output .= ESTORE_CART_DOES_NOT_MEET_MIN_REQUIREMENT; $output .= ESTORE_CART_MAXIMUM_CHECKOUT_AMOUNT_REQUIRED . WP_ESTORE_CURRENCY_SYMBOL . $maximum_cart_co_amount; $output .= '</p>'; return $output; } } //Create the checkout button form $output .= '<div class="eStore_cart_checkout_button">'; if (get_option('eStore_show_t_c')) { $output .= eStore_show_terms_and_cond(); } if (WP_ESTORE_ENABLE_NEW_CHECKOUT_REDIRECTION === '1') { //TODO - make the new checkout the default $output .= '<form action="' . WP_ESTORE_WP_SITE_URL . '?eStore_checkout=process" method="post">'; } else { $output .= '<form action="' . WP_ESTORE_URL . '/eStore_payment_submission.php" method="post">'; } $checkout_button = WP_ESTORE_URL . '/images/checkout_paypal.png'; if (get_option('eStore_use_multiple_gateways')) { $output .= ESTORE_PAYMENT_METHOD; $output .= '<select class="eStore_gateway" name="eStore_gateway">'; if (get_option('eStore_use_paypal_gateway')) { if (isset($_COOKIE['eStore_gateway']) && $_COOKIE['eStore_gateway'] == "paypal") { $output .= '<option value="paypal" selected="selected">' . ESTORE_PAYPAL . '</option>'; $checkout_button = WP_ESTORE_URL . '/images/checkout_paypal.png'; } else { $output .= '<option value="paypal">' . ESTORE_PAYPAL . '</option>'; } } if (get_option('eStore_use_manual_gateway')) { if (isset($_COOKIE['eStore_gateway']) && $_COOKIE['eStore_gateway'] == "manual") { $output .= '<option value="manual" selected="selected">' . ESTORE_MANUAL . '</option>'; $checkout_button = WP_ESTORE_URL . '/images/checkout_manual.png'; } else { $output .= '<option value="manual">' . ESTORE_MANUAL . '</option>'; } } if (get_option('eStore_use_2co_gateway')) { if (isset($_COOKIE['eStore_gateway']) && $_COOKIE['eStore_gateway'] == "2co") { $output .= '<option value="2co" selected="selected">' . ESTORE_TWO_CO . '</option>'; $checkout_button = WP_ESTORE_URL . '/images/checkout_2co.png'; } else { $output .= '<option value="2co">' . ESTORE_TWO_CO . '</option>'; } } if (get_option('eStore_use_authorize_gateway')) { if (isset($_COOKIE['eStore_gateway']) && $_COOKIE['eStore_gateway'] == "authorize") { $output .= '<option value="authorize" selected="selected">' . ESTORE_AUTHORIZE . '</option>'; $checkout_button = WP_ESTORE_URL . '/images/checkout_authorize.gif'; } else { $output .= '<option value="authorize">' . ESTORE_AUTHORIZE . '</option>'; } } //Add the payment gateway bundle checkout options if (defined('WP_PAYMENT_GATEWAY_BUNDLE_VERSION')) { if ($wp_pg_bundle_config->getValue('wp_pg_use_gco_gateway')) { if (isset($_COOKIE['eStore_gateway']) && $_COOKIE['eStore_gateway'] == "gco") { $output .= '<option value="gco" selected="selected">' . $wp_pg_bundle_config->getValue('wp_pg_gco_selector_label') . '</option>'; $checkout_button = WP_PAYMENT_GATEWAY_BUNDLE_PLUGIN_URL . '/images/checkout_gco.gif'; } else { $output .= '<option value="gco">' . $wp_pg_bundle_config->getValue('wp_pg_gco_selector_label') . '</option>'; } } if ($wp_pg_bundle_config->getValue('wp_pg_use_pppro_gateway')) { if (isset($_COOKIE['eStore_gateway']) && $_COOKIE['eStore_gateway'] == "pppro") { $output .= '<option value="pppro" selected="selected">' . $wp_pg_bundle_config->getValue('wp_pg_pppro_selector_label') . '</option>'; $checkout_button = WP_PAYMENT_GATEWAY_BUNDLE_PLUGIN_URL . '/images/checkout_pppro.gif'; } else { $output .= '<option value="pppro">' . $wp_pg_bundle_config->getValue('wp_pg_pppro_selector_label') . '</option>'; } } if ($wp_pg_bundle_config->getValue('wp_pg_use_sagepay_gateway')) { if (isset($_COOKIE['eStore_gateway']) && $_COOKIE['eStore_gateway'] == "sagepay") { $output .= '<option value="sagepay" selected="selected">' . $wp_pg_bundle_config->getValue('wp_pg_sagepay_selector_label') . '</option>'; $checkout_button = WP_PAYMENT_GATEWAY_BUNDLE_PLUGIN_URL . '/images/checkout_sagepay.gif'; } else { $output .= '<option value="sagepay">' . $wp_pg_bundle_config->getValue('wp_pg_sagepay_selector_label') . '</option>'; } } if ($wp_pg_bundle_config->getValue('wp_pg_use_auth_aim_gateway')) { if (isset($_COOKIE['eStore_gateway']) && $_COOKIE['eStore_gateway'] == "auth_aim") { $output .= '<option value="auth_aim" selected="selected">' . $wp_pg_bundle_config->getValue('wp_pg_auth_aim_selector_label') . '</option>'; $checkout_button = WP_PAYMENT_GATEWAY_BUNDLE_PLUGIN_URL . '/images/checkout_auth_aim.gif'; } else { $output .= '<option value="auth_aim">' . $wp_pg_bundle_config->getValue('wp_pg_auth_aim_selector_label') . '</option>'; } } if ($wp_pg_bundle_config->getValue('wp_pg_use_eway_gateway')) { if (isset($_COOKIE['eStore_gateway']) && $_COOKIE['eStore_gateway'] == "eway") { $output .= '<option value="eway" selected="selected">' . $wp_pg_bundle_config->getValue('wp_pg_eway_selector_label') . '</option>'; $checkout_button = WP_PAYMENT_GATEWAY_BUNDLE_PLUGIN_URL . '/images/checkout_eway.gif'; } else { $output .= '<option value="eway">' . $wp_pg_bundle_config->getValue('wp_pg_eway_selector_label') . '</option>'; } } if ($wp_pg_bundle_config->getValue('wp_pg_use_epay_dk_gateway')) { if (isset($_COOKIE['eStore_gateway']) && $_COOKIE['eStore_gateway'] == "epay_dk") { $output .= '<option value="epay_dk" selected="selected">' . $wp_pg_bundle_config->getValue('wp_pg_epay_dk_selector_label') . '</option>'; $checkout_button = WP_PAYMENT_GATEWAY_BUNDLE_PLUGIN_URL . '/images/checkout_epay_dk.gif'; } else { $output .= '<option value="epay_dk">' . $wp_pg_bundle_config->getValue('wp_pg_epay_dk_selector_label') . '</option>'; } } if ($wp_pg_bundle_config->getValue('wp_pg_use_verotel_flexpay_gateway')) { if (isset($_COOKIE['eStore_gateway']) && $_COOKIE['eStore_gateway'] == "verotel") { $output .= '<option value="verotel" selected="selected">' . $wp_pg_bundle_config->getValue('wp_pg_verotel_flexpay_selector_label') . '</option>'; $checkout_button = WP_PAYMENT_GATEWAY_BUNDLE_PLUGIN_URL . '/images/checkout_verotel.gif'; } else { $output .= '<option value="verotel">' . $wp_pg_bundle_config->getValue('wp_pg_verotel_flexpay_selector_label') . '</option>'; } } if ($wp_pg_bundle_config->getValue('wp_pg_use_freshbooks')) { if (isset($_COOKIE['eStore_gateway']) && $_COOKIE['eStore_gateway'] == "freshbooks") { $output .= '<option value="freshbooks" selected="selected">' . $wp_pg_bundle_config->getValue('wp_pg_freshbooks_selector_label') . '</option>'; $checkout_button = WP_PAYMENT_GATEWAY_BUNDLE_PLUGIN_URL . '/images/checkout_freshbooks.gif'; } else { $output .= '<option value="freshbooks">' . $wp_pg_bundle_config->getValue('wp_pg_freshbooks_selector_label') . '</option>'; } } } $output = apply_filters('eStore_cart_checkout_option_mc_filter', $output); $output .= '</select><br />'; } else { if (get_option('eStore_use_paypal_gateway')) { $output .= '<input type="hidden" name="eStore_gateway" id="eStore_gateway" value="paypal" />'; $checkout_button = WP_ESTORE_URL . '/images/checkout_paypal.png'; } else { if (get_option('eStore_use_manual_gateway')) { $output .= '<input type="hidden" name="eStore_gateway" id="eStore_gateway" value="manual" />'; $checkout_button = WP_ESTORE_URL . '/images/checkout_manual.png'; } else { if (get_option('eStore_use_2co_gateway')) { $output .= '<input type="hidden" name="eStore_gateway" id="eStore_gateway" value="2co" />'; $checkout_button = WP_ESTORE_URL . '/images/checkout_2co.png'; } else { if (get_option('eStore_use_authorize_gateway')) { $output .= '<input type="hidden" name="eStore_gateway" id="eStore_gateway" value="authorize" />'; $checkout_button = WP_ESTORE_URL . '/images/checkout_authorize.gif'; } else { if (defined('WP_PAYMENT_GATEWAY_BUNDLE_VERSION')) { if ($wp_pg_bundle_config->getValue('wp_pg_use_gco_gateway')) { $output .= '<input type="hidden" name="eStore_gateway" id="eStore_gateway" value="gco" />'; $checkout_button = WP_PAYMENT_GATEWAY_BUNDLE_PLUGIN_URL . '/images/checkout_gco.gif'; } else { if ($wp_pg_bundle_config->getValue('wp_pg_use_pppro_gateway')) { $output .= '<input type="hidden" name="eStore_gateway" id="eStore_gateway" value="pppro" />'; $checkout_button = WP_PAYMENT_GATEWAY_BUNDLE_PLUGIN_URL . '/images/checkout_pppro.gif'; } else { if ($wp_pg_bundle_config->getValue('wp_pg_use_sagepay_gateway')) { $output .= '<input type="hidden" name="eStore_gateway" id="eStore_gateway" value="sagepay" />'; $checkout_button = WP_PAYMENT_GATEWAY_BUNDLE_PLUGIN_URL . '/images/checkout_sagepay.gif'; } else { if ($wp_pg_bundle_config->getValue('wp_pg_use_auth_aim_gateway')) { $output .= '<input type="hidden" name="eStore_gateway" id="eStore_gateway" value="auth_aim" />'; $checkout_button = WP_PAYMENT_GATEWAY_BUNDLE_PLUGIN_URL . '/images/checkout_auth_aim.gif'; } else { if ($wp_pg_bundle_config->getValue('wp_pg_use_eway_gateway')) { $output .= '<input type="hidden" name="eStore_gateway" id="eStore_gateway" value="eway" />'; $checkout_button = WP_PAYMENT_GATEWAY_BUNDLE_PLUGIN_URL . '/images/checkout_eway.gif'; } else { if ($wp_pg_bundle_config->getValue('wp_pg_use_epay_dk_gateway')) { $output .= '<input type="hidden" name="eStore_gateway" id="eStore_gateway" value="epay_dk" />'; $checkout_button = WP_PAYMENT_GATEWAY_BUNDLE_PLUGIN_URL . '/images/checkout_epay_dk.gif'; } else { if ($wp_pg_bundle_config->getValue('wp_pg_use_verotel_flexpay_gateway')) { $output .= '<input type="hidden" name="eStore_gateway" id="eStore_gateway" value="verotel" />'; $checkout_button = WP_PAYMENT_GATEWAY_BUNDLE_PLUGIN_URL . '/images/checkout_verotel.gif'; } else { if ($wp_pg_bundle_config->getValue('wp_pg_use_freshbooks')) { $output .= '<input type="hidden" name="eStore_gateway" id="eStore_gateway" value="freshbooks" />'; $checkout_button = WP_PAYMENT_GATEWAY_BUNDLE_PLUGIN_URL . '/images/checkout_freshbooks.gif'; } else { $output = apply_filters('eStore_cart_checkout_option_single_filter', $output); } } } } } } } } } } } } } } $checkout_button = apply_filters('eStore_cart_checkout_button_img_url_filter', $checkout_button); //$output .= '<input type="hidden" name="eStore_url" id="eStore_url" value="'.WP_ESTORE_URL.'" />'; if (get_option('eStore_enable_fancy_redirection_on_checkout')) { if (WP_ESTORE_ENABLE_NEW_CHECKOUT_REDIRECTION === '1') { $output .= '<a href="' . WP_ESTORE_WP_SITE_URL . '?eStore_checkout=process" class="redirect_trigger" rel="#overlay">'; } else { $output .= '<a href="' . WP_ESTORE_URL . '/eStore_payment_submission.php" class="redirect_trigger" rel="#overlay">'; } $output .= '<input type="image" src="' . $checkout_button . '" name="submit" class="eStore_paypal_checkout_button" alt="Checkout" />'; $output .= '</a>'; } else { $output .= '<input type="image" src="' . $checkout_button . '" name="submit" class="eStore_paypal_checkout_button" alt="Checkout" />'; } $output .= '</form>'; $output .= '</div>'; $output = apply_filters('eStore_cart_checkout_button_form_filter', $output); $below_cart_co_button = ""; $below_cart_co_button = apply_filters('eStore_below_cart_checkout_filter', $below_cart_co_button); if (!empty($below_cart_co_button)) { $output .= '<div class="eStore_below_cart_checkout">' . $below_cart_co_button . '</div>'; } return $output; }