Version Description
None
Download this release
Release Info
Developer | mra13 |
Plugin | WordPress Simple PayPal Shopping Cart |
Version | 3.8 |
Comparing to | |
See all releases |
Code changes from version 3.7 to 3.8
- images/cart-orders-icon.png +0 -0
- paypal.php +235 -159
- readme.txt +24 -20
- wp_shopping_cart.php +163 -42
- wp_shopping_cart_misc_functions.php +82 -0
- wp_shopping_cart_orders.php +169 -0
- wp_shopping_cart_shortcodes.php +2 -2
images/cart-orders-icon.png
ADDED
Binary file
|
paypal.php
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
$debug_log = "ipn_handle_debug.log"; // Debug log file name
|
4 |
|
5 |
class paypal_ipn_handler {
|
@@ -10,143 +10,190 @@ class paypal_ipn_handler {
|
|
10 |
var $ipn_response; // holds the IPN response from paypal
|
11 |
var $ipn_data = array(); // array contains the POST values for IPN
|
12 |
var $fields = array(); // array holds the fields to submit to paypal
|
|
|
13 |
|
14 |
function paypal_ipn_handler()
|
15 |
{
|
16 |
$this->paypal_url = 'https://www.paypal.com/cgi-bin/webscr';
|
17 |
$this->last_error = '';
|
18 |
-
$this->ipn_log_file = 'ipn_handle_debug.log';
|
19 |
$this->ipn_response = '';
|
20 |
}
|
21 |
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
$payment_currency = get_option('cart_payment_currency');
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
$this->debug_log('Updating Affiliate Database Table with Sales Data if Using the WP Affiliate Platform Plugin.',true);
|
110 |
-
|
111 |
if (function_exists('wp_aff_platform_install'))
|
112 |
{
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
$commission_amount = ($sale_amount*$commission_level)/100;
|
128 |
-
|
129 |
-
$updatedb = "INSERT INTO $aff_sales_table VALUES ('$referrer','$clientdate','$clienttime','','','$commission_amount','$sale_amount')";
|
130 |
-
$results = $wpdb->query($updatedb);
|
131 |
-
|
132 |
-
$message = 'The sale has been registered in the WP Affiliates Platform Database for referrer: '.$referrer.' with amount: '.$commission_amount;
|
133 |
-
$this->debug_log($message,true);
|
134 |
-
}
|
135 |
-
else
|
136 |
-
{
|
137 |
-
$this->debug_log('No Referrer Found. This is not an affiliate sale',true);
|
138 |
-
}
|
139 |
}
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
}
|
147 |
|
148 |
-
function validate_ipn()
|
149 |
-
|
150 |
// parse the paypal URL
|
151 |
$url_parsed=parse_url($this->paypal_url);
|
152 |
|
@@ -163,12 +210,20 @@ class paypal_ipn_handler {
|
|
163 |
$post_string.="cmd=_notify-validate"; // append ipn command
|
164 |
|
165 |
// open the connection to paypal
|
166 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
if(!$fp)
|
168 |
{
|
169 |
// could not open the connection. If loggin is on, the error message
|
170 |
// will be in the log.
|
171 |
-
$this->debug_log('Connection to '.$url_parsed['host']." failed.fsockopen error no. $errnum: $errstr",false);
|
172 |
return false;
|
173 |
|
174 |
}
|
@@ -192,16 +247,15 @@ class paypal_ipn_handler {
|
|
192 |
$this->debug_log('Connection to '.$url_parsed['host'].' successfuly completed.',true);
|
193 |
}
|
194 |
|
195 |
-
if (eregi("VERIFIED",$this->ipn_response))
|
|
|
196 |
{
|
197 |
-
// Valid IPN transaction.
|
198 |
$this->debug_log('IPN successfully verified.',true);
|
199 |
return true;
|
200 |
-
|
201 |
}
|
202 |
else
|
203 |
{
|
204 |
-
// Invalid IPN transaction.
|
205 |
$this->debug_log('IPN validation failed.',false);
|
206 |
return false;
|
207 |
}
|
@@ -251,40 +305,62 @@ class paypal_ipn_handler {
|
|
251 |
fwrite($fp, $text );
|
252 |
fclose($fp); // close file
|
253 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
254 |
}
|
255 |
|
256 |
// Start of IPN handling (script execution)
|
257 |
-
|
258 |
-
$ipn_handler_instance = new paypal_ipn_handler();
|
259 |
-
|
260 |
-
$debug_enabled = true; //get_option('wp_cart_enable_debug');
|
261 |
-
|
262 |
-
if ($debug_enabled)
|
263 |
{
|
264 |
-
|
265 |
-
|
266 |
-
$ipn_handler_instance->ipn_log_file = $debug_log;
|
267 |
-
}
|
268 |
-
|
269 |
-
$sandbox = false; //get_option('wp_cart_enable_sandbox');
|
270 |
-
|
271 |
-
if ($sandbox) // Enable sandbox testing
|
272 |
-
{
|
273 |
-
$ipn_handler_instance->paypal_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
|
274 |
-
}
|
275 |
|
276 |
-
$
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
$ipn_handler_instance->debug_log('Creating prodcut Information to send.',true);
|
282 |
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
287 |
}
|
288 |
-
$ipn_handler_instance->debug_log('Paypal class finished.',true,true);
|
289 |
|
290 |
-
?>
|
1 |
<?php
|
2 |
+
|
3 |
$debug_log = "ipn_handle_debug.log"; // Debug log file name
|
4 |
|
5 |
class paypal_ipn_handler {
|
10 |
var $ipn_response; // holds the IPN response from paypal
|
11 |
var $ipn_data = array(); // array contains the POST values for IPN
|
12 |
var $fields = array(); // array holds the fields to submit to paypal
|
13 |
+
var $sandbox_mode = false;
|
14 |
|
15 |
function paypal_ipn_handler()
|
16 |
{
|
17 |
$this->paypal_url = 'https://www.paypal.com/cgi-bin/webscr';
|
18 |
$this->last_error = '';
|
19 |
+
$this->ipn_log_file = WP_CART_PATH.'ipn_handle_debug.log';
|
20 |
$this->ipn_response = '';
|
21 |
}
|
22 |
|
23 |
+
function validate_and_dispatch_product()
|
24 |
+
{
|
25 |
+
// Check Product Name , Price , Currency , Receivers email ,
|
26 |
+
global $products,$currency,$paypal_email;
|
27 |
+
$txn_id = $this->ipn_data['txn_id'];
|
28 |
+
$transaction_type = $this->ipn_data['txn_type'];
|
29 |
+
$transaction_subject = $this->ipn_data['transaction_subject'];
|
30 |
+
$custom_value_str = $this->ipn_data['custom'];
|
31 |
+
//$this->debug_log('custom values from paypal: '.$custom_value_str,true);
|
32 |
+
$first_name = $this->ipn_data['first_name'];
|
33 |
+
$last_name = $this->ipn_data['last_name'];
|
34 |
+
$buyer_email = $this->ipn_data['payer_email'];
|
35 |
+
$street_address = $this->ipn_data['address_street'];
|
36 |
+
$city = $this->ipn_data['address_city'];
|
37 |
+
$state = $this->ipn_data['address_state'];
|
38 |
+
$zip = $this->ipn_data['address_zip'];
|
39 |
+
$country = $this->ipn_data['address_country'];
|
40 |
+
$address = $street_address.", ".$city.", ".$state.", ".$zip.", ".$country;
|
41 |
+
$custom_values = wp_cart_get_custom_var_array($custom_value_str);
|
42 |
+
|
43 |
+
if ($transaction_type == "cart")
|
44 |
+
{
|
45 |
+
$this->debug_log('Transaction Type: Shopping Cart',true);
|
46 |
+
// Cart Items
|
47 |
+
$num_cart_items = $this->ipn_data['num_cart_items'];
|
48 |
+
$this->debug_log('Number of Cart Items: '.$num_cart_items,true);
|
49 |
+
|
50 |
+
$i = 1;
|
51 |
+
$cart_items = array();
|
52 |
+
while($i < $num_cart_items+1)
|
53 |
+
{
|
54 |
+
$item_number = $this->ipn_data['item_number' . $i];
|
55 |
+
$item_name = $this->ipn_data['item_name' . $i];
|
56 |
+
$quantity = $this->ipn_data['quantity' . $i];
|
57 |
+
$mc_gross = $this->ipn_data['mc_gross_' . $i];
|
58 |
+
$mc_currency = $this->ipn_data['mc_currency'];
|
59 |
+
|
60 |
+
$current_item = array(
|
61 |
+
'item_number' => $item_number,
|
62 |
+
'item_name' => $item_name,
|
63 |
+
'quantity' => $quantity,
|
64 |
+
'mc_gross' => $mc_gross,
|
65 |
+
'mc_currency' => $mc_currency,
|
66 |
+
);
|
67 |
+
|
68 |
+
array_push($cart_items, $current_item);
|
69 |
+
$i++;
|
70 |
+
}
|
71 |
+
}
|
72 |
+
else
|
73 |
+
{
|
74 |
+
$cart_items = array();
|
75 |
+
$this->debug_log('Transaction Type: Buy Now',true);
|
76 |
+
$item_number = $this->ipn_data['item_number'];
|
77 |
+
$item_name = $this->ipn_data['item_name'];
|
78 |
+
$quantity = $this->ipn_data['quantity'];
|
79 |
+
$mc_gross = $this->ipn_data['mc_gross'];
|
80 |
+
$mc_currency = $this->ipn_data['mc_currency'];
|
81 |
+
|
82 |
+
$current_item = array(
|
83 |
+
'item_number' => $item_number,
|
84 |
+
'item_name' => $item_name,
|
85 |
+
'quantity' => $quantity,
|
86 |
+
'mc_gross' => $mc_gross,
|
87 |
+
'mc_currency' => $mc_currency,
|
88 |
+
);
|
89 |
+
array_push($cart_items, $current_item);
|
90 |
+
}
|
91 |
+
|
92 |
+
$product_id_array = Array();
|
93 |
+
$product_name_array = Array();
|
94 |
+
$product_price_array = Array();
|
95 |
+
$attachments_array = Array();
|
96 |
+
$download_link_array = Array();
|
97 |
+
|
98 |
$payment_currency = get_option('cart_payment_currency');
|
99 |
+
|
100 |
+
foreach ($cart_items as $current_cart_item)
|
101 |
+
{
|
102 |
+
$cart_item_data_num = $current_cart_item['item_number'];
|
103 |
+
$cart_item_data_name = $current_cart_item['item_name'];
|
104 |
+
$cart_item_data_quantity = $current_cart_item['quantity'];
|
105 |
+
$cart_item_data_total = $current_cart_item['mc_gross'];
|
106 |
+
$cart_item_data_currency = $current_cart_item['mc_currency'];
|
107 |
+
|
108 |
+
$this->debug_log('Item Number: '.$cart_item_data_num,true);
|
109 |
+
$this->debug_log('Item Name: '.$cart_item_data_name,true);
|
110 |
+
$this->debug_log('Item Quantity: '.$cart_item_data_quantity,true);
|
111 |
+
$this->debug_log('Item Total: '.$cart_item_data_total,true);
|
112 |
+
$this->debug_log('Item Currency: '.$cart_item_data_currency,true);
|
113 |
+
|
114 |
+
// Compare the values
|
115 |
+
if ($payment_currency != $cart_item_data_currency)
|
116 |
+
{
|
117 |
+
$this->debug_log('Invalid Product Currency : '.$payment_currency,false);
|
118 |
+
return false;
|
119 |
+
}
|
120 |
+
}
|
121 |
+
|
122 |
+
/*** Send notification email ***/
|
123 |
+
//TODO
|
124 |
+
$post_id = $custom_values['wp_cart_id'];
|
125 |
+
$ip_address = $custom_values['ip'];
|
126 |
+
$currency_symbol = get_option('cart_currency_symbol');
|
127 |
+
$this->debug_log('custom values',true);
|
128 |
+
$this->debug_log_array($custom_values,true);
|
129 |
+
//$this->debug_log('post id: '.$post_id,true);
|
130 |
+
if($post_id){
|
131 |
+
|
132 |
+
$updated_wpsc_order = array(
|
133 |
+
'ID' => $post_id,
|
134 |
+
'post_status' => 'publish',
|
135 |
+
'post_type' => 'wpsc_cart_orders',
|
136 |
+
);
|
137 |
+
wp_update_post($updated_wpsc_order);
|
138 |
+
|
139 |
+
update_post_meta( $post_id, 'wpsc_first_name', $first_name );
|
140 |
+
update_post_meta( $post_id, 'wpsc_last_name', $last_name );
|
141 |
+
update_post_meta( $post_id, 'wpsc_email_address', $buyer_email );
|
142 |
+
update_post_meta( $post_id, 'wpsc_txn_id', $txn_id );
|
143 |
+
$mc_gross = $this->ipn_data['mc_gross'];
|
144 |
+
update_post_meta( $post_id, 'wpsc_total_amount', $mc_gross);
|
145 |
+
update_post_meta( $post_id, 'wpsc_ipaddress', $ip_address );
|
146 |
+
update_post_meta( $post_id, 'wpsc_address', $address );
|
147 |
+
$status = "Paid";
|
148 |
+
update_post_meta( $post_id, 'wpsc_order_status', $status );
|
149 |
+
$cart_items = get_post_meta( $post_id, 'wpsc_cart_items', true );
|
150 |
+
$subject = "Thank you for the purchase";
|
151 |
+
$body .= "Dear $first_name $last_name"."\n";
|
152 |
+
$body .= "\nThank you for your purchase! You ordered the following item(s):\n";
|
153 |
+
if($cart_items){
|
154 |
+
foreach ($cart_items as $item){
|
155 |
+
$body .= "\n".$item['name']." x ".$item['quantity']." - ".$currency_symbol.$item['price']."\n";
|
156 |
+
if($item['file_url']){
|
157 |
+
$file_url = base64_decode($item['file_url']);
|
158 |
+
$body .= "Download Link: ".$file_url."\n";
|
159 |
+
}
|
160 |
+
}
|
161 |
+
}
|
162 |
+
if($buyer_email){
|
163 |
+
wp_mail($buyer_email, $subject, $body);
|
164 |
+
$this->debug_log('Product Email successfully sent to '.$buyer_email,true);
|
165 |
+
update_post_meta( $post_id, 'wpsc_buyer_email_sent', 'Email sent to: '.$buyer_email);
|
166 |
+
}
|
167 |
+
}
|
168 |
+
|
169 |
+
/**** Affiliate plugin integratin ****/
|
170 |
$this->debug_log('Updating Affiliate Database Table with Sales Data if Using the WP Affiliate Platform Plugin.',true);
|
|
|
171 |
if (function_exists('wp_aff_platform_install'))
|
172 |
{
|
173 |
+
$this->debug_log('WP Affiliate Platform is installed, registering sale...',true);
|
174 |
+
$referrer = $custom_values['ap_id'];
|
175 |
+
$sale_amount = $this->ipn_data['mc_gross'];
|
176 |
+
if (!empty($referrer))
|
177 |
+
{
|
178 |
+
do_action('wp_affiliate_process_cart_commission', array("referrer" => $referrer, "sale_amt" => $sale_amount, "txn_id" => $txn_id, "buyer_email" => $buyer_email));
|
179 |
+
|
180 |
+
$message = 'The sale has been registered in the WP Affiliates Platform Database for referrer: '.$referrer.' for sale amount: '.$sale_amount;
|
181 |
+
$this->debug_log($message,true);
|
182 |
+
}
|
183 |
+
else
|
184 |
+
{
|
185 |
+
$this->debug_log('No Referrer Found. This is not an affiliate sale',true);
|
186 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
187 |
}
|
188 |
+
else
|
189 |
+
{
|
190 |
+
$this->debug_log('Not Using the WP Affiliate Platform Plugin.',true);
|
191 |
+
}
|
192 |
+
return true;
|
193 |
+
}
|
|
|
194 |
|
195 |
+
function validate_ipn()
|
196 |
+
{
|
197 |
// parse the paypal URL
|
198 |
$url_parsed=parse_url($this->paypal_url);
|
199 |
|
210 |
$post_string.="cmd=_notify-validate"; // append ipn command
|
211 |
|
212 |
// open the connection to paypal
|
213 |
+
if($this->sandbox_mode){//connect to PayPal sandbox
|
214 |
+
$uri = 'ssl://'.$url_parsed['host'];
|
215 |
+
$port = '443';
|
216 |
+
$fp = fsockopen($uri,$port,$err_num,$err_str,30);
|
217 |
+
}
|
218 |
+
else{//connect to live PayPal site using standard approach
|
219 |
+
$fp = fsockopen($url_parsed['host'],"80",$err_num,$err_str,30);
|
220 |
+
}
|
221 |
+
|
222 |
if(!$fp)
|
223 |
{
|
224 |
// could not open the connection. If loggin is on, the error message
|
225 |
// will be in the log.
|
226 |
+
$this->debug_log('Connection to '.$url_parsed['host']." failed. fsockopen error no. $errnum: $errstr",false);
|
227 |
return false;
|
228 |
|
229 |
}
|
247 |
$this->debug_log('Connection to '.$url_parsed['host'].' successfuly completed.',true);
|
248 |
}
|
249 |
|
250 |
+
//if (eregi("VERIFIED",$this->ipn_response))
|
251 |
+
if (strpos($this->ipn_response, "VERIFIED") !== false)// Valid IPN transaction.
|
252 |
{
|
|
|
253 |
$this->debug_log('IPN successfully verified.',true);
|
254 |
return true;
|
|
|
255 |
}
|
256 |
else
|
257 |
{
|
258 |
+
// Invalid IPN transaction. Check the log for details.
|
259 |
$this->debug_log('IPN validation failed.',false);
|
260 |
return false;
|
261 |
}
|
305 |
fwrite($fp, $text );
|
306 |
fclose($fp); // close file
|
307 |
}
|
308 |
+
|
309 |
+
function debug_log_array($array_to_write,$success,$end=false)
|
310 |
+
{
|
311 |
+
if (!$this->ipn_log) return; // is logging turned off?
|
312 |
+
$text = '['.date('m/d/Y g:i A').'] - '.(($success)?'SUCCESS :':'FAILURE :'). "\n";
|
313 |
+
ob_start();
|
314 |
+
print_r($array_to_write);
|
315 |
+
$var = ob_get_contents();
|
316 |
+
ob_end_clean();
|
317 |
+
$text .= $var;
|
318 |
+
|
319 |
+
if ($end)
|
320 |
+
{
|
321 |
+
$text .= "\n------------------------------------------------------------------\n\n";
|
322 |
+
}
|
323 |
+
// Write to log
|
324 |
+
$fp=fopen($this->ipn_log_file,'a');
|
325 |
+
fwrite($fp, $text );
|
326 |
+
fclose($fp); // close filee
|
327 |
+
}
|
328 |
}
|
329 |
|
330 |
// Start of IPN handling (script execution)
|
331 |
+
function wpc_handle_paypal_ipn()
|
|
|
|
|
|
|
|
|
|
|
332 |
{
|
333 |
+
$debug_log = "ipn_handle_debug.log"; // Debug log file name
|
334 |
+
$ipn_handler_instance = new paypal_ipn_handler();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
335 |
|
336 |
+
$debug_enabled = false;
|
337 |
+
$debug = get_option('wp_shopping_cart_enable_debug');
|
338 |
+
if ($debug){
|
339 |
+
$debug_enabled = true;
|
340 |
+
}
|
|
|
341 |
|
342 |
+
if ($debug_enabled)
|
343 |
+
{
|
344 |
+
echo 'Debug is enabled. Check the '.$debug_log.' file for debug output.';
|
345 |
+
$ipn_handler_instance->ipn_log = true;
|
346 |
+
//$ipn_handler_instance->ipn_log_file = realpath(dirname(__FILE__)).'/'.$debug_log;
|
347 |
+
}
|
348 |
+
$sandbox = get_option('wp_shopping_cart_enable_sandbox');
|
349 |
+
if ($sandbox) // Enable sandbox testing
|
350 |
+
{
|
351 |
+
$ipn_handler_instance->paypal_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
|
352 |
+
$ipn_handler_instance->sandbox_mode = true;
|
353 |
+
}
|
354 |
+
$ipn_handler_instance->debug_log('Paypal Class Initiated by '.$_SERVER['REMOTE_ADDR'],true);
|
355 |
+
// Validate the IPN
|
356 |
+
if ($ipn_handler_instance->validate_ipn())
|
357 |
+
{
|
358 |
+
$ipn_handler_instance->debug_log('Creating product Information to send.',true);
|
359 |
+
if(!$ipn_handler_instance->validate_and_dispatch_product())
|
360 |
+
{
|
361 |
+
$ipn_handler_instance->debug_log('IPN product validation failed.',false);
|
362 |
+
}
|
363 |
+
}
|
364 |
+
$ipn_handler_instance->debug_log('Paypal class finished.',true,true);
|
365 |
}
|
|
|
366 |
|
|
readme.txt
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
=== WordPress Simple Paypal Shopping Cart ===
|
2 |
Contributors: Ruhul Amin, Tips and Tricks HQ
|
3 |
Donate link: http://www.tipsandtricks-hq.com
|
4 |
-
Tags: shopping cart, WordPress shopping cart, Paypal shopping cart, sell products, online shop, shop, e-commerce, wordpress ecommerce, wordpress store, store, PayPal cart widget, sell digital products, paypal
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 3.6
|
7 |
-
Stable tag: 3.
|
8 |
License: GPLv2 or later
|
9 |
|
10 |
Very easy to use Simple WordPress Paypal Shopping Cart Plugin. Great for selling products online in one click from your WordPress site.
|
@@ -15,14 +15,14 @@ WordPress Simple Paypal Shopping Cart allows you to add an 'Add to Cart' button
|
|
15 |
|
16 |
It also allows you to add/display the shopping cart on any post or page or sidebar easily. The shopping cart shows the user what they currently have in the cart and allows them to change quantity or remove the items.
|
17 |
|
18 |
-
It can be easily integrated with the NextGen Photo Gallery plugin to
|
19 |
|
20 |
WP simple Paypal Cart Plugin, interfaces with the Paypal sandbox to allow for testing.
|
21 |
|
22 |
This plugin is a lightweight solution (with minimal number of lines of code and minimal options) so it doesn't slow down your site.
|
23 |
|
24 |
For video tutorial, screenshots, detailed documentation, support and updates, please visit:
|
25 |
-
[WP Simple Cart Details Page](http://www.tipsandtricks-hq.com
|
26 |
or
|
27 |
[WP Simple Cart Documentation](http://www.tipsandtricks-hq.com/ecommerce/wp-shopping-cart)
|
28 |
|
@@ -31,9 +31,13 @@ or
|
|
31 |
* Easily create "add to cart" button with options if needed (price, shipping, options variations). The cart's shortcode can be displayed on posts or pages.
|
32 |
* Use a function to add dynamic "add to cart" button directly in your theme.
|
33 |
* Minimal number of configuration items to keep the plugin lightweight.
|
|
|
|
|
|
|
34 |
* Show a nicely formatted product display box on the fly using a simple shortcode.
|
35 |
-
* You can use Paypal sandbox to do testing if needed.
|
36 |
-
* Collect special
|
|
|
37 |
* Compatible with WordPress Multi-site Installation.
|
38 |
* and more...
|
39 |
|
@@ -47,10 +51,12 @@ There are a few exact duplicate copies of this plugin that other people made. We
|
|
47 |
* Check the developer's site.
|
48 |
|
49 |
== Usage ==
|
50 |
-
1. To add an 'Add to Cart' button for a product, simply add the shortcode [
|
|
|
51 |
2. To add the 'Add to Cart' button on the sidebar or from other template files use the following function:
|
52 |
<?php echo print_wp_cart_button_for_product('PRODUCT-NAME', PRODUCT-PRICE); ?>
|
53 |
Replace PRODUCT-NAME and PRODUCT-PRICE with the actual name and price.
|
|
|
54 |
3. To add the shopping cart to a post or page (eg. checkout page) simply add the shortcode [show_wp_shopping_cart] to a post or page or use the sidebar widget to add the shopping cart to the sidebar. The shopping cart will only be visible in a post or page when a customer adds a product.
|
55 |
|
56 |
= Using Product Display Box =
|
@@ -63,34 +69,30 @@ Simply replace the values with your product specific data
|
|
63 |
|
64 |
= Using Shipping =
|
65 |
|
66 |
-
1. To use shipping cost use the
|
67 |
-
[
|
68 |
|
69 |
or use the following php function from your wordpress template files
|
70 |
<?php echo print_wp_cart_button_for_product('product name',price,shipping cost); ?>
|
71 |
|
72 |
= Using Variation Control =
|
73 |
|
74 |
-
1. To use variation control use the
|
75 |
-
[
|
76 |
-
|
77 |
-
example, [wp_cart:Demo Product 1:price:15:var1[Size|Small|Medium|Large]:end]
|
78 |
|
79 |
-
|
80 |
-
[wp_cart:PRODUCT-NAME:price:PRODUCT-PRICE:shipping:SHIPPING-COST:var1[VARIATION-NAME|VARIATION1|VARIATION2|VARIATION3]:end]
|
81 |
|
82 |
-
|
83 |
|
84 |
-
|
85 |
-
[wp_cart:PRODUCT-NAME:price:PRODUCT-PRICE:var1[VARIATION-NAME|VARIATION1|VARIATION2|VARIATION3]:var2[VARIATION-NAME|VARIATION1|VARIATION2]:end]
|
86 |
|
87 |
-
|
88 |
|
89 |
== Installation ==
|
90 |
|
91 |
1. Unzip and Upload the folder 'wordpress-paypal-shopping-cart' to the '/wp-content/plugins/' directory
|
92 |
2. Activate the plugin through the 'Plugins' menu in WordPress
|
93 |
-
3. Go to Settings and configure the options
|
94 |
4. Use the trigger text to add a product to a post or page where u want it to appear.
|
95 |
|
96 |
== Frequently Asked Questions ==
|
@@ -102,6 +104,8 @@ example, [wp_cart:Demo Product 1:price:15:shipping:2:var1[Size|Small|Medium|Larg
|
|
102 |
6. Does this plugin use a return URL to redirect customers to a specified page after Paypal has processed the payment? Yes.
|
103 |
7. How can I add a buy button on the sidebar widget of my site?
|
104 |
Check the documentation on [how to add buy buttons to the sidebar](http://www.tipsandtricks-hq.com/ecommerce/wordpress-shopping-cart-additional-resources-322#add_button_in_sidebar)
|
|
|
|
|
105 |
|
106 |
== Screenshots ==
|
107 |
Visit the plugin site at http://www.tipsandtricks-hq.com/?p=768 for screenshots.
|
1 |
=== WordPress Simple Paypal Shopping Cart ===
|
2 |
Contributors: Ruhul Amin, Tips and Tricks HQ
|
3 |
Donate link: http://www.tipsandtricks-hq.com
|
4 |
+
Tags: cart, shopping cart, WordPress shopping cart, Paypal shopping cart, sell products, online shop, shop, e-commerce, wordpress ecommerce, wordpress store, store, PayPal cart widget, sell digital products, digital downloads, paypal, paypal cart, e-shop,
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 3.6
|
7 |
+
Stable tag: 3.8
|
8 |
License: GPLv2 or later
|
9 |
|
10 |
Very easy to use Simple WordPress Paypal Shopping Cart Plugin. Great for selling products online in one click from your WordPress site.
|
15 |
|
16 |
It also allows you to add/display the shopping cart on any post or page or sidebar easily. The shopping cart shows the user what they currently have in the cart and allows them to change quantity or remove the items.
|
17 |
|
18 |
+
It can be easily integrated with the NextGen Photo Gallery plugin to accommodate the selling of photographs from your gallery.
|
19 |
|
20 |
WP simple Paypal Cart Plugin, interfaces with the Paypal sandbox to allow for testing.
|
21 |
|
22 |
This plugin is a lightweight solution (with minimal number of lines of code and minimal options) so it doesn't slow down your site.
|
23 |
|
24 |
For video tutorial, screenshots, detailed documentation, support and updates, please visit:
|
25 |
+
[WP Simple Cart Details Page](http://www.tipsandtricks-hq.com/wordpress-simple-paypal-shopping-cart-plugin-768)
|
26 |
or
|
27 |
[WP Simple Cart Documentation](http://www.tipsandtricks-hq.com/ecommerce/wp-shopping-cart)
|
28 |
|
31 |
* Easily create "add to cart" button with options if needed (price, shipping, options variations). The cart's shortcode can be displayed on posts or pages.
|
32 |
* Use a function to add dynamic "add to cart" button directly in your theme.
|
33 |
* Minimal number of configuration items to keep the plugin lightweight.
|
34 |
+
* Sell any kind of tangible products from your site.
|
35 |
+
* Sell any type of media file that you upload to your WordPress site. For example: you can sell ebooks (PDF), music (MP3), videos, photos etc.
|
36 |
+
* Your customers will automatically get an email with the media file that they paid for.
|
37 |
* Show a nicely formatted product display box on the fly using a simple shortcode.
|
38 |
+
* You can use Paypal sandbox to do testing if needed (before you go live).
|
39 |
+
* Collect special instructions from your customers on the PayPal checkout page.
|
40 |
+
* The orders menu will show you all the orders that you have received from your site.
|
41 |
* Compatible with WordPress Multi-site Installation.
|
42 |
* and more...
|
43 |
|
51 |
* Check the developer's site.
|
52 |
|
53 |
== Usage ==
|
54 |
+
1. To add an 'Add to Cart' button for a product, simply add the shortcode [wp_cart_button name="PRODUCT-NAME" price="PRODUCT-PRICE"] to a post or page next to the product. Replace PRODUCT-NAME and PRODUCT-PRICE with the actual name and price.
|
55 |
+
|
56 |
2. To add the 'Add to Cart' button on the sidebar or from other template files use the following function:
|
57 |
<?php echo print_wp_cart_button_for_product('PRODUCT-NAME', PRODUCT-PRICE); ?>
|
58 |
Replace PRODUCT-NAME and PRODUCT-PRICE with the actual name and price.
|
59 |
+
|
60 |
3. To add the shopping cart to a post or page (eg. checkout page) simply add the shortcode [show_wp_shopping_cart] to a post or page or use the sidebar widget to add the shopping cart to the sidebar. The shopping cart will only be visible in a post or page when a customer adds a product.
|
61 |
|
62 |
= Using Product Display Box =
|
69 |
|
70 |
= Using Shipping =
|
71 |
|
72 |
+
1. To use shipping cost for your product, use the "shipping" parameter. Here is an example shortcode usage:
|
73 |
+
[wp_cart_button name="Test Product" price="19.95" shipping="4.99"]
|
74 |
|
75 |
or use the following php function from your wordpress template files
|
76 |
<?php echo print_wp_cart_button_for_product('product name',price,shipping cost); ?>
|
77 |
|
78 |
= Using Variation Control =
|
79 |
|
80 |
+
1. To use variation control use the variation parameter in the shortcode:
|
81 |
+
[wp_cart_button name="Test Product" price="25.95" var1="VARIATION-NAME|VARIATION1|VARIATION2|VARIATION3"]
|
|
|
|
|
82 |
|
83 |
+
example usage: [wp_cart_button name="Test Product" price="29.95" var1="Size|small|medium|large"]
|
|
|
84 |
|
85 |
+
2. To use multiple variation for a product (2nd or 3rd variation), use the following:
|
86 |
|
87 |
+
[wp_cart_button name="Test Product" price="29.95" var1="Size|small|medium|large" var2="Color|red|green|blue"]
|
|
|
88 |
|
89 |
+
[wp_cart_button name="Test Product" price="29.95" var1="Size|small|medium|large" var2="Color|red|green|blue" var3="Sleeve|short|full"]
|
90 |
|
91 |
== Installation ==
|
92 |
|
93 |
1. Unzip and Upload the folder 'wordpress-paypal-shopping-cart' to the '/wp-content/plugins/' directory
|
94 |
2. Activate the plugin through the 'Plugins' menu in WordPress
|
95 |
+
3. Go to Settings and configure the options (for example: your email, Shopping Cart name, Return URL etc.)
|
96 |
4. Use the trigger text to add a product to a post or page where u want it to appear.
|
97 |
|
98 |
== Frequently Asked Questions ==
|
104 |
6. Does this plugin use a return URL to redirect customers to a specified page after Paypal has processed the payment? Yes.
|
105 |
7. How can I add a buy button on the sidebar widget of my site?
|
106 |
Check the documentation on [how to add buy buttons to the sidebar](http://www.tipsandtricks-hq.com/ecommerce/wordpress-shopping-cart-additional-resources-322#add_button_in_sidebar)
|
107 |
+
8. Can I use this plugin to sell digital downloads?
|
108 |
+
Yes. See the [digital download usage documnentation] (http://www.tipsandtricks-hq.com/ecommerce/wp-simple-cart-sell-digital-downloads-2468)
|
109 |
|
110 |
== Screenshots ==
|
111 |
Visit the plugin site at http://www.tipsandtricks-hq.com/?p=768 for screenshots.
|
wp_shopping_cart.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: WP Simple Paypal Shopping cart
|
4 |
-
Version: v3.
|
5 |
Plugin URI: http://www.tipsandtricks-hq.com/?p=768
|
6 |
Author: Ruhul Amin
|
7 |
Author URI: http://www.tipsandtricks-hq.com/
|
@@ -12,9 +12,11 @@ if(!isset($_SESSION)){
|
|
12 |
session_start();
|
13 |
}
|
14 |
|
15 |
-
define('WP_CART_VERSION', '3.
|
16 |
define('WP_CART_FOLDER', dirname(plugin_basename(__FILE__)));
|
|
|
17 |
define('WP_CART_URL', plugins_url('',__FILE__));
|
|
|
18 |
|
19 |
define('WP_CART_LIVE_PAYPAL_URL', 'https://www.paypal.com/cgi-bin/webscr');
|
20 |
define('WP_CART_SANDBOX_PAYPAL_URL', 'https://www.sandbox.paypal.com/cgi-bin/webscr');
|
@@ -27,6 +29,8 @@ add_option('wp_cart_empty_text', __("Your cart is empty", "WSPSC"));
|
|
27 |
add_option('cart_return_from_paypal_url', get_bloginfo('wpurl'));
|
28 |
|
29 |
include_once('wp_shopping_cart_shortcodes.php');
|
|
|
|
|
30 |
|
31 |
function always_show_cart_handler($atts)
|
32 |
{
|
@@ -57,6 +61,12 @@ function shopping_cart_show($content)
|
|
57 |
return $content;
|
58 |
}
|
59 |
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
// Reset the Cart as this is a returned customer from Paypal
|
61 |
if (isset($_GET["merchant_return_link"]) && !empty($_GET["merchant_return_link"]))
|
62 |
{
|
@@ -85,13 +95,15 @@ function reset_wp_cart()
|
|
85 |
if(empty($products))
|
86 |
{
|
87 |
unset($_SESSION['simpleCart']);
|
|
|
88 |
return;
|
89 |
}
|
90 |
foreach ($products as $key => $item)
|
91 |
{
|
92 |
unset($products[$key]);
|
93 |
}
|
94 |
-
$_SESSION['simpleCart'] = $products;
|
|
|
95 |
}
|
96 |
|
97 |
if (isset($_POST['addcart']))
|
@@ -143,11 +155,59 @@ if (isset($_POST['addcart']))
|
|
143 |
$shipping = str_replace($default_cur_symbol,"",$shipping);
|
144 |
|
145 |
$product = array('name' => stripslashes($_POST['product']), 'price' => $price, 'quantity' => $count, 'shipping' => $shipping, 'cartLink' => $_POST['cartLink'], 'item_number' => $_POST['item_number']);
|
|
|
|
|
|
|
|
|
146 |
array_push($products, $product);
|
147 |
}
|
148 |
|
149 |
sort($products);
|
150 |
$_SESSION['simpleCart'] = $products;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
|
152 |
if (get_option('wp_shopping_cart_auto_redirect_to_checkout_page'))
|
153 |
{
|
@@ -190,6 +250,11 @@ else if (isset($_POST['delcart']))
|
|
190 |
unset($products[$key]);
|
191 |
}
|
192 |
$_SESSION['simpleCart'] = $products;
|
|
|
|
|
|
|
|
|
|
|
193 |
}
|
194 |
|
195 |
function print_wp_shopping_cart()
|
@@ -236,21 +301,18 @@ function print_wp_shopping_cart()
|
|
236 |
$urls = '';
|
237 |
|
238 |
$return = get_option('cart_return_from_paypal_url');
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
}
|
252 |
-
$title = get_option('wp_cart_title');
|
253 |
-
//if (empty($title)) $title = __("Your Shopping Cart", "WSPSC");
|
254 |
|
255 |
global $plugin_dir_name;
|
256 |
$output .= '<div class="shopping_cart" style=" padding: 5px;">';
|
@@ -372,9 +434,8 @@ function print_wp_shopping_cart()
|
|
372 |
if(!empty($wp_cart_note_to_seller_text)){
|
373 |
$output .= '<input type="hidden" name="no_note" value="0" /><input type="hidden" name="cn" value="'.$wp_cart_note_to_seller_text.'" />';
|
374 |
}
|
375 |
-
|
376 |
-
|
377 |
-
}
|
378 |
$output .= '</form>';
|
379 |
}
|
380 |
$output .= "
|
@@ -387,19 +448,31 @@ function print_wp_shopping_cart()
|
|
387 |
|
388 |
function wp_cart_add_custom_field()
|
389 |
{
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
403 |
}
|
404 |
|
405 |
function print_wp_cart_button_new($content)
|
@@ -544,7 +617,7 @@ function wp_cart_add_read_form_javascript()
|
|
544 |
//-->
|
545 |
</script>';
|
546 |
}
|
547 |
-
function print_wp_cart_button_for_product($name, $price, $shipping=0, $var1='', $var2='', $var3='')
|
548 |
{
|
549 |
$addcart = get_option('addToCartButtonName');
|
550 |
if (!$addcart || ($addcart == '') )
|
@@ -604,7 +677,12 @@ function print_wp_cart_button_for_product($name, $price, $shipping=0, $var1='',
|
|
604 |
}
|
605 |
$replacement .= '<input type="hidden" name="product" value="'.$name.'" /><input type="hidden" name="price" value="'.$price.'" /><input type="hidden" name="shipping" value="'.$shipping.'" /><input type="hidden" name="addcart" value="1" /><input type="hidden" name="cartLink" value="'.cart_current_page_url().'" />';
|
606 |
$replacement .= '<input type="hidden" name="product_tmp" value="'.$name.'" />';
|
607 |
-
|
|
|
|
|
|
|
|
|
|
|
608 |
$replacement .= '</div>';
|
609 |
return $replacement;
|
610 |
}
|
@@ -645,6 +723,15 @@ function cart_current_page_url() {
|
|
645 |
|
646 |
function show_wp_cart_options_page ()
|
647 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
648 |
if (isset($_POST['info_update']))
|
649 |
{
|
650 |
$nonce = $_REQUEST['_wpnonce'];
|
@@ -675,6 +762,7 @@ function show_wp_cart_options_page ()
|
|
675 |
update_option('wp_use_aff_platform', ($_POST['wp_use_aff_platform']!='') ? 'checked="checked"':'' );
|
676 |
|
677 |
update_option('wp_shopping_cart_enable_sandbox', ($_POST['wp_shopping_cart_enable_sandbox']!='') ? 'checked="checked"':'' );
|
|
|
678 |
|
679 |
echo '<div id="message" class="updated fade">';
|
680 |
echo '<p><strong>'.(__("Options Updated!", "WSPSC")).'</strong></p></div>';
|
@@ -742,7 +830,12 @@ function show_wp_cart_options_page ()
|
|
742 |
if (get_option('wp_shopping_cart_enable_sandbox'))
|
743 |
$wp_shopping_cart_enable_sandbox = 'checked="checked"';
|
744 |
else
|
745 |
-
$wp_shopping_cart_enable_sandbox = '';
|
|
|
|
|
|
|
|
|
|
|
746 |
?>
|
747 |
<h2><?php _e("Simple PayPal Shopping Cart Settings", "WSPSC"); ?> v <?php echo WP_CART_VERSION; ?></h2>
|
748 |
|
@@ -776,11 +869,6 @@ echo '
|
|
776 |
<td><input type="text" name="cart_paypal_email" value="'.$defaultEmail.'" size="40" /></td>
|
777 |
</tr>
|
778 |
<tr valign="top">
|
779 |
-
<th scope="row">'.(__("Enable Sandbox Testing", "WSPSC")).'</th>
|
780 |
-
<td><input type="checkbox" name="wp_shopping_cart_enable_sandbox" value="1" '.$wp_shopping_cart_enable_sandbox.' />
|
781 |
-
<br />'.(__("Check this option if you want to do PayPal sandbox testing. You will need to create a PayPal sandbox account from PayPal Developer site", "WSPSC")).'</td>
|
782 |
-
</tr>
|
783 |
-
<tr valign="top">
|
784 |
<th scope="row">'.(__("Shopping Cart title", "WSPSC")).'</th>
|
785 |
<td><input type="text" name="wp_cart_title" value="'.$title.'" size="40" /></td>
|
786 |
</tr>
|
@@ -874,6 +962,36 @@ echo '
|
|
874 |
</tr>
|
875 |
</table>
|
876 |
</div></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
877 |
<div class="submit">
|
878 |
<input type="submit" name="info_update" value="'.(__("Update Options »", "WSPSC")).'" />
|
879 |
</div>
|
@@ -966,6 +1084,9 @@ add_filter('plugin_action_links', 'wp_simple_cart_add_settings_link', 10, 2 );
|
|
966 |
add_action('admin_menu','wp_cart_options_page');
|
967 |
add_action('widgets_init','wp_paypal_shopping_cart_load_widgets');
|
968 |
|
|
|
|
|
|
|
969 |
//add_filter('the_content', 'print_wp_cart_button',11);
|
970 |
add_filter('the_content', 'print_wp_cart_button_new',11);
|
971 |
add_filter('the_content', 'shopping_cart_show');
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: WP Simple Paypal Shopping cart
|
4 |
+
Version: v3.8
|
5 |
Plugin URI: http://www.tipsandtricks-hq.com/?p=768
|
6 |
Author: Ruhul Amin
|
7 |
Author URI: http://www.tipsandtricks-hq.com/
|
12 |
session_start();
|
13 |
}
|
14 |
|
15 |
+
define('WP_CART_VERSION', '3.8');
|
16 |
define('WP_CART_FOLDER', dirname(plugin_basename(__FILE__)));
|
17 |
+
define('WP_CART_PATH',plugin_dir_path( __FILE__ ));
|
18 |
define('WP_CART_URL', plugins_url('',__FILE__));
|
19 |
+
define('WP_CART_SITE_URL',site_url());
|
20 |
|
21 |
define('WP_CART_LIVE_PAYPAL_URL', 'https://www.paypal.com/cgi-bin/webscr');
|
22 |
define('WP_CART_SANDBOX_PAYPAL_URL', 'https://www.sandbox.paypal.com/cgi-bin/webscr');
|
29 |
add_option('cart_return_from_paypal_url', get_bloginfo('wpurl'));
|
30 |
|
31 |
include_once('wp_shopping_cart_shortcodes.php');
|
32 |
+
include_once('wp_shopping_cart_misc_functions.php');
|
33 |
+
include_once('wp_shopping_cart_orders.php');
|
34 |
|
35 |
function always_show_cart_handler($atts)
|
36 |
{
|
61 |
return $content;
|
62 |
}
|
63 |
|
64 |
+
// Reset cart option
|
65 |
+
if (isset($_REQUEST["reset_wp_cart"]) && !empty($_REQUEST["reset_wp_cart"]))
|
66 |
+
{
|
67 |
+
reset_wp_cart();
|
68 |
+
}
|
69 |
+
|
70 |
// Reset the Cart as this is a returned customer from Paypal
|
71 |
if (isset($_GET["merchant_return_link"]) && !empty($_GET["merchant_return_link"]))
|
72 |
{
|
95 |
if(empty($products))
|
96 |
{
|
97 |
unset($_SESSION['simpleCart']);
|
98 |
+
unset($_SESSION['simple_cart_id']);
|
99 |
return;
|
100 |
}
|
101 |
foreach ($products as $key => $item)
|
102 |
{
|
103 |
unset($products[$key]);
|
104 |
}
|
105 |
+
$_SESSION['simpleCart'] = $products;
|
106 |
+
unset($_SESSION['simple_cart_id']);
|
107 |
}
|
108 |
|
109 |
if (isset($_POST['addcart']))
|
155 |
$shipping = str_replace($default_cur_symbol,"",$shipping);
|
156 |
|
157 |
$product = array('name' => stripslashes($_POST['product']), 'price' => $price, 'quantity' => $count, 'shipping' => $shipping, 'cartLink' => $_POST['cartLink'], 'item_number' => $_POST['item_number']);
|
158 |
+
if(isset($_POST['file_url']) && !empty($_POST['file_url'])){
|
159 |
+
$file_url = strip_tags($_POST['file_url']);
|
160 |
+
$product['file_url'] = $file_url;
|
161 |
+
}
|
162 |
array_push($products, $product);
|
163 |
}
|
164 |
|
165 |
sort($products);
|
166 |
$_SESSION['simpleCart'] = $products;
|
167 |
+
if(!isset($_SESSION['simple_cart_id']) && empty($_SESSION['simple_cart_id']))
|
168 |
+
{
|
169 |
+
//First time adding to the cart
|
170 |
+
//$cart_id = uniqid();
|
171 |
+
//$_SESSION['simple_cart_id'] = $cart_id;
|
172 |
+
$wpsc_order = array(
|
173 |
+
'post_title' => 'WPSC Cart Order',
|
174 |
+
'post_type' => 'wpsc_cart_orders',
|
175 |
+
'post_content' => '',
|
176 |
+
'post_status' => 'trash',
|
177 |
+
);
|
178 |
+
// Insert the post into the database
|
179 |
+
$post_id = wp_insert_post($wpsc_order);
|
180 |
+
if($post_id){
|
181 |
+
//echo "post id: ".$post_id;
|
182 |
+
$_SESSION['simple_cart_id'] = $post_id;
|
183 |
+
$updated_wpsc_order = array(
|
184 |
+
'ID' => $post_id,
|
185 |
+
'post_title' => $post_id,
|
186 |
+
'post_type' => 'wpsc_cart_orders',
|
187 |
+
);
|
188 |
+
wp_update_post($updated_wpsc_order);
|
189 |
+
$status = "In Progress";
|
190 |
+
update_post_meta($post_id, 'wpsc_order_status', $status);
|
191 |
+
}
|
192 |
+
}
|
193 |
+
else
|
194 |
+
{
|
195 |
+
//cart updating
|
196 |
+
if(isset($_SESSION['simple_cart_id']) && !empty($_SESSION['simple_cart_id']))
|
197 |
+
{
|
198 |
+
//echo "siimplecart id set";
|
199 |
+
$post_id = $_SESSION['simple_cart_id'];
|
200 |
+
if(isset($_SESSION['simpleCart']) && !empty($_SESSION['simpleCart']))
|
201 |
+
{
|
202 |
+
//echo "updated cart id: ".$post_id;
|
203 |
+
update_post_meta( $post_id, 'wpsc_cart_items', $_SESSION['simpleCart']);
|
204 |
+
}
|
205 |
+
}
|
206 |
+
else{
|
207 |
+
echo "<p>Error! Your session is out of sync. Please reset your session.</p>";
|
208 |
+
}
|
209 |
+
}
|
210 |
+
|
211 |
|
212 |
if (get_option('wp_shopping_cart_auto_redirect_to_checkout_page'))
|
213 |
{
|
250 |
unset($products[$key]);
|
251 |
}
|
252 |
$_SESSION['simpleCart'] = $products;
|
253 |
+
if(isset($_SESSION['simple_cart_id']) && !empty($_SESSION['simple_cart_id']))
|
254 |
+
{
|
255 |
+
$post_id = $_SESSION['simple_cart_id'];
|
256 |
+
update_post_meta( $post_id, 'wpsc_cart_items', $_SESSION['simpleCart']);
|
257 |
+
}
|
258 |
}
|
259 |
|
260 |
function print_wp_shopping_cart()
|
301 |
$urls = '';
|
302 |
|
303 |
$return = get_option('cart_return_from_paypal_url');
|
304 |
+
if(empty($return)){
|
305 |
+
$return = WP_CART_SITE_URL.'/';
|
306 |
+
}
|
307 |
+
$return_url = add_query_arg('reset_wp_cart', '1', $return);
|
308 |
+
|
309 |
+
$urls .= '<input type="hidden" name="return" value="'.$return_url.'" />';
|
310 |
+
|
311 |
+
$notify = WP_CART_SITE_URL.'/?simple_cart_ipn=1';
|
312 |
+
$urls .= '<input type="hidden" name="notify_url" value="'.$notify.'" />';
|
313 |
+
|
314 |
+
$title = get_option('wp_cart_title');
|
315 |
+
//if (empty($title)) $title = __("Your Shopping Cart", "WSPSC");
|
|
|
|
|
|
|
316 |
|
317 |
global $plugin_dir_name;
|
318 |
$output .= '<div class="shopping_cart" style=" padding: 5px;">';
|
434 |
if(!empty($wp_cart_note_to_seller_text)){
|
435 |
$output .= '<input type="hidden" name="no_note" value="0" /><input type="hidden" name="cn" value="'.$wp_cart_note_to_seller_text.'" />';
|
436 |
}
|
437 |
+
|
438 |
+
$output .= wp_cart_add_custom_field();
|
|
|
439 |
$output .= '</form>';
|
440 |
}
|
441 |
$output .= "
|
448 |
|
449 |
function wp_cart_add_custom_field()
|
450 |
{
|
451 |
+
$_SESSION['wp_cart_custom_values'] = "";
|
452 |
+
$custom_field_val = "";
|
453 |
+
$name = 'wp_cart_id';
|
454 |
+
$value = $_SESSION['simple_cart_id'];
|
455 |
+
$custom_field_val = wpc_append_values_to_custom_field($name,$value);
|
456 |
+
|
457 |
+
$clientip = $_SERVER['REMOTE_ADDR'];
|
458 |
+
if (!empty($clientip)){
|
459 |
+
$name = 'ip';
|
460 |
+
$value = $clientip;
|
461 |
+
$custom_field_val = wpc_append_values_to_custom_field($name,$value);
|
462 |
+
}
|
463 |
+
|
464 |
+
if (function_exists('wp_aff_platform_install'))
|
465 |
+
{
|
466 |
+
$name = 'ap_id';
|
467 |
+
$value = '';
|
468 |
+
if(isset($_SESSION['ap_id'])){$value = $_SESSION['ap_id'];}
|
469 |
+
else if (isset($_COOKIE['ap_id'])){$value = $_COOKIE['ap_id'];}
|
470 |
+
if(!empty($value)){
|
471 |
+
$custom_field_val = wpc_append_values_to_custom_field($name,$value);
|
472 |
+
}
|
473 |
+
}
|
474 |
+
$output = '<input type="hidden" name="custom" value="'.$custom_field_val.'" />';
|
475 |
+
return $output;
|
476 |
}
|
477 |
|
478 |
function print_wp_cart_button_new($content)
|
617 |
//-->
|
618 |
</script>';
|
619 |
}
|
620 |
+
function print_wp_cart_button_for_product($name, $price, $shipping=0, $var1='', $var2='', $var3='', $atts=array())
|
621 |
{
|
622 |
$addcart = get_option('addToCartButtonName');
|
623 |
if (!$addcart || ($addcart == '') )
|
677 |
}
|
678 |
$replacement .= '<input type="hidden" name="product" value="'.$name.'" /><input type="hidden" name="price" value="'.$price.'" /><input type="hidden" name="shipping" value="'.$shipping.'" /><input type="hidden" name="addcart" value="1" /><input type="hidden" name="cartLink" value="'.cart_current_page_url().'" />';
|
679 |
$replacement .= '<input type="hidden" name="product_tmp" value="'.$name.'" />';
|
680 |
+
if($atts['file_url']){
|
681 |
+
$file_url = $atts['file_url'];
|
682 |
+
$file_url = base64_encode($file_url);
|
683 |
+
$replacement .= '<input type="hidden" name="file_url" value="'.$file_url.'" />';
|
684 |
+
}
|
685 |
+
$replacement .= '</form>';
|
686 |
$replacement .= '</div>';
|
687 |
return $replacement;
|
688 |
}
|
723 |
|
724 |
function show_wp_cart_options_page ()
|
725 |
{
|
726 |
+
if(isset($_POST['wspsc_reset_logfile'])) {
|
727 |
+
// Reset the debug log file
|
728 |
+
if(wspsc_reset_logfile()){
|
729 |
+
echo '<div id="message" class="updated fade"><p><strong>Debug log file has been reset!</strong></p></div>';
|
730 |
+
}
|
731 |
+
else{
|
732 |
+
echo '<div id="message" class="updated fade"><p><strong>Debug log file could not be reset!</strong></p></div>';
|
733 |
+
}
|
734 |
+
}
|
735 |
if (isset($_POST['info_update']))
|
736 |
{
|
737 |
$nonce = $_REQUEST['_wpnonce'];
|
762 |
update_option('wp_use_aff_platform', ($_POST['wp_use_aff_platform']!='') ? 'checked="checked"':'' );
|
763 |
|
764 |
update_option('wp_shopping_cart_enable_sandbox', ($_POST['wp_shopping_cart_enable_sandbox']!='') ? 'checked="checked"':'' );
|
765 |
+
update_option('wp_shopping_cart_enable_debug', ($_POST['wp_shopping_cart_enable_debug']!='') ? 'checked="checked"':'' );
|
766 |
|
767 |
echo '<div id="message" class="updated fade">';
|
768 |
echo '<p><strong>'.(__("Options Updated!", "WSPSC")).'</strong></p></div>';
|
830 |
if (get_option('wp_shopping_cart_enable_sandbox'))
|
831 |
$wp_shopping_cart_enable_sandbox = 'checked="checked"';
|
832 |
else
|
833 |
+
$wp_shopping_cart_enable_sandbox = '';
|
834 |
+
|
835 |
+
$wp_shopping_cart_enable_debug = '';
|
836 |
+
if (get_option('wp_shopping_cart_enable_debug')){
|
837 |
+
$wp_shopping_cart_enable_debug = 'checked="checked"';
|
838 |
+
}
|
839 |
?>
|
840 |
<h2><?php _e("Simple PayPal Shopping Cart Settings", "WSPSC"); ?> v <?php echo WP_CART_VERSION; ?></h2>
|
841 |
|
869 |
<td><input type="text" name="cart_paypal_email" value="'.$defaultEmail.'" size="40" /></td>
|
870 |
</tr>
|
871 |
<tr valign="top">
|
|
|
|
|
|
|
|
|
|
|
872 |
<th scope="row">'.(__("Shopping Cart title", "WSPSC")).'</th>
|
873 |
<td><input type="text" name="wp_cart_title" value="'.$title.'" size="40" /></td>
|
874 |
</tr>
|
962 |
</tr>
|
963 |
</table>
|
964 |
</div></div>
|
965 |
+
|
966 |
+
<div class="postbox">
|
967 |
+
<h3><label for="title">'.(__("Testing and Debugging Settings", "WSPSC")).'</label></h3>
|
968 |
+
<div class="inside">
|
969 |
+
|
970 |
+
<table class="form-table">
|
971 |
+
|
972 |
+
<tr valign="top">
|
973 |
+
<th scope="row">'.(__("Enable Debug", "WSPSC")).'</th>
|
974 |
+
<td><input type="checkbox" name="wp_shopping_cart_enable_debug" value="1" '.$wp_shopping_cart_enable_debug.' />
|
975 |
+
<br />'.(__("If checked, debug output will be written to the log file. This is useful for troubleshooting post payment failures", "WSPSC")).'
|
976 |
+
<p><i>You can check the debug log file by clicking on the link below (The log file can be viewed using any text editor):</i>
|
977 |
+
<ul>
|
978 |
+
<li><a href="'.WP_CART_URL.'/ipn_handle_debug.log" target="_blank">ipn_handle_debug.log</a></li>
|
979 |
+
</ul>
|
980 |
+
</p>
|
981 |
+
<input type="submit" name="wspsc_reset_logfile" style="font-weight:bold; color:red" value="Reset Debug Log file"/> Simple PayPal Shopping Cart debug log file is "reset" and timestamped with a log file reset message.
|
982 |
+
</td></tr>
|
983 |
+
|
984 |
+
<tr valign="top">
|
985 |
+
<th scope="row">'.(__("Enable Sandbox Testing", "WSPSC")).'</th>
|
986 |
+
<td><input type="checkbox" name="wp_shopping_cart_enable_sandbox" value="1" '.$wp_shopping_cart_enable_sandbox.' />
|
987 |
+
<br />'.(__("Check this option if you want to do PayPal sandbox testing. You will need to create a PayPal sandbox account from PayPal Developer site", "WSPSC")).'</td>
|
988 |
+
</tr>
|
989 |
+
|
990 |
+
</table>
|
991 |
+
|
992 |
+
</div>
|
993 |
+
</div>
|
994 |
+
|
995 |
<div class="submit">
|
996 |
<input type="submit" name="info_update" value="'.(__("Update Options »", "WSPSC")).'" />
|
997 |
</div>
|
1084 |
add_action('admin_menu','wp_cart_options_page');
|
1085 |
add_action('widgets_init','wp_paypal_shopping_cart_load_widgets');
|
1086 |
|
1087 |
+
add_action('init','wp_cart_init_handler');
|
1088 |
+
add_action( 'admin_init', 'wp_cart_admin_init_handler' );
|
1089 |
+
|
1090 |
//add_filter('the_content', 'print_wp_cart_button',11);
|
1091 |
add_filter('the_content', 'print_wp_cart_button_new',11);
|
1092 |
add_filter('the_content', 'shopping_cart_show');
|
wp_shopping_cart_misc_functions.php
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/* TODO
|
4 |
+
- add email menu
|
5 |
+
- Simple discount coupons option (see the user submitted coupon code version and incorporate that in here)
|
6 |
+
- Mention the available languages
|
7 |
+
*/
|
8 |
+
|
9 |
+
/* this function gets called when init is fired */
|
10 |
+
function wp_cart_init_handler()
|
11 |
+
{
|
12 |
+
//Add any common init hook handing code
|
13 |
+
if(is_admin())//Init hook handing code for wp-admin
|
14 |
+
{
|
15 |
+
wpc_create_orders_page();
|
16 |
+
}
|
17 |
+
else//Init hook handing code for front end
|
18 |
+
{
|
19 |
+
if(isset($_REQUEST['simple_cart_ipn']))
|
20 |
+
{
|
21 |
+
include_once('paypal.php');
|
22 |
+
wpc_handle_paypal_ipn();
|
23 |
+
exit;
|
24 |
+
}
|
25 |
+
}
|
26 |
+
}
|
27 |
+
|
28 |
+
function wp_cart_admin_init_handler()
|
29 |
+
{
|
30 |
+
wpsc_add_meta_boxes();
|
31 |
+
}
|
32 |
+
|
33 |
+
function wpc_append_values_to_custom_field($name,$value)
|
34 |
+
{
|
35 |
+
$custom_field_val = $_SESSION['wp_cart_custom_values'];
|
36 |
+
$new_val = $name.'='.$value;
|
37 |
+
if (empty($custom_field_val)){
|
38 |
+
$custom_field_val = $new_val;
|
39 |
+
}
|
40 |
+
else{
|
41 |
+
$custom_field_val = $custom_field_val.'&'.$new_val;
|
42 |
+
}
|
43 |
+
$_SESSION['wp_cart_custom_values'] = $custom_field_val;
|
44 |
+
return $custom_field_val;
|
45 |
+
}
|
46 |
+
|
47 |
+
function wp_cart_get_custom_var_array($custom_val_string)
|
48 |
+
{
|
49 |
+
$delimiter = "&";
|
50 |
+
$customvariables = array();
|
51 |
+
$namevaluecombos = explode($delimiter, $custom_val_string);
|
52 |
+
foreach ($namevaluecombos as $keyval_unparsed)
|
53 |
+
{
|
54 |
+
$equalsignposition = strpos($keyval_unparsed, '=');
|
55 |
+
if ($equalsignposition === false)
|
56 |
+
{
|
57 |
+
$customvariables[$keyval_unparsed] = '';
|
58 |
+
continue;
|
59 |
+
}
|
60 |
+
$key = substr($keyval_unparsed, 0, $equalsignposition);
|
61 |
+
$value = substr($keyval_unparsed, $equalsignposition + 1);
|
62 |
+
$customvariables[$key] = $value;
|
63 |
+
}
|
64 |
+
return $customvariables;
|
65 |
+
}
|
66 |
+
|
67 |
+
function wspsc_reset_logfile()
|
68 |
+
{
|
69 |
+
$log_reset = true;
|
70 |
+
$logfile = dirname(__FILE__).'/ipn_handle_debug.log';
|
71 |
+
$text = '['.date('m/d/Y g:i A').'] - SUCCESS : Log file reset';
|
72 |
+
$text .= "\n------------------------------------------------------------------\n\n";
|
73 |
+
$fp = fopen($logfile, 'w');
|
74 |
+
if($fp != FALSE) {
|
75 |
+
@fwrite($fp, $text);
|
76 |
+
@fclose($fp);
|
77 |
+
}
|
78 |
+
else{
|
79 |
+
$log_reset = false;
|
80 |
+
}
|
81 |
+
return $log_reset;
|
82 |
+
}
|
wp_shopping_cart_orders.php
ADDED
@@ -0,0 +1,169 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
add_action( 'save_post', 'wpsc_cart_save_orders', 10, 2 );
|
4 |
+
|
5 |
+
function wpc_create_orders_page()
|
6 |
+
{
|
7 |
+
register_post_type( 'wpsc_cart_orders',
|
8 |
+
array(
|
9 |
+
'labels' => array(
|
10 |
+
'name' => 'Cart Orders',
|
11 |
+
'singular_name' => 'Cart Order',
|
12 |
+
'add_new' => 'Add New',
|
13 |
+
'add_new_item' => 'Add New Order',
|
14 |
+
'edit' => 'Edit',
|
15 |
+
'edit_item' => 'Edit Order',
|
16 |
+
'new_item' => 'New Order',
|
17 |
+
'view' => 'View',
|
18 |
+
'view_item' => 'View Order',
|
19 |
+
'search_items' => 'Search Order',
|
20 |
+
'not_found' => 'No order found',
|
21 |
+
'not_found_in_trash' => 'No order found in Trash',
|
22 |
+
'parent' => 'Parent Order'
|
23 |
+
),
|
24 |
+
|
25 |
+
'public' => true,
|
26 |
+
'menu_position' => 80,
|
27 |
+
'supports' => false,
|
28 |
+
'taxonomies' => array( '' ),
|
29 |
+
'menu_icon' => WP_CART_URL.'/images/cart-orders-icon.png',
|
30 |
+
'has_archive' => true
|
31 |
+
)
|
32 |
+
);
|
33 |
+
}
|
34 |
+
|
35 |
+
function wpsc_add_meta_boxes()
|
36 |
+
{
|
37 |
+
add_meta_box( 'order_review_meta_box',
|
38 |
+
'Order Review',
|
39 |
+
'wpsc_order_review_meta_box',
|
40 |
+
'wpsc_cart_orders',
|
41 |
+
'normal',
|
42 |
+
'high'
|
43 |
+
);
|
44 |
+
}
|
45 |
+
|
46 |
+
function wpsc_order_review_meta_box($wpsc_cart_orders)
|
47 |
+
{
|
48 |
+
// Retrieve current name of the Director and Movie Rating based on review ID
|
49 |
+
$order_id = $wpsc_cart_orders->ID;
|
50 |
+
$first_name = get_post_meta( $wpsc_cart_orders->ID, 'wpsc_first_name', true );
|
51 |
+
$last_name = get_post_meta( $wpsc_cart_orders->ID, 'wpsc_last_name', true );
|
52 |
+
$email = get_post_meta( $wpsc_cart_orders->ID, 'wpsc_email_address', true );
|
53 |
+
$txn_id = get_post_meta( $wpsc_cart_orders->ID, 'wpsc_txn_id', true );
|
54 |
+
$ip_address = get_post_meta( $wpsc_cart_orders->ID, 'wpsc_ipaddress', true );
|
55 |
+
$total_amount = get_post_meta( $wpsc_cart_orders->ID, 'wpsc_total_amount', true );
|
56 |
+
$address = get_post_meta( $wpsc_cart_orders->ID, 'wpsc_address', true );
|
57 |
+
$email_sent_value = get_post_meta( $wpsc_cart_orders->ID, 'wpsc_buyer_email_sent', true );
|
58 |
+
|
59 |
+
$email_sent_field_msg = "No";
|
60 |
+
if(!empty($email_sent_value)){
|
61 |
+
$email_sent_field_msg = "Yes. ".$email_sent_value;
|
62 |
+
}
|
63 |
+
?>
|
64 |
+
<table>
|
65 |
+
<p>Order ID: #<?php echo $order_id;?></p>
|
66 |
+
<?php if($txn_id){?>
|
67 |
+
<p>Transaction ID: #<?php echo $txn_id;?></p>
|
68 |
+
<?php } ?>
|
69 |
+
<tr>
|
70 |
+
<td>First Name</td>
|
71 |
+
<td><input type="text" size="40" name="wpsc_first_name" value="<?php echo $first_name; ?>" /></td>
|
72 |
+
</tr>
|
73 |
+
<tr>
|
74 |
+
<td>Last Name</td>
|
75 |
+
<td><input type="text" size="40" name="wpsc_last_name" value="<?php echo $last_name; ?>" /></td>
|
76 |
+
</tr>
|
77 |
+
<tr>
|
78 |
+
<td>Email Address</td>
|
79 |
+
<td><input type="text" size="40" name="wpsc_email_address" value="<?php echo $email; ?>" /></td>
|
80 |
+
</tr>
|
81 |
+
<tr>
|
82 |
+
<td>IP Address</td>
|
83 |
+
<td><input type="text" size="40" name="wpsc_ipaddress" value="<?php echo $ip_address; ?>" /></td>
|
84 |
+
</tr>
|
85 |
+
<tr>
|
86 |
+
<td>Total</td>
|
87 |
+
<td><input type="text" size="20" name="wpsc_total_amount" value="<?php echo $total_amount; ?>" /></td>
|
88 |
+
</tr>
|
89 |
+
<tr>
|
90 |
+
<td>Address</td>
|
91 |
+
<td><textarea name="wpsc_address" cols="83" rows="2"><?php echo $address;?></textarea></td>
|
92 |
+
</tr>
|
93 |
+
<tr>
|
94 |
+
<td>Buyer Email Sent?</td>
|
95 |
+
<td><input type="text" size="80" name="wpsc_buyer_email_sent" value="<?php echo $email_sent_field_msg; ?>" readonly /></td>
|
96 |
+
</tr>
|
97 |
+
|
98 |
+
</table>
|
99 |
+
<?php
|
100 |
+
}
|
101 |
+
|
102 |
+
function wpsc_cart_save_orders( $order_id, $wpsc_cart_orders ) {
|
103 |
+
// Check post type for movie reviews
|
104 |
+
if ( $wpsc_cart_orders->post_type == 'wpsc_cart_orders' ) {
|
105 |
+
// Store data in post meta table if present in post data
|
106 |
+
if ( isset( $_POST['wpsc_first_name'] ) && $_POST['wpsc_first_name'] != '' ) {
|
107 |
+
update_post_meta( $order_id, 'wpsc_first_name', $_POST['wpsc_first_name'] );
|
108 |
+
}
|
109 |
+
if ( isset( $_POST['wpsc_last_name'] ) && $_POST['wpsc_last_name'] != '' ) {
|
110 |
+
update_post_meta( $order_id, 'wpsc_last_name', $_POST['wpsc_last_name'] );
|
111 |
+
}
|
112 |
+
if ( isset( $_POST['wpsc_email_address'] ) && $_POST['wpsc_email_address'] != '' ) {
|
113 |
+
update_post_meta( $order_id, 'wpsc_email_address', $_POST['wpsc_email_address'] );
|
114 |
+
}
|
115 |
+
if ( isset( $_POST['wpsc_ipaddress'] ) && $_POST['wpsc_ipaddress'] != '' ) {
|
116 |
+
update_post_meta( $order_id, 'wpsc_ipaddress', $_POST['wpsc_ipaddress'] );
|
117 |
+
}
|
118 |
+
if ( isset( $_POST['wpsc_total_amount'] ) && $_POST['wpsc_total_amount'] != '' ) {
|
119 |
+
update_post_meta( $order_id, 'wpsc_total_amount', $_POST['wpsc_total_amount'] );
|
120 |
+
}
|
121 |
+
if ( isset( $_POST['wpsc_address'] ) && $_POST['wpsc_address'] != '' ) {
|
122 |
+
update_post_meta( $order_id, 'wpsc_address', $_POST['wpsc_address'] );
|
123 |
+
}
|
124 |
+
}
|
125 |
+
}
|
126 |
+
|
127 |
+
add_filter( 'manage_edit-wpsc_cart_orders_columns', 'wpsc_orders_display_columns' );
|
128 |
+
function wpsc_orders_display_columns( $columns )
|
129 |
+
{
|
130 |
+
//unset( $columns['title'] );
|
131 |
+
unset( $columns['comments'] );
|
132 |
+
unset( $columns['date'] );
|
133 |
+
//$columns['wpsc_order_id'] = 'Order ID';
|
134 |
+
$columns['title'] = 'Order ID';
|
135 |
+
$columns['wpsc_first_name'] = 'First Name';
|
136 |
+
$columns['wpsc_last_name'] = 'Last Name';
|
137 |
+
$columns['wpsc_email_address'] = 'Email';
|
138 |
+
$columns['wpsc_total_amount'] = 'Total';
|
139 |
+
$columns['wpsc_order_status'] = "Status";
|
140 |
+
$columns['date'] = 'Date';
|
141 |
+
return $columns;
|
142 |
+
}
|
143 |
+
|
144 |
+
//add_action( 'manage_posts_custom_column', 'wpsc_populate_order_columns' , 10, 2);
|
145 |
+
add_action('manage_wpsc_cart_orders_posts_custom_column', 'wpsc_populate_order_columns', 10, 2);
|
146 |
+
function wpsc_populate_order_columns($column, $post_id)
|
147 |
+
{
|
148 |
+
if ( 'wpsc_first_name' == $column ) {
|
149 |
+
$ip_address = get_post_meta( $post_id, 'wpsc_first_name', true );
|
150 |
+
echo $ip_address;
|
151 |
+
}
|
152 |
+
else if ( 'wpsc_last_name' == $column ) {
|
153 |
+
$ip_address = get_post_meta( $post_id, 'wpsc_last_name', true );
|
154 |
+
echo $ip_address;
|
155 |
+
}
|
156 |
+
else if ( 'wpsc_email_address' == $column ) {
|
157 |
+
$email = get_post_meta( $post_id, 'wpsc_email_address', true );
|
158 |
+
echo $email;
|
159 |
+
}
|
160 |
+
else if ( 'wpsc_total_amount' == $column ) {
|
161 |
+
$total_amount = get_post_meta( $post_id, 'wpsc_total_amount', true );
|
162 |
+
echo $total_amount;
|
163 |
+
}
|
164 |
+
else if ( 'wpsc_order_status' == $column ) {
|
165 |
+
$status = get_post_meta( $post_id, 'wpsc_order_status', true );
|
166 |
+
echo $status;
|
167 |
+
}
|
168 |
+
}
|
169 |
+
|
wp_shopping_cart_shortcodes.php
CHANGED
@@ -16,7 +16,7 @@ function wp_cart_button_handler($atts){
|
|
16 |
if(empty($price)){
|
17 |
return '<div style="color:red;">Error! You must specify a price for your product in the shortcode.</div>';
|
18 |
}
|
19 |
-
return print_wp_cart_button_for_product($name, $price, $shipping, $var1, $var2, $var3);
|
20 |
}
|
21 |
|
22 |
function wp_cart_display_product_handler($atts)
|
@@ -42,7 +42,7 @@ function wp_cart_display_product_handler($atts)
|
|
42 |
return '<div style="color:red;">Error! You must specify a thumbnail image for your product in the shortcode.</div>';
|
43 |
}
|
44 |
$currency_symbol = get_option('cart_currency_symbol');
|
45 |
-
$button_code = print_wp_cart_button_for_product($name, $price, $shipping, $var1, $var2, $var3);
|
46 |
$display_code = <<<EOT
|
47 |
<div class="wp_cart_product_display_box">
|
48 |
<div class="wp_cart_product_thumbnail">
|
16 |
if(empty($price)){
|
17 |
return '<div style="color:red;">Error! You must specify a price for your product in the shortcode.</div>';
|
18 |
}
|
19 |
+
return print_wp_cart_button_for_product($name, $price, $shipping, $var1, $var2, $var3, $atts);
|
20 |
}
|
21 |
|
22 |
function wp_cart_display_product_handler($atts)
|
42 |
return '<div style="color:red;">Error! You must specify a thumbnail image for your product in the shortcode.</div>';
|
43 |
}
|
44 |
$currency_symbol = get_option('cart_currency_symbol');
|
45 |
+
$button_code = print_wp_cart_button_for_product($name, $price, $shipping, $var1, $var2, $var3, $atts);
|
46 |
$display_code = <<<EOT
|
47 |
<div class="wp_cart_product_display_box">
|
48 |
<div class="wp_cart_product_thumbnail">
|