PayPal Buy Now Button - Version 1.1.1

Version Description

Download this release

Release Info

Developer scottpaterson
Plugin Icon 128x128 PayPal Buy Now Button
Version 1.1.1
Comparing to
See all releases

Code changes from version 1.0.0 to 1.1.1

Files changed (3) hide show
  1. manager.php +66 -0
  2. readme.txt +32 -17
  3. wp-ecommerce-paypal.php +332 -71
manager.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if (!defined('ABSPATH')) exit; // Exit if accessed directly
4
+
5
+ define('PLICENSE_PRODUCT_NAME', 'wpecpp');
6
+
7
+ if (!class_exists('wpecpp_PLicense_Activation')) {
8
+ class wpecpp_PLicense_Activation {
9
+
10
+ function is_plicense_valid() {
11
+ $plicense_key = get_option('plicsence_key'.PLICENSE_PRODUCT_NAME);
12
+ if (!$plicense_key) return false;
13
+
14
+ if (false === ($value = get_transient('plicense_state'))) {
15
+ if ($this->wpecpp_plicense_valid_check($plicense_key)) {
16
+ set_transient('plicense_state', 1, 30 * MINUTE_IN_SECONDS);
17
+ return true;
18
+ }
19
+ }
20
+ else return true;
21
+
22
+ return false;
23
+ }
24
+
25
+ }
26
+ }
27
+
28
+ if(isset($_POST['wpecpp_plicsence_key'])) {
29
+ global $wpecpp_PLicense_Activation;
30
+ $license = $_POST['wpecpp_plicsence_key'];
31
+
32
+
33
+ $serverurl = "https://wpplugin.org/wp-content/plugins/product-licensing-system/verify.php";
34
+
35
+ $response = wp_remote_post($serverurl, array(
36
+ 'method' => 'POST',
37
+ 'timeout' => 20,
38
+ 'redirection' => 5,
39
+ 'httpversion' => '1.0',
40
+ 'blocking' => true,
41
+ 'headers' => array(),
42
+ 'body' => array( 'domain' => $_SERVER['SERVER_NAME'], 'licensekey' => $license ),
43
+ 'cookies' => array()
44
+ )
45
+ );
46
+
47
+ if (is_wp_error($response))
48
+ $response = '';
49
+
50
+ $result = json_decode($response['body'], true);
51
+
52
+ //print_r ($result);
53
+
54
+ //avaiable 'valid' value is true, false, pending, expired
55
+ update_option('wpecpp_plicsence_key_status', $result['valid']);
56
+ update_option('wpecpp_plicsence_key'.PLICENSE_PRODUCT_NAME, $license);
57
+
58
+ if($result['valid'] == "true")
59
+ return "1";
60
+ else {
61
+ delete_transient('plicense_state');
62
+ }
63
+ return "2";
64
+ }
65
+
66
+ ?>
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: ecommerce, paypal, button, buy now, shortcode, buy now button, paypal butt
5
  Author URI: https://wpplugin.org
6
  Requires at least: 3.0
7
  Tested up to: 4.1
8
- Stable tag: 1.0.0
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -33,28 +33,37 @@ Convert your website to a eCommerce website and start selling your product in ju
33
  * Choose cancel payment url
34
  * Choose succesful payment url
35
 
36
- > #### WP eCommerce PayPal Pro
37
- > WP eCommerce PayPal Pro comes with the following features.<br />
38
  >
39
- > Charge Tax<br />
40
- > Charge Shipping & Handling<br />
41
- > Apply a discount amount or discount rate percentage<br />
42
- > Add a drop-down menu with different prices and options<br />
43
- > Add item weight & weight unit<br />
44
- > Add a custom button image<br />
 
45
  > Add an Item ID or SKU<br />
46
- > Option to disable customer prompt for a note <br />
47
- > Change text for PayPal's Return to Merchant button <br />
48
- > Change button size in shortcode <br />
 
49
  >
