tsonade
دوشنبه 28 اسفند 1391, 19:41 عصر
سلام
من این پلاگین را روی وردپرس نصب کردم
http://www.tipsandtricks-hq.com/wordpress-simple-paypal-shopping-cart-plugin-768
این پلاگین اطلاعات سفارش را به سبد خرید منقل می کند و با کلیک روی پرداخت ما را به سایت پی پال منتقل می کند
می خوام این اطلاعات را روی فرم دیگری منتقل کنم و آنها را بعد از تایید به ایمیل مشخص شده ارسال کنم
چند تا مشکل دارم
اول اینکه اطلاعاتی که از سبد خرید به پی پال منتقل میشه را چطور مشخص کنم ؟
می خوام متغییرش رو پیدا کنم البته این کد ها خیلی سخته و من فقط یک اشنایی کلی باهاشون دارم
دوم اینکه چطور این اطلاعات را به فرم دیگر منتقل کنم ؟
ممنون
<?php
/*
Plugin Name: WP Simple Paypal Shopping cart
Version: v3.5
Plugin URI: http://www.tipsandtricks-hq.com/?p=768
Author: Ruhul Amin
Author URI: http://www.tipsandtricks-hq.com/
Description: Simple WordPress Shopping Cart Plugin, very easy to use and great for selling products and services from your blog!
*/
/*
This program is free software; you can redistribute it
under the terms of the GNU General Public License version 2,
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
if(!isset($_SESSION)){
session_start();
}
define('WP_CART_FOLDER', dirname(plugin_basename(__FILE__)));
define('WP_CART_URL', plugins_url('',__FILE__));
define('WP_CART_LIVE_PAYPAL_URL', 'http://imobil.ir/wp-content/plugins/wordpress-simple-paypal-shopping-cart/order.php');
define('WP_CART_SANDBOX_PAYPAL_URL', 'https://www.sandbox.paypal.com/cgi-bin/webscr');
// loading language files
load_plugin_textdomain('WSPSC', false, WP_CART_FOLDER . '/languages');
add_option('wp_cart_title', __("Your Shopping Cart", "WSPSC"));
add_option('wp_cart_empty_text', __("Your cart is empty", "WSPSC"));
add_option('cart_return_from_paypal_url', get_bloginfo('wpurl'));
include_once('wp_shopping_cart_shortcodes.php');
function always_show_cart_handler($atts)
{
return print_wp_shopping_cart();
}
function show_wp_shopping_cart_handler()
{
if (cart_not_empty())
{
$output = print_wp_shopping_cart();
}
return $output;
}
function shopping_cart_show($content)
{
if (strpos($content, "<!--show-wp-shopping-cart-->") !== FALSE)
{
if (cart_not_empty())
{
$content = preg_replace('/<p>\s*<!--(.*)-->\s*<\/p>/i', "<!--$1-->", $content);
$matchingText = '<!--show-wp-shopping-cart-->';
$replacementText = print_wp_shopping_cart();
$content = str_replace($matchingText, $replacementText, $content);
}
}
return $content;
}
// Reset the Cart as this is a returned customer from Paypal
if (isset($_GET["merchant_return_link"]) && !empty($_GET["merchant_return_link"]))
{
reset_wp_cart();
header('Location: ' . get_option('cart_return_from_paypal_url'));
}
if (isset($_GET["mc_gross"])&& $_GET["mc_gross"]> 0)
{
reset_wp_cart();
header('Location: ' . get_option('cart_return_from_paypal_url'));
}
//Clear the cart if the customer landed on the thank you page
if (get_option('wp_shopping_cart_reset_after_redirect ion_to_return_page'))
{
if(get_option('cart_return_from_paypal_url') == cart_current_page_url())
{
reset_wp_cart();
}
}
function reset_wp_cart()
{
$products = $_SESSION['simpleCart'];
if(empty($products))
{
unset($_SESSION['simpleCart']);
return;
}
foreach ($products as $key => $item)
{
unset($products[$key]);
}
$_SESSION['simpleCart'] = $products;
}
if (isset($_POST['addcart']))
{
$domain_url = $_SERVER['SERVER_NAME'];
$cookie_domain = str_replace("www","",$domain_url);
setcookie("cart_in_use","true",time()+21600,"/",$cookie_domain); //useful to not serve cached page when using with a caching plugin
//sanitize data
$_POST['product'] = strip_tags($_POST['product']);//for PHP5.2 use filter_var($_POST['product'], FILTER_SANITIZE_STRING);
$_POST['item_number'] = strip_tags($_POST['item_number']);
if(isset($_POST['price']))$_POST['price'] = strip_tags($_POST['price']);
isset($_POST['shipping'])?$_POST['shipping'] = strip_tags($_POST['shipping']):$_POST['shipping']='';
isset($_POST['cartLink'])?$_POST['cartLink'] = strip_tags($_POST['cartLink']):$_POST['cartLink']='';
$count = 1;
$products = $_SESSION['simpleCart'];
if (is_array($products))
{
foreach ($products as $key => $item)
{
if ($item['name'] == stripslashes($_POST['product']))
{
$count += $item['quantity'];
$item['quantity']++;
unset($products[$key]);
array_push($products, $item);
}
}
}
else
{
$products = array();
}
if ($count == 1)
{
if (!empty($_POST[$_POST['product']])){
$price = $_POST[$_POST['product']];
}
else{
$price = $_POST['price'];
}
$default_cur_symbol = get_option('cart_currency_symbol');
$price = str_replace($default_cur_symbol,"",$price);
$shipping = $_POST['shipping'];
$shipping = str_replace($default_cur_symbol,"",$shipping);
$product = array('name' => stripslashes($_POST['product']), 'price' => $price, 'quantity' => $count, 'shipping' => $shipping, 'cartLink' => $_POST['cartLink'], 'item_number' => $_POST['item_number']);
array_push($products, $product);
}
sort($products);
$_SESSION['simpleCart'] = $products;
if (get_option('wp_shopping_cart_auto_redirect_to_che ckout_page'))
{
$checkout_url = get_option('cart_checkout_page_url');
if(empty($checkout_url))
{
echo "<br /><strong>".(__("Shopping Cart Configuration Error! You must specify a value in the 'Checkout Page URL' field for the automatic redirection feature to work!", "WSPSC"))."</strong><br />";
}
else
{
$redirection_parameter = 'Location: '.$checkout_url;
header($redirection_parameter);
exit;
}
}
}
else if (isset($_POST['cquantity']))
{
$products = $_SESSION['simpleCart'];
foreach ($products as $key => $item)
{
if ((stripslashes($item['name']) == stripslashes($_POST['product'])) && $_POST['quantity'])
{
$item['quantity'] = $_POST['quantity'];
unset($products[$key]);
array_push($products, $item);
}
else if (($item['name'] == stripslashes($_POST['product'])) && !$_POST['quantity'])
unset($products[$key]);
}
sort($products);
$_SESSION['simpleCart'] = $products;
}
else if (isset($_POST['delcart']))
{
$products = $_SESSION['simpleCart'];
foreach ($products as $key => $item)
{
if ($item['name'] == stripslashes($_POST['product']))
unset($products[$key]);
}
$_SESSION['simpleCart'] = $products;
}
function print_wp_shopping_cart()
{
if (!cart_not_empty())
{
$empty_cart_text = get_option('wp_cart_empty_text');
if (!empty($empty_cart_text))
{
if (preg_match("/http/", $empty_cart_text))
{
$output .= '<img src="'.$empty_cart_text.'" alt="'.$empty_cart_text.'" />';
}
else
{
$output .= $empty_cart_text;
}
}
$cart_products_page_url = get_option('cart_products_page_url');
if (!empty($cart_products_page_url))
{
$output .= '<br /><a rel="nofollow" href="'.$cart_products_page_url.'">'.(__("Visit The Shop", "WSPSC")).'</a>';
}
return $output;
}
$email = get_bloginfo('admin_email');
$use_affiliate_platform = get_option('wp_use_aff_platform');
$defaultCurrency = get_option('cart_payment_currency');
$defaultSymbol = get_option('cart_currency_symbol');
$defaultEmail = get_option('cart_paypal_email');
if (!empty($defaultCurrency))
$paypal_currency = $defaultCurrency;
else
$paypal_currency = __("USD", "WSPSC");
if (!empty($defaultSymbol))
$paypal_symbol = $defaultSymbol;
else
$paypal_symbol = __("$", "WSPSC");
if (!empty($defaultEmail))
$email = $defaultEmail;
$decimal = '.';
$urls = '';
$return = get_option('cart_return_from_paypal_url');
if (!empty($return))
$urls .= '<input type="hidden" name="return" value="'.$return.'" />';
if ($use_affiliate_platform)
{
if (function_exists('wp_aff_platform_install'))
{
$notify = WP_AFF_PLATFORM_URL.'/api/ipn_handler.php';
//$notify = WP_CART_URL.'/paypal.php';
$urls .= '<input type="hidden" name="notify_url" value="'.$notify.'" />';
}
}
$title = get_option('wp_cart_title');
//if (empty($title)) $title = __("Your Shopping Cart", "WSPSC");
global $plugin_dir_name;
$output .= '<div class="shopping_cart" style=" padding: 5px;">';
if (!get_option('wp_shopping_cart_image_hide'))
{
$output .= "<img src='".WP_CART_URL."/images/shopping_cart_icon.png' value='".(__("Cart", "WSPSC"))."' title='".(__("Cart", "WSPSC"))."' />";
}
if(!empty($title))
{
$output .= '<h2>';
$output .= $title;
$output .= '</h2>';
}
$output .= '<br /><span id="pinfo" style="display: none; font-weight: bold; color: red;">'.(__("Hit enter to submit new Quantity.", "WSPSC")).'</span>';
$output .= '<table style="width: 100%;">';
$count = 1;
$total_items = 0;
$total = 0;
$form = '';
if ($_SESSION['simpleCart'] && is_array($_SESSION['simpleCart']))
{
$output .= '
<tr>
<th style="text-align: left">'.(__("Item Name", "WSPSC")).'</th><th>'.(__("Quantity", "WSPSC")).'</th><th>'.(__("Price", "WSPSC")).'</th><th></th>
</tr>';
foreach ($_SESSION['simpleCart'] as $item)
{
$total += $item['price'] * $item['quantity'];
$item_total_shipping += $item['shipping'] * $item['quantity'];
$total_items += $item['quantity'];
}
if(!empty($item_total_shipping))
{
$baseShipping = get_option('cart_base_shipping_cost');
$postage_cost = $item_total_shipping + $baseShipping;
}
else
{
$postage_cost = 0;
}
$cart_free_shipping_threshold = get_option('cart_free_shipping_threshold');
if (!empty($cart_free_shipping_threshold) && $total > $cart_free_shipping_threshold)
{
$postage_cost = 0;
}
foreach ($_SESSION['simpleCart'] as $item)
{
$output .= "
<tr><td style='overflow: hidden;'><a href='".$item['cartLink']."'>".$item['name']."</a></td>
<td style='text-align: center'><form method=\"post\" action=\"\" name='pcquantity' style='display: inline'>
<input type=\"hidden\" name=\"product\" value=\"".htmlspecialchars($item['name'])."\" />
<input type='hidden' name='cquantity' value='1' /><input type='text' name='quantity' value='".$item['quantity']."' size='1' onchange='document.pcquantity.submit();' onkeypress='document.getElementById(\"pinfo\").style.display = \"\";' /></form></td>
<td style='text-align: center'>".print_payment_currency(($item['price'] * $item['quantity']), $paypal_symbol, $decimal)."</td>
<td><form method=\"post\" action=\"\">
<input type=\"hidden\" name=\"product\" value=\"".$item['name']."\" />
<input type='hidden' name='delcart' value='1' />
<input type='image' src='".WP_CART_URL."/images/Shoppingcart_delete.png' value='".(__("Remove", "WSPSC"))."' title='".(__("Remove", "WSPSC"))."' /></form></td></tr>
";
$form .= "
<input type=\"hidden\" name=\"item_name_$count\" value=\"".$item['name']."\" />
<input type=\"hidden\" name=\"amount_$count\" value='".number_format($item['price'],2)."' />
<input type=\"hidden\" name=\"quantity_$count\" value=\"".$item['quantity']."\" />
<input type='hidden' name='item_number' value='".$item['item_number']."' />
";
$count++;
}
if (!get_option('wp_shopping_cart_use_profile_shippin g'))
{
$postage_cost = number_format($postage_cost,2);
$form .= "<input type=\"hidden\" name=\"shipping_1\" value='".$postage_cost."' />"; //You can also use "handling_cart" variable to use shipping and handling here
}
if (get_option('wp_shopping_cart_collect_address'))//force address collection
{
$form .= "<input type=\"hidden\" name=\"no_shipping\" value=\"2\" />";
}
}
$count--;
if ($count)
{
//$output .= '<tr><td></td><td></td><td></td></tr>';
if ($postage_cost != 0)
{
$output .= "
<tr><td colspan='2' style='font-weight: bold; text-align: right;'>".(__("Subtotal", "WSPSC")).": </td><td style='text-align: center'>".print_payment_currency($total, $paypal_symbol, $decimal)."</td><td></td></tr>
<tr><td colspan='2' style='font-weight: bold; text-align: right;'>".(__("Shipping", "WSPSC")).": </td><td style='text-align: center'>".print_payment_currency($postage_cost, $paypal_symbol, $decimal)."</td><td></td></tr>";
}
$output .= "
<tr><td colspan='2' style='font-weight: bold; text-align: right;'>".(__("Total", "WSPSC")).": </td><td style='text-align: center'>".print_payment_currency(($total+$postage_cost), $paypal_symbol, $decimal)."</td><td></td></tr>
<tr><td colspan='4'>";
$paypal_checkout_url = WP_CART_LIVE_PAYPAL_URL;
if (get_option('wp_shopping_cart_enable_sandbox')){
$paypal_checkout_url = WP_CART_SANDBOX_PAYPAL_URL;
}
$output .= '<form action="'.$paypal_checkout_url.'" method="post">'.$form;
if ($count)
$output .= '<input type="image" src="'.WP_CART_URL.'/images/'.(__("paypal_checkout_EN.png", "WSPSC")).'" name="submit" class="wp_cart_checkout_button" alt="'.(__("Make payments with PayPal - it\'s fast, free and secure!", "WSPSC")).'" />';
$output .= $urls.'
<input type="hidden" name="business" value="'.$email.'" />
<input type="hidden" name="currency_code" value="'.$paypal_currency.'" />
<input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="upload" value="1" />
<input type="hidden" name="rm" value="2" />
<input type="hidden" name="charset" value="utf-8" />
<input type="hidden" name="mrb" value="3FWGC6LFTMTUG" />';
$wp_cart_note_to_seller_text = get_option('wp_cart_note_to_seller_text');
if(!empty($wp_cart_note_to_seller_text)){
$output .= '<input type="hidden" name="no_note" value="0" /><input type="hidden" name="cn" value="'.$wp_cart_note_to_seller_text.'" />';
}
if ($use_affiliate_platform){
$output .= wp_cart_add_custom_field();
}
$output .= '</form>';
}
$output .= "
</td></tr>
</table></div>
";
return $output;
}
function wp_cart_add_custom_field()
{
if (function_exists('wp_aff_platform_install'))
{
$output = '';
if (!empty($_SESSION['ap_id']))
{
$output = '<input type="hidden" name="custom" value="'.$_SESSION['ap_id'].'" id="wp_affiliate" />';
}
else if (isset($_COOKIE['ap_id']))
{
$output = '<input type="hidden" name="custom" value="'.$_COOKIE['ap_id'].'" id="wp_affiliate" />';
}
return $output;
}
}
function print_wp_cart_button_new($content)
{
$addcart = get_option('addToCartButtonName');
if (!$addcart || ($addcart == '') )
$addcart = __("Add to Cart", "WSPSC");
$pattern = '#\[wp_cart:.+:price:.+:end]#';
preg_match_all ($pattern, $content, $matches);
foreach ($matches[0] as $match)
{
$var_output = '';
$pos = strpos($match,":var1");
if ($pos)
{
$match_tmp = $match;
// Variation control is used
$pos2 = strpos($match,":var2");
if ($pos2)
{
//echo '<br />'.$match_tmp.'<br />';
$pattern = '#var2\[.*]:#';
preg_match_all ($pattern, $match_tmp, $matches3);
$match3 = $matches3[0][0];
//echo '<br />'.$match3.'<br />';
$match_tmp = str_replace ($match3, '', $match_tmp);
$pattern = 'var2[';
$m3 = str_replace ($pattern, '', $match3);
$pattern = ']:';
$m3 = str_replace ($pattern, '', $m3);
$pieces3 = explode('|',$m3);
$variation2_name = $pieces3[0];
$var_output .= $variation2_name." : ";
$var_output .= '<select name="variation2" onchange="ReadForm (this.form, false);">';
for ($i=1;$i<sizeof($pieces3); $i++)
{
$var_output .= '<option value="'.$pieces3[$i].'">'.$pieces3[$i].'</option>';
}
$var_output .= '</select><br />';
}
$pattern = '#var1\[.*]:#';
preg_match_all ($pattern, $match_tmp, $matches2);
$match2 = $matches2[0][0];
$match_tmp = str_replace ($match2, '', $match_tmp);
$pattern = 'var1[';
$m2 = str_replace ($pattern, '', $match2);
$pattern = ']:';
$m2 = str_replace ($pattern, '', $m2);
$pieces2 = explode('|',$m2);
$variation_name = $pieces2[0];
$var_output .= $variation_name." : ";
$var_output .= '<select name="variation1" onchange="ReadForm (this.form, false);">';
for ($i=1;$i<sizeof($pieces2); $i++)
{
$var_output .= '<option value="'.$pieces2[$i].'">'.$pieces2[$i].'</option>';
}
$var_output .= '</select><br />';
}
$pattern = '[wp_cart:';
$m = str_replace ($pattern, '', $match);
$pattern = 'price:';
$m = str_replace ($pattern, '', $m);
$pattern = 'shipping:';
$m = str_replace ($pattern, '', $m);
$pattern = ':end]';
$m = str_replace ($pattern, '', $m);
$pieces = explode(':',$m);
$replacement = '<div class="wp_cart_button_wrapper">';
$replacement .= '<form method="post" class="wp-cart-button-form" action="" style="display:inline" onsubmit="return ReadForm(this, true);">';
if (!empty($var_output))
{
$replacement .= $var_output;
}
من این پلاگین را روی وردپرس نصب کردم
http://www.tipsandtricks-hq.com/wordpress-simple-paypal-shopping-cart-plugin-768
این پلاگین اطلاعات سفارش را به سبد خرید منقل می کند و با کلیک روی پرداخت ما را به سایت پی پال منتقل می کند
می خوام این اطلاعات را روی فرم دیگری منتقل کنم و آنها را بعد از تایید به ایمیل مشخص شده ارسال کنم
چند تا مشکل دارم
اول اینکه اطلاعاتی که از سبد خرید به پی پال منتقل میشه را چطور مشخص کنم ؟
می خوام متغییرش رو پیدا کنم البته این کد ها خیلی سخته و من فقط یک اشنایی کلی باهاشون دارم
دوم اینکه چطور این اطلاعات را به فرم دیگر منتقل کنم ؟
ممنون
<?php
/*
Plugin Name: WP Simple Paypal Shopping cart
Version: v3.5
Plugin URI: http://www.tipsandtricks-hq.com/?p=768
Author: Ruhul Amin
Author URI: http://www.tipsandtricks-hq.com/
Description: Simple WordPress Shopping Cart Plugin, very easy to use and great for selling products and services from your blog!
*/
/*
This program is free software; you can redistribute it
under the terms of the GNU General Public License version 2,
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
if(!isset($_SESSION)){
session_start();
}
define('WP_CART_FOLDER', dirname(plugin_basename(__FILE__)));
define('WP_CART_URL', plugins_url('',__FILE__));
define('WP_CART_LIVE_PAYPAL_URL', 'http://imobil.ir/wp-content/plugins/wordpress-simple-paypal-shopping-cart/order.php');
define('WP_CART_SANDBOX_PAYPAL_URL', 'https://www.sandbox.paypal.com/cgi-bin/webscr');
// loading language files
load_plugin_textdomain('WSPSC', false, WP_CART_FOLDER . '/languages');
add_option('wp_cart_title', __("Your Shopping Cart", "WSPSC"));
add_option('wp_cart_empty_text', __("Your cart is empty", "WSPSC"));
add_option('cart_return_from_paypal_url', get_bloginfo('wpurl'));
include_once('wp_shopping_cart_shortcodes.php');
function always_show_cart_handler($atts)
{
return print_wp_shopping_cart();
}
function show_wp_shopping_cart_handler()
{
if (cart_not_empty())
{
$output = print_wp_shopping_cart();
}
return $output;
}
function shopping_cart_show($content)
{
if (strpos($content, "<!--show-wp-shopping-cart-->") !== FALSE)
{
if (cart_not_empty())
{
$content = preg_replace('/<p>\s*<!--(.*)-->\s*<\/p>/i', "<!--$1-->", $content);
$matchingText = '<!--show-wp-shopping-cart-->';
$replacementText = print_wp_shopping_cart();
$content = str_replace($matchingText, $replacementText, $content);
}
}
return $content;
}
// Reset the Cart as this is a returned customer from Paypal
if (isset($_GET["merchant_return_link"]) && !empty($_GET["merchant_return_link"]))
{
reset_wp_cart();
header('Location: ' . get_option('cart_return_from_paypal_url'));
}
if (isset($_GET["mc_gross"])&& $_GET["mc_gross"]> 0)
{
reset_wp_cart();
header('Location: ' . get_option('cart_return_from_paypal_url'));
}
//Clear the cart if the customer landed on the thank you page
if (get_option('wp_shopping_cart_reset_after_redirect ion_to_return_page'))
{
if(get_option('cart_return_from_paypal_url') == cart_current_page_url())
{
reset_wp_cart();
}
}
function reset_wp_cart()
{
$products = $_SESSION['simpleCart'];
if(empty($products))
{
unset($_SESSION['simpleCart']);
return;
}
foreach ($products as $key => $item)
{
unset($products[$key]);
}
$_SESSION['simpleCart'] = $products;
}
if (isset($_POST['addcart']))
{
$domain_url = $_SERVER['SERVER_NAME'];
$cookie_domain = str_replace("www","",$domain_url);
setcookie("cart_in_use","true",time()+21600,"/",$cookie_domain); //useful to not serve cached page when using with a caching plugin
//sanitize data
$_POST['product'] = strip_tags($_POST['product']);//for PHP5.2 use filter_var($_POST['product'], FILTER_SANITIZE_STRING);
$_POST['item_number'] = strip_tags($_POST['item_number']);
if(isset($_POST['price']))$_POST['price'] = strip_tags($_POST['price']);
isset($_POST['shipping'])?$_POST['shipping'] = strip_tags($_POST['shipping']):$_POST['shipping']='';
isset($_POST['cartLink'])?$_POST['cartLink'] = strip_tags($_POST['cartLink']):$_POST['cartLink']='';
$count = 1;
$products = $_SESSION['simpleCart'];
if (is_array($products))
{
foreach ($products as $key => $item)
{
if ($item['name'] == stripslashes($_POST['product']))
{
$count += $item['quantity'];
$item['quantity']++;
unset($products[$key]);
array_push($products, $item);
}
}
}
else
{
$products = array();
}
if ($count == 1)
{
if (!empty($_POST[$_POST['product']])){
$price = $_POST[$_POST['product']];
}
else{
$price = $_POST['price'];
}
$default_cur_symbol = get_option('cart_currency_symbol');
$price = str_replace($default_cur_symbol,"",$price);
$shipping = $_POST['shipping'];
$shipping = str_replace($default_cur_symbol,"",$shipping);
$product = array('name' => stripslashes($_POST['product']), 'price' => $price, 'quantity' => $count, 'shipping' => $shipping, 'cartLink' => $_POST['cartLink'], 'item_number' => $_POST['item_number']);
array_push($products, $product);
}
sort($products);
$_SESSION['simpleCart'] = $products;
if (get_option('wp_shopping_cart_auto_redirect_to_che ckout_page'))
{
$checkout_url = get_option('cart_checkout_page_url');
if(empty($checkout_url))
{
echo "<br /><strong>".(__("Shopping Cart Configuration Error! You must specify a value in the 'Checkout Page URL' field for the automatic redirection feature to work!", "WSPSC"))."</strong><br />";
}
else
{
$redirection_parameter = 'Location: '.$checkout_url;
header($redirection_parameter);
exit;
}
}
}
else if (isset($_POST['cquantity']))
{
$products = $_SESSION['simpleCart'];
foreach ($products as $key => $item)
{
if ((stripslashes($item['name']) == stripslashes($_POST['product'])) && $_POST['quantity'])
{
$item['quantity'] = $_POST['quantity'];
unset($products[$key]);
array_push($products, $item);
}
else if (($item['name'] == stripslashes($_POST['product'])) && !$_POST['quantity'])
unset($products[$key]);
}
sort($products);
$_SESSION['simpleCart'] = $products;
}
else if (isset($_POST['delcart']))
{
$products = $_SESSION['simpleCart'];
foreach ($products as $key => $item)
{
if ($item['name'] == stripslashes($_POST['product']))
unset($products[$key]);
}
$_SESSION['simpleCart'] = $products;
}
function print_wp_shopping_cart()
{
if (!cart_not_empty())
{
$empty_cart_text = get_option('wp_cart_empty_text');
if (!empty($empty_cart_text))
{
if (preg_match("/http/", $empty_cart_text))
{
$output .= '<img src="'.$empty_cart_text.'" alt="'.$empty_cart_text.'" />';
}
else
{
$output .= $empty_cart_text;
}
}
$cart_products_page_url = get_option('cart_products_page_url');
if (!empty($cart_products_page_url))
{
$output .= '<br /><a rel="nofollow" href="'.$cart_products_page_url.'">'.(__("Visit The Shop", "WSPSC")).'</a>';
}
return $output;
}
$email = get_bloginfo('admin_email');
$use_affiliate_platform = get_option('wp_use_aff_platform');
$defaultCurrency = get_option('cart_payment_currency');
$defaultSymbol = get_option('cart_currency_symbol');
$defaultEmail = get_option('cart_paypal_email');
if (!empty($defaultCurrency))
$paypal_currency = $defaultCurrency;
else
$paypal_currency = __("USD", "WSPSC");
if (!empty($defaultSymbol))
$paypal_symbol = $defaultSymbol;
else
$paypal_symbol = __("$", "WSPSC");
if (!empty($defaultEmail))
$email = $defaultEmail;
$decimal = '.';
$urls = '';
$return = get_option('cart_return_from_paypal_url');
if (!empty($return))
$urls .= '<input type="hidden" name="return" value="'.$return.'" />';
if ($use_affiliate_platform)
{
if (function_exists('wp_aff_platform_install'))
{
$notify = WP_AFF_PLATFORM_URL.'/api/ipn_handler.php';
//$notify = WP_CART_URL.'/paypal.php';
$urls .= '<input type="hidden" name="notify_url" value="'.$notify.'" />';
}
}
$title = get_option('wp_cart_title');
//if (empty($title)) $title = __("Your Shopping Cart", "WSPSC");
global $plugin_dir_name;
$output .= '<div class="shopping_cart" style=" padding: 5px;">';
if (!get_option('wp_shopping_cart_image_hide'))
{
$output .= "<img src='".WP_CART_URL."/images/shopping_cart_icon.png' value='".(__("Cart", "WSPSC"))."' title='".(__("Cart", "WSPSC"))."' />";
}
if(!empty($title))
{
$output .= '<h2>';
$output .= $title;
$output .= '</h2>';
}
$output .= '<br /><span id="pinfo" style="display: none; font-weight: bold; color: red;">'.(__("Hit enter to submit new Quantity.", "WSPSC")).'</span>';
$output .= '<table style="width: 100%;">';
$count = 1;
$total_items = 0;
$total = 0;
$form = '';
if ($_SESSION['simpleCart'] && is_array($_SESSION['simpleCart']))
{
$output .= '
<tr>
<th style="text-align: left">'.(__("Item Name", "WSPSC")).'</th><th>'.(__("Quantity", "WSPSC")).'</th><th>'.(__("Price", "WSPSC")).'</th><th></th>
</tr>';
foreach ($_SESSION['simpleCart'] as $item)
{
$total += $item['price'] * $item['quantity'];
$item_total_shipping += $item['shipping'] * $item['quantity'];
$total_items += $item['quantity'];
}
if(!empty($item_total_shipping))
{
$baseShipping = get_option('cart_base_shipping_cost');
$postage_cost = $item_total_shipping + $baseShipping;
}
else
{
$postage_cost = 0;
}
$cart_free_shipping_threshold = get_option('cart_free_shipping_threshold');
if (!empty($cart_free_shipping_threshold) && $total > $cart_free_shipping_threshold)
{
$postage_cost = 0;
}
foreach ($_SESSION['simpleCart'] as $item)
{
$output .= "
<tr><td style='overflow: hidden;'><a href='".$item['cartLink']."'>".$item['name']."</a></td>
<td style='text-align: center'><form method=\"post\" action=\"\" name='pcquantity' style='display: inline'>
<input type=\"hidden\" name=\"product\" value=\"".htmlspecialchars($item['name'])."\" />
<input type='hidden' name='cquantity' value='1' /><input type='text' name='quantity' value='".$item['quantity']."' size='1' onchange='document.pcquantity.submit();' onkeypress='document.getElementById(\"pinfo\").style.display = \"\";' /></form></td>
<td style='text-align: center'>".print_payment_currency(($item['price'] * $item['quantity']), $paypal_symbol, $decimal)."</td>
<td><form method=\"post\" action=\"\">
<input type=\"hidden\" name=\"product\" value=\"".$item['name']."\" />
<input type='hidden' name='delcart' value='1' />
<input type='image' src='".WP_CART_URL."/images/Shoppingcart_delete.png' value='".(__("Remove", "WSPSC"))."' title='".(__("Remove", "WSPSC"))."' /></form></td></tr>
";
$form .= "
<input type=\"hidden\" name=\"item_name_$count\" value=\"".$item['name']."\" />
<input type=\"hidden\" name=\"amount_$count\" value='".number_format($item['price'],2)."' />
<input type=\"hidden\" name=\"quantity_$count\" value=\"".$item['quantity']."\" />
<input type='hidden' name='item_number' value='".$item['item_number']."' />
";
$count++;
}
if (!get_option('wp_shopping_cart_use_profile_shippin g'))
{
$postage_cost = number_format($postage_cost,2);
$form .= "<input type=\"hidden\" name=\"shipping_1\" value='".$postage_cost."' />"; //You can also use "handling_cart" variable to use shipping and handling here
}
if (get_option('wp_shopping_cart_collect_address'))//force address collection
{
$form .= "<input type=\"hidden\" name=\"no_shipping\" value=\"2\" />";
}
}
$count--;
if ($count)
{
//$output .= '<tr><td></td><td></td><td></td></tr>';
if ($postage_cost != 0)
{
$output .= "
<tr><td colspan='2' style='font-weight: bold; text-align: right;'>".(__("Subtotal", "WSPSC")).": </td><td style='text-align: center'>".print_payment_currency($total, $paypal_symbol, $decimal)."</td><td></td></tr>
<tr><td colspan='2' style='font-weight: bold; text-align: right;'>".(__("Shipping", "WSPSC")).": </td><td style='text-align: center'>".print_payment_currency($postage_cost, $paypal_symbol, $decimal)."</td><td></td></tr>";
}
$output .= "
<tr><td colspan='2' style='font-weight: bold; text-align: right;'>".(__("Total", "WSPSC")).": </td><td style='text-align: center'>".print_payment_currency(($total+$postage_cost), $paypal_symbol, $decimal)."</td><td></td></tr>
<tr><td colspan='4'>";
$paypal_checkout_url = WP_CART_LIVE_PAYPAL_URL;
if (get_option('wp_shopping_cart_enable_sandbox')){
$paypal_checkout_url = WP_CART_SANDBOX_PAYPAL_URL;
}
$output .= '<form action="'.$paypal_checkout_url.'" method="post">'.$form;
if ($count)
$output .= '<input type="image" src="'.WP_CART_URL.'/images/'.(__("paypal_checkout_EN.png", "WSPSC")).'" name="submit" class="wp_cart_checkout_button" alt="'.(__("Make payments with PayPal - it\'s fast, free and secure!", "WSPSC")).'" />';
$output .= $urls.'
<input type="hidden" name="business" value="'.$email.'" />
<input type="hidden" name="currency_code" value="'.$paypal_currency.'" />
<input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="upload" value="1" />
<input type="hidden" name="rm" value="2" />
<input type="hidden" name="charset" value="utf-8" />
<input type="hidden" name="mrb" value="3FWGC6LFTMTUG" />';
$wp_cart_note_to_seller_text = get_option('wp_cart_note_to_seller_text');
if(!empty($wp_cart_note_to_seller_text)){
$output .= '<input type="hidden" name="no_note" value="0" /><input type="hidden" name="cn" value="'.$wp_cart_note_to_seller_text.'" />';
}
if ($use_affiliate_platform){
$output .= wp_cart_add_custom_field();
}
$output .= '</form>';
}
$output .= "
</td></tr>
</table></div>
";
return $output;
}
function wp_cart_add_custom_field()
{
if (function_exists('wp_aff_platform_install'))
{
$output = '';
if (!empty($_SESSION['ap_id']))
{
$output = '<input type="hidden" name="custom" value="'.$_SESSION['ap_id'].'" id="wp_affiliate" />';
}
else if (isset($_COOKIE['ap_id']))
{
$output = '<input type="hidden" name="custom" value="'.$_COOKIE['ap_id'].'" id="wp_affiliate" />';
}
return $output;
}
}
function print_wp_cart_button_new($content)
{
$addcart = get_option('addToCartButtonName');
if (!$addcart || ($addcart == '') )
$addcart = __("Add to Cart", "WSPSC");
$pattern = '#\[wp_cart:.+:price:.+:end]#';
preg_match_all ($pattern, $content, $matches);
foreach ($matches[0] as $match)
{
$var_output = '';
$pos = strpos($match,":var1");
if ($pos)
{
$match_tmp = $match;
// Variation control is used
$pos2 = strpos($match,":var2");
if ($pos2)
{
//echo '<br />'.$match_tmp.'<br />';
$pattern = '#var2\[.*]:#';
preg_match_all ($pattern, $match_tmp, $matches3);
$match3 = $matches3[0][0];
//echo '<br />'.$match3.'<br />';
$match_tmp = str_replace ($match3, '', $match_tmp);
$pattern = 'var2[';
$m3 = str_replace ($pattern, '', $match3);
$pattern = ']:';
$m3 = str_replace ($pattern, '', $m3);
$pieces3 = explode('|',$m3);
$variation2_name = $pieces3[0];
$var_output .= $variation2_name." : ";
$var_output .= '<select name="variation2" onchange="ReadForm (this.form, false);">';
for ($i=1;$i<sizeof($pieces3); $i++)
{
$var_output .= '<option value="'.$pieces3[$i].'">'.$pieces3[$i].'</option>';
}
$var_output .= '</select><br />';
}
$pattern = '#var1\[.*]:#';
preg_match_all ($pattern, $match_tmp, $matches2);
$match2 = $matches2[0][0];
$match_tmp = str_replace ($match2, '', $match_tmp);
$pattern = 'var1[';
$m2 = str_replace ($pattern, '', $match2);
$pattern = ']:';
$m2 = str_replace ($pattern, '', $m2);
$pieces2 = explode('|',$m2);
$variation_name = $pieces2[0];
$var_output .= $variation_name." : ";
$var_output .= '<select name="variation1" onchange="ReadForm (this.form, false);">';
for ($i=1;$i<sizeof($pieces2); $i++)
{
$var_output .= '<option value="'.$pieces2[$i].'">'.$pieces2[$i].'</option>';
}
$var_output .= '</select><br />';
}
$pattern = '[wp_cart:';
$m = str_replace ($pattern, '', $match);
$pattern = 'price:';
$m = str_replace ($pattern, '', $m);
$pattern = 'shipping:';
$m = str_replace ($pattern, '', $m);
$pattern = ':end]';
$m = str_replace ($pattern, '', $m);
$pieces = explode(':',$m);
$replacement = '<div class="wp_cart_button_wrapper">';
$replacement .= '<form method="post" class="wp-cart-button-form" action="" style="display:inline" onsubmit="return ReadForm(this, true);">';
if (!empty($var_output))
{
$replacement .= $var_output;
}