50
- > [Wp eCommerce PayPal Pro >>](https://wpplugin.org/wp-ecommerce-paypal/)
 
51
 
52
  == Installation ==
53
 
54
- 1. Upload `wp-ecommerce-paypal.zip` to the `/wp-content/plugins/` directory
55
- 2. Activate the plugin through the 'Plugins' menu in WordPress
56
- 3. In your sidebar, select 'Settings -> WP eCommerce Paypal' and configure the settings.
57
- 4. Place `[wpecpp name='Product name goes here' price='6.99']` in a post or page where you want your a PayPal button to show.
 
 
 
 
 
 
58
 
59
  == Frequently Asked Questions ==
60
 
@@ -71,10 +80,16 @@ Yes, there is no limit to the amount you can put on one post / page, or your ent
71
 
72
  == Changelog ==
73
 
 
 
 
74
  = 1.0.0 =
75
  * Initial release
76
 
77
  == Upgrade Notice ==
78
 
 
 
 
79
  = 1.0.0 =
80
  Initial release
5
  Author URI: https://wpplugin.org
6
  Requires at least: 3.0
7
  Tested up to: 4.1
8
+ Stable tag: 1.1
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
33
  * Choose cancel payment url
34
  * Choose succesful payment url
35
 
36
+ > #### WP eCommerce PayPal Plus
37
+ > WP eCommerce PayPal Plus comes with the following features.<br />
38
  >
39
+ > Charge Fixed Tax <br />
40
+ > Charge Tax Rate <br />
41
+ > Charge Shipping & Handling per item<br />
42
+ > Show Price Beside Button <br />
43
+ > Show Name Beside Button <br />
44
+ > Apply a Fixed Discount per item <br />
45
+ > Apply a Discount Rate per item<br />
46
  > Add an Item ID or SKU<br />
47
+ > Hide Customer's Custom Note Field<br />
48
+ > Change PayPal's Return to Merchant Text<br />
49
+ > Each Button Can Have Its Own Size<br />
50
+ > Add a Custom Button Image<br />
51
  >
52
+ >
53
+ > [Get a WP eCommerce PayPal Plus License Key >>](https://wpplugin.org/wp-ecommerce-paypal/)
54
 
55
  == Installation ==
56
 
57
+ = Automatic Installation =
58
+ > 1. Sign in to your WordPress site as an administrator.
59
+ > 2. In the main menu go to Plugins -> Add New.
60
+ > 3. Search for WP eCommerce PayPal and click install.
61
+
62
+ = Manual Installation =
63
+ > 1. Upload `wp-ecommerce-paypal.zip` to the `/wp-content/plugins/` directory
64
+ > 2. Activate the plugin through the 'Plugins' menu in WordPress
65
+ > 3. In your sidebar, select 'Settings -> WP eCommerce Paypal' and configure the settings.
66
+ > 4. Place `[wpecpp name='Product name goes here' price='6.99']` in a post or page where you want your a PayPal button to show.
67
 
68
  == Frequently Asked Questions ==
69
 
80
 
81
  == Changelog ==
82
 
83
+ = 1.1 =
84
+ * Code improvements and integrated premium features
85
+
86
  = 1.0.0 =
87
  * Initial release
88
 
89
  == Upgrade Notice ==
90
 
91
+ = 1.1 =
92
+ Code improvements and integrated premium features
93
+
94
  = 1.0.0 =
95
  Initial release
wp-ecommerce-paypal.php CHANGED
@@ -7,7 +7,7 @@ Description: A simple and easy way to integrate PayPal into your WordPress websi
7
  Author: Scott Paterson
8
  Author URI: https://wpplugin.org
9
  License: GPL2
10
- Version: 1.0
11
  */
12
 
13
  /* Copyright 2014-2015 Scott Paterson
@@ -34,17 +34,20 @@ Version: 1.0
34
 
35
 
36
 
 
 
 
37
  // plugin functions
38
- wpecppl_WPeCommerceLite::init_WPeCommerceLite();
39
 
40
- class wpecppl_WPeCommerceLite {
41
  public static function init_WPeCommerceLite() {
42
- register_activation_hook( __FILE__, array( __CLASS__, "wpecppl_activate" ));
43
- register_deactivation_hook( __FILE__, array( __CLASS__, "wpecppl_deactivate" ));
44
- register_uninstall_hook( __FILE__, array( __CLASS__, "wpecppl_uninstall" ));
45
 
46
 
47
- $WPeCommerceLiteoptions = array(
48
  'currency' => '25',
49
  'language' => '3',
50
  'liveaccount' => '',
@@ -54,16 +57,29 @@ $WPeCommerceLiteoptions = array(
54
  'opens' => '2',
55
  'cancel' => '',
56
  'return' => '',
 
 
 
 
 
 
 
 
57
  );
58
 
59
- add_option("WPeCommerceLiteoptions", $WPeCommerceLiteoptions);
 
60
  }
61
- function wpecppl_activate() {
 
62
  }
63
- function wpecppl_deactivate() {
 
64
  }
65
- function wpecppl_uninstall() {
66
- delete_option("WPeCommerceLiteoptions");
 
 
67
  }
68
  }
69
 
@@ -73,61 +89,64 @@ delete_option("WPeCommerceLiteoptions");
73
 
74
 
75
 
 
76
 
 
77
 
78
-
79
- // settings page menu link
80
- add_action( "admin_menu", "wpecppl_plugin_menu" );
81
-
82
- function wpecppl_plugin_menu() {
83
- add_options_page( "WP eCommerce PayPal", "WP eCommerce PayPal", "manage_options", "wp-ecommerce-lite", "wpecppl_plugin_options" );
84
  }
85
 
86
- add_filter('plugin_action_links', 'myplugin_plugin_action_links', 10, 2);
87
-
88
- function myplugin_plugin_action_links($links, $file) {
89
- static $this_plugin;
90
-
91
- if (!$this_plugin) {
92
- $this_plugin = plugin_basename(__FILE__);
93
- }
94
-
95
- if ($file == $this_plugin) {
96
- // The "page" query string value must be equal to the slug
97
- // of the Settings admin page we defined earlier, which in
98
- // this case equals "myplugin-settings".
99
- $settings_link = '<a href="' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=wp-ecommerce-lite">Settings</a>';
100
- array_unshift($links, $settings_link);
101
- }
102
 
103
- return $links;
104
- }
105
 
106
 
107
 
108
 
 
 
109
 
 
 
 
 
110
 
 
 
 
 
 
 
 
 
 
 
 
111
 
 
 
 
 
112
 
113
 
 
 
 
 
114
 
115
 
116
 
117
 
118
- // view admin page
119
- function wpecppl_plugin_options() {
120
- if ( !current_user_can( "manage_options" ) ) {
121
- wp_die( __( "You do not have sufficient permissions to access this page." ) );
122
- }
123
 
 
124
 
125
 
126
 
127
 
128
  echo "<table width='100%'><tr><td width='65%'>";
129
  echo "<h1><label style='color: #0074A2;'>WP eCommerce PayPal Settings</label></h1>";
130
-
131
  echo "<form method='post' action='".$_SERVER["REQUEST_URI"]."'>";
132
 
133
 
@@ -143,10 +162,16 @@ $options['size'] = $_POST['size'];
143
  $options['opens'] = $_POST['opens'];
144
  $options['cancel'] = $_POST['cancel'];
145
  $options['return'] = $_POST['return'];
 
 
 
 
 
 
 
146
 
147
 
148
-
149
- update_option("WPeCommerceLiteoptions", $options);
150
 
151
  echo "<br /><div class='updated'><p><strong>"; _e("Settings Updated."); echo "</strong></p></div>";
152
 
@@ -154,7 +179,7 @@ echo "<br /><div class='updated'><p><strong>"; _e("Settings Updated."); echo "</
154
 
155
 
156
  // get options
157
- $options = get_option('WPeCommerceLiteoptions');
158
  foreach ($options as $k => $v ) { $value[$k] = $v; }
159
 
160
 
@@ -172,7 +197,22 @@ echo "<br /><hr>";
172
  To use this plugin, put the shortcode <b>[wpecpp name='example product name' price='6.99']</b> in your page or post anywhere you want the PayPal button to show.
173
  You can put the shortcode as many times as you want in a post or page, there is no limit.
174
 
 
 
 
 
 
 
 
 
 
 
 
 
 
175
  <br /><br /><hr>
 
 
176
  <h3><label style="color: #0074A2;">Language & Currency</label></h3>
177
 
178
  <b>Language:</b>
@@ -256,17 +296,129 @@ echo "<br /><br /><hr>";
256
 
257
 
258
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
259
  echo "<h3><label style='color: #0074A2;'>Other</label></h3>";
260
 
261
  echo "<table><tr><td valign='top'>";
262
- echo "<b>Button Size and type:</b></td><td valign='top'>";
263
- echo "<input "; if ($value['size'] == "1") { echo "checked='checked'"; } echo " type='radio' name='size' value='1'>Small <br /><img src='https://www.paypalobjects.com/en_US/i/btn/btn_buynow_SM.gif'></td><td valign='top'>";
264
- echo "<input "; if ($value['size'] == "2") { echo "checked='checked'"; } echo " type='radio' name='size' value='2'>Big <br /><img src='https://www.paypalobjects.com/en_US/i/btn/btn_buynow_LG.gif'></td><td>";
265
- echo "<input "; if ($value['size'] == "3") { echo "checked='checked'"; } echo " type='radio' name='size' value='3'>Big with credit cards <br /><img src='https://www.paypalobjects.com/en_US/i/btn/btn_buynowCC_LG.gif'></td></tr></table><br />";
266
 
267
- echo "<b>PayPal opens in:</b>";
268
- echo "&nbsp; &nbsp; <input "; if ($value['opens'] == "1") { echo "checked='checked'"; } echo " type='radio' name='opens' value='1'>Same page";
269
- echo "&nbsp; &nbsp; <input "; if ($value['opens'] == "2") { echo "checked='checked'"; } echo " type='radio' name='opens' value='2'>New page<br /><br />";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
270
 
271
 
272
  $siteurl = get_site_url();
@@ -279,6 +431,12 @@ echo "<b>Return URL: </b>";
279
  echo "<input type='text' name='return' value='".$value['return']."'> Optional <br />";
280
  echo "If the customer goes to PayPal and successfully pays, where are they redirected to after. Example: $siteurl/thankyou. Max length: 1,024. <br /><br />";
281
 
 
 
 
 
 
 
282
  ?>
283
  <hr>
284
 
@@ -289,48 +447,117 @@ echo "If the customer goes to PayPal and successfully pays, where are they redir
289
 
290
  </form>
291
 
 
 
 
 
 
 
 
 
 
 
 
 
 
292
  </td><td width='5%'>
293
  </td><td width='30%' valign='top'>
294
 
 
295
  <div style="background-color:#fff;padding: 5px;border: 1px solid #0074A2;">
296
 
 
 
 
297
  <center><h1><label style="color: #0074A2;">Get more sales!</label></h1></center>
298
 
299
- <center><b>Upgrade to WP eCommerce PayPal Pro</b></center>
300
 
301
- <br />
302
 
303
- Pro Features: <br />
304
- &#10004; Charge Tax <br />
 
305
  &#10004; Charge Shipping & Handling<br />
306
- &#10004; Apply a discount amount <br />
307
- &#10004; Apply a discount percentage<br />
 
 
 
 
 
 
 
 
308
  &#10004; Add a menu with different prices / options<br />
309
  &#10004; Add item weight & weight unit<br />
310
- &#10004; Add a custom button image<br />
311
- &#10004; Add an Item ID or SKU<br />
312
- &#10004; Option to disable customer note field<br />
313
- &#10004; Change text for PayPal's Return to Merchant button<br />
314
- &#10004; Change button size in shortcode<br />
315
 
316
  <br />
317
 
318
  <center><a target='_blank' href="https://wpplugin.org/wp-ecommerce-paypal/" class='button-primary'>Buy Now</a></center>
319
 
320
- </div>
321
 
322
 
 
323
 
 
324
 
325
 
326
 
 
327
 
328
- </td></tr></table>
329
 
330
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
331
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
332
 
333
 
 
 
 
334
  }
335
 
336
 
@@ -341,16 +568,16 @@ Pro Features: <br />
341
 
342
  // shortcode
343
 
344
- add_shortcode('wpecpp', 'wpecppl_options');
345
 
346
 
347
- function wpecppl_options($atts) {
348
 
349
  // get shortcode user fields
350
- $atts = shortcode_atts(array('name' => 'Example Name','price' => '0.00'), $atts);
351
 
352
  // get settings page values
353
- $options = get_option('WPeCommerceLiteoptions');
354
  foreach ($options as $k => $v ) { $value[$k] = $v; }
355
 
356
 
@@ -524,27 +751,61 @@ $imageb = "https://www.paypalobjects.com/th_TH/i/btn/btn_buynow_LG.gif";
524
  $imagecc = "https://www.paypalobjects.com/th_TH/TH/i/btn/btn_buynowCC_LG.gif";
525
  } //Thai
526
 
 
 
 
 
 
527
  if ($value['size'] == "1") { $img = $image; }
528
  if ($value['size'] == "2") { $img = $imageb; }
529
  if ($value['size'] == "3") { $img = $imagecc; }
 
 
530
 
531
  // window action
532
  if ($value['opens'] == "1") { $target = ""; }
533
  if ($value['opens'] == "2") { $target = "_blank"; }
534
 
 
 
 
 
 
 
 
 
535
  $output = "";
536
- $output .= "<form target='$target' action='https://www.$path.com/cgi-bin/webscr' method='post'>";
 
 
 
 
 
 
 
 
 
537
  $output .= "<input type='hidden' name='cmd' value='_xclick' />";
538
  $output .= "<input type='hidden' name='business' value='$account' />";
539
  $output .= "<input type='hidden' name='item_name' value='". $atts['name'] ."' />";
540
  $output .= "<input type='hidden' name='currency_code' value='$currency' />";
541
  $output .= "<input type='hidden' name='amount' value='". $atts['price'] ."' />";
 
 
 
 
 
 
 
 
 
542
  $output .= "<input type='hidden' name='lc' value='$language'>";
 
543
  $output .= "<input type='hidden' name='return' value='". $value['return'] ."' />";
544
  $output .= "<input type='hidden' name='cancel_return' value='". $value['cancel'] ."' />";
545
  $output .= "<input type='image' src='$img' border='0' name='submit' alt='Make your payments with PayPal. It is free, secure, effective.'>";
546
  $output .= "<img alt='' border='0' src='https://www.paypal.com/it_IT/i/scr/pixel.gif' width='1' height='1'>";
547
- $output .= "</form>";
548
 
549
  return $output;
550
 
7
  Author: Scott Paterson
8
  Author URI: https://wpplugin.org
9
  License: GPL2
10
+ Version: 1.1
11
  */
12
 
13
  /* Copyright 2014-2015 Scott Paterson
34
 
35
 
36
 
37
+
38
+
39
+
40
  // plugin functions
41
+ wpecpp_WPeCommerceLite::init_WPeCommerceLite();
42
 
43
+ class wpecpp_WPeCommerceLite {
44
  public static function init_WPeCommerceLite() {
45
+ register_activation_hook( __FILE__, array( __CLASS__, "wpecpp_activate" ));
46
+ register_deactivation_hook( __FILE__, array( __CLASS__, "wpecpp_deactivate" ));
47
+ register_uninstall_hook( __FILE__, array( __CLASS__, "wpecpp_uninstall" ));
48
 
49
 
50
+ $wpecpp_settingsoptions = array(
51
  'currency' => '25',
52
  'language' => '3',
53
  'liveaccount' => '',
57
  'opens' => '2',
58
  'cancel' => '',
59
  'return' => '',
60
+ 'note' => '1',
61
+ 'tax_rate' => '',
62
+ 'tax' => '',
63
+ 'weight_unit' => '1',
64
+ 'cbt' => '',
65
+ 'upload_image' => '',
66
+ 'showprice' => '1',
67
+ 'showname' => '1',
68
  );
69
 
70
+
71
+ add_option("wpecpp_settingsoptions", $wpecpp_settingsoptions);
72
  }
73
+ function wpecpp_activate() {
74
+ update_option("wpecpp_plicsence_key_status","");
75
  }
76
+ function wpecpp_deactivate() {
77
+ delete_option("wpecpp_my_plugin_notice_shown");
78
  }
79
+ function wpecpp_uninstall() {
80
+ delete_option("wpecpp_settingsoptions");
81
+ delete_option("wpecpp_plicsence_key_status");
82
+ delete_option("wpecpp_plicsence_key");
83
  }
84
  }
85
 
89
 
90
 
91
 
92
+ // display activation notice
93
 
94
+ add_action('admin_notices', 'wpecpp_my_plugin_admin_notices');
95
 
96
+ function wpecpp_my_plugin_admin_notices() {
97
+ if (!get_option('wpecpp_my_plugin_notice_shown')) {
98
+ echo "<div class='updated'><p><a href='admin.php?page=wp-ecommerce-settings'>Click here to view the plugin settings</a>.</p></div>";
99
+ update_option("wpecpp_my_plugin_notice_shown", "true");
100
+ }
 
101
  }
102
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
 
 
 
104
 
105
 
106
 
107
 
108
+ // settings page menu link
109
+ add_action( "admin_menu", "wpecpp_plugin_menu" );
110
 
111
+ function wpecpp_plugin_menu() {
112
+ add_options_page( "WP eCommerce PayPal", "WP eCommerce PayPal", "manage_options", "wp-ecommerce-settings", "wpecpp_plugin_options" );
113
+ }
114
+ add_filter('plugin_action_links', 'wpecpp_myplugin_plugin_action_links', 10, 2);
115
 
116
+ function wpecpp_myplugin_plugin_action_links($links, $file) {
117
+ static $this_plugin;
118
+ if (!$this_plugin) {
119
+ $this_plugin = plugin_basename(__FILE__);
120
+ }
121
+ if ($file == $this_plugin) {
122
+ $settings_link = '<a href="' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=wp-ecommerce-settings">Settings</a>';
123
+ array_unshift($links, $settings_link);
124
+ }
125
+ return $links;
126
+ }
127
 
128
+ function wpecpp_plugin_options() {
129
+ if ( !current_user_can( "manage_options" ) ) {
130
+ wp_die( __( "You do not have sufficient permissions to access this page." ) );
131
+ }
132
 
133
 
134
+ // manager
135
+ include_once ('manager.php');
136
+ $kstatus = get_option('wpecpp_plicsence_key_status');
137
+ if (empty($kstatus)) { $kstatus = "false"; }
138
 
139
 
140
 
141
 
 
 
 
 
 
142
 
143
+ // settings page
144
 
145
 
146
 
147
 
148
  echo "<table width='100%'><tr><td width='65%'>";
149
  echo "<h1><label style='color: #0074A2;'>WP eCommerce PayPal Settings</label></h1>";
 
150
  echo "<form method='post' action='".$_SERVER["REQUEST_URI"]."'>";
151
 
152
 
162
  $options['opens'] = $_POST['opens'];
163
  $options['cancel'] = $_POST['cancel'];
164
  $options['return'] = $_POST['return'];
165
+ $options['note'] = $_POST['note'];
166
+ $options['tax_rate'] = $_POST['tax_rate'];
167
+ $options['tax'] = $_POST['tax'];
168
+ $options['cbt'] = $_POST['cbt'];
169
+ $options['upload_image'] = $_POST['upload_image'];
170
+ $options['showprice'] = $_POST['showprice'];
171
+ $options['showname'] = $_POST['showname'];
172
 
173
 
174
+ update_option("wpecpp_settingsoptions", $options);
 
175
 
176
  echo "<br /><div class='updated'><p><strong>"; _e("Settings Updated."); echo "</strong></p></div>";
177
 
179
 
180
 
181
  // get options
182
+ $options = get_option('wpecpp_settingsoptions');
183
  foreach ($options as $k => $v ) { $value[$k] = $v; }
184
 
185
 
197
  To use this plugin, put the shortcode <b>[wpecpp name='example product name' price='6.99']</b> in your page or post anywhere you want the PayPal button to show.
198
  You can put the shortcode as many times as you want in a post or page, there is no limit.
199
 
200
+ <?php
201
+ if ($kstatus == "true") {
202
+ echo "<br /><br />";
203
+ echo "- To add a fixed discount amount to an item, add <b>discount_amount</b> to this shortcode - Example for $1.50 off: <br /><b>[wpecpp name='example product name' price='6.99' discount_amount='1.50']</b><br /><br />";
204
+ echo "- To add a percentage discount amount to an item, add <b>discount_rate</b> to this shortcode - Example for 5% discount: <br /><b>[wpecpp name='example product name' price='6.99' discount_rate ='5']</b><br /><br />";
205
+ //echo "- To add an items weight, add <b>weight</b> to this shortcode - Example for 5 lbs weight: <br /><b>[wpecpp name='example product name' price='6.99' weight ='5']</b> <br />Change units in the settings below. You can go to two decimal points.";
206
+ echo "- To add a shipping and handling charge to an item, add <b>shipping</b> to this shortcode - Example for $5.00 shipping <br /> and handling fee: <b>[wpecpp name='example product name' price='6.99' shipping ='5']</b><br /><br />";
207
+ echo "- To add an item id / SKU to an item, add <b>item_id</b> to this shortcode - Example for item id 1234 <br /> and handling fee: <b>[wpecpp name='example product name' price='6.99' item_id ='1234']</b><br /><br />";
208
+ echo "- To set a Buy Now button size per button, add <b>size</b> to this shortcode. Use 1 for small, 2 for normal, and 3 for normal with credit card logos. - Example for size small: <b>[wpecpp name='example product name' price='6.99' size='1']</b><br /><br />";
209
+ }
210
+ ?>
211
+
212
+
213
  <br /><br /><hr>
214
+
215
+
216
  <h3><label style="color: #0074A2;">Language & Currency</label></h3>
217
 
218
  <b>Language:</b>
296
 
297
 
298
 
299
+ if ($kstatus == "true") {
300
+
301
+ echo "<h3><label style='color: #0074A2;'>Tax Settings</label></h3>";
302
+
303
+ echo "<b>Tax Fixed Amount: </b>";
304
+ echo "<input type='text' name='tax' value='".$value['tax']."'> Optional <br />";
305
+ echo "Set a fixed amount, for example for $0.70 tax, enter .70 <br /><br />";
306
+
307
+
308
+ echo "<b>Tax Rate (Percentage) Amount: </b>";
309
+ echo "<input type='text' name='tax_rate' value='".$value['tax_rate']."'> Optional <br />";
310
+ echo "Set a tax rate, for example for 2.5% tax, enter 2.5 <br /><br />";
311
+
312
+
313
+ echo "<hr>";
314
+
315
+
316
+ }
317
+
318
+
319
+
320
+
321
  echo "<h3><label style='color: #0074A2;'>Other</label></h3>";
322
 
323
  echo "<table><tr><td valign='top'>";
 
 
 
 
324
 
325
+
326
+
327
+ if ($kstatus == "true") {
328
+ echo "<b>Show Price beside button:</b></td>";
329
+ echo "<td><input "; if ($value['showprice'] == "1") { echo "checked='checked'"; } echo " type='radio' name='showprice' value='1'>Show</td>";
330
+ echo "<td><input "; if ($value['showprice'] == "2") { echo "checked='checked'"; } echo " type='radio' name='showprice' value='2'>Hide</td></tr><tr><td>";
331
+
332
+ echo "<b>Show Name beside button:</b></td>";
333
+ echo "<td><input "; if ($value['showname'] == "1") { echo "checked='checked'"; } echo " type='radio' name='showname' value='1'>Show</td>";
334
+ echo "<td><input "; if ($value['showname'] == "2") { echo "checked='checked'"; } echo " type='radio' name='showname' value='2'>Hide</td></tr><tr><td>";
335
+ }
336
+
337
+
338
+
339
+
340
+ echo "<b>Button Size and type:</b></td><td valign='top' style='text-align: center;'>";
341
+ echo "<input "; if ($value['size'] == "1") { echo "checked='checked'"; } echo " type='radio' name='size' value='1'>Small <br /><img src='https://www.paypalobjects.com/en_US/i/btn/btn_buynow_SM.gif'></td><td valign='top' style='text-align: center;'>";
342
+ echo "<input "; if ($value['size'] == "2") { echo "checked='checked'"; } echo " type='radio' name='size' value='2'>Big <br /><img src='https://www.paypalobjects.com/en_US/i/btn/btn_buynow_LG.gif'></td><td valign='top' style='text-align: center;'>";
343
+ echo "<input "; if ($value['size'] == "3") { echo "checked='checked'"; } echo " type='radio' name='size' value='3'>Big with credit cards <br /><img src='https://www.paypalobjects.com/en_US/i/btn/btn_buynowCC_LG.gif'></td><td valign='top' style='text-align: center;'>";
344
+
345
+ if ($kstatus == "true") {
346
+ echo "<input "; if ($value['size'] == "4") { echo "checked='checked'"; } echo " type='radio' name='size' value='4'>";
347
+ ?>
348
+ Custom Image:
349
+ <input id="upload_image" type="text" size="1" name="upload_image" value="<?php echo $value['upload_image']; ?>" style="display: none;">
350
+ <input id="upload_image_button" type="button" value="Upload Image">
351
+
352
+
353
+ <?php
354
+
355
+ function wpecpp_my_admin_scripts() {
356
+ wp_enqueue_script('media-upload');
357
+ wp_enqueue_script('thickbox');
358
+ wp_register_script('my-upload', WP_PLUGIN_URL.'/my-script.js', array('jquery','media-upload','thickbox'));
359
+ wp_enqueue_script('my-upload');
360
+ }
361
+
362
+ function wpecpp_my_admin_styles() {
363
+ wp_enqueue_style('thickbox');
364
+ }
365
+
366
+ if (isset($_GET['page']) && $_GET['page'] == 'my_plugin_page') {
367
+ add_action('admin_print_scripts', 'wpecpp_my_admin_scripts');
368
+ add_action('admin_print_styles', 'wpecpp_my_admin_styles');
369
+ }
370
+
371
+ ?>
372
+
373
+ <script>
374
+ jQuery(document).ready(function() {
375
+
376
+ jQuery('#upload_image_button').click(function() {
377
+ formfield = jQuery('#upload_image').attr('name');
378
+ tb_show('', 'media-upload.php?type=image&amp;TB_iframe=true');
379
+ return false;
380
+ });
381
+
382
+ window.send_to_editor = function(html) {
383
+ imgurl = jQuery('img',html).attr('src');
384
+ jQuery('#upload_image').val(imgurl);
385
+ tb_remove();
386
+ }
387
+
388
+ })
389
+ </script>
390
+
391
+
392
+
393
+
394
+
395
+
396
+
397
+
398
+
399
+
400
+
401
+
402
+
403
+ <?php
404
+ }
405
+
406
+ echo "</td></tr><tr><td><b>PayPal opens in:</b></td>";
407
+ echo "<td><input "; if ($value['opens'] == "1") { echo "checked='checked'"; } echo " type='radio' name='opens' value='1'>Same page</td>";
408
+ echo "<td><input "; if ($value['opens'] == "2") { echo "checked='checked'"; } echo " type='radio' name='opens' value='2'>New page</td></tr>";
409
+
410
+ if ($kstatus == "true") {
411
+ echo "<tr><td><b>Customer custom note field in PayPal:</b></td>";
412
+ echo "<td><input "; if ($value['note'] == "1") { echo "checked='checked'"; } echo " type='radio' name='note' value='1'>Show</td>";
413
+ echo "<td><input "; if ($value['note'] == "2") { echo "checked='checked'"; } echo " type='radio' name='note' value='2'>Hide</td></tr>";
414
+
415
+ //echo "<tr><td><b>Shipping Weight Unit:</b></td>";
416
+ //echo "<td><input "; if ($value['weight_unit'] == "1") { echo "checked='checked'"; } echo " type='radio' name='weight_unit' value='1'>Lbs - Pounds</td>";
417
+ //echo "<td><input "; if ($value['weight_unit'] == "2") { echo "checked='checked'"; } echo " type='radio' name='weight_unit' value='2'>Kgs - Kilograms</td></tr>";
418
+ }
419
+
420
+ echo "</table><br /><br />";
421
+
422
 
423
 
424
  $siteurl = get_site_url();
431
  echo "<input type='text' name='return' value='".$value['return']."'> Optional <br />";
432
  echo "If the customer goes to PayPal and successfully pays, where are they redirected to after. Example: $siteurl/thankyou. Max length: 1,024. <br /><br />";
433
 
434
+ if ($kstatus == "true") {
435
+ echo "<b>Return to merchant button text: </b>";
436
+ echo "<input type='text' name='cbt' value='".$value['cbt']."'> Optional <br />";
437
+ echo "Sets the text for the Return to Merchant button on the PayPal Payment Complete page. <b> Note: (per PayPal) this only takes effect if the Return URL is set.</b> Max length: 60. <br /><br />";
438
+ }
439
+
440
  ?>
441
  <hr>
442
 
447
 
448
  </form>
449
 
450
+
451
+
452
+
453
+
454
+
455
+
456
+
457
+
458
+
459
+
460
+
461
+
462
+
463
  </td><td width='5%'>
464
  </td><td width='30%' valign='top'>
465
 
466
+
467
  <div style="background-color:#fff;padding: 5px;border: 1px solid #0074A2;">
468
 
469
+
470
+ <?php if ($kstatus == "false") { ?>
471
+
472
  <center><h1><label style="color: #0074A2;">Get more sales!</label></h1></center>
473
 
474
+ <center><b>Upgrade to WP eCommerce PayPal Plus</b></center>
475
 
476
+ <br />
477
 
478
+ Plus Features: <br />
479
+ &#10004; Charge Fixed Tax <br />
480
+ &#10004; Charge Tax Rate <br />
481
  &#10004; Charge Shipping & Handling<br />
482
+ &#10004; Show Price Beside Button <br />
483
+ &#10004; Show Name Beside Button <br />
484
+ &#10004; Apply a Fixed Discount <br />
485
+ &#10004; Apply a Discount Rate<br />
486
+ &#10004; Add an Item ID or SKU<br />
487
+ &#10004; Hide Customer's Custom Note Field<br />
488
+ &#10004; Change PayPal's Return to Merchant Text<br />
489
+ &#10004; Each Button Can Have Its Own Size<br />
490
+ &#10004; Add a Custom Button Image<br />
491
+ <!---
492
  &#10004; Add a menu with different prices / options<br />
493
  &#10004; Add item weight & weight unit<br />
494
+ --->
 
 
 
 
495
 
496
  <br />
497
 
498
  <center><a target='_blank' href="https://wpplugin.org/wp-ecommerce-paypal/" class='button-primary'>Buy Now</a></center>
499
 
 
500
 
501
 
502
+ <br />
503
 
504
+ <div style="border-top: 1px solid #0074A2;"></div>
505
 
506
 
507
 
508
+ <?php } ?>
509
 
 
510
 
511
 
512
+
513
+ <form method="post" action="">
514
+ <table style="width:100%;">
515
+ <thead><tr><th colspan="2" align="left">
516
+ <?php
517
+
518
+ if ($kstatus == "true") {
519
+ echo '<center><b>Your license key is:</b></center>';
520
+ $buttonvalue = "Change";
521
+ } else {
522
+ echo '<center><b>If you have a license key, enter it here:</b></center>';
523
+ $buttonvalue = "Activate";
524
+ }
525
+
526
+ ?>
527
+ </th></tr></thead>
528
+ <tbody>
529
+ <tr>
530
+ <td>
531
+ <input class="textfield" name="wpecpp_plicsence_key" size="25" type="text" id="wpecpp_plicsence_key" value="<?php echo get_option('wpecpp_plicsence_key'.PLICENSE_PRODUCT_NAME); ?>" />
532
+ &nbsp; <input type="submit" value="<?php echo $buttonvalue; ?>" class="button-primary" id="plicense_activate" name="plicense_activate">&nbsp;&nbsp;&nbsp;
533
  <?php
534
+ echo "<center>";
535
+ switch (get_option('wpecpp_plicsence_key_status')) {
536
+ case 'true': echo '<span style="color:green;">License key is active.</span>'; break;
537
+ case 'false': echo '<span style="color:red;">License key is not valid.</span>'; break;
538
+ case 'pending': echo '<span style="color:red;">License key is pending.</span>'; break;
539
+ case 'expired': echo '<span style="color:red;">License key is expired.</span>'; break;
540
+ }
541
+ ?>
542
+ </center>
543
+ </td>
544
+ </tr>
545
+ </tbody>
546
+ </table>
547
+ </form>
548
+
549
+ </div>
550
+
551
+
552
+
553
+
554
+
555
+ </td></tr></table>
556
 
557
 
558
+ <?php
559
+
560
+ // end settings page and required permissions
561
  }
562
 
563
 
568
 
569
  // shortcode
570
 
571
+ add_shortcode('wpecpp', 'wpecpp_options');
572
 
573
 
574
+ function wpecpp_options($atts) {
575
 
576
  // get shortcode user fields
577
+ $atts = shortcode_atts(array('name' => 'Example Name','price' => '0.00','discount_rate' => '','discount_amount' => '','weight' => '','shipping' => '','item_id' => '','size' => ''), $atts);
578
 
579
  // get settings page values
580
+ $options = get_option('wpecpp_settingsoptions');
581
  foreach ($options as $k => $v ) { $value[$k] = $v; }
582
 
583
 
751
  $imagecc = "https://www.paypalobjects.com/th_TH/TH/i/btn/btn_buynowCC_LG.gif";
752
  } //Thai
753
 
754
+ if (!empty($atts['size'])) {
755
+ if ($atts['size'] == "1") { $img = $image; }
756
+ if ($atts['size'] == "2") { $img = $imageb; }
757
+ if ($atts['size'] == "3") { $img = $imagecc; }
758
+ } else {
759
  if ($value['size'] == "1") { $img = $image; }
760
  if ($value['size'] == "2") { $img = $imageb; }
761
  if ($value['size'] == "3") { $img = $imagecc; }
762
+ if ($value['size'] == "4") { $img = $value['upload_image']; }
763
+ }
764
 
765
  // window action
766
  if ($value['opens'] == "1") { $target = ""; }
767
  if ($value['opens'] == "2") { $target = "_blank"; }
768
 
769
+ // note action
770
+ if ($value['note'] == "1") { $note = "0"; }
771
+ if ($value['note'] == "2") { $note = "1"; }
772
+
773
+ // weight unit
774
+ if ($value['weight_unit'] == "1") { $weight_unit = "lbs"; }
775
+ if ($value['weight_unit'] == "2") { $weight_unit = "kgs"; }
776
+
777
  $output = "";
778
+ $output .= "<table><tr>";
779
+ if ($kstatus == "true") {
780
+ if ($value['showname'] == "1") {
781
+ $output .= "<td colspan='2'><label>". $atts['name'] ."</label></td></tr><tr>";
782
+ }
783
+ if ($value['showprice'] == "1") {
784
+ $output .= "<td><label>". $atts['price'] ."</label> &nbsp;</td>";
785
+ }
786
+ }
787
+ $output .= "<td><form target='$target' action='https://www.$path.com/cgi-bin/webscr' method='post'>";
788
  $output .= "<input type='hidden' name='cmd' value='_xclick' />";
789
  $output .= "<input type='hidden' name='business' value='$account' />";
790
  $output .= "<input type='hidden' name='item_name' value='". $atts['name'] ."' />";
791
  $output .= "<input type='hidden' name='currency_code' value='$currency' />";
792
  $output .= "<input type='hidden' name='amount' value='". $atts['price'] ."' />";
793
+ $output .= "<input type='hidden' name='tax' value='". $value['tax'] ."' />";
794
+ $output .= "<input type='hidden' name='tax_rate' value='". $value['tax_rate'] ."' />";
795
+ $output .= "<input type='hidden' name='weight' value='". $atts['weight'] ."' />";
796
+ $output .= "<input type='hidden' name='weight_unit' value='$weight_unit' />";
797
+ $output .= "<input type='hidden' name='discount_amount' value='". $atts['discount_amount'] ."' />";
798
+ $output .= "<input type='hidden' name='discount_rate' value='". $atts['discount_rate'] ."' />";
799
+ $output .= "<input type='hidden' name='cbt' value='". $value['cbt'] ."' />";
800
+ $output .= "<input type='hidden' name='shipping' value='". $atts['shipping'] ."' />";
801
+ $output .= "<input type='hidden' name='item_number' value='". $atts['item_id'] ."' />";
802
  $output .= "<input type='hidden' name='lc' value='$language'>";
803
+ $output .= "<input type='hidden' name='no_note' value='$note'>";
804
  $output .= "<input type='hidden' name='return' value='". $value['return'] ."' />";
805
  $output .= "<input type='hidden' name='cancel_return' value='". $value['cancel'] ."' />";
806
  $output .= "<input type='image' src='$img' border='0' name='submit' alt='Make your payments with PayPal. It is free, secure, effective.'>";
807
  $output .= "<img alt='' border='0' src='https://www.paypal.com/it_IT/i/scr/pixel.gif' width='1' height='1'>";
808
+ $output .= "</form></td></tr></table>";
809
 
810
  return $output;
811