WP eCommerce - Version 3.8.Public.Beta.3

Version Description

Download this release

Release Info

Developer valentinas
Plugin Icon 128x128 WP eCommerce
Version 3.8.Public.Beta.3
Comparing to
See all releases

Code changes from version 3.8.Public.Beta.2 to 3.8.Public.Beta.3

Files changed (58) hide show
  1. readme.txt +118 -118
  2. wp-shopping-cart.php +166 -157
  3. wpsc-admin/admin-form-functions.php +48 -16
  4. wpsc-admin/admin.php +235 -196
  5. wpsc-admin/ajax-and-init.php +2049 -2473
  6. wpsc-admin/css/admin.css +1750 -1803
  7. wpsc-admin/css/settingspage.css +2 -2
  8. wpsc-admin/display-coupons.php +0 -1
  9. wpsc-admin/display-groups.page.php +2 -536
  10. wpsc-admin/display-items.page.php +363 -610
  11. wpsc-admin/display-options-settings.page.php +1 -1
  12. wpsc-admin/display-sales-logs.php +2 -2
  13. wpsc-admin/display-update.page.php +97 -98
  14. wpsc-admin/display-upgrades.page.php +156 -156
  15. wpsc-admin/display-variations.page.php +240 -240
  16. wpsc-admin/includes/display-items-functions.php +631 -1223
  17. wpsc-admin/includes/product-functions.php +263 -277
  18. wpsc-admin/includes/products.php +419 -534
  19. wpsc-admin/includes/purchlogs_upgrade.php +1 -1
  20. wpsc-admin/includes/save-data.functions.php +650 -265
  21. wpsc-admin/includes/settings-pages/admin.php +5 -5
  22. wpsc-admin/includes/settings-pages/checkout.php +20 -38
  23. wpsc-admin/includes/settings-pages/gateway.php +6 -6
  24. wpsc-admin/includes/settings-pages/general.php +1 -1
  25. wpsc-admin/includes/settings-pages/import.php +1 -1
  26. wpsc-admin/includes/settings-pages/marketing.php +1 -1
  27. wpsc-admin/includes/settings-pages/presentation.php +84 -22
  28. wpsc-admin/includes/settings-pages/shipping.php +17 -7
  29. wpsc-admin/includes/settings-pages/taxes.php +188 -183
  30. wpsc-admin/includes/tax_and_shipping.php +1 -1
  31. wpsc-admin/includes/updating-functions.php +590 -590
  32. wpsc-admin/js/admin.js +1067 -1359
  33. wpsc-admin/js/jquery.livequery.js +250 -250
  34. wpsc-admin/js/variations.js +7 -1
  35. wpsc-admin/js/wpsc-swfupload-handlers.js +362 -362
  36. wpsc-core/images/cb_controls.png +0 -0
  37. wpsc-core/images/cb_loading.gif +0 -0
  38. wpsc-core/js/jquery.colorbox-min.js +3 -3
  39. wpsc-core/js/jquery.infieldlabel.min.js +2 -2
  40. wpsc-core/js/wp-e-commerce.js +76 -5
  41. wpsc-core/js/wpsc_colorbox.css +2 -2
  42. wpsc-core/wpsc-constants.php +2 -2
  43. wpsc-core/wpsc-deprecated.php +356 -2
  44. wpsc-core/wpsc-functions.php +121 -17
  45. wpsc-core/wpsc-installer.php +11 -4
  46. wpsc-includes/ajax.functions.php +16 -11
  47. wpsc-includes/breadcrumbs.class.php +6 -2
  48. wpsc-includes/cart.class.php +11 -6
  49. wpsc-includes/category.functions.php +23 -13
  50. wpsc-includes/checkout.class.php +16 -25
  51. wpsc-includes/coupons.class.php +2 -0
  52. wpsc-includes/display.functions.php +426 -419
  53. wpsc-includes/form-display.functions.php +23 -23
  54. wpsc-includes/fpdf/font/desktop.ini +4 -4
  55. wpsc-includes/merchant.class.php +24 -2
  56. wpsc-includes/misc.functions.php +14 -22
  57. wpsc-includes/processing.functions.php +391 -392
  58. wpsc-includes/product-template.php +1047 -1705
readme.txt CHANGED
@@ -1,118 +1,118 @@
1
- === WP e-Commerce ===
2
- Contributors: Dan Milward, Tom Howard, Jeffry Ghazally, Chris Beavan, Allen Han
3
- Donate link: http://www.instinct.co.nz/e-commerce
4
- Tags: e-commerce, shop, cart, dropshop, ajax, web2.0, paypal, authorize, exchange, stock control, ecommerce
5
- Requires at least: 2.7
6
- Tested up to: 2.9
7
- Stable tag: 3.7.5.3
8
-
9
- WP e-Commerce is a Web 2.0 application designed with usability, aesthetics, and presentation in mind.
10
-
11
- == Description ==
12
-
13
- The WP e-Commerce shopping cart plugin for WordPress is an elegant easy to use fully featured shopping cart application suitable for selling your products, services, and or fees online.
14
-
15
- WP e-Commerce is a Web 2.0 application designed with usability, aesthetics, and presentation in mind.
16
-
17
- Perfect for:
18
-
19
- * Bands & Record Labels
20
- * Clothing Companies
21
- * Crafters & Artists
22
- * Books, DVDs & MP3 files
23
-
24
- == Installation ==
25
-
26
- 1. Upload the folder 'wp-e-commerce' to the '/wp-content/plugins/' directory
27
- 2. Activate the plugin through the 'Plugins' menu in WordPress
28
-
29
- = Updating =
30
-
31
- Simply copy the new files across and replace the old files saving saving ones you've modified. If you have product images uploaded then do not overwrite the product_images folder or images folder. If you have downloadable products for sale do not overwrite the files folder.
32
-
33
- When updating it is important that you do not overwrite the entire images folder. Instead you should copy over the contents of the new images folder into the existing images folder on your server - saving all the exiting product images you may have already uploaded.
34
-
35
- If you experience database errors try de-activating and re-activating your plugin.
36
-
37
-
38
- == Changelog ==
39
-
40
- = 3.7.5.3 =
41
- * Support for WordPress 2.9 canonical URLs for Products and Categories
42
-
43
- = 3.7.5.2 =
44
- * More Fixes to the Paypal Pro merchant file
45
- * Image thumbnail size fixes
46
- * Updated readme to mark plugin as working with 2.9
47
- * Purchase log filtering bug fixed
48
- * Fix for a bug when no shipping module is used where the shipping country and region were not being changed
49
- * Remove button on checkout page now clears stock claims
50
-
51
- = 3.7.5.1 =
52
- * Fixes to the Paypal Pro merchant file
53
- * Fixes to the Paypal Express Checkout merchant file
54
- * Tracking email improvements
55
- * HTML in descriptions does not break RSS (thanks to http://www.leewillis.co.uk)
56
- * Category permalinks will now be regenerated properly on instalation
57
- * Category list bug preventing viewing a product when viewing a category fixed.
58
-
59
-
60
- = 3.7.5 =
61
- * Added code for upgrades/additions from nielo.info and lsdev.biz, we will be using this for new modules in the future.
62
- * All In One SEO Pack compatibility bugfixes and improvements.
63
- * CSV has had some work done on it, it now takes larger files, and associates a CSV file to a single category of your choice. We'd love to be able to allow users to add the categories and images as part of the CSV file. We will look into it more at a later date.
64
- * SSL we fixed the image issue from beta1 and used James Collis recommended fix (using is_ssl() for our conditions) Thanks James!
65
- * �Show list of Product Groups� shows all Groups <- there may be some backwards compatibility issues (we havent encountered any but nevertheless if you spot any let us know)
66
- * When duplicating products, their tags do not get duplicated for the new product. <- Oh yes they DO!
67
- * Google Checkout now sends off Discount Coupons As well. And we fixed the `name` vs `code` Issue people mentioned in the forum
68
- * Category shortcode backwards compatibility
69
- * Fix Purchlogs - We had a lot of users that somehow by passed the 'fix purchase logs' page when upgrading from 3.6, so we added some better conditions to the mix and added it on to the debug page (a powerful wp-e-commerce page that is hidden from most users as it's usage is very corrosive backing up your DB and files is strongly recommended if not necessary when you work with this page).
70
- * Valid XHTML for front end of wpec YAY!
71
- * Fixed adding variations when adding products
72
- * Sender from the 'resend email to buyer' link on the purchase log details page has been fixed
73
- * Shipping Discount Bug that stopped shipping working at all.
74
- * Categories Widget has had numerous changes �
75
- * Better MU support.
76
- * Canadian Tax � Fixes
77
- * US Tax �Fixes
78
- * Product Categories Caching Issue Resolved
79
- * Coupons � �Apply to all Products� and numerous bug fixes
80
- * �Your Account� done some fixes to it.
81
- * �Accepted Payment� goes straight to �Closed Order�
82
- * Stock claims are now cleared when the cart is emptied
83
- * Purchase log bulk actions now work
84
- * PayPal gateway module fixes and improvements
85
- * HTML Tables can now be added to product descriptions
86
- * Flat Rate and Weight Rate improvements
87
-
88
-
89
- = 3.7.4 =
90
- * Changes to shipping to fix the bugs from 3.7.3 with shipping and the new shipping_discount feature
91
- * Fixes for variations under grid view
92
-
93
-
94
- == Frequently Asked Questions ==
95
-
96
- = Where do I find DropShop and Grid View =
97
-
98
- From the BlogShop of course http://www.instinct.co.nz/shop/
99
-
100
- = How do I customize WP e-Commerce =
101
-
102
- First of all you should check out the presentation settings which are in the Shop Options page.
103
-
104
- Advanced users can edit the CSS (and do just about anything). Not so advanced users can contact Instinct and either purchase professional support.
105
-
106
- == Screenshots ==
107
-
108
- We're taking this one step further.
109
-
110
- Check out our flickr guides online
111
- www.flickr.com/photos/danmilward/sets/72157594425079473/detail/
112
-
113
- == Readme Validator ==
114
-
115
- This readme was made using:
116
- wordpress.org/extend/plugins/about/validator/
117
-
118
- Totally totally cool tool!!
1
+ === WP e-Commerce ===
2
+ Contributors: Dan Milward, Tom Howard, Jeffry Ghazally, Chris Beavan, Allen Han
3
+ Donate link: http://www.instinct.co.nz/e-commerce
4
+ Tags: e-commerce, shop, cart, dropshop, ajax, web2.0, paypal, authorize, exchange, stock control, ecommerce
5
+ Requires at least: 2.7
6
+ Tested up to: 2.9
7
+ Stable tag: 3.7.5.3
8
+
9
+ WP e-Commerce is a Web 2.0 application designed with usability, aesthetics, and presentation in mind.
10
+
11
+ == Description ==
12
+
13
+ The WP e-Commerce shopping cart plugin for WordPress is an elegant easy to use fully featured shopping cart application suitable for selling your products, services, and or fees online.
14
+
15
+ WP e-Commerce is a Web 2.0 application designed with usability, aesthetics, and presentation in mind.
16
+
17
+ Perfect for:
18
+
19
+ * Bands & Record Labels
20
+ * Clothing Companies
21
+ * Crafters & Artists
22
+ * Books, DVDs & MP3 files
23
+
24
+ == Installation ==
25
+
26
+ 1. Upload the folder 'wp-e-commerce' to the '/wp-content/plugins/' directory
27
+ 2. Activate the plugin through the 'Plugins' menu in WordPress
28
+
29
+ = Updating =
30
+
31
+ Simply copy the new files across and replace the old files saving saving ones you've modified. If you have product images uploaded then do not overwrite the product_images folder or images folder. If you have downloadable products for sale do not overwrite the files folder.
32
+
33
+ When updating it is important that you do not overwrite the entire images folder. Instead you should copy over the contents of the new images folder into the existing images folder on your server - saving all the exiting product images you may have already uploaded.
34
+
35
+ If you experience database errors try de-activating and re-activating your plugin.
36
+
37
+
38
+ == Changelog ==
39
+
40
+ = 3.7.5.3 =
41
+ * Support for WordPress 2.9 canonical URLs for Products and Categories
42
+
43
+ = 3.7.5.2 =
44
+ * More Fixes to the Paypal Pro merchant file
45
+ * Image thumbnail size fixes
46
+ * Updated readme to mark plugin as working with 2.9
47
+ * Purchase log filtering bug fixed
48
+ * Fix for a bug when no shipping module is used where the shipping country and region were not being changed
49
+ * Remove button on checkout page now clears stock claims
50
+
51
+ = 3.7.5.1 =
52
+ * Fixes to the Paypal Pro merchant file
53
+ * Fixes to the Paypal Express Checkout merchant file
54
+ * Tracking email improvements
55
+ * HTML in descriptions does not break RSS (thanks to http://www.leewillis.co.uk)
56
+ * Category permalinks will now be regenerated properly on instalation
57
+ * Category list bug preventing viewing a product when viewing a category fixed.
58
+
59
+
60
+ = 3.7.5 =
61
+ * Added code for upgrades/additions from nielo.info and lsdev.biz, we will be using this for new modules in the future.
62
+ * All In One SEO Pack compatibility bugfixes and improvements.
63
+ * CSV has had some work done on it, it now takes larger files, and associates a CSV file to a single category of your choice. We'd love to be able to allow users to add the categories and images as part of the CSV file. We will look into it more at a later date.
64
+ * SSL we fixed the image issue from beta1 and used James Collis recommended fix (using is_ssl() for our conditions) Thanks James!
65
+ * �Show list of Product Groups� shows all Groups <- there may be some backwards compatibility issues (we havent encountered any but nevertheless if you spot any let us know)
66
+ * When duplicating products, their tags do not get duplicated for the new product. <- Oh yes they DO!
67
+ * Google Checkout now sends off Discount Coupons As well. And we fixed the `name` vs `code` Issue people mentioned in the forum
68
+ * Category shortcode backwards compatibility
69
+ * Fix Purchlogs - We had a lot of users that somehow by passed the 'fix purchase logs' page when upgrading from 3.6, so we added some better conditions to the mix and added it on to the debug page (a powerful wp-e-commerce page that is hidden from most users as it's usage is very corrosive backing up your DB and files is strongly recommended if not necessary when you work with this page).
70
+ * Valid XHTML for front end of wpec YAY!
71
+ * Fixed adding variations when adding products
72
+ * Sender from the 'resend email to buyer' link on the purchase log details page has been fixed
73
+ * Shipping Discount Bug that stopped shipping working at all.
74
+ * Categories Widget has had numerous changes �
75
+ * Better MU support.
76
+ * Canadian Tax � Fixes
77
+ * US Tax �Fixes
78
+ * Product Categories Caching Issue Resolved
79
+ * Coupons � �Apply to all Products� and numerous bug fixes
80
+ * �Your Account� done some fixes to it.
81
+ * �Accepted Payment� goes straight to �Closed Order�
82
+ * Stock claims are now cleared when the cart is emptied
83
+ * Purchase log bulk actions now work
84
+ * PayPal gateway module fixes and improvements
85
+ * HTML Tables can now be added to product descriptions
86
+ * Flat Rate and Weight Rate improvements
87
+
88
+
89
+ = 3.7.4 =
90
+ * Changes to shipping to fix the bugs from 3.7.3 with shipping and the new shipping_discount feature
91
+ * Fixes for variations under grid view
92
+
93
+
94
+ == Frequently Asked Questions ==
95
+
96
+ = Where do I find DropShop and Grid View =
97
+
98
+ From the BlogShop of course http://www.instinct.co.nz/shop/
99
+
100
+ = How do I customize WP e-Commerce =
101
+
102
+ First of all you should check out the presentation settings which are in the Shop Options page.
103
+
104
+ Advanced users can edit the CSS (and do just about anything). Not so advanced users can contact Instinct and either purchase professional support.
105
+
106
+ == Screenshots ==
107
+
108
+ We're taking this one step further.
109
+
110
+ Check out our flickr guides online
111
+ www.flickr.com/photos/danmilward/sets/72157594425079473/detail/
112
+
113
+ == Readme Validator ==
114
+
115
+ This readme was made using:
116
+ wordpress.org/extend/plugins/about/validator/
117
+
118
+ Totally totally cool tool!!
wp-shopping-cart.php CHANGED
@@ -1,157 +1,166 @@
1
- <?php
2
-
3
- /*
4
- Plugin Name: WP e-Commerce
5
- Plugin URI: http://getshopped.org/
6
- Description: A plugin that provides a WordPress Shopping Cart. See also: <a href="http://getshopped.org" target="_blank">GetShopped.org</a> | <a href="http://getshopped.org/forums/" target="_blank">Support Forum</a> | <a href="http://getshopped.org/resources/docs/" target="_blank">Documentation</a>
7
- Version: 3.8 Development
8
- Author: Instinct Entertainment
9
- Author URI: http://getshopped.org/
10
- */
11
-
12
- /**
13
- * WP_eCommerce
14
- *
15
- * Main WPEC Plugin Class
16
- *
17
- * @package wp-e-commerce
18
- */
19
- class WP_eCommerce {
20
-
21
- /**
22
- * Start WPEC on plugins loaded
23
- */
24
- function WP_eCommerce() {
25
- add_action( 'plugins_loaded', array( $this, 'init' ), 8 );
26
- }
27
-
28
- /**
29
- * Takes care of loading up WPEC
30
- */
31
- function init() {
32
- // Previous to initializing
33
- do_action( 'wpsc_pre_init' );
34
-
35
- // Initialize
36
- $this->start();
37
- $this->constants();
38
- $this->includes();
39
- $this->load();
40
-
41
- // Finished initializing
42
- do_action( 'wpsc_init' );
43
- }
44
-
45
- /**
46
- * Initialize the basic WPEC constants
47
- */
48
- function start() {
49
- // Set the core file path
50
- define( 'WPSC_FILE_PATH', dirname( __FILE__ ) );
51
-
52
- // Define the path to the plugin folder
53
- define( 'WPSC_DIR_NAME', basename( WPSC_FILE_PATH ) );
54
-
55
- // Define the URL to the plugin folder
56
- define( 'WPSC_FOLDER', dirname( plugin_basename( __FILE__ ) ) );
57
- define( 'WPSC_URL', plugins_url( '', __FILE__ ) );
58
-
59
- // Finished starting
60
- do_action( 'wpsc_started' );
61
- }
62
-
63
- /**
64
- * Setup the WPEC core constants
65
- */
66
- function constants() {
67
- // Define globals and constants used by wp-e-commerce
68
- require_once( WPSC_FILE_PATH . '/wpsc-core/wpsc-constants.php' );
69
-
70
- // Load the WPEC core constants
71
- wpsc_core_constants();
72
-
73
- // Is WordPress Multisite
74
- wpsc_core_is_multisite();
75
-
76
- // Start the wpsc session
77
- wpsc_core_load_session();
78
-
79
- // Which version of WPEC
80
- wpsc_core_constants_version_processing();
81
-
82
- // WPEC Table names and related constants
83
- wpsc_core_constants_table_names();
84
-
85
- // Uploads directory info
86
- wpsc_core_constants_uploads();
87
-
88
- // Any additional constants can hook in here
89
- do_action( 'wpsc_constants' );
90
- }
91
-
92
- /**
93
- * Include the rest of WPEC's files
94
- */
95
- function includes() {
96
- require_once( WPSC_FILE_PATH . '/wpsc-core/wpsc-functions.php' );
97
- require_once( WPSC_FILE_PATH . '/wpsc-core/wpsc-installer.php' );
98
- require_once( WPSC_FILE_PATH . '/wpsc-core/wpsc-includes.php' );
99
-
100
- // Any additional file includes can hook in here
101
- do_action( 'wpsc_includes' );
102
- }
103
-
104
- /**
105
- * Setup the WPEC core
106
- */
107
- function load() {
108
- // Before setup
109
- do_action( 'wpsc_pre_load' );
110
-
111
- // Legacy action
112
- do_action( 'wpsc_before_init' );
113
-
114
- // Setup the core WPEC globals
115
- wpsc_core_setup_globals();
116
-
117
- // Setup the core WPEC cart
118
- wpsc_core_setup_cart();
119
-
120
- // Load the thumbnail sizes
121
- wpsc_core_load_thumbnail_sizes();
122
-
123
- // Load the purchase log statuses
124
- wpsc_core_load_purchase_log_statuses();
125
-
126
- // Load the gateways
127
- wpsc_core_load_gateways();
128
-
129
- // Load the shipping modules
130
- wpsc_core_load_shipping_modules();
131
-
132
- // Set page title array for important WPSC pages
133
- wpsc_core_load_page_titles();
134
-
135
- // WPEC is fully loaded
136
- do_action( 'wpsc_loaded' );
137
- }
138
-
139
- /**
140
- * WPEC Activation Hook
141
- */
142
- function install() {
143
- define( 'WPSC_FILE_PATH', dirname( __FILE__ ) );
144
- require_once( WPSC_FILE_PATH . '/wpsc-core/wpsc-installer.php' );
145
- $this->constants();
146
- wpsc_install();
147
-
148
- }
149
- }
150
-
151
- // Start WPEC
152
- $wpec = new WP_eCommerce();
153
-
154
- // Activation
155
- register_activation_hook( __FILE__, array( $wpec, 'install' ) );
156
-
157
- ?>
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ Plugin Name: WP e-Commerce
5
+ Plugin URI: http://getshopped.org/
6
+ Description: A plugin that provides a WordPress Shopping Cart. See also: <a href="http://getshopped.org" target="_blank">GetShopped.org</a> | <a href="http://getshopped.org/forums/" target="_blank">Support Forum</a> | <a href="http://getshopped.org/resources/docs/" target="_blank">Documentation</a>
7
+ Version: 3.8 Development
8
+ Author: Instinct Entertainment
9
+ Author URI: http://getshopped.org/
10
+ */
11
+
12
+ /**
13
+ * WP_eCommerce
14
+ *
15
+ * Main WPEC Plugin Class
16
+ *
17
+ * @package wp-e-commerce
18
+ */
19
+ class WP_eCommerce {
20
+
21
+ /**
22
+ * Start WPEC on plugins loaded
23
+ */
24
+ function WP_eCommerce() {
25
+ add_action( 'plugins_loaded', array( $this, 'init' ), 8 );
26
+ }
27
+
28
+ /**
29
+ * Takes care of loading up WPEC
30
+ */
31
+ function init() {
32
+ // Previous to initializing
33
+ do_action( 'wpsc_pre_init' );
34
+
35
+ // Initialize
36
+ $this->start();
37
+ $this->constants();
38
+ $this->includes();
39
+ $this->load();
40
+
41
+ // Finished initializing
42
+ do_action( 'wpsc_init' );
43
+ }
44
+
45
+ /**
46
+ * Initialize the basic WPEC constants
47
+ */
48
+ function start() {
49
+ // Set the core file path
50
+ define( 'WPSC_FILE_PATH', dirname( __FILE__ ) );
51
+
52
+ // Define the path to the plugin folder
53
+ define( 'WPSC_DIR_NAME', basename( WPSC_FILE_PATH ) );
54
+
55
+ // Define the URL to the plugin folder
56
+ define( 'WPSC_FOLDER', dirname( plugin_basename( __FILE__ ) ) );
57
+ define( 'WPSC_URL', plugins_url( '', __FILE__ ) );
58
+
59
+ // Finished starting
60
+ do_action( 'wpsc_started' );
61
+ }
62
+
63
+ /**
64
+ * Setup the WPEC core constants
65
+ */
66
+ function constants() {
67
+ // Define globals and constants used by wp-e-commerce
68
+ require_once( WPSC_FILE_PATH . '/wpsc-core/wpsc-constants.php' );
69
+
70
+ // Load the WPEC core constants
71
+ wpsc_core_constants();
72
+
73
+ // Is WordPress Multisite
74
+ wpsc_core_is_multisite();
75
+
76
+ // Start the wpsc session
77
+ wpsc_core_load_session();
78
+
79
+ // Which version of WPEC
80
+ wpsc_core_constants_version_processing();
81
+
82
+ // WPEC Table names and related constants
83
+ wpsc_core_constants_table_names();
84
+
85
+ // Uploads directory info
86
+ wpsc_core_constants_uploads();
87
+
88
+ // Any additional constants can hook in here
89
+ do_action( 'wpsc_constants' );
90
+ }
91
+
92
+ /**
93
+ * Include the rest of WPEC's files
94
+ */
95
+ function includes() {
96
+ require_once( WPSC_FILE_PATH . '/wpsc-core/wpsc-functions.php' );
97
+ require_once( WPSC_FILE_PATH . '/wpsc-core/wpsc-installer.php' );
98
+ require_once( WPSC_FILE_PATH . '/wpsc-core/wpsc-includes.php' );
99
+
100
+ // Any additional file includes can hook in here
101
+ do_action( 'wpsc_includes' );
102
+ }
103
+
104
+ /**
105
+ * Setup the WPEC core
106
+ */
107
+ function load() {
108
+ // Before setup
109
+ do_action( 'wpsc_pre_load' );
110
+
111
+ // Legacy action
112
+ do_action( 'wpsc_before_init' );
113
+
114
+ // Setup the core WPEC globals
115
+ wpsc_core_setup_globals();
116
+
117
+ // Setup the core WPEC cart
118
+ wpsc_core_setup_cart();
119
+
120
+ // Load the thumbnail sizes
121
+ wpsc_core_load_thumbnail_sizes();
122
+
123
+ // Load the purchase log statuses
124
+ wpsc_core_load_purchase_log_statuses();
125
+
126
+ // Load unique names and checout form types
127
+ wpsc_core_load_checkout_data();
128
+
129
+ // Load the gateways
130
+ wpsc_core_load_gateways();
131
+
132
+ // Load the shipping modules
133
+ wpsc_core_load_shipping_modules();
134
+
135
+ // Set page title array for important WPSC pages
136
+ wpsc_core_load_page_titles();
137
+
138
+ // WPEC is fully loaded
139
+ do_action( 'wpsc_loaded' );
140
+ }
141
+
142
+ /**
143
+ * WPEC Activation Hook
144
+ */
145
+ function install() {
146
+ global $wp_version;
147
+ if((float)$wp_version < 3.0){
148
+ deactivate_plugins(plugin_basename(__FILE__)); // Deactivate ourselves
149
+ wp_die( __('Looks like you\'re running an older version of WordPress, you need to be running at least WordPress 3.0 to use WP e-Commerce 3.8', 'wpsc'), __('WP e-Commerce 3.8 not compatible', 'wpsc'), array('back_link' => true));
150
+ return;
151
+ }
152
+ define( 'WPSC_FILE_PATH', dirname( __FILE__ ) );
153
+ require_once( WPSC_FILE_PATH . '/wpsc-core/wpsc-installer.php' );
154
+ $this->constants();
155
+ wpsc_install();
156
+
157
+ }
158
+ }
159
+
160
+ // Start WPEC
161
+ $wpec = new WP_eCommerce();
162
+
163
+ // Activation
164
+ register_activation_hook( __FILE__, array( $wpec, 'install' ) );
165
+
166
+ ?>
wpsc-admin/admin-form-functions.php CHANGED
@@ -292,6 +292,7 @@ function wpsc_packing_slip($purchase_id) {
292
  global $wpdb;
293
  $purch_sql = "SELECT * FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `id`='".$purchase_id."'";
294
  $purch_data = $wpdb->get_row($purch_sql,ARRAY_A) ;
 
295
  //echo "<p style='padding-left: 5px;'><strong>".__('Date', 'wpsc')."</strong>:".date("jS M Y", $purch_data['date'])."</p>";
296
 
297
  $cartsql = "SELECT * FROM `".WPSC_TABLE_CART_CONTENTS."` WHERE `purchaseid`=".$purchase_id."";
@@ -315,33 +316,65 @@ function wpsc_packing_slip($purchase_id) {
315
 
316
  if($input_data != null) {
317
  $form_data = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `active` = '1'",ARRAY_A);
318
-
319
  foreach($form_data as $form_field) {
320
- switch($form_field['type']) {
321
- case 'country':
322
-
323
- $delivery_region_count = $wpdb->get_var("SELECT COUNT(`regions`.`id`) FROM `".WPSC_TABLE_REGION_TAX."` AS `regions` INNER JOIN `".WPSC_TABLE_CURRENCY_LIST."` AS `country` ON `country`.`id` = `regions`.`country_id` WHERE `country`.`isocode` IN('".$wpdb->escape( $purch_data['billing_country'])."')");
324
 
325
- if(is_numeric($purch_data['shipping_region']) && ($delivery_region_count > 0)) {
326
- echo " <tr><td>".__('State', 'wpsc').":</td><td>".wpsc_get_region($purch_data['shipping_region'])."</td></tr>\n\r";
327
- }
328
- echo " <tr><td>".wp_kses($form_field['name'], array() ).":</td><td>".wpsc_get_country($purch_data['billing_country'])."</td></tr>\n\r";
 
 
 
 
 
329
  break;
330
 
331
  case 'delivery_country':
332
- echo " <tr><td>".$form_field['name'].":</td><td>".wpsc_get_country($purch_data['shipping_country'])."</td></tr>\n\r";
 
 
 
 
333
  break;
334
-
335
  case 'heading':
336
- echo " <tr class='heading'><td colspan='2'><strong>".wp_kses($form_field['name'], array()).":</strong></td></tr>\n\r";
 
 
 
 
337
  break;
338
-
339
- default:
340
- echo " <tr><td>".wp_kses($form_field['name'], array() ).":</td><td>".htmlentities(stripslashes($rekeyed_input[$form_field['id']]['value']), ENT_QUOTES)."</td></tr>\n\r";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
341
  break;
342
  }
 
343
  }
344
  } else {
 
345
  echo " <tr><td>".__('Name', 'wpsc').":</td><td>".$purch_data['firstname']." ".$purch_data['lastname']."</td></tr>\n\r";
346
  echo " <tr><td>".__('Address', 'wpsc').":</td><td>".$purch_data['address']."</td></tr>\n\r";
347
  echo " <tr><td>".__('Phone', 'wpsc').":</td><td>".$purch_data['phone']."</td></tr>\n\r";
@@ -386,7 +419,6 @@ function wpsc_packing_slip($purchase_id) {
386
  $all_no_shipping = true;
387
  $file_link_list = array();
388
  foreach($cart_log as $cart_row) {
389
-
390
  $alternate = "";
391
  $j++;
392
  if(($j % 2) != 0) {
292
  global $wpdb;
293
  $purch_sql = "SELECT * FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `id`='".$purchase_id."'";
294
  $purch_data = $wpdb->get_row($purch_sql,ARRAY_A) ;
295
+
296
  //echo "<p style='padding-left: 5px;'><strong>".__('Date', 'wpsc')."</strong>:".date("jS M Y", $purch_data['date'])."</p>";
297
 
298
  $cartsql = "SELECT * FROM `".WPSC_TABLE_CART_CONTENTS."` WHERE `purchaseid`=".$purchase_id."";
316
 
317
  if($input_data != null) {
318
  $form_data = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `active` = '1'",ARRAY_A);
319
+
320
  foreach($form_data as $form_field) {
 
 
 
 
321
 
322
+ switch($form_field['type']) {
323
+ case 'country':
324
+
325
+ $delivery_region_count = $wpdb->get_var("SELECT COUNT(`regions`.`id`) FROM `".WPSC_TABLE_REGION_TAX."` AS `regions` INNER JOIN `".WPSC_TABLE_CURRENCY_LIST."` AS `country` ON `country`.`id` = `regions`.`country_id` WHERE `country`.`isocode` IN('".$wpdb->escape( $purch_data['billing_country'])."')");
326
+
327
+ if(is_numeric($purch_data['billing_region']) && ($delivery_region_count > 0))
328
+ echo " <tr><td>".__('State', 'wpsc').":</td><td>".wpsc_get_region($purch_data['billing_region'])."</td></tr>\n\r";
329
+
330
+ echo " <tr><td>".wp_kses($form_field['name'], array() ).":</td><td>".htmlentities(stripslashes($rekeyed_input[$form_field['id']]['value']), ENT_QUOTES)."</td></tr>\n\r";
331
  break;
332
 
333
  case 'delivery_country':
334
+
335
+ if(is_numeric($purch_data['shipping_region']) && ($delivery_region_count > 0))
336
+ echo " <tr><td>".__('State', 'wpsc').":</td><td>".wpsc_get_region($purch_data['shipping_region'])."</td></tr>\n\r";
337
+
338
+ echo " <tr><td>".wp_kses($form_field['name'], array() ).":</td><td>".htmlentities(stripslashes($rekeyed_input[$form_field['id']]['value']), ENT_QUOTES)."</td></tr>\n\r";
339
  break;
340
+
341
  case 'heading':
342
+
343
+ if($form_field['name'] == "Hidden Fields")
344
+ continue;
345
+ else
346
+ echo " <tr class='heading'><td colspan='2'><strong>".wp_kses($form_field['name'], array()).":</strong></td></tr>\n\r";
347
  break;
348
+
349
+ default:
350
+
351
+ if( $form_field['name'] == "Cupcakes") {
352
+ parse_str($rekeyed_input[$form_field['id']]['value'], $cupcakes );
353
+
354
+ foreach( $cupcakes as $product_id => $quantity ) {
355
+
356
+ $product = get_post($product_id);
357
+ $string .= "(".$quantity.") ".$product->post_title.", ";
358
+
359
+ }
360
+ $string = rtrim($string, ", ");
361
+ echo " <tr><td>".wp_kses($form_field['name'], array() ).":</td><td>".htmlentities(stripslashes($string), ENT_QUOTES)."</td></tr>\n\r";
362
+
363
+ } else {
364
+
365
+ if ($form_field['name']=="State" && !empty($purch_data['billing_region']) || $form_field['name']=="State" && !empty($purch_data['billing_region']))
366
+ echo "";
367
+ else
368
+ echo " <tr><td>".wp_kses($form_field['name'], array() ).":</td><td>".htmlentities(stripslashes($rekeyed_input[$form_field['id']]['value']), ENT_QUOTES)."</td></tr>\n\r";
369
+
370
+ }
371
+
372
  break;
373
  }
374
+
375
  }
376
  } else {
377
+
378
  echo " <tr><td>".__('Name', 'wpsc').":</td><td>".$purch_data['firstname']." ".$purch_data['lastname']."</td></tr>\n\r";
379
  echo " <tr><td>".__('Address', 'wpsc').":</td><td>".$purch_data['address']."</td></tr>\n\r";
380
  echo " <tr><td>".__('Phone', 'wpsc').":</td><td>".$purch_data['phone']."</td></tr>\n\r";
419
  $all_no_shipping = true;
420
  $file_link_list = array();
421
  foreach($cart_log as $cart_row) {
 
422
  $alternate = "";
423
  $j++;
424
  if(($j % 2) != 0) {
wpsc-admin/admin.php CHANGED
@@ -16,7 +16,7 @@ require_once( WPSC_FILE_PATH . '/wpsc-admin/display-variations.page.php' );
16
  require_once( WPSC_FILE_PATH . '/wpsc-admin/display-upgrades.page.php' );
17
  require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/display-items-functions.php' );
18
  require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/product-functions.php' );
19
- require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/save-data.functions.php');
20
  require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/updating-functions.php' );
21
  require_once( WPSC_FILE_PATH . '/wpsc-admin/display-coupons.php' );
22
  require_once( WPSC_FILE_PATH . '/wpsc-includes/purchaselogs.class.php' );
@@ -24,22 +24,36 @@ require_once( WPSC_FILE_PATH . '/wpsc-includes/theming.class.php' );
24
  require_once( WPSC_FILE_PATH . '/wpsc-admin/ajax-and-init.php' );
25
  require_once( WPSC_FILE_PATH . '/wpsc-admin/display-options-settings.page.php' );
26
  require_once( WPSC_FILE_PATH . '/wpsc-admin/display-sales-logs.php' );
27
- if ( (isset( $_SESSION['wpsc_activate_debug_page'] ) && ($_SESSION['wpsc_activate_debug_page'] == true)) || (defined( 'WPSC_ADD_DEBUG_PAGE' ) && (constant( 'WPSC_ADD_DEBUG_PAGE' ) == true)) )
28
  require_once( WPSC_FILE_PATH . '/wpsc-admin/display-debug.page.php' );
29
 
30
  //settings pages include
31
  require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/settings-pages/general.php' );
32
 
33
- if ( !get_option( 'wpsc_checkout_form_fields' ) ) {
34
- $form_types = array( "text", "email", "address", "city", "country", "delivery_address", "delivery_city", "delivery_country", "textarea", "heading", "select", "radio", "checkbox" );
35
- update_option( 'wpsc_checkout_form_fields', $form_types );
36
- }
37
-
38
  if ( !get_option( 'wpsc_checkout_form_sets' ) ) {
39
  $form_sets = array( 'Default Checkout Forms' );
40
  update_option( 'wpsc_checkout_form_sets', $form_sets );
41
  }
42
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  /**
44
  * wpsc_admin_pages function, all the definitons of admin pages are stores here.
45
  * No parameters, returns nothing
@@ -52,15 +66,15 @@ if ( !get_option( 'wpsc_checkout_form_sets' ) ) {
52
  * or bypass the normal download system.
53
  */
54
  function wpsc_admin_pages() {
55
- global $userdata, $show_update_page; // set in /wpsc-admin/display-update.page.php
56
 
57
  // Code to enable or disable the debug page
58
  if ( isset( $_GET['wpsc_activate_debug_page'] ) ) {
59
  if ( 'true' == $_GET['wpsc_activate_debug_page'] ) {
60
  $_SESSION['wpsc_activate_debug_page'] = true;
61
  } else if ( 'false' == $_GET['wpsc_activate_debug_page'] ) {
62
- $_SESSION['wpsc_activate_debug_page'] = false;
63
- }
64
  }
65
 
66
  // Only add pages if the function exists to do so?
@@ -69,51 +83,19 @@ function wpsc_admin_pages() {
69
  // Add to Dashboard
70
  $page_hooks[] = $purchase_log_page = add_submenu_page( 'index.php', __( 'Store Sales', 'wpsc' ), __( 'Store Sales', 'wpsc' ), 'administrator', 'wpsc-sales-logs', 'wpsc_display_sales_logs' );
71
 
72
- if ( !isset( $show_update_page ) )
73
- $show_update_page = 1;
74
-
75
- if ( 1 === (int)$show_update_page )
76
  $page_hooks[] = add_submenu_page( 'index.php', __( 'Update Store', 'wpsc' ), __( 'Store Update', 'wpsc' ), 'administrator', 'wpsc-update', 'wpsc_display_update_page' );
77
 
78
  $page_hooks[] = add_submenu_page( 'index.php', __( 'Store Upgrades', 'wpsc' ), __( 'Store Upgrades', 'wpsc' ), 'administrator', 'wpsc-upgrades', 'wpsc_display_upgrades_page' );
79
 
80
  // Set the base page for Products
81
- $products_page = 'wpsc-edit-products';
82
-
83
- // Add 'Products' top level menu
84
- if ( $userdata->user_level <= 2 ) {
85
- if ( function_exists( 'add_object_page' ) ) {
86
- $edit_products_page = add_object_page( __( 'Products', 'wpsc' ), __( 'Products', 'wpsc' ), 'author', $products_page, array(), WPSC_CORE_IMAGES_URL . "/credit_cards.png" );
87
- } else {
88
- $edit_products_page = add_menu_page( __( 'Products', 'wpsc' ), __( 'Products', 'wpsc' ), 'author', $products_page );
89
- }
90
- } else {
91
- if ( function_exists( 'add_object_page' ) ) {
92
- $edit_products_page = add_object_page( __( 'Products', 'wpsc' ), __( 'Products', 'wpsc' ), 'administrator', $products_page, array(), WPSC_CORE_IMAGES_URL . "/credit_cards.png" );
93
- } else {
94
- $edit_products_page = add_menu_page( __( 'Products', 'wpsc' ), __( 'Products', 'wpsc' ), 'administrator', $products_page );
95
- }
96
- }
97
-
98
- // Add products sub pages
99
- $page_hooks[] = $edit_products_page = add_submenu_page( $products_page, __( 'Products', 'wpsc' ), __( 'Products', 'wpsc' ), 'administrator', 'wpsc-edit-products', 'wpsc_display_edit_products_page' );
100
- $page_hooks[] = add_submenu_page( $products_page, __( 'Categories', 'wpsc' ), __( 'Categories', 'wpsc' ), 'administrator', 'wpsc-edit-groups', 'wpsc_display_categories_page' );
101
- $page_hooks[] = add_submenu_page( $products_page, __( 'Variations', 'wpsc' ), __( 'Variations', 'wpsc' ), 'administrator', 'edit-tags.php?taxonomy=wpsc-variation' );
102
-
103
- // Add coupons page
104
- $page_hooks[] = $edit_coupons_page = add_submenu_page( $products_page, __( 'Coupons', 'wpsc' ), __( 'Coupons', 'wpsc' ), 'administrator', 'wpsc-edit-coupons', 'wpsc_display_coupons_page' );
105
 
106
- // Box order
107
- $box_order = get_option( 'wpsc_product_page_order' );
108
- if ( isset( $box_order['side'] ) && is_array( $box_order['side'] ) && is_array( $box_order['advanced'] ) )
109
- $box_order = array_merge( $box_order['side'], $box_order['advanced'] );
110
-
111
- foreach ( (array)$box_order as $box )
112
- $boxes[$box] = ucwords( str_replace( "_", " ", $box ) );
113
 
114
  // Add Settings pages
115
  $page_hooks[] = $edit_options_page = add_options_page( __( 'Store Settings', 'wpsc' ), __( 'Store', 'wpsc' ), 'administrator', 'wpsc-settings', 'wpsc_display_settings_page' );
116
- add_action('admin_print_scripts-' . $edit_options_page , 'wpsc_print_admin_scripts');
117
 
118
  // Debug Page
119
  if ( ( defined( 'WPSC_ADD_DEBUG_PAGE' ) && ( WPSC_ADD_DEBUG_PAGE == true ) ) || ( isset( $_SESSION['wpsc_activate_debug_page'] ) && ( true == $_SESSION['wpsc_activate_debug_page'] ) ) )
@@ -128,44 +110,34 @@ function wpsc_admin_pages() {
128
  add_contextual_help( 'products_page_wpsc-edit-groups', $header . "<a target='_blank' href='http://getshopped.org/resources/docs/building-your-store/categories/'>About the Categories Page</a>" );
129
  add_contextual_help( 'products_page_edit-tags', $header . "<a target='_blank' href='http://getshopped.org/resources/docs/building-your-store/variations/'>About the Variations Page</a>" );
130
  add_contextual_help( 'settings_page_wpsc-settings', $header . "<a target='_blank' href='http://getshopped.org/resources/docs/store-settings/general/'>General Settings</a><br />
131
- <a target='_blank' href='http://getshopped.org/resources/docs/store-settings/presentation/'>Presentation Options</a> <br />
132
- <a target='_blank' href='http://getshopped.org/resources/docs/store-settings/admin/'>Admin Options</a> <br />
133
- <a target='_blank' href='http://getshopped.org/resources/docs/store-settings/shipping'>Shipping Options</a> <br />
134
- <a target='_blank' href='http://getshopped.org/resources/docs/store-settings/payment-options/'>Payment Options</a> <br />
135
- <a target='_blank' href='http://getshopped.org/resources/docs/building-your-store/marketing'>Marketing Options</a> <br />
136
- <a target='_blank' href='http://getshopped.org/resources/docs/store-settings/import/'>Import Options</a> <br />
137
- <a target='_blank' href='http://getshopped.org/resources/docs/store-settings/checkout/'>Checkout Options</a> <br />" );
138
- add_contextual_help( 'products_page_wpsc-edit-coupons', $header . "<a target='_blank' href='http://getshopped.org/resources/docs/building-your-store/marketing'>Marketing Options</a><br />");
139
  }
140
 
141
  $page_hooks = apply_filters( 'wpsc_additional_pages', $page_hooks, $products_page );
142
 
143
  do_action( 'wpsc_add_submenu' );
144
- }
145
 
146
  // Include the javascript and CSS for this page
147
  // This is so important that I can't even express it in one line
 
148
  foreach ( $page_hooks as $page_hook ) {
149
- add_action( 'load-' . $page_hook, 'wpsc_admin_include_css_and_js' );
150
-
151
  switch ( $page_hook ) {
152
- case $edit_products_page :
153
- add_action( 'load-' . $page_hook, 'wpsc_admin_edit_products_page_js' );
154
- break;
155
-
156
- case $edit_options_page :
157
- add_action( 'load-' . $page_hook, 'wpsc_admin_include_optionspage_css_and_js' );
158
- break;
159
-
160
- case $purchase_log_page :
161
- add_action( 'admin_head', 'wpsc_product_log_rss_feed' );
162
- break;
163
-
164
- case $edit_coupons_page :
165
- add_action( 'load-' . $page_hook, 'wpsc_admin_include_coupon_js' );
166
- break;
167
-
168
-
169
  }
170
  }
171
 
@@ -177,11 +149,9 @@ function wpsc_admin_pages() {
177
 
178
  return;
179
  }
180
-
181
  function wpsc_product_log_rss_feed() {
182
  echo "<link type='application/rss+xml' href='" . get_option( 'siteurl' ) . "/wp-admin/index.php?rss=true&amp;rss_key=key&amp;action=purchase_log&amp;type=rss' title='WP e-Commerce Purchase Log RSS' rel='alternate'/>";
183
  }
184
-
185
  function wpsc_admin_include_coupon_js() {
186
 
187
  // Variables
@@ -203,7 +173,7 @@ function wpsc_admin_include_coupon_js() {
203
  * wpsc_admin_css_and_js function, includes the wpsc_admin CSS and JS
204
  * No parameters, returns nothing
205
  */
206
- function wpsc_admin_include_css_and_js() {
207
  $siteurl = get_option( 'siteurl' );
208
  if ( is_ssl ( ) )
209
  $siteurl = str_replace( "http://", "https://", $siteurl );
@@ -218,56 +188,21 @@ function wpsc_admin_include_css_and_js() {
218
  wp_enqueue_script( 'wp-e-commerce-legacy-ajax', WPSC_URL . '/wpsc-admin/js/ajax.js', false, $version_identifier ); // needs removing
219
  wp_enqueue_script( 'wp-e-commerce-variations', WPSC_URL . '/wpsc-admin/js/variations.js', array( 'jquery' ), $version_identifier );
220
 
221
- // TODO - This should DEFINITELY come out when we convert to custom post types in the backend
222
- wp_deregister_script( 'postbox' );
223
-
224
  wp_enqueue_style( 'wp-e-commerce-admin', WPSC_URL . '/wpsc-admin/css/admin.css', false, $version_identifier, 'all' );
225
  wp_enqueue_style( 'wp-e-commerce-admin-dynamic', $siteurl . "/wp-admin/admin.php?wpsc_admin_dynamic_css=true", false, $version_identifier, 'all' );
226
- wp_localize_script( 'wp-e-commerce-tags', 'postL10n', array(
227
- 'tagsUsed' => __( 'Tags used on this post:' ),
228
- 'add' => esc_attr( __( 'Add' ) ),
229
- 'addTag' => esc_attr( __( 'Add new tag' ) ),
230
- 'separate' => __( 'Separate tags with commas' ),
231
- ) );
232
  // Prototype breaks dragging and dropping, I need it gone
233
  wp_deregister_script( 'prototype' );
 
234
  // remove the old javascript and CSS, we want it no more, it smells bad
235
  remove_action( 'admin_head', 'wpsc_admin_css' );
236
- }
237
-
238
- function wpsc_admin_edit_products_page_js() {
239
-
240
- $version_identifier = WPSC_VERSION . '.' . WPSC_MINOR_VERSION;
241
- wp_enqueue_script( 'wp-e-commerce-tags', WPSC_URL . '/wpsc-admin/js/product_tagcloud.js', array( 'livequery' ), $version_identifier );
242
-
243
- if ( user_can_richedit ( ) )
244
- wp_enqueue_script( 'editor' );
245
 
246
- // Queue up the thickbox style
247
- wp_enqueue_style( 'thickbox' );
248
-
249
- // Queue up the required WP core JS
250
- wp_enqueue_script( 'media-upload' );
251
- wp_enqueue_script( 'post' );
252
- wp_enqueue_script( 'autosave' );
253
- wp_enqueue_script( 'swfupload' );
254
- wp_enqueue_script( 'swfupload-swfobject' );
255
- wp_enqueue_script( 'swfupload-queue' );
256
-
257
- // Switch upload handlers
258
- wp_deregister_script( 'swfupload-handlers' );
259
- wp_enqueue_script( 'wpsc-swfupload-handlers', WPSC_URL . '/wpsc-admin/js/wpsc-swfupload-handlers.js', false, $version_identifier );
260
-
261
- add_action( 'admin_head', 'wp_tiny_mce' );
262
-
263
- // remove cforms timymce code from running on the products page, because it breaks tinymce for us
264
- remove_filter( 'mce_external_plugins', 'cforms_plugin' );
265
- remove_filter( 'mce_buttons', 'cforms_button' );
266
-
267
- //add_action( 'admin_print_footer_scripts', 'wp_tiny_mce', 25 );
268
- wp_enqueue_script( 'quicktags' );
269
-
270
- do_action( 'wpsc_admin_edit_products_js' );
271
  }
272
 
273
  /**
@@ -284,28 +219,75 @@ function wpsc_admin_include_optionspage_css_and_js() {
284
  }
285
 
286
  function wpsc_meta_boxes() {
287
- //$pagename = 'products_page_wpsc-edit-products';
288
- //$pagename = 'store_page_wpsc-edit-products';
289
-
290
- $pagename = 'toplevel_page_wpsc-edit-products';
291
- add_meta_box('wpsc_price_control_forms','Price Control','wpsc_price_control_forms',$pagename,'normal','high');
292
- add_meta_box('wpsc_stock_control_forms','Stock Control','wpsc_stock_control_forms',$pagename,'normal','high');
293
- add_meta_box('wpsc_product_taxes_forms','Taxes','wpsc_product_taxes_forms',$pagename,'normal','high');
294
- add_meta_box( 'wpsc_product_category_and_tag_forms', 'Category and Tags', 'wpsc_product_category_and_tag_forms', $pagename, 'normal', 'high' );
295
- add_meta_box( 'wpsc_product_tag_forms', 'Product Tags', 'wpsc_product_tag_forms', $pagename, 'normal', 'high' );
 
 
 
 
 
 
 
 
 
296
  add_meta_box( 'wpsc_product_download_forms', 'Product Download', 'wpsc_product_download_forms', $pagename, 'normal', 'high' );
297
  add_meta_box( 'wpsc_product_image_forms', 'Product Images', 'wpsc_product_image_forms', $pagename, 'normal', 'high' );
298
  add_meta_box( 'wpsc_product_shipping_forms', 'Shipping', 'wpsc_product_shipping_forms', $pagename, 'normal', 'high' );
299
- add_meta_box( 'wpsc_product_variation_forms', 'Variation Control', 'wpsc_product_variation_forms', $pagename, 'normal', 'high' );
300
  add_meta_box( 'wpsc_product_advanced_forms', 'Advanced Settings', 'wpsc_product_advanced_forms', $pagename, 'normal', 'high' );
301
- add_meta_box( 'wpsc_product_external_link_forms', 'Off Site Product link', 'wpsc_product_external_link_forms', $pagename, 'normal', 'high' );
302
  }
303
 
304
- add_action( 'admin_menu', 'wpsc_meta_boxes' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
305
 
306
  function wpsc_admin_dynamic_js() {
307
  header( 'Content-Type: text/javascript' );
308
- header( 'Expires: ' . gmdate( 'r', mktime( 0, 0, 0, date( 'm' ), (date( 'd' ) + 12 ), date( 'Y' ) ) ) . '' );
309
  header( 'Cache-Control: public, must-revalidate, max-age=86400' );
310
  header( 'Pragma: public' );
311
 
@@ -313,17 +295,15 @@ function wpsc_admin_dynamic_js() {
313
  $hidden_boxes = get_option( 'wpsc_hidden_box' );
314
 
315
  $form_types1 = get_option( 'wpsc_checkout_form_fields' );
316
- $unique_names1 = Array( 'billingfirstname', 'billinglastname', 'billingaddress', 'billingcity', 'billingstate',
317
- 'billingcountry', 'billingemail', 'billingphone', 'billingpostcode',
318
- 'delivertoafriend', 'shippingfirstname', 'shippinglastname', 'shippingaddress',
319
- 'shippingcity', 'shippingstate', 'shippingcountry', 'shippingpostcode' );
320
  $form_types = '';
321
- foreach ( $form_types1 as $form_type ) {
322
  $form_types .= "<option value='" . $form_type . "'>" . __( $form_type, 'wpsc' ) . "</option>";
323
  }
324
 
325
  $unique_names = "<option value='-1'>Select a Unique Name</option>";
326
- foreach ( $unique_names1 as $unique_name ) {
327
  $unique_names.= "<option value='" . $unique_name . "'>" . $unique_name . "</option>";
328
  }
329
 
@@ -371,13 +351,13 @@ function wpsc_admin_dynamic_js() {
371
  exit();
372
  }
373
 
374
- if ( isset( $_GET['wpsc_admin_dynamic_js'] ) && ($_GET['wpsc_admin_dynamic_js'] == 'true') ) {
375
  add_action( "admin_init", 'wpsc_admin_dynamic_js' );
376
  }
377
 
378
  function wpsc_admin_dynamic_css() {
379
  header( 'Content-Type: text/css' );
380
- header( 'Expires: ' . gmdate( 'r', mktime( 0, 0, 0, date( 'm' ), (date( 'd' ) + 12 ), date( 'Y' ) ) ) . '' );
381
  header( 'Cache-Control: public, must-revalidate, max-age=86400' );
382
  header( 'Pragma: public' );
383
  $flash = 0;
@@ -407,7 +387,7 @@ function wpsc_admin_dynamic_css() {
407
  exit();
408
  }
409
 
410
- if ( isset( $_GET['wpsc_admin_dynamic_css'] ) && ($_GET['wpsc_admin_dynamic_css'] == 'true') ) {
411
  add_action( "admin_init", 'wpsc_admin_dynamic_css' );
412
  }
413
 
@@ -428,7 +408,7 @@ function wpsc_admin_latest_activity() {
428
  $year = date( "Y" );
429
  $month = date( "m" );
430
  $start_timestamp = mktime( 0, 0, 0, $month, 1, $year );
431
- $end_timestamp = mktime( 0, 0, 0, ($month + 1 ), 0, $year );
432
  $sql = "SELECT COUNT(*) FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `date` BETWEEN '$start_timestamp' AND '$end_timestamp' AND `processed` IN (2,3,4) ORDER BY `date` DESC";
433
  $currentMonthOrders = $wpdb->get_var( $sql );
434
 
@@ -446,7 +426,7 @@ function wpsc_admin_latest_activity() {
446
  echo "<p class='dashboardWidgetSpecial'>";
447
  //calculates average sales amount per order for the month
448
  if ( $currentMonthOrders > 0 ) {
449
- $monthsAverage = ((int)admin_display_total_price( $start_timestamp, $end_timestamp ) / (int)$currentMonthOrders);
450
  echo wpsc_currency_display( $monthsAverage );
451
  }
452
  //echo "</span>";
@@ -472,8 +452,8 @@ function wpsc_admin_latest_activity() {
472
  echo "</p>";
473
  echo "<p class='dashboardWidgetSpecial'>";
474
  //calculates average sales amount per order for the month
475
- if ( (admin_display_total_price() > 0) && ($totalOrders > 0) ) {
476
- $totalAverage = ((int)admin_display_total_price() / (int)$totalOrders);
477
  } else {
478
  $totalAverage = 0;
479
  }
@@ -503,31 +483,31 @@ function wpsc_dashboard_widget_setup() {
503
  wp_enqueue_style( 'wp-e-commerce-admin', WPSC_URL . '/wpsc-admin/css/admin.css', false, $version_identifier, 'all' );
504
  wp_enqueue_script( 'datepicker-ui', WPSC_URL . "/wpsc-core/js/ui.datepicker.js", array( 'jquery', 'jquery-ui-core', 'jquery-ui-sortable' ), $version_identifier );
505
  // Add the dashboard widgets
506
- wp_add_dashboard_widget( 'wpsc_dashboard_news', __( 'Getshopped News' ), 'wpsc_dashboard_news' );
507
- wp_add_dashboard_widget( 'wpsc_dashboard_widget', __( 'Sales Summary' ), 'wpsc_dashboard_widget' );
508
- wp_add_dashboard_widget( 'wpsc_quarterly_dashboard_widget', __( 'Sales by Quarter' ), 'wpsc_quarterly_dashboard_widget' );
509
- wp_add_dashboard_widget( 'wpsc_dashboard_4months_widget', __( 'Sales by Month' ), 'wpsc_dashboard_4months_widget' );
510
-
511
  // Sort the Dashboard widgets so ours it at the top
512
  global $wp_meta_boxes;
513
  $normal_dashboard = $wp_meta_boxes['dashboard']['normal']['core'];
514
  // Backup and delete our new dashbaord widget from the end of the array
515
- $wpsc_widget_backup = array('wpsc_dashboard_news' => $normal_dashboard['wpsc_dashboard_news']);
516
- $wpsc_widget_backup += array('wpsc_dashboard_widget' => $normal_dashboard['wpsc_dashboard_widget']);
517
- $wpsc_widget_backup += array('wpsc_quarterly_dashboard_widget' => $normal_dashboard['wpsc_quarterly_dashboard_widget']);
518
- $wpsc_widget_backup += array('wpsc_dashboard_4months_widget' => $normal_dashboard['wpsc_dashboard_4months_widget']);
519
-
520
- unset($normal_dashboard['wpsc_dashboard_news']);
521
- unset($normal_dashboard['wpsc_dashboard_widget']);
522
- unset($normal_dashboard['wpsc_quarterly_dashboard_widget']);
523
- unset($normal_dashboard['wpsc_dashboard_4months_widget']);
524
-
525
  // Merge the two arrays together so our widget is at the beginning
526
-
527
- $sorted_dashboard = array_merge($wpsc_widget_backup, $normal_dashboard);
528
-
529
- // Save the sorted array back into the original metaboxes
530
-
531
  $wp_meta_boxes['dashboard']['normal']['core'] = $sorted_dashboard;
532
  }
533
  }
@@ -538,10 +518,10 @@ function wpsc_dashboard_widget_setup() {
538
 
539
  add_action( 'wp_dashboard_setup', 'wpsc_dashboard_widget_setup' );
540
 
541
- function wpsc_dashboard_news(){
542
- $rss = fetch_feed('http://getshopped.org/category/wp-e-commerce-plugin/');
543
- $args = array('show_author' => 1, 'show_date' => 1, 'show_summary' => 1, 'items'=>3 );
544
- wp_widget_rss_output($rss, $args);
545
 
546
  }
547
 
@@ -564,7 +544,7 @@ function wpsc_quarterly_dashboard_widget() {
564
  if ( get_option( 'wpsc_business_year_start' ) == false ) {
565
  ?>
566
  <form action='' method='post'>
567
- <label for='date_start'><?php _e('Financial Year End' ,'wpsc'); ?>: </label>
568
  <input id='date_start' type='text' class='pickdate' size='11' value='<?php echo get_option( 'wpsc_last_date' ); ?>' name='add_start' />
569
  <!--<select name='add_start[day]'>
570
  <?php
@@ -586,18 +566,18 @@ function wpsc_quarterly_dashboard_widget() {
586
  }
587
  echo "<option $selected value='$i'>" . date( "M", mktime( 0, 0, 0, $i, 1, date( "Y" ) ) ) . "</option>";
588
  }
589
- ?>
590
  </select>
591
  <select name='add_start[year]'>
592
  <?php
593
- for ( $i = date( "Y" ); $i <= (date( "Y" ) + 12); ++$i ) {
594
  $selected = '';
595
  if ( $i == date( "Y" ) ) {
596
  $selected = "selected='true'";
597
  }
598
  echo "<option $selected value='$i'>" . $i . "</option>";
599
  }
600
- ?>
601
  </select>-->
602
  <input type='hidden' name='wpsc_admin_action' value='wpsc_quarterly' />
603
  <input type='submit' class='button primary' value='Submit' name='wpsc_submit' />
@@ -621,8 +601,8 @@ function wpsc_quarterly_dashboard_widget() {
621
  ?>
622
  <div id='box'>
623
  <p class='atglance'>
624
- <span class='wpsc_quart_left'><?php _e('At a Glance' , 'wpsc'); ?></span>
625
- <span class='wpsc_quart_right'><?php _e('Revenue' , 'wpsc'); ?></span>
626
  </p>
627
  <div style='clear:both'></div>
628
  <p class='quarterly'>
@@ -676,14 +656,14 @@ function wpsc_dashboard_4months_widget() {
676
  $months[] = mktime( 0, 0, 0, $this_month, 1, $this_year );
677
 
678
  $products = $wpdb->get_results( "SELECT `cart`.`prodid`,
679
- `cart`.`name`
680
  FROM `" . WPSC_TABLE_CART_CONTENTS . "` AS `cart`
681
  INNER JOIN `" . WPSC_TABLE_PURCHASE_LOGS . "` AS `logs`
682
- ON `cart`.`purchaseid` = `logs`.`id`
683
- WHERE `logs`.`processed` >= 2
684
  AND `logs`.`date` >= " . $months[0] . "
685
- GROUP BY `cart`.`prodid`
686
- ORDER BY SUM(`cart`.`price` * `cart`.`quantity`) DESC
687
  LIMIT 4", ARRAY_A ); //get 4 products with top income in 4 last months.
688
 
689
  $timeranges[0]["start"] = mktime( 0, 0, 0, $this_month - 3, 1, $this_year ); //make array of time ranges
@@ -699,12 +679,12 @@ function wpsc_dashboard_4months_widget() {
699
  foreach ( (array)$products as $product ) { //run through products and get each product income amounts and name
700
  $sale_totals = array( );
701
  foreach ( $timeranges as $timerange ) { //run through time ranges of product, and get its income over each time range
702
- $prodsql = "SELECT
703
- SUM(`cart`.`price` * `cart`.`quantity`) AS sum
704
  FROM `" . WPSC_TABLE_CART_CONTENTS . "` AS `cart`
705
  INNER JOIN `" . WPSC_TABLE_PURCHASE_LOGS . "` AS `logs`
706
- ON `cart`.`purchaseid` = `logs`.`id`
707
- WHERE `logs`.`processed` >= 2
708
  AND `logs`.`date` >= " . $timerange["start"] . "
709
  AND `logs`.`date` < " . $timerange["end"] . "
710
  AND `cart`.`prodid` = " . $product['prodid'] . "
@@ -714,7 +694,7 @@ function wpsc_dashboard_4months_widget() {
714
  $prod_data[] = array(
715
  'sale_totals' => $sale_totals,
716
  'product_name' => $product['name'] ); //result: array of 2: $prod_data[0] = array(income)
717
- $sums = array( ); //reset array //$prod_data[1] = product name
718
  }
719
 
720
  $tablerow = 1;
@@ -759,25 +739,84 @@ function wpsc_fav_action( $actions ) {
759
  }
760
  add_filter( 'favorite_actions', 'wpsc_fav_action' );
761
 
762
- function wpsc_print_admin_scripts(){
763
  global $version_identifier;
764
- wp_enqueue_script( 'wp-e-commerce-dynamic', get_bloginfo('url') . "/index.php?wpsc_user_dynamic_js=true", false, $version_identifier );
765
  }
766
 
767
  /**
768
  * wpsc_update_permalinks update the product pages permalinks when WordPress permalinks are changed
769
- * @public
770
  *
771
- * @3.8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
772
  * @returns nothing
773
  */
774
- function wpsc_update_permalinks($return = ''){
775
- wpsc_update_page_urls(true);
776
- return $return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
777
  }
778
- add_action('permalink_structure_changed' ,'wpsc_update_permalinks');
779
- add_action('get_sample_permalink_html' ,'wpsc_update_permalinks');
780
- add_action('wp_ajax_category_sort_order', 'wpsc_ajax_set_category_order');
 
 
781
 
782
 
783
  ?>
16
  require_once( WPSC_FILE_PATH . '/wpsc-admin/display-upgrades.page.php' );
17
  require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/display-items-functions.php' );
18
  require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/product-functions.php' );
19
+ require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/save-data.functions.php' );
20
  require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/updating-functions.php' );
21
  require_once( WPSC_FILE_PATH . '/wpsc-admin/display-coupons.php' );
22
  require_once( WPSC_FILE_PATH . '/wpsc-includes/purchaselogs.class.php' );
24
  require_once( WPSC_FILE_PATH . '/wpsc-admin/ajax-and-init.php' );
25
  require_once( WPSC_FILE_PATH . '/wpsc-admin/display-options-settings.page.php' );
26
  require_once( WPSC_FILE_PATH . '/wpsc-admin/display-sales-logs.php' );
27
+ if ( ( isset( $_SESSION['wpsc_activate_debug_page'] ) && ( $_SESSION['wpsc_activate_debug_page'] == true ) ) || ( defined( 'WPSC_ADD_DEBUG_PAGE' ) && ( constant( 'WPSC_ADD_DEBUG_PAGE' ) == true ) ) )
28
  require_once( WPSC_FILE_PATH . '/wpsc-admin/display-debug.page.php' );
29
 
30
  //settings pages include
31
  require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/settings-pages/general.php' );
32
 
 
 
 
 
 
33
  if ( !get_option( 'wpsc_checkout_form_sets' ) ) {
34
  $form_sets = array( 'Default Checkout Forms' );
35
  update_option( 'wpsc_checkout_form_sets', $form_sets );
36
  }
37
 
38
+ /**
39
+ * Checks whether to display or hide the update wp-e-commerce link
40
+ *
41
+ * @access public
42
+ *
43
+ * @since 3.8
44
+ * @return boolean true - show link, false- hide link
45
+ */
46
+ function wpsc_show_update_link() {
47
+ global $wpdb;
48
+ // Check if old product_list table exists
49
+ // If it exists AND get_option wpsc_upgrade_complete is not true then return true
50
+ $sql = 'SHOW TABLES LIKE "'.$wpdb->prefix.'wpsc_product_list"';
51
+ $var = $wpdb->get_var( $sql );
52
+ if ( !empty( $var ) && false == get_option( 'wpsc_hide_update' ) )
53
+ return true;
54
+ else
55
+ return false;
56
+ }
57
  /**
58
  * wpsc_admin_pages function, all the definitons of admin pages are stores here.
59
  * No parameters, returns nothing
66
  * or bypass the normal download system.
67
  */
68
  function wpsc_admin_pages() {
69
+ global $userdata, $show_update_page, $post_type, $typenow, $current_screen; // set in /wpsc-admin/display-update.page.php
70
 
71
  // Code to enable or disable the debug page
72
  if ( isset( $_GET['wpsc_activate_debug_page'] ) ) {
73
  if ( 'true' == $_GET['wpsc_activate_debug_page'] ) {
74
  $_SESSION['wpsc_activate_debug_page'] = true;
75
  } else if ( 'false' == $_GET['wpsc_activate_debug_page'] ) {
76
+ $_SESSION['wpsc_activate_debug_page'] = false;
77
+ }
78
  }
79
 
80
  // Only add pages if the function exists to do so?
83
  // Add to Dashboard
84
  $page_hooks[] = $purchase_log_page = add_submenu_page( 'index.php', __( 'Store Sales', 'wpsc' ), __( 'Store Sales', 'wpsc' ), 'administrator', 'wpsc-sales-logs', 'wpsc_display_sales_logs' );
85
 
86
+ if ( wpsc_show_update_link() )
 
 
 
87
  $page_hooks[] = add_submenu_page( 'index.php', __( 'Update Store', 'wpsc' ), __( 'Store Update', 'wpsc' ), 'administrator', 'wpsc-update', 'wpsc_display_update_page' );
88
 
89
  $page_hooks[] = add_submenu_page( 'index.php', __( 'Store Upgrades', 'wpsc' ), __( 'Store Upgrades', 'wpsc' ), 'administrator', 'wpsc-upgrades', 'wpsc_display_upgrades_page' );
90
 
91
  // Set the base page for Products
92
+ $products_page = 'edit.php?post_type=wpsc-product';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
 
94
+ $page_hooks[] = $edit_coupons_page = add_submenu_page( $products_page , __( 'Coupons', 'wpsc' ), __( 'Coupons', 'wpsc' ), 'administrator', 'wpsc-edit-coupons', 'wpsc_display_coupons_page' );
 
 
 
 
 
 
95
 
96
  // Add Settings pages
97
  $page_hooks[] = $edit_options_page = add_options_page( __( 'Store Settings', 'wpsc' ), __( 'Store', 'wpsc' ), 'administrator', 'wpsc-settings', 'wpsc_display_settings_page' );
98
+ add_action( 'admin_print_scripts-' . $edit_options_page , 'wpsc_print_admin_scripts' );
99
 
100
  // Debug Page
101
  if ( ( defined( 'WPSC_ADD_DEBUG_PAGE' ) && ( WPSC_ADD_DEBUG_PAGE == true ) ) || ( isset( $_SESSION['wpsc_activate_debug_page'] ) && ( true == $_SESSION['wpsc_activate_debug_page'] ) ) )
110
  add_contextual_help( 'products_page_wpsc-edit-groups', $header . "<a target='_blank' href='http://getshopped.org/resources/docs/building-your-store/categories/'>About the Categories Page</a>" );
111
  add_contextual_help( 'products_page_edit-tags', $header . "<a target='_blank' href='http://getshopped.org/resources/docs/building-your-store/variations/'>About the Variations Page</a>" );
112
  add_contextual_help( 'settings_page_wpsc-settings', $header . "<a target='_blank' href='http://getshopped.org/resources/docs/store-settings/general/'>General Settings</a><br />
113
+ <a target='_blank' href='http://getshopped.org/resources/docs/store-settings/checkout/'>Checkout Options</a> <br />" );
114
+ add_contextual_help( 'products_page_wpsc-edit-coupons', $header . "<a target='_blank' href='http://getshopped.org/resources/docs/building-your-store/marketing'>Marketing Options</a><br />" );
 
 
 
 
 
 
115
  }
116
 
117
  $page_hooks = apply_filters( 'wpsc_additional_pages', $page_hooks, $products_page );
118
 
119
  do_action( 'wpsc_add_submenu' );
120
+ };
121
 
122
  // Include the javascript and CSS for this page
123
  // This is so important that I can't even express it in one line
124
+
125
  foreach ( $page_hooks as $page_hook ) {
126
+ add_action( 'load-' . $page_hook, 'wpsc_admin_include_css_and_js_refac' );
127
+
128
  switch ( $page_hook ) {
129
+
130
+ case $edit_options_page :
131
+ add_action( 'load-' . $page_hook, 'wpsc_admin_include_optionspage_css_and_js' );
132
+ break;
133
+
134
+ case $purchase_log_page :
135
+ add_action( 'admin_head', 'wpsc_product_log_rss_feed' );
136
+ break;
137
+
138
+ case $edit_coupons_page :
139
+ add_action( 'load-' . $page_hook, 'wpsc_admin_include_coupon_js' );
140
+ break;
 
 
 
 
 
141
  }
142
  }
143
 
149
 
150
  return;
151
  }
 
152
  function wpsc_product_log_rss_feed() {
153
  echo "<link type='application/rss+xml' href='" . get_option( 'siteurl' ) . "/wp-admin/index.php?rss=true&amp;rss_key=key&amp;action=purchase_log&amp;type=rss' title='WP e-Commerce Purchase Log RSS' rel='alternate'/>";
154
  }
 
155
  function wpsc_admin_include_coupon_js() {
156
 
157
  // Variables
173
  * wpsc_admin_css_and_js function, includes the wpsc_admin CSS and JS
174
  * No parameters, returns nothing
175
  */
176
+ function wpsc_admin_include_css_and_js( ) {
177
  $siteurl = get_option( 'siteurl' );
178
  if ( is_ssl ( ) )
179
  $siteurl = str_replace( "http://", "https://", $siteurl );
188
  wp_enqueue_script( 'wp-e-commerce-legacy-ajax', WPSC_URL . '/wpsc-admin/js/ajax.js', false, $version_identifier ); // needs removing
189
  wp_enqueue_script( 'wp-e-commerce-variations', WPSC_URL . '/wpsc-admin/js/variations.js', array( 'jquery' ), $version_identifier );
190
 
 
 
 
191
  wp_enqueue_style( 'wp-e-commerce-admin', WPSC_URL . '/wpsc-admin/css/admin.css', false, $version_identifier, 'all' );
192
  wp_enqueue_style( 'wp-e-commerce-admin-dynamic', $siteurl . "/wp-admin/admin.php?wpsc_admin_dynamic_css=true", false, $version_identifier, 'all' );
193
+
 
 
 
 
 
194
  // Prototype breaks dragging and dropping, I need it gone
195
  wp_deregister_script( 'prototype' );
196
+
197
  // remove the old javascript and CSS, we want it no more, it smells bad
198
  remove_action( 'admin_head', 'wpsc_admin_css' );
 
 
 
 
 
 
 
 
 
199
 
200
+ // Localize scripts
201
+ wp_localize_script( 'wp-e-commerce-admin', 'wpsc_adminL10n', array(
202
+ 'unsaved_changes_detected' => __( 'Unsaved changes have been detected. Click OK to lose these changes and continue.', 'wpsc' ),
203
+ 'dragndrop_set' => ( get_option( 'wpsc_sort_by' ) == 'dragndrop' ? 'true' : 'false' ),
204
+ 'l10n_print_after' => 'try{convertEntities(wpsc_adminL10n);}catch(e){};'
205
+ ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
206
  }
207
 
208
  /**
219
  }
220
 
221
  function wpsc_meta_boxes() {
222
+ global $post;
223
+ $pagename = 'wpsc-product';
224
+ remove_meta_box( 'wpsc-variationdiv', 'wpsc-product', 'core' );
225
+
226
+ //if a variation page do not show these metaboxes
227
+ if ( $post->post_parent == 0 ) {
228
+ add_meta_box( 'wpsc_product_variation_forms', 'Variations', 'wpsc_product_variation_forms', $pagename, 'normal', 'high' );
229
+ add_meta_box( 'wpsc_product_external_link_forms', 'Off Site Product link', 'wpsc_product_external_link_forms', $pagename, 'normal', 'high' );
230
+ }else {
231
+ remove_meta_box( 'tagsdiv-product_tag', 'wpsc-product', 'core' );
232
+ remove_meta_box( 'wpsc_product_external_link_forms', 'wpsc-product', 'core' );
233
+ remove_meta_box( 'wpsc_product_categorydiv', 'wpsc-product', 'core' );
234
+ }
235
+
236
+ add_meta_box( 'wpsc_price_control_forms', 'Price Control', 'wpsc_price_control_forms', $pagename, 'side', 'low' );
237
+ add_meta_box( 'wpsc_stock_control_forms', 'Stock Control', 'wpsc_stock_control_forms', $pagename, 'side', 'low' );
238
+ add_meta_box( 'wpsc_product_taxes_forms', 'Taxes', 'wpsc_product_taxes_forms', $pagename, 'side', 'low' );
239
+ add_meta_box( 'wpsc_additional_desc', 'Additional Description', 'wpsc_additional_desc', $pagename, 'normal', 'high' );
240
  add_meta_box( 'wpsc_product_download_forms', 'Product Download', 'wpsc_product_download_forms', $pagename, 'normal', 'high' );
241
  add_meta_box( 'wpsc_product_image_forms', 'Product Images', 'wpsc_product_image_forms', $pagename, 'normal', 'high' );
242
  add_meta_box( 'wpsc_product_shipping_forms', 'Shipping', 'wpsc_product_shipping_forms', $pagename, 'normal', 'high' );
 
243
  add_meta_box( 'wpsc_product_advanced_forms', 'Advanced Settings', 'wpsc_product_advanced_forms', $pagename, 'normal', 'high' );
244
+
245
  }
246
 
247
+ add_action( 'admin_footer', 'wpsc_meta_boxes' );
248
+
249
+ add_action( 'admin_head', 'wpsc_admin_include_css_and_js' );
250
+ add_action( 'admin_head', 'wpsc_admin_include_css_and_js_refac' );
251
+ add_action( 'admin_enqueue_scripts', 'wpsc_admin_include_css_and_js_refac' );
252
+ function wpsc_admin_include_css_and_js_refac( $pagehook ) {
253
+
254
+ global $post_type, $current_screen;
255
+ $siteurl = get_option( 'siteurl' );
256
+ if ( is_ssl ( ) )
257
+ $siteurl = str_replace( "http://", "https://", $siteurl );
258
+
259
+ wp_admin_css( 'dashboard' );
260
+
261
+ $version_identifier = WPSC_VERSION . "." . WPSC_MINOR_VERSION;
262
+ $pages = array( 'index.php', 'options-general.php', 'edit.php', 'post.php', 'post-new.php' );
263
+
264
+ if ( ( in_array( $pagehook, $pages ) && $post_type == 'wpsc-product' ) || $current_screen->id == 'edit-wpsc_product_category' || $current_screen->id == 'dashboard_page_wpsc-sales-logs' || $current_screen->id == 'settings_page_wpsc-settings' || $current_screen->id == 'wpsc-product_page_wpsc-edit-coupons' ) {
265
+ wp_enqueue_script( 'livequery', WPSC_URL . '/wpsc-admin/js/jquery.livequery.js', array( 'jquery' ), '1.0.3' );
266
+ wp_enqueue_script( 'wp-e-commerce-admin-parameters', $siteurl . '/wp-admin/admin.php?wpsc_admin_dynamic_js=true', false, $version_identifier );
267
+ wp_enqueue_script( 'wp-e-commerce-admin', WPSC_URL . '/wpsc-admin/js/admin.js', array( 'jquery', 'jquery-ui-core', 'jquery-ui-sortable' ), $version_identifier, false );
268
+ wp_enqueue_script( 'wp-e-commerce-legacy-ajax', WPSC_URL . '/wpsc-admin/js/ajax.js', false, $version_identifier ); // needs removing
269
+ wp_enqueue_script( 'wp-e-commerce-variations', WPSC_URL . '/wpsc-admin/js/variations.js', array( 'jquery' ), $version_identifier );
270
+ wp_enqueue_script( 'inline-edit-post' );
271
+ wp_enqueue_style( 'wp-e-commerce-admin', WPSC_URL . '/wpsc-admin/css/admin.css', false, $version_identifier, 'all' );
272
+ wp_enqueue_style( 'wp-e-commerce-admin-dynamic', $siteurl . "/wp-admin/admin.php?wpsc_admin_dynamic_css=true", false, $version_identifier, 'all' );
273
+ // Localize scripts
274
+ wp_localize_script( 'wp-e-commerce-admin', 'wpsc_adminL10n', array(
275
+ 'unsaved_changes_detected' => __( 'Unsaved changes have been detected. Click OK to lose these changes and continue.', 'wpsc' ),
276
+ 'dragndrop_set' => ( get_option( 'wpsc_sort_by' ) == 'dragndrop' ? 'true' : 'false' ),
277
+ 'l10n_print_after' => 'try{convertEntities(wpsc_adminL10n);}catch(e){};'
278
+ ) );
279
+ }
280
+ if ( 'dashboard_page_wpsc-upgrades' == $pagehook )
281
+ wp_enqueue_style( 'wp-e-commerce-admin', WPSC_URL . '/wpsc-admin/css/admin.css', false, $version_identifier, 'all' );
282
+ wp_deregister_script( 'prototype' );
283
+
284
+ // remove the old javascript and CSS, we want it no more, it smells bad
285
+ remove_action( 'admin_head', 'wpsc_admin_css' );
286
+ }
287
 
288
  function wpsc_admin_dynamic_js() {
289
  header( 'Content-Type: text/javascript' );
290
+ header( 'Expires: ' . gmdate( 'r', mktime( 0, 0, 0, date( 'm' ), ( date( 'd' ) + 12 ), date( 'Y' ) ) ) . '' );
291
  header( 'Cache-Control: public, must-revalidate, max-age=86400' );
292
  header( 'Pragma: public' );
293
 
295
  $hidden_boxes = get_option( 'wpsc_hidden_box' );
296
 
297
  $form_types1 = get_option( 'wpsc_checkout_form_fields' );
298
+ $unique_names1 = get_option( 'wpsc_checkout_unique_names' );
299
+
 
 
300
  $form_types = '';
301
+ foreach ( (array)$form_types1 as $form_type ) {
302
  $form_types .= "<option value='" . $form_type . "'>" . __( $form_type, 'wpsc' ) . "</option>";
303
  }
304
 
305
  $unique_names = "<option value='-1'>Select a Unique Name</option>";
306
+ foreach ( (array)$unique_names1 as $unique_name ) {
307
  $unique_names.= "<option value='" . $unique_name . "'>" . $unique_name . "</option>";
308
  }
309
 
351
  exit();
352
  }
353
 
354
+ if ( isset( $_GET['wpsc_admin_dynamic_js'] ) && ( $_GET['wpsc_admin_dynamic_js'] == 'true' ) ) {
355
  add_action( "admin_init", 'wpsc_admin_dynamic_js' );
356
  }
357
 
358
  function wpsc_admin_dynamic_css() {
359
  header( 'Content-Type: text/css' );
360
+ header( 'Expires: ' . gmdate( 'r', mktime( 0, 0, 0, date( 'm' ), ( date( 'd' ) + 12 ), date( 'Y' ) ) ) . '' );
361
  header( 'Cache-Control: public, must-revalidate, max-age=86400' );
362
  header( 'Pragma: public' );
363
  $flash = 0;
387
  exit();
388
  }
389
 
390
+ if ( isset( $_GET['wpsc_admin_dynamic_css'] ) && ( $_GET['wpsc_admin_dynamic_css'] == 'true' ) ) {
391
  add_action( "admin_init", 'wpsc_admin_dynamic_css' );
392
  }
393
 
408
  $year = date( "Y" );
409
  $month = date( "m" );
410
  $start_timestamp = mktime( 0, 0, 0, $month, 1, $year );
411
+ $end_timestamp = mktime( 0, 0, 0, ( $month + 1 ), 0, $year );
412
  $sql = "SELECT COUNT(*) FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `date` BETWEEN '$start_timestamp' AND '$end_timestamp' AND `processed` IN (2,3,4) ORDER BY `date` DESC";
413
  $currentMonthOrders = $wpdb->get_var( $sql );
414
 
426
  echo "<p class='dashboardWidgetSpecial'>";
427
  //calculates average sales amount per order for the month
428
  if ( $currentMonthOrders > 0 ) {
429
+ $monthsAverage = ( (int)admin_display_total_price( $start_timestamp, $end_timestamp ) / (int)$currentMonthOrders );
430
  echo wpsc_currency_display( $monthsAverage );
431
  }
432
  //echo "</span>";
452
  echo "</p>";
453
  echo "<p class='dashboardWidgetSpecial'>";
454
  //calculates average sales amount per order for the month
455
+ if ( ( admin_display_total_price() > 0 ) && ( $totalOrders > 0 ) ) {
456
+ $totalAverage = ( (int)admin_display_total_price() / (int)$totalOrders );
457
  } else {
458
  $totalAverage = 0;
459
  }
483
  wp_enqueue_style( 'wp-e-commerce-admin', WPSC_URL . '/wpsc-admin/css/admin.css', false, $version_identifier, 'all' );
484
  wp_enqueue_script( 'datepicker-ui', WPSC_URL . "/wpsc-core/js/ui.datepicker.js", array( 'jquery', 'jquery-ui-core', 'jquery-ui-sortable' ), $version_identifier );
485
  // Add the dashboard widgets
486
+ wp_add_dashboard_widget( 'wpsc_dashboard_news', __( 'Getshopped News' , 'wpsc' ), 'wpsc_dashboard_news' );
487
+ wp_add_dashboard_widget( 'wpsc_dashboard_widget', __( 'Sales Summary', 'wpsc' ), 'wpsc_dashboard_widget' );
488
+ wp_add_dashboard_widget( 'wpsc_quarterly_dashboard_widget', __( 'Sales by Quarter', 'wpsc' ), 'wpsc_quarterly_dashboard_widget' );
489
+ wp_add_dashboard_widget( 'wpsc_dashboard_4months_widget', __( 'Sales by Month', 'wpsc' ), 'wpsc_dashboard_4months_widget' );
490
+
491
  // Sort the Dashboard widgets so ours it at the top
492
  global $wp_meta_boxes;
493
  $normal_dashboard = $wp_meta_boxes['dashboard']['normal']['core'];
494
  // Backup and delete our new dashbaord widget from the end of the array
495
+ $wpsc_widget_backup = array( 'wpsc_dashboard_news' => $normal_dashboard['wpsc_dashboard_news'] );
496
+ $wpsc_widget_backup += array( 'wpsc_dashboard_widget' => $normal_dashboard['wpsc_dashboard_widget'] );
497
+ $wpsc_widget_backup += array( 'wpsc_quarterly_dashboard_widget' => $normal_dashboard['wpsc_quarterly_dashboard_widget'] );
498
+ $wpsc_widget_backup += array( 'wpsc_dashboard_4months_widget' => $normal_dashboard['wpsc_dashboard_4months_widget'] );
499
+
500
+ unset( $normal_dashboard['wpsc_dashboard_news'] );
501
+ unset( $normal_dashboard['wpsc_dashboard_widget'] );
502
+ unset( $normal_dashboard['wpsc_quarterly_dashboard_widget'] );
503
+ unset( $normal_dashboard['wpsc_dashboard_4months_widget'] );
504
+
505
  // Merge the two arrays together so our widget is at the beginning
506
+
507
+ $sorted_dashboard = array_merge( $wpsc_widget_backup, $normal_dashboard );
508
+
509
+ // Save the sorted array back into the original metaboxes
510
+
511
  $wp_meta_boxes['dashboard']['normal']['core'] = $sorted_dashboard;
512
  }
513
  }
518
 
519
  add_action( 'wp_dashboard_setup', 'wpsc_dashboard_widget_setup' );
520
 
521
+ function wpsc_dashboard_news() {
522
+ $rss = fetch_feed( 'http://getshopped.org/category/wp-e-commerce-plugin/' );
523
+ $args = array( 'show_author' => 1, 'show_date' => 1, 'show_summary' => 1, 'items'=>3 );
524
+ wp_widget_rss_output( $rss, $args );
525
 
526
  }
527
 
544
  if ( get_option( 'wpsc_business_year_start' ) == false ) {
545
  ?>
546
  <form action='' method='post'>
547
+ <label for='date_start'><?php _e( 'Financial Year End' , 'wpsc' ); ?>: </label>
548
  <input id='date_start' type='text' class='pickdate' size='11' value='<?php echo get_option( 'wpsc_last_date' ); ?>' name='add_start' />
549
  <!--<select name='add_start[day]'>
550
  <?php
566
  }
567
  echo "<option $selected value='$i'>" . date( "M", mktime( 0, 0, 0, $i, 1, date( "Y" ) ) ) . "</option>";
568
  }
569
+ ?>
570
  </select>
571
  <select name='add_start[year]'>
572
  <?php
573
+ for ( $i = date( "Y" ); $i <= ( date( "Y" ) + 12 ); ++$i ) {
574
  $selected = '';
575
  if ( $i == date( "Y" ) ) {
576
  $selected = "selected='true'";
577
  }
578
  echo "<option $selected value='$i'>" . $i . "</option>";
579
  }
580
+ ?>
581
  </select>-->
582
  <input type='hidden' name='wpsc_admin_action' value='wpsc_quarterly' />
583
  <input type='submit' class='button primary' value='Submit' name='wpsc_submit' />
601
  ?>
602
  <div id='box'>
603
  <p class='atglance'>
604
+ <span class='wpsc_quart_left'><?php _e( 'At a Glance' , 'wpsc' ); ?></span>
605
+ <span class='wpsc_quart_right'><?php _e( 'Revenue' , 'wpsc' ); ?></span>
606
  </p>
607
  <div style='clear:both'></div>
608
  <p class='quarterly'>
656
  $months[] = mktime( 0, 0, 0, $this_month, 1, $this_year );
657
 
658
  $products = $wpdb->get_results( "SELECT `cart`.`prodid`,
659
+ `cart`.`name`
660
  FROM `" . WPSC_TABLE_CART_CONTENTS . "` AS `cart`
661
  INNER JOIN `" . WPSC_TABLE_PURCHASE_LOGS . "` AS `logs`
662
+ ON `cart`.`purchaseid` = `logs`.`id`
663
+ WHERE `logs`.`processed` >= 2
664
  AND `logs`.`date` >= " . $months[0] . "
665
+ GROUP BY `cart`.`prodid`
666
+ ORDER BY SUM(`cart`.`price` * `cart`.`quantity`) DESC
667
  LIMIT 4", ARRAY_A ); //get 4 products with top income in 4 last months.
668
 
669
  $timeranges[0]["start"] = mktime( 0, 0, 0, $this_month - 3, 1, $this_year ); //make array of time ranges
679
  foreach ( (array)$products as $product ) { //run through products and get each product income amounts and name
680
  $sale_totals = array( );
681
  foreach ( $timeranges as $timerange ) { //run through time ranges of product, and get its income over each time range
682
+ $prodsql = "SELECT
683
+ SUM(`cart`.`price` * `cart`.`quantity`) AS sum
684
  FROM `" . WPSC_TABLE_CART_CONTENTS . "` AS `cart`
685
  INNER JOIN `" . WPSC_TABLE_PURCHASE_LOGS . "` AS `logs`
686
+ ON `cart`.`purchaseid` = `logs`.`id`
687
+ WHERE `logs`.`processed` >= 2
688
  AND `logs`.`date` >= " . $timerange["start"] . "
689
  AND `logs`.`date` < " . $timerange["end"] . "
690
  AND `cart`.`prodid` = " . $product['prodid'] . "
694
  $prod_data[] = array(
695
  'sale_totals' => $sale_totals,
696
  'product_name' => $product['name'] ); //result: array of 2: $prod_data[0] = array(income)
697
+ $sums = array( ); //reset array //$prod_data[1] = product name
698
  }
699
 
700
  $tablerow = 1;
739
  }
740
  add_filter( 'favorite_actions', 'wpsc_fav_action' );
741
 
742
+ function wpsc_print_admin_scripts() {
743
  global $version_identifier;
744
+ wp_enqueue_script( 'wp-e-commerce-dynamic', get_bloginfo( 'url' ) . "/index.php?wpsc_user_dynamic_js=true", false, $version_identifier );
745
  }
746
 
747
  /**
748
  * wpsc_update_permalinks update the product pages permalinks when WordPress permalinks are changed
 
749
  *
750
+ * @public
751
+ *
752
+ * @3.8
753
+ * @returns nothing
754
+ */
755
+ function wpsc_update_permalinks( $return = '' ) {
756
+ wpsc_update_page_urls( true );
757
+ return $return;
758
+ }
759
+
760
+ /**
761
+ * wpsc_ajax_ie_save save changes made using inline edit
762
+ *
763
+ * @public
764
+ *
765
+ * @3.8
766
  * @returns nothing
767
  */
768
+ function wpsc_ajax_ie_save() {
769
+
770
+ $product_post_type = get_post_type_object( 'wpsc-product' );
771
+
772
+ if ( !current_user_can( $product_post_type->cap->edit_posts ) ) {
773
+ echo '({"error":"' . __( 'Error: you don\'t have required permissions to edit this product', 'wpsc' ) . '", "id": "'. $_POST['id'] .'"})';
774
+ die();
775
+ }
776
+
777
+ global $wpdb;
778
+
779
+ $product = array(
780
+ 'ID' => $_POST['id'],
781
+ 'post_title' => $_POST['title']
782
+ );
783
+
784
+ $id = wp_update_post( $product );
785
+ if ( $id > 0 ) {
786
+ $product_meta = get_product_meta( $product['ID'], 'product_metadata', true );
787
+ if ( is_numeric( $_POST['weight'] ) || empty( $_POST['weight'] ) )
788
+ $product_meta['weight'] = $_POST['weight'];
789
+
790
+ update_product_meta( $product['ID'], 'product_metadata', $product_meta );
791
+ update_product_meta( $product['ID'], 'price', (float)$_POST['price'] );
792
+ update_product_meta( $product['ID'], 'special_price', (float)$_POST['special_price'] );
793
+ update_product_meta( $product['ID'], 'sku', $_POST['sku'] );
794
+ if ( $_POST['stock'] === '' )
795
+ update_product_meta( $product['ID'], 'stock', '' );
796
+ else
797
+ update_product_meta( $product['ID'], 'stock', absint( $_POST['stock'] ) );
798
+
799
+ $post = get_post( $id );
800
+ $meta = get_product_meta( $id, 'product_metadata', true );
801
+ $price = get_product_meta( $id, 'price', true );
802
+ $special_price = get_product_meta( $id, 'special_price', true );
803
+ $sku = get_product_meta( $id, 'sku', true );
804
+ $sku = ( $sku )?$sku:'N/A';
805
+ $stock = get_product_meta( $id, 'stock', true );
806
+ $stock = ( $stock === '' )?'N/A':$stock;
807
+ $results = array( 'id' => $id, 'title' => $post->post_title, 'weight' => absint( $meta['weight'] ), 'price' => wpsc_currency_display( $price ), 'special_price' => wpsc_currency_display( $special_price ), 'sku' => $sku, 'stock' => $stock );
808
+ echo '(' . json_encode( $results ) . ')';
809
+ die();
810
+ } else {
811
+ echo '({"error":"' . __( 'Error updating product', 'wpsc' ) . '", "id": "'. $_POST['id'] .'"})';
812
+ }
813
+ die();
814
  }
815
+
816
+ add_action( 'permalink_structure_changed' , 'wpsc_update_permalinks' );
817
+ add_action( 'get_sample_permalink_html' , 'wpsc_update_permalinks' );
818
+ add_action( 'wp_ajax_category_sort_order', 'wpsc_ajax_set_category_order' );
819
+ add_action( 'wp_ajax_wpsc_ie_save', 'wpsc_ajax_ie_save' );
820
 
821
 
822
  ?>
wpsc-admin/ajax-and-init.php CHANGED
@@ -1,2473 +1,2049 @@
1
- <?php
2
-
3
- /**
4
- * WP eCommerce Admin AJAX functions
5
- *
6
- * These are the WPSC Admin AJAX functions
7
- *
8
- * @package wp-e-commerce
9
- * @since 3.7
10
- */
11
- function wpsc_ajax_add_tracking() {
12
- global $wpdb;
13
- foreach ( $_POST as $key => $value ) {
14
- if ( $value != '' ) {
15
- $parts = preg_split( '/^wpsc_trackingid/', $key );
16
- if ( count( $parts ) > '1' ) {
17
- $id = $parts[1];
18
- $trackingid = $value;
19
- $sql = "UPDATE `" . WPSC_TABLE_PURCHASE_LOGS . "` SET `track_id`='" . $trackingid . "' WHERE `id`=" . $id;
20
- $wpdb->query( $sql );
21
- }
22
- }
23
- }
24
- }
25
-
26
- if ( isset( $_REQUEST['submit'] ) && ($_REQUEST['submit'] == 'Add Tracking ID') ) {
27
- add_action( 'admin_init', 'wpsc_ajax_add_tracking' );
28
- }
29
-
30
- function wpsc_delete_currency_layer() {
31
- global $wpdb;
32
- $meta_key = 'currency[' . $_POST['currSymbol'] . ']';
33
- $sql = "DELETE FROM `" . WPSC_TABLE_PRODUCTMETA . "` WHERE `meta_key`='" . $meta_key . "' LIMIT 1";
34
- $wpdb->query( $sql );
35
- }
36
-
37
- if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'delete_currency_layer') ) {
38
- add_action( 'admin_init', 'wpsc_delete_currency_layer' );
39
- }
40
-
41
- function wpsc_purchlog_email_trackid() {
42
- global $wpdb;
43
- $id = absint( $_POST['purchlog_id'] );
44
- $trackingid = $wpdb->get_var( "SELECT `track_id` FROM " . WPSC_TABLE_PURCHASE_LOGS . " WHERE `id`={$id} LIMIT 1" );
45
-
46
- $message = get_option( 'wpsc_trackingid_message' );
47
- $message = str_replace( '%trackid%', $trackingid, $message );
48
- $message = str_replace( '%shop_name%', get_option( 'blogname' ), $message );
49
-
50
- $email_form_field = $wpdb->get_var( "SELECT `id` FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `type` IN ('email') AND `active` = '1' ORDER BY `order` ASC LIMIT 1" );
51
- $email = $wpdb->get_var( "SELECT `value` FROM `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` WHERE `log_id`=" . $id . " AND `form_id` = '$email_form_field' LIMIT 1" );
52
-
53
-
54
- $subject = get_option( 'wpsc_trackingid_subject' );
55
- $subject = str_replace( '%shop_name%', get_option( 'blogname' ), $subject );
56
- wp_mail( $email, $subject, $message, "From: " . get_option( 'return_email' ) . " <" . get_option( 'return_email' ) . ">" );
57
- exit( true );
58
- }
59
-
60
- if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'purchlog_email_trackid') ) {
61
- add_action( 'admin_init', 'wpsc_purchlog_email_trackid' );
62
- }
63
-
64
- function wpsc_ajax_sales_quarterly() {
65
- global $wpdb;
66
- $lastdate = $_POST['add_start'];
67
- $date = preg_split( '/-/', $lastdate );
68
- if ( !isset( $date[0] ) )
69
- $date[0] = 0;
70
- if ( !isset( $date[1] ) )
71
- $date[1] = 0;
72
- if ( !isset( $date[2] ) )
73
- $date[2] = 0;
74
- $lastquart = mktime( 0, 0, 0, $date[1], $date[2], $date[0] );
75
- if ( $lastquart != get_option( 'wpsc_last_quarter' ) ) {
76
- update_option( 'wpsc_last_date', $lastdate );
77
- update_option( 'wpsc_fourth_quart', $lastquart );
78
- $thirdquart = mktime( 0, 0, 0, $date[1] - 3, $date[2], $date[0] );
79
- update_option( 'wpsc_third_quart', $thirdquart );
80
- $secondquart = mktime( 0, 0, 0, $date[1] - 6, $date[2], $date[0] );
81
- update_option( 'wpsc_second_quart', $secondquart );
82
- $firstquart = mktime( 0, 0, 0, $date[1] - 9, $date[2], $date[0] );
83
- update_option( 'wpsc_first_quart', $firstquart );
84
- $finalquart = mktime( 0, 0, 0, $date[1], $date[2], $date[0] - 1 );
85
- update_option( 'wpsc_final_quart', $finalquart );
86
- }
87
- }
88
-
89
- if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'wpsc_quarterly') ) {
90
- add_action( 'admin_init', 'wpsc_ajax_sales_quarterly' );
91
- }
92
-
93
- function wpsc_ajax_load_product() {
94
- global $wpdb;
95
- $product_id = absint( $_REQUEST['product'] );
96
- check_admin_referer( 'edit-product_' . $product_id );
97
- wpsc_display_product_form( $product_id );
98
- exit();
99
- }
100
-
101
- if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'load_product') ) {
102
- add_action( 'admin_init', 'wpsc_ajax_load_product' );
103
- }
104
-
105
- function wpsc_delete_file() {
106
- global $wpdb;
107
- $output = 0;
108
- $row_number = absint( $_GET['row_number'] );
109
- $product_id = absint( $_GET['product_id'] );
110
- $file_name = basename( $_GET['file_name'] );
111
- check_admin_referer( 'delete_file_' . $file_name );
112
-
113
-
114
- $product_id_to_delete = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_title = '$file_name' AND post_parent = '$product_id' AND post_type ='wpsc-product-file'" ) );
115
-
116
- wp_delete_post( $product_id_to_delete, true );
117
-
118
- if ( $_POST['ajax'] !== 'true' ) {
119
- $sendback = wp_get_referer();
120
- wp_redirect( $sendback );
121
- }
122
-
123
- echo "jQuery('#select_product_file_row_$row_number').fadeOut('fast',function() {\n";
124
- echo " jQuery(this).remove();\n";
125
- echo " jQuery('div.select_product_file p:even').removeClass('alt');\n";
126
- echo " jQuery('div.select_product_file p:odd').addClass('alt');\n";
127
- echo "});\n";
128
-
129
- exit( "" );
130
- }
131
-
132
- if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'delete_file') ) {
133
- add_action( 'admin_init', 'wpsc_delete_file' );
134
- }
135
- function wpsc_untrash_product(){
136
- $product_id = $_GET['product'];
137
-
138
- if ( !current_user_can( 'delete_post', $product_id ) )
139
- wp_die( __( 'You are not allowed to restore this product from the trash.', 'wpsc' ) );
140
-
141
- if ( !wp_untrash_post( $product_id ) )
142
- wp_die( __( 'Error in restoring from trash...' ) );
143
-
144
- $untrashed++;
145
- $sendback = wp_get_referer();
146
- $sendback = remove_query_arg( 'wpsc_admin_action', $sendback );
147
- $sendback = add_query_arg( 'untrashed', $untrashed, $sendback );
148
-
149
- wp_redirect($sendback);
150
- }
151
-
152
- if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'untrash') ) {
153
- add_action( 'admin_init', 'wpsc_untrash_product' );
154
- }
155
-
156
-
157
- /**
158
- * Delete a product from the DB , either moves it to trash or deletes it permanently
159
- * @access public
160
- *
161
- * @since 3.8
162
- * @return redirects to edit products page
163
- */
164
- function wpsc_delete_product(){
165
- global $wpdb;
166
- $force_trash = false;
167
- if ( 'delete' == $_REQUEST['wpsc_admin_action'])
168
- $force_trash = true;
169
- $delete = 0;
170
- $sendback = wp_get_referer();
171
- $product_id = $_GET['product'];
172
- if ( !current_user_can( 'delete_post', $product_id ) )
173
- wp_die( __( 'You are not allowed to delete this post.' ) );
174
-
175
- if($force_trash){
176
- if ( !wp_delete_post( $product_id , $force_trash) )
177
- wp_die( __( 'Error in deleting...' ) );
178
- }else{
179
- do_action( 'wpsc_delete_product', $product_id );
180
- if ( !wp_trash_post( $product_id ) )
181
- wp_die( __( 'Error placing product in trash...' ) );
182
- }
183
- $sendback = remove_query_arg( 'wpsc_admin_action', $sendback );
184
- $sendback = add_query_arg( 'deleted', $deleted, $sendback );
185
- wp_redirect( $sendback );
186
- exit();
187
-
188
- }
189
- if ( isset( $_REQUEST['wpsc_admin_action'] ) && (('delete' == $_REQUEST['wpsc_admin_action']) || ( 'trash' ==$_REQUEST['wpsc_admin_action']))) {
190
- add_action( 'admin_init', 'wpsc_delete_product' );
191
- }
192
-
193
- function wpsc_bulk_modify_products() {
194
- global $wpdb;
195
- $doaction = $_POST['bulkAction'];
196
- $sendback = wp_get_referer();
197
- //exit('<pre>'.print_r($_POST,1).'</pre>');
198
- if(!empty($_POST['post']))
199
- $product_ids = $_POST['post'];
200
- else
201
- $product_ids = array();
202
- switch ( $doaction ) {
203
-
204
- case 'addgroup':
205
-
206
- foreach ( (array)$product_ids as $product_id ) {
207
- $product_id = absint( $product_id );
208
- $current_product_categories = get_the_product_category($product_id);
209
- $new_product_category = array();
210
- if(isset($_POST['bulk_category']) && is_numeric($_POST['bulk_category'])){
211
- array_push($new_product_category,$_POST['bulk_category']);
212
- }else{
213
- //No Valid Group was selected for bulk assignment :(
214
- $sendback = add_query_arg( 'addedgroup', 'quack', $sendback );
215
- break;
216
- }
217
- if(isset($current_product_categories)){
218
- foreach($current_product_categories as $category){
219
- array_push($new_product_category,$category->term_id);
220
- }
221
- }
222
-
223
- wp_set_product_categories($product_id,$new_product_category);
224
- $added++;
225
- }
226
- $sendback = add_query_arg( 'addedgroup', $added, $sendback );
227
- break;
228
-
229
- case 'publish':
230
- foreach ( (array)$product_ids as $product_id ) {
231
- $product_id = absint( $product_id );
232
- wp_publish_post( $product_id );
233
- $published++;
234
- }
235
- $sendback = add_query_arg( 'published', $published, $sendback );
236
- break;
237
-
238
- case 'unpublish':
239
- foreach ( (array)$product_ids as $product_id ) {
240
- $product_id = absint( $product_id );
241
- wp_update_post( array( 'ID' => $product_id, 'post_status' => 'draft' ) );
242
- $published++;
243
- }
244
- $sendback = add_query_arg( 'published', $published, $sendback );
245
- break;
246
-
247
-
248
- case 'trash':
249
- $trashed = 0;
250
- foreach ( (array)$product_ids as $product_id ) {
251
- if ( !current_user_can( 'delete_post', $product_id ) ) {
252
- wp_die( __( 'You are not allowed to move this product to the trash.', 'wpsc' ) );
253
- }
254
- if ( !wp_trash_post( $product_id ) ) {
255
- wp_die( __( 'Error in moving to trash...' ) );
256
- }
257
- $trashed++;
258
- }
259
- $sendback = add_query_arg( array( 'trashed' => $trashed, 'ids' => join( ',', $product_ids ) ), $sendback );
260
- break;
261
-
262
- case 'untrash':
263
- $untrashed = 0;
264
- foreach ( (array)$product_ids as $product_id ) {
265
- if ( !current_user_can( 'delete_post', $product_id ) ) {
266
- wp_die( __( 'You are not allowed to restore this product from the trash.', 'wpsc' ) );
267
- }
268
- if ( !wp_untrash_post( $product_id ) ) {
269
- wp_die( __( 'Error in restoring from trash...' ) );
270
- }
271
- $untrashed++;
272
- }
273
- $sendback = add_query_arg( 'untrashed', $untrashed, $sendback );
274
- break;
275
-
276
- case 'delete':
277
- $deleted = 0;
278
- foreach ( (array)$product_ids as $product_id ) {
279
- $product_del = & get_post( $product_id );
280
-
281
- if ( !current_user_can( 'delete_post', $product_id ) ) {
282
- wp_die( __( 'You are not allowed to delete this post.' ) );
283
- }
284
-
285
- if ( $product_del->post_type == 'attachment' ) {
286
- if ( !wp_delete_attachment( $product_id ) ) {
287
- wp_die( __( 'Error in deleting...' ) );
288
- }
289
- } else {
290
- if ( !wp_delete_post( $product_id ) ) {
291
- wp_die( __( 'Error in deleting...' ) );
292
- }
293
- }
294
- $deleted++;
295
- }
296
- $sendback = add_query_arg( 'deleted', $deleted, $sendback );
297
- break;
298
-
299
-
300
- default:
301
- if ( isset( $_POST['search'] ) && !empty( $_POST['search'] ) ) {
302
- // urlencode the search query to allow for spaces, etc
303
- $sendback = add_query_arg( 'search', urlencode( stripslashes( $_POST['search'] ) ), $sendback );
304
- }elseif( !empty( $_POST['category'] )){
305
- $sendback = add_query_arg( 'category_id', (int)$_POST['category'], $sendback);
306
-
307
- }
308
- break;
309
- }
310
-
311
- wp_redirect( $sendback );
312
- exit();
313
- }
314
-
315
- if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'bulk_modify') ) {
316
- add_action( 'admin_init', 'wpsc_bulk_modify_products' );
317
- }
318
-
319
- function wpsc_modify_product_price() {
320
- global $wpdb;
321
- $product_data = array_pop( $_POST['product_price'] );
322
-
323
- $product_id = absint( $product_data['id'] );
324
- $product_price = $product_data['price'];
325
- $product_nonce = $product_data['nonce'];
326
-
327
- if ( wp_verify_nonce( $product_nonce, 'edit-product_price-' . $product_id ) ) {
328
- $product_price = (float)str_replace( ',','',$product_price );
329
- if ( update_post_meta( $product_id, '_wpsc_price', $product_price ) ) {
330
- echo "success = 1;\n\r";
331
- echo "new_price = '" . wpsc_currency_display( $product_price,array( 'display_as_html' => false ) ) . "';\n\r";
332
- } else {
333
- echo "success = 0;\n\r";
334
- }
335
- } else {
336
- echo "success = -1;\n\r";
337
- }
338
- exit();
339
- }
340
-
341
- if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'modify_price') ) {
342
- add_action( 'admin_init', 'wpsc_modify_product_price' );
343
- }
344
-
345
- function wpsc_modify_sales_product_price() {
346
- global $wpdb;
347
- $product_data = array_pop( $_POST['sale_product_price'] );
348
-
349
- $product_id = absint( $product_data['id'] );
350
- $product_price = $product_data['price'];
351
- $product_nonce = $product_data['nonce'];
352
-
353
- if ( wp_verify_nonce( $product_nonce, 'sale-edit-product_price-' . $product_id ) ) {
354
- $product_price = (float)str_replace( ',','',$product_price );
355
- if ( update_post_meta( $product_id, '_wpsc_special_price', $product_price ) ) {
356
- echo "success = 1;\n\r";
357
- echo "new_price = '" . wpsc_currency_display( $product_price,array( 'display_as_html' => false ) ) . "';\n\r";
358
- } else {
359
- echo "success = 0;\n\r";
360
- }
361
- } else {
362
- echo "success = -1;\n\r";
363
- }
364
- exit();
365
- }
366
-
367
- if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'modify_sales_price') ) {
368
- add_action( 'admin_init', 'wpsc_modify_sales_product_price' );
369
- }
370
-
371
- function wpsc_modify_sku() {
372
- global $wpdb;
373
- $product_data = array_pop( $_POST['sku_field'] );
374
-
375
- $product_id = absint( $product_data['id'] );
376
- $sku = $product_data['sku'];
377
- $product_nonce = $product_data['nonce'];
378
-
379
- if ( wp_verify_nonce( $product_nonce, 'edit-sku-' . $product_id ) ) {
380
- if ( update_post_meta( $product_id, '_wpsc_sku', $sku ) ) {
381
- echo "success = 1;\n\r";
382
- echo "new_price = '" . $sku . "';\n\r";
383
- } else {
384
- echo "success = 0;\n\r";
385
- }
386
- } else {
387
- echo "success = -1;\n\r";
388
- }
389
- exit();
390
- }
391
-
392
- if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'modify_sku') ) {
393
- add_action( 'admin_init', 'wpsc_modify_sku' );
394
- }
395
-
396
- function wpsc_modify_weight() {
397
- global $wpdb;
398
-
399
- $product_data = array_pop( $_POST['weight_field'] );
400
-
401
- $product_id = absint( $product_data['id'] );
402
- $product_nonce = $product_data['nonce'];
403
-
404
- if ( wp_verify_nonce( $product_nonce, 'edit-weight-' . $product_id ) ) {
405
-
406
- $old_array = get_product_meta( $product_id, 'product_metadata' );
407
- $old_array = array_pop( $old_array );
408
-
409
- $weight = wpsc_convert_weight( $product_data['weight'], $old_array["weight_unit"], "gram" );
410
-
411
- foreach ( $old_array as $key => $value ) {
412
- if ( $key == 'weight' ) {
413
- $old_array[$key] = $weight;
414
- }
415
- }
416
-
417
- if ( update_product_meta( $product_id, 'product_metadata', $old_array ) ) {
418
- echo "success = 1;\n\r";
419
- echo "new_price = '" . wpsc_convert_weight( $weight, "gram", $old_array["weight_unit"] ) . "';\n\r";
420
- } else {
421
- echo "success = 0;\n\r";
422
- }
423
- } else {
424
- echo "success = -1;\n\r";
425
- }
426
- exit();
427
- }
428
-
429
- if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'modify_weight') ) {
430
- add_action( 'admin_init', 'wpsc_modify_weight' );
431
- }
432
-
433
- function wpsc_modify_stock() {
434
- global $wpdb;
435
- $product_data = array_pop( $_POST['stock_field'] );
436
-
437
- $product_id = absint( $product_data['id'] );
438
- $stock = (int)$product_data['stock'];
439
- $product_nonce = $product_data['nonce'];
440
-
441
- if ( wp_verify_nonce( $product_nonce, 'edit-stock-' . $product_id ) ) {
442
- if ( update_post_meta( $product_id, '_wpsc_stock', $stock ) ) {
443
- echo "success = 1;\n\r";
444
- echo "new_price = '" . $stock . "';\n\r";
445
- } else {
446
- echo "success = 0;\n\r";
447
- }
448
- } else {
449
- echo "success = -1;\n\r";
450
- }
451
- exit();
452
- }
453
-
454
- if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'modify_stock') ) {
455
- add_action( 'admin_init', 'wpsc_modify_stock' );
456
- }
457
-
458
- /**
459
- Function and action for publishing or unpublishing single products
460
- */
461
- function wpsc_ajax_toggle_published() {
462
- global $wpdb;
463
-
464
- $product_id = absint( $_GET['product'] );
465
- check_admin_referer( 'toggle_publish_' . $product_id );
466
-
467
- $status = (wpsc_toggle_publish_status( $product_id )) ? ('true') : ('false');
468
- $sendback = add_query_arg( 'flipped', "1", wp_get_referer() );
469
- wp_redirect( $sendback );
470
- exit();
471
- }
472
-
473
- if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'toggle_publish') ) {
474
- add_action( 'admin_init', 'wpsc_ajax_toggle_published' );
475
- }
476
-
477
- /**
478
- Function and action for duplicating products,
479
- Refactored for 3.8
480
- * Purposely not duplicating stick post status (logically, products are most often duplicated because they share many attributes, where products are generally 'featured' uniquely.)
481
- */
482
- function wpsc_duplicate_product() {
483
- global $wpdb;
484
-
485
- // Get the original post
486
- $id = absint( $_GET['product'] );
487
- $post = wpsc_duplicate_this_dangit( $id );
488
-
489
- // Copy the post and insert it
490
- if ( isset( $post ) && $post != null ) {
491
- $new_id = wpsc_duplicate_product_process( $post );
492
-
493
- $duplicated = true;
494
- $sendback = wp_get_referer();
495
- $sendback = add_query_arg( 'duplicated', (int)$duplicated, $sendback );
496
-
497
- wp_redirect( $sendback );
498
- exit();
499
- } else {
500
- wp_die( __( 'Sorry, for some reason, we couldn\'t duplicate this product because it could not be found in the database, check there for this ID: ' ) . $id );
501
- }
502
- }
503
-
504
- function wpsc_duplicate_this_dangit( $id ) {
505
- $post = get_post($id);
506
- return $post;
507
- }
508
-
509
- function wpsc_duplicate_product_process( $post ) {
510
- global $wpdb, $current_user;
511
- wp_get_current_user();
512
- $user_ID = $current_user->ID;
513
-
514
- $new_post_date = $post->post_date;
515
- $new_post_date_gmt = get_gmt_from_date( $new_post_date );
516
-
517
- $new_post_type = $post->post_type;
518
- $post_content = str_replace( "'", "''", $post->post_content );
519
- $post_content_filtered = str_replace( "'", "''", $post->post_content_filtered );
520
- $post_excerpt = str_replace( "'", "''", $post->post_excerpt );
521
- $post_title = str_replace( "'", "''", $post->post_title ) . " (Duplicate)";
522
- $post_name = str_replace( "'", "''", $post->post_name );
523
- $comment_status = str_replace( "'", "''", $post->comment_status );
524
- $ping_status = str_replace( "'", "''", $post->ping_status );
525
-
526
- $defaults = array(
527
- 'post_status' => $post->post_status,
528
- 'post_type' => $new_post_type,
529
- 'post_author' => $user_ID,
530
- 'ping_status' => $ping_status,
531
- 'post_parent' => $post->post_parent,
532
- 'menu_order' => $post->menu_order,
533
- 'to_ping' => $post->to_ping,
534
- 'pinged' => $post->pinged,
535
- 'post_excerpt' => $post_excerpt,
536
- 'post_title' => $post_title,
537
- 'post_content' => $post_content,
538
- 'post_content_filtered' => $post_content_filtered,
539
- 'import_id' => 0
540
- );
541
- // Insert the new template in the post table
542
- $new_post_id = wp_insert_post($defaults);
543
- //$new_post_id = $wpdb->insert_id;
544
-
545
- // Copy the taxonomies
546
- wpsc_duplicate_taxonomies( $post->ID, $new_post_id, $post->post_type );
547
-
548
- // Copy the meta information
549
- wpsc_duplicate_product_meta( $post->ID, $new_post_id );
550
-
551
- // Finds children (Which includes product files AND product images), their meta values, and duplicates them.
552
- wpsc_duplicate_children( $post->ID, $new_post_id );
553
-
554
- return $new_post_id;
555
- }
556
-
557
- /**
558
- * Copy the taxonomies of a post to another post
559
- */
560
- function wpsc_duplicate_taxonomies( $id, $new_id, $post_type ) {
561
- global $wpdb;
562
- if ( isset( $wpdb->terms ) ) {
563
- // WordPress 2.3
564
- $taxonomies = get_object_taxonomies( $post_type ); //array("category", "post_tag");
565
- foreach ( $taxonomies as $taxonomy ) {
566
- $post_terms = wp_get_object_terms( $id, $taxonomy );
567
- for ( $i = 0; $i < count( $post_terms ); $i++ ) {
568
- wp_set_object_terms( $new_id, $post_terms[$i]->slug, $taxonomy, true );
569
- }
570
- }
571
- }
572
- }
573
-
574
- /**
575
- * Copy the meta information of a post to another post
576
- */
577
- function wpsc_duplicate_product_meta( $id, $new_id ) {
578
- global $wpdb;
579
- $post_meta_infos = $wpdb->get_results( "SELECT meta_key, meta_value FROM $wpdb->postmeta WHERE post_id=$id" );
580
-
581
- if ( count( $post_meta_infos ) != 0 ) {
582
- $sql_query = "INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) ";
583
-
584
- foreach ( $post_meta_infos as $meta_info ) {
585
- $meta_key = $meta_info->meta_key;
586
- $meta_value = addslashes( $meta_info->meta_value );
587
-
588
- $sql_query_sel[] = "SELECT $new_id, '$meta_key', '$meta_value'";
589
- }
590
- $sql_query.= implode( " UNION ALL ", $sql_query_sel );
591
- $wpdb->query( $sql_query );
592
- }
593
- }
594
-
595
- /**
596
- * Duplicates children product and children meta
597
- */
598
- function wpsc_duplicate_children( $old_parent_id, $new_parent_id ) {
599
- global $wpdb;
600
-
601
- //Get children products and duplicate them
602
- $child_posts = $wpdb->get_results( "SELECT * FROM $wpdb->posts WHERE post_parent = $old_parent_id" );
603
-
604
- foreach ( $child_posts as $child_post ) {
605
-
606
- $new_post_date = $child_post->post_date;
607
- $new_post_date_gmt = get_gmt_from_date( $new_post_date );
608
-
609
- $new_post_type = $child_post->post_type;
610
- $post_content = str_replace( "'", "''", $child_post->post_content );
611
- $post_content_filtered = str_replace( "'", "''", $child_post->post_content_filtered );
612
- $post_excerpt = str_replace( "'", "''", $child_post->post_excerpt );
613
- $post_title = str_replace( "'", "''", $child_post->post_title );
614
- $post_name = str_replace( "'", "''", $child_post->post_name );
615
- $comment_status = str_replace( "'", "''", $child_post->comment_status );
616
- $ping_status = str_replace( "'", "''", $child_post->ping_status );
617
-
618
- $wpdb->query(
619
- "INSERT INTO $wpdb->posts
620
- (post_author, post_date, post_date_gmt, post_content, post_content_filtered, post_title, post_excerpt, post_status, post_type, comment_status, ping_status, post_password, to_ping, pinged, post_modified, post_modified_gmt, post_parent, menu_order, post_mime_type)
621
- VALUES
622
- ('$child_post->post_author', '$new_post_date', '$new_post_date_gmt', '$post_content', '$post_content_filtered', '$post_title', '$post_excerpt', '$child_post->post_status', '$new_post_type', '$comment_status', '$ping_status', '$child_post->post_password', '$child_post->to_ping', '$child_post->pinged', '$new_post_date', '$new_post_date_gmt', '$new_parent_id', '$child_post->menu_order', '$child_post->post_mime_type')" );
623
-
624
- $old_post_id = $child_post->ID;
625
- $new_post_id = $wpdb->insert_id;
626
- $child_meta = $wpdb->get_results( "SELECT post_id, meta_key, meta_value FROM $wpdb->postmeta WHERE post_id = $old_post_id" );
627
-
628
- foreach ( $child_meta as $child_meta ) {
629
- $wpdb->query(
630
- "INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value)
631
- VALUES('$new_post_id', '$child_meta->meta_key', '$child_meta->meta_value')"
632
- );
633
- }
634
- }
635
- }
636
-
637
- if ( isset( $_GET['wpsc_admin_action'] ) && ($_GET['wpsc_admin_action'] == 'duplicate_product') ) {
638
- add_action( 'admin_init', 'wpsc_duplicate_product' );
639
- }
640
-
641
- function wpsc_purchase_log_csv() {
642
- global $wpdb, $user_level, $wp_rewrite, $wpsc_purchlog_statuses;
643
- get_currentuserinfo();
644
- if ( ($_GET['rss_key'] == 'key') && is_numeric( $_GET['start_timestamp'] ) && is_numeric( $_GET['end_timestamp'] ) && ($user_level >= 7) ) {
645
- $form_sql = "SELECT * FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `active` = '1' AND `display_log` = '1';";
646
- $form_data = $wpdb->get_results( $form_sql, ARRAY_A );
647
-
648
- $start_timestamp = $_GET['start_timestamp'];
649
- $end_timestamp = $_GET['end_timestamp'];
650
- $data = $wpdb->get_results( "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `date` BETWEEN '$start_timestamp' AND '$end_timestamp' ORDER BY `date` DESC", ARRAY_A );
651
-
652
- header( 'Content-Type: text/csv' );
653
- header( 'Content-Disposition: inline; filename="Purchase Log ' . date( "M-d-Y", $start_timestamp ) . ' to ' . date( "M-d-Y", $end_timestamp ) . '.csv"' );
654
-
655
- foreach ( (array)$data as $purchase ) {
656
- $country_sql = "SELECT * FROM `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` WHERE `log_id` = '" . $purchase['id'] . "' AND `form_id` = '" . get_option( 'country_form_field' ) . "' LIMIT 1";
657
- $country_data = $wpdb->get_results( $country_sql, ARRAY_A );
658
- $country = $country_data[0]['value'];
659
-
660
- $output .= "\"" . $purchase['totalprice'] . "\",";
661
-
662
- foreach ( (array)$form_data as $form_field ) {
663
- $collected_data_sql = "SELECT * FROM `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` WHERE `log_id` = '" . $purchase['id'] . "' AND `form_id` = '" . $form_field['id'] . "' LIMIT 1";
664
- $collected_data = $wpdb->get_results( $collected_data_sql, ARRAY_A );
665
- $collected_data = $collected_data[0];
666
- $output .= "\"" . $collected_data['value'] . "\",";
667
- }
668
-
669
- if ( get_option( 'payment_method' ) == 2 ) {
670
- $gateway_name = '';
671
- $nzshpcrt_gateways = nzshpcrt_get_gateways();
672
-
673
- foreach ( $nzshpcrt_gateways as $gateway ) {
674
- if ( $purchase['gateway'] != 'testmode' ) {
675
- if ( $gateway['internalname'] == $purchase['gateway'] ) {
676
- $gateway_name = $gateway['name'];
677
- }
678
- } else {
679
- $gateway_name = "Manual Payment";
680
- }
681
- }
682
- $output .= "\"" . $gateway_name . "\",";
683
- }
684
-
685
- if ( $purchase['processed'] < 1 ) {
686
- $purchase['processed'] = 1;
687
- }
688
-
689
- $status_name = wpsc_find_purchlog_status_name( $purchase['processed'] );
690
- $output .= "\"" . $status_name . "\",";
691
-
692
- $output .= "\"" . date( "jS M Y", $purchase['date'] ) . "\"";
693
-
694
- $cartsql = "SELECT * FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid`=" . $purchase['id'] . "";
695
- $cart = $wpdb->get_results( $cartsql, ARRAY_A );
696
-
697
- foreach ( (array)$cart as $item ) {
698
- $output .= ",";
699
- $product = $wpdb->get_row( "SELECT * FROM `" . $wpdb->posts . "` WHERE `id`=" . $item['prodid'] . " LIMIT 1", ARRAY_A );
700
- $skuvalue = get_product_meta($item['prodid'], 'sku', true);
701
- $output .= "\"" . $item['quantity'] . " " . str_replace( '"', '\"', $product['name'] ) . $variation_list . "\"";
702
- $output .= "," . $skuvalue;
703
- }
704
- $output .= "\n"; // terminates the row/line in the CSV file
705
- }
706
- echo $output;
707
- exit();
708
- }
709
- }
710
-
711
- if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'wpsc_downloadcsv') ) {
712
- add_action( 'admin_init', 'wpsc_purchase_log_csv' );
713
- }
714
-
715
- function wpsc_admin_ajax() {
716
- global $wpdb, $user_level, $wp_rewrite;
717
- get_currentuserinfo();
718
-
719
- if ( $_POST['action'] == 'product-page-order' ) {
720
- $current_order = get_option( 'wpsc_product_page_order' );
721
- $new_order = $_POST['order'];
722
-
723
- if ( isset( $new_order["advanced"] ) ) {
724
- $current_order["advanced"] = array_unique( explode( ',', $new_order["advanced"] ) );
725
- }
726
- if ( isset( $new_order["side"] ) ) {
727
- $current_order["side"] = array_unique( explode( ',', $new_order["side"] ) );
728
- }
729
-
730
- update_option( 'wpsc_product_page_order', $current_order );
731
- exit( print_r( $order, 1 ) );
732
- }
733
-
734
- function wpec_hide_box( &$value, $key, $p ) {
735
-
736
- foreach ( $p as $pkey => $val ) {
737
- if ( $key == $pkey ) {
738
- $value = $val;
739
- }
740
- }
741
- }
742
-
743
- if ( $_POST['action'] == 'postbox-hide' ) {
744
- $current_order = get_option( 'wpsc_product_page_order' );
745
-
746
- $hidden_key = $_POST["hidden_val"];
747
- $hidden_val = $_POST["hidden"];
748
-
749
- $hidden = array( $hidden_key => $hidden_val );
750
-
751
- array_walk( $current_order["hiddenboxes"], "wpec_hide_box", $hidden );
752
-
753
- update_option( 'wpsc_product_page_order', $current_order );
754
- return print_r( $current_order );
755
- }
756
-
757
- function wpec_close_box( &$value, $key, $p ) {
758
- if ( in_array( $key, $p ) ) {
759
- $value = 0;
760
- } else {
761
- $value = 1;
762
- }
763
- }
764
-
765
- if ( $_POST['action'] == 'closed-postboxes' ) {
766
- $current_order = get_option( 'wpsc_product_page_order' );
767
-
768
- $closed = $_POST["closed"];
769
- $closed = array_unique( explode( ',', $closed ) );
770
-
771
- array_walk( $current_order["closedboxes"], "wpec_close_box", $closed );
772
-
773
- update_option( 'wpsc_product_page_order', $current_order );
774
- }
775
-
776
- if ( ($_POST['save_image_upload_state'] == "true") && is_numeric( $_POST['image_upload_state'] ) ) {
777
- $upload_state = (int)(bool)$_POST['image_upload_state'];
778
- update_option( 'wpsc_use_flash_uploader', $upload_state );
779
- exit( "done" );
780
- }
781
-
782
- if ( ($_POST['remove_variation_value'] == "true") && is_numeric( $_POST['variation_value_id'] ) ) {
783
- $value_id = absint( $_GET['variation_value_id'] );
784
- echo wp_delete_term( $value_id, 'wpsc-variation' );
785
- exit();
786
- }
787
-
788
- if ( ($_POST['remove_form_field'] == "true") && is_numeric( $_POST['form_id'] ) ) {
789
- if ( current_user_can( 'level_7' ) ) {
790
- $wpdb->query( $wpdb->prepare( "UPDATE `" . WPSC_TABLE_CHECKOUT_FORMS . "` SET `active` = '0' WHERE `id` = %d LIMIT 1 ;", $_POST['form_id'] ) );
791
- exit( ' ' );
792
- }
793
- }
794
-
795
-
796
- if ( $_POST['hide_ecom_dashboard'] == 'true' ) {
797
- require_once (ABSPATH . WPINC . '/rss.php');
798
- $rss = fetch_rss( 'http://www.instinct.co.nz/feed/' );
799
- $rss->items = array_slice( $rss->items, 0, 5 );
800
- $rss_hash = sha1( serialize( $rss->items ) );
801
- update_option( 'wpsc_ecom_news_hash', $rss_hash );
802
- exit( 1 );
803
- }
804
-
805
- if ( ($_POST['remove_meta'] == 'true') && is_numeric( $_POST['meta_id'] ) ) {
806
- $meta_id = (int)$_POST['meta_id'];
807
- if ( delete_meta( $meta_id ) ) {
808
- echo $meta_id;
809
- exit();
810
- }
811
- echo 0;
812
- exit();
813
- }
814
-
815
- if ( ($_REQUEST['log_state'] == "true") && is_numeric( $_POST['id'] ) && is_numeric( $_POST['value'] ) ) {
816
- $newvalue = $_POST['value'];
817
- if ( $_REQUEST['suspend'] == 'true' ) {
818
- if ( $_REQUEST['value'] == 1 ) {
819
- wpsc_member_dedeactivate_subscriptions( $_POST['id'] );
820
- } else {
821
- wpsc_member_deactivate_subscriptions( $_POST['id'] );
822
- }
823
- exit();
824
- } else {
825
-
826
- $log_data = $wpdb->get_row( "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `id` = '" . $_POST['id'] . "' LIMIT 1", ARRAY_A );
827
- if ( ($newvalue == 2) && function_exists( 'wpsc_member_activate_subscriptions' ) ) {
828
- wpsc_member_activate_subscriptions( $_POST['id'] );
829
- }
830
-
831
- $update_sql = "UPDATE `" . WPSC_TABLE_PURCHASE_LOGS . "` SET `processed` = '" . $newvalue . "' WHERE `id` = '" . $_POST['id'] . "' LIMIT 1";
832
- $wpdb->query( $update_sql );
833
- if ( ($newvalue > $log_data['processed']) && ($log_data['processed'] < 2) ) {
834
- transaction_results( $log_data['sessionid'], false );
835
- }
836
-
837
- $status_name = wpsc_find_purchlog_status_name( $purchase['processed'] );
838
- echo "document.getElementById(\"form_group_" . $_POST['id'] . "_text\").innerHTML = '" . $status_name . "';\n";
839
-
840
-
841
- $year = date( "Y" );
842
- $month = date( "m" );
843
- $start_timestamp = mktime( 0, 0, 0, $month, 1, $year );
844
- $end_timestamp = mktime( 0, 0, 0, ($month + 1 ), 0, $year );
845
-
846
- echo "document.getElementById(\"log_total_month\").innerHTML = '" . addslashes( wpsc_currency_display( admin_display_total_price( $start_timestamp, $end_timestamp ) ) ) . "';\n";
847
- echo "document.getElementById(\"log_total_absolute\").innerHTML = '" . addslashes( wpsc_currency_display( admin_display_total_price() ) ) . "';\n";
848
- exit();
849
- }
850
- }
851
-
852
- if ( isset( $_POST['language_setting'] ) && ($_GET['page'] = WPSC_DIR_NAME . '/wpsc-admin/display-options.page.php') ) {
853
- if ( $user_level >= 7 ) {
854
- update_option( 'language_setting', $_POST['language_setting'] );
855
- }
856
- }
857
- }
858
-
859
- function wpsc_admin_sale_rss() {
860
- global $wpdb;
861
- if ( ($_GET['rss'] == "true") && ($_GET['rss_key'] == 'key') && ($_GET['action'] == "purchase_log") ) {
862
- $sql = "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `date`!='' ORDER BY `date` DESC";
863
- $purchase_log = $wpdb->get_results( $sql, ARRAY_A );
864
- header( "Content-Type: application/xml; charset=UTF-8" );
865
- header( 'Content-Disposition: inline; filename="WP_E-Commerce_Purchase_Log.rss"' );
866
- $output = '';
867
- $output .= "<?xml version='1.0'?>\n\r";
868
- $output .= "<rss version='2.0'>\n\r";
869
- $output .= " <channel>\n\r";
870
- $output .= " <title>WP e-Commerce Product Log</title>\n\r";
871
- $output .= " <link>" . get_option( 'siteurl' ) . "/wp-admin/admin.php?page=" . WPSC_DIR_NAME . "/display-log.php</link>\n\r";
872
- $output .= " <description>This is the WP e-Commerce Product Log RSS feed</description>\n\r";
873
- $output .= " <generator>WP e-Commerce Plugin</generator>\n\r";
874
-
875
- foreach ( (array)$purchase_log as $purchase ) {
876
- $purchase_link = get_option( 'siteurl' ) . "/wp-admin/admin.php?page=" . WPSC_DIR_NAME . "/display-log.php&amp;purchaseid=" . $purchase['id'];
877
- $output .= " <item>\n\r";
878
- $output .= " <title>Purchase # " . $purchase['id'] . "</title>\n\r";
879
- $output .= " <link>$purchase_link</link>\n\r";
880
- $output .= " <description>This is an entry in the purchase log.</description>\n\r";
881
- $output .= " <pubDate>" . date( "r", $purchase['date'] ) . "</pubDate>\n\r";
882
- $output .= " <guid>$purchase_link</guid>\n\r";
883
- $output .= " </item>\n\r";
884
- }
885
- $output .= " </channel>\n\r";
886
- $output .= "</rss>";
887
- echo $output;
888
- exit();
889
- }
890
- }
891
-
892
- function wpsc_swfupload_images() {
893
- global $wpdb, $current_user, $user_ID;
894
- $file = $_FILES['async-upload'];
895
- $product_id = absint( $_POST['product_id'] );
896
- $nonce = $_POST['_wpnonce'];
897
- $output = '';
898
- // Flash often fails to send cookies with the POST or upload, so we need to pass it in GET or POST instead, code is from wp-admin/async-upload.php
899
- if ( is_ssl() && empty( $_COOKIE[SECURE_AUTH_COOKIE] ) && !empty( $_REQUEST['auth_cookie'] ) ) {
900
- $_COOKIE[SECURE_AUTH_COOKIE] = $_REQUEST['auth_cookie'];
901
- } else if ( empty( $_COOKIE[AUTH_COOKIE] ) && !empty( $_REQUEST['auth_cookie'] ) ) {
902
- $_COOKIE[AUTH_COOKIE] = $_REQUEST['auth_cookie'];
903
- }
904
- unset( $current_user );
905
-
906
- if ( !current_user_can( 'upload_files' ) ) {
907
- exit( "status=-1;\n" );
908
- }
909
-
910
- if ( !wp_verify_nonce( $nonce, 'product-swfupload' ) ) {
911
- exit( "status=-1;\n" );
912
- }
913
-
914
-
915
-
916
- $id = media_handle_upload( 'async-upload', $product_id );
917
-
918
- if ( !is_wp_error( $id ) ) {
919
- $src = wp_get_attachment_image_src( $id );
920
- $output .= "upload_status=1;\n";
921
- $output .= "image_src='" . $src[0] . "';\n";
922
- $output .= "image_id='$id';\n";
923
- $output .= "product_id='$product_id';\n";
924
- $output .= "replace_existing=0;";
925
- } else {
926
- $output .= "status=0;\n";
927
- }
928
-
929
-
930
- exit( $output );
931
- }
932
-
933
- function wpsc_display_invoice() {
934
-
935
- global $body_id;
936
-
937
- $body_id = 'wpsc-packing-slip';
938
- $purchase_id = (int)$_GET['purchaselog_id'];
939
- include_once(WPSC_FILE_PATH . "/wpsc-admin/admin-form-functions.php");
940
- require_once(ABSPATH . 'wp-admin/includes/media.php');
941
- wp_iframe( 'wpsc_packing_slip', $purchase_id );
942
- exit();
943
- }
944
- //other actions are here
945
- if ( isset( $_GET['display_invoice'] ) && ( 'true' == $_GET['display_invoice'] ) )
946
- add_action( 'admin_init', 'wpsc_display_invoice', 0 );
947
-
948
- if ( isset( $_REQUEST['wpsc_admin_action'] ) && ( 'wpsc_display_invoice' == $_REQUEST['wpsc_admin_action'] ) )
949
- add_action( 'admin_init', 'wpsc_display_invoice' );
950
-
951
- /**
952
- * Purchase log ajax code starts here
953
- */
954
- function wpsc_purchlog_resend_email() {
955
- global $wpdb;
956
- $shipping=0;
957
- $siteurl = get_option( 'siteurl' );
958
- $log_id = $_GET['email_buyer_id'];
959
- if ( is_numeric( $log_id ) ) {
960
-
961
- $selectsql = "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `id`= " . $log_id . " LIMIT 1";
962
-
963
- $purchase_log = $wpdb->get_row( $selectsql, ARRAY_A );
964
-
965
- if ( ($purchase_log['gateway'] == "testmode") && ($purchase_log['processed'] < 2) ) {
966
- $message = get_option( "wpsc_email_receipt" );
967
- $message_html = "<h2 style='font-size:16px;font-weight:bold;color:#000;border:0px;padding-top: 0px;' >" . __( 'Your Order', 'wpsc' ) . "</h2>";
968
- } else {
969
- $message = get_option( "wpsc_email_receipt" );
970
- $message_html = $message;
971
- }
972
-
973
- $order_url = $siteurl . "/wp-admin/admin.php?page=" . WPSC_DIR_NAME . "/display-log.php&amp;purchcaseid=" . $purchase_log['id'];
974
-
975
- $cartsql = "SELECT * FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid`=" . $purchase_log['id'] . "";
976
- $cart = $wpdb->get_results( $cartsql, ARRAY_A );
977
- if ( $purchase_log['shipping_country'] != '' ) {
978
- $billing_country = $purchase_log['billing_country'];
979
- $shipping_country = $purchase_log['shipping_country'];
980
- } else {
981
- $country = $wpdb->get_results( "SELECT * FROM `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` WHERE `log_id`=" . $purchase_log['id'] . " AND `form_id` = '" . get_option( 'country_form_field' ) . "' LIMIT 1", ARRAY_A );
982
- $billing_country = $country[0]['value'];
983
- $shipping_country = $country[0]['value'];
984
- }
985
-
986
- $email_form_field = $wpdb->get_results( "SELECT `id`,`type` FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `type` IN ('email') AND `active` = '1' ORDER BY `order` ASC LIMIT 1", ARRAY_A );
987
- $email_address = $wpdb->get_results( "SELECT * FROM `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` WHERE `log_id`=" . $purchase_log['id'] . " AND `form_id` = '" . $email_form_field[0]['id'] . "' LIMIT 1", ARRAY_A );
988
- $email = $email_address[0]['value'];
989
-
990
- $previous_download_ids = array( 0 );
991
-
992
- if ( ($cart != null ) ) {
993
- foreach ( $cart as $row ) {
994
- $link = "";
995
- $productsql = "SELECT * FROM $wpdb->posts WHERE `ID`=" . $row['prodid'] . "";
996
- $product_data = $wpdb->get_results( $productsql, ARRAY_A );
997
- $attachment = array(
998
- 'post_parent' => $row['prodid'],
999
- 'post_type' => "wpsc-product-file",
1000
- 'post_status' => 'inherit'
1001
- );
1002
- $dl_data = (array)get_posts( $attachment );
1003
- if ( $dl_data[0]->ID > 0 ) {
1004
- if ( $purchase_log['email_sent'] != 1 ) {
1005
- $wpdb->query( "UPDATE `" . WPSC_TABLE_DOWNLOAD_STATUS . "` SET `active`='1' WHERE `fileid`='" . $product_data[0]['file'] . "' AND `purchid` = '" . $purchase_log['id'] . "' LIMIT 1" );
1006
- }
1007
-
1008
- if ( ($purchase_log['processed'] >= 2 ) ) {
1009
- $download_data = $wpdb->get_results( "SELECT *
1010
- FROM `" . WPSC_TABLE_DOWNLOAD_STATUS . "` INNER JOIN $wpdb->posts
1011
- ON `" . WPSC_TABLE_DOWNLOAD_STATUS . "`.`fileid` = $wpdb->posts.`ID`
1012
- WHERE `" . WPSC_TABLE_DOWNLOAD_STATUS . "`.`active`='1'
1013
- AND `" . WPSC_TABLE_DOWNLOAD_STATUS . "`.`purchid`='" . $purchase_log['id'] . "'
1014
- AND (
1015
- `" . WPSC_TABLE_DOWNLOAD_STATUS . "`.`cartid` = '" . $row['id'] . "'
1016
- OR (
1017
- `" . WPSC_TABLE_DOWNLOAD_STATUS . "`.`cartid` IS NULL
1018
- AND `" . WPSC_TABLE_DOWNLOAD_STATUS . "`.`fileid` = '{$dl_data[0]->ID}'
1019
- )
1020
- )
1021
- AND `" . WPSC_TABLE_DOWNLOAD_STATUS . "`.`id` NOT IN ('" . implode( "','", $previous_download_ids ) . "')", ARRAY_A );
1022
- $link = array( );
1023
-
1024
- if ( sizeof( $download_data ) != 0 ) {
1025
-
1026
- foreach ( $download_data as $single_download ) {
1027
- if ( $single_download['uniqueid'] == null ) {// if the uniqueid is not equal to null, its "valid", regardless of what it is
1028
- $link[] = array( "url" => $siteurl . "?downloadid=" . $single_download['id'], "name" => $single_download["post_title"] );
1029
- } else {
1030
- $link[] = array( "url" => $siteurl . "?downloadid=" . $single_download['uniqueid'], "name" => $single_download["post_title"] );
1031
- }
1032
- }
1033
- }
1034
- $previous_download_ids[] = $download_data['id'];
1035
- $order_status = 4;
1036
- }
1037
- }
1038
- do_action( 'wpsc_confirm_checkout', $purchase_log['id'] );
1039
-
1040
- $shipping = $row['pnp'] * $row['quantity'];
1041
- $total_shipping += $shipping;
1042
- if ( isset( $_SESSION['quote_shipping'] ) ) {
1043
- $shipping = $_SESSION['quote_shipping'];
1044
- }
1045
- $total_shipping += $shipping;
1046
-
1047
- if ( $product_data[0]['special'] == 1 ) {
1048
- $price_modifier = $product_data[0]['special_price'];
1049
- } else {
1050
- $price_modifier = 0;
1051
- }
1052
-
1053
- $total+= ( $row['price'] * $row['quantity']);
1054
- $message_price = wpsc_currency_display( ( $row['price'] * $row['quantity'] ),array( 'display_as_html' => false ) );
1055
-
1056
- $shipping_price = wpsc_currency_display( $shipping,array( 'display_as_html' => false ) );
1057
-
1058
-
1059
-
1060
- if ( $link != '' ) {
1061
- $product_list .= " - " . $product_data['post_title'] . stripslashes( $variation_list ) . " " . $message_price . " " . __( 'Click to download', 'wpsc' ) . ":";
1062
- $product_list_html .= " - " . $product_data['post_title'] . stripslashes( $variation_list ) . " " . $message_price . "&nbsp;&nbsp;" . __( 'Click to download', 'wpsc' ) . ":\n\r";
1063
- foreach ( $link as $single_link ) {
1064
- $product_list .= "\n\r " . $single_link["name"] . ": " . $single_link["url"] . "\n\r";
1065
- $product_list_html .= "<a href='" . $single_link["url"] . "'>" . $single_link["name"] . "</a>\n";
1066
- }
1067
- } else {
1068
- $plural = '';
1069
-
1070
- if ( $row['quantity'] > 1 ) {
1071
- $plural = "s";
1072
- }
1073
-
1074
- $product_list.= " - " . $row['quantity'] . " " . $product_data[0]['post_title'] . $variation_list . " " . $message_price . "\n";
1075
- if ( $shipping > 0 )
1076
- $product_list .= " - " . __( 'Shipping', 'wpsc' ) . ":" . $shipping_price . "\n\r";
1077
- $product_list_html.= " - " . $row['quantity'] . " " . $product_data[0]['post_title'] . $variation_list . " " . $message_price . "\n";
1078
- if ( $shipping > 0 )
1079
- $product_list_html .= " - " . __( 'Shipping', 'wpsc' ) . ":" . $shipping_price . "\n\r";
1080
- }
1081
-
1082
- $report.= " - " . $product_data[0]['post_title'] . $variation_list . " " . $message_price . "\n";
1083
- }
1084
-
1085
- if ( $purchase_log['discount_data'] != '' ) {
1086
- $coupon_data = $wpdb->get_row( "SELECT * FROM `" . WPSC_TABLE_COUPON_CODES . "` WHERE coupon_code='" . $wpdb->escape( $purchase_log['discount_data'] ) . "' LIMIT 1", ARRAY_A );
1087
- if ( $coupon_data['use-once'] == 1 ) {
1088
- $wpdb->query( "UPDATE `" . WPSC_TABLE_COUPON_CODES . "` SET `active`='0', `is-used`='1' WHERE `id`='" . $coupon_data['id'] . "' LIMIT 1" );
1089
- }
1090
- }
1091
-
1092
- $total_shipping += $purchase_log['base_shipping'];
1093
-
1094
- $total = (($total + $total_shipping) - $purchase_log['discount_value']);
1095
- $product_list.= "Your Purchase # " . $purchase_log['id'] . "\n\r";
1096
- if ( $purchase_log['discount_value'] > 0 ) {
1097
- $discount_email.= __( 'Discount', 'wpsc' ) . ": " . wpsc_currency_display( $purchase_log['discount_value'],array( 'display_as_html' => false ) ) . "\n\r";
1098
- }
1099
- $total_shipping_email.= __( 'Total Shipping', 'wpsc' ) . ": " . wpsc_currency_display( $total_shipping,array( 'display_as_html' => false ) ) . "\n\r";
1100
- $total_price_email.= __( 'Total', 'wpsc' ) . ": " . wpsc_currency_display( $total,array( 'display_as_html' => false ) ) . "\n\r";
1101
- $product_list_html.= "Your Purchase # " . $purchase_log['id'] . "\n\n\r";
1102
- if ( $purchase_log['discount_value'] > 0 ) {
1103
- $discount_html.= __( 'Discount', 'wpsc' ) . ": " . wpsc_currency_display( $purchase_log['discount_value'],array( 'display_as_html' => false ) ) . "\n\r";
1104
- }
1105
- $total_shipping_html.= __( 'Total Shipping', 'wpsc' ) . ": " . wpsc_currency_display( $total_shipping,array( 'display_as_html' => false ) ) . "\n\r";
1106
- $total_price_html.= __( 'Total', 'wpsc' ) . ": " . wpsc_currency_display( $total,array( 'display_as_html' => false ) ) . "\n\r";
1107
- if ( isset( $_GET['ti'] ) ) {
1108
- $message.= "\n\r" . __( 'Your Transaction ID', 'wpsc' ) . ": " . $_GET['ti'];
1109
- $message_html.= "\n\r" . __( 'Your Transaction ID', 'wpsc' ) . ": " . $_GET['ti'];
1110
- $report.= "\n\r" . __( 'Transaction ID', 'wpsc' ) . ": " . $_GET['ti'];
1111
- } else {
1112
- $report_id = "Purchase # " . $purchase_log['id'] . "\n\r";
1113
- }
1114
-
1115
-
1116
-
1117
- $message = str_replace( '%product_list%', $product_list, $message );
1118
- $message = str_replace( '%total_shipping%', $total_shipping_email, $message );
1119
- $message = str_replace( '%total_price%', $total_price_email, $message );
1120
- $message = str_replace( '%shop_name%', get_option( 'blogname' ), $message );
1121
-
1122
- $report = str_replace( '%product_list%', $report_product_list, $report );
1123
- $report = str_replace( '%total_shipping%', $total_shipping_email, $report );
1124
- $report = str_replace( '%total_price%', $total_price_email, $report );
1125
- $report = str_replace( '%shop_name%', get_option( 'blogname' ), $report );
1126
-
1127
- $message_html = str_replace( '%product_list%', $product_list_html, $message_html );
1128
- $message_html = str_replace( '%total_shipping%', $total_shipping_html, $message_html );
1129
- $message_html = str_replace( '%total_price%', $total_price_email, $message_html );
1130
- $message_html = str_replace( '%shop_name%', get_option( 'blogname' ), $message_html );
1131
-
1132
- if ( ($email != '' ) ) {
1133
- add_filter( 'wp_mail_from', 'wpsc_replace_reply_address', 0 );
1134
- add_filter( 'wp_mail_from_name', 'wpsc_replace_reply_name', 0 );
1135
- if ( $purchase_log['processed'] < 2 ) {
1136
- $payment_instructions = strip_tags( stripslashes( get_option( 'payment_instructions' ) ) );
1137
- $message = __( 'Thank you, your purchase is pending, you will be sent an email once the order clears.', 'wpsc' ) . "\n\r" . $payment_instructions . "\n\r" . $message;
1138
- $resent = (bool)wp_mail( $email, __( 'Order Pending: Payment Required', 'wpsc' ), $message );
1139
- $sent = 1;
1140
- } else {
1141
- $resent = (bool)wp_mail( $email, __( 'Purchase Receipt', 'wpsc' ), $message );
1142
- $sent = 1;
1143
- }
1144
- remove_filter( 'wp_mail_from_name', 'wpsc_replace_reply_name' );
1145
- remove_filter( 'wp_mail_from', 'wpsc_replace_reply_address' );
1146
- }
1147
- }
1148
- }
1149
- $sendback = wp_get_referer();
1150
-
1151
- if ( isset( $sent ) ) {
1152
- $sendback = add_query_arg( 'sent', $sent, $sendback );
1153
- }
1154
- wp_redirect( $sendback );
1155
- exit();
1156
- }
1157
-
1158
- if ( isset( $_REQUEST['email_buyer_id'] ) && is_numeric( $_REQUEST['email_buyer_id'] ) ) {
1159
- add_action( 'admin_init', 'wpsc_purchlog_resend_email' );
1160
- }
1161
-
1162
- function wpsc_purchlog_clear_download_items() {
1163
- global $wpdb;
1164
- if ( is_numeric( $_GET['purchaselog_id'] ) ) {
1165
- $purchase_id = (int)$_GET['purchaselog_id'];
1166
- $downloadable_items = $wpdb->get_results( "SELECT * FROM `" . WPSC_TABLE_DOWNLOAD_STATUS . "` WHERE `purchid` IN ('$purchase_id')", ARRAY_A );
1167
-
1168
- $clear_locks_sql = "UPDATE`" . WPSC_TABLE_DOWNLOAD_STATUS . "` SET `ip_number` = '' WHERE `purchid` IN ('$purchase_id')";
1169
- $wpdb->query( $clear_locks_sql );
1170
- $cleared = true;
1171
-
1172
- $email_form_field = $wpdb->get_var( "SELECT `id` FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `type` IN ('email') AND `active` = '1' ORDER BY `order` ASC LIMIT 1" );
1173
- $email_address = $wpdb->get_var( "SELECT `value` FROM `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` WHERE `log_id`='{$purchase_id}' AND `form_id` = '{$email_form_field}' LIMIT 1" );
1174
-
1175
- foreach ( (array)$downloadable_items as $downloadable_item ) {
1176
- $download_links .= $siteurl . "?downloadid=" . $downloadable_item['uniqueid'] . "\n";
1177
- }
1178
-
1179
-
1180
- wp_mail( $email_address, __( 'The administrator has unlocked your file', 'wpsc' ), str_replace( "[download_links]", $download_links, __( 'Dear CustomerWe are pleased to advise you that your order has been updated and your downloads are now active.Please download your purchase using the links provided below.[download_links]Thank you for your custom.', 'wpsc' ) ), "From: " . get_option( 'return_email' ) . "" );
1181
-
1182
-
1183
- $sendback = wp_get_referer();
1184
-
1185
- if ( isset( $cleared ) ) {
1186
- $sendback = add_query_arg( 'cleared', $cleared, $sendback );
1187
- }
1188
- wp_redirect( $sendback );
1189
- exit();
1190
- }
1191
- }
1192
-
1193
- if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'clear_locks') ) {
1194
- add_action( 'admin_init', 'wpsc_purchlog_clear_download_items' );
1195
- }
1196
-
1197
- //call to change view for purchase log
1198
-
1199
- function wpsc_purchlog_filter_by() {
1200
- wpsc_change_purchlog_view( $_POST['view_purchlogs_by'], $_POST['view_purchlogs_by_status'] );
1201
- }
1202
-
1203
- if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'purchlog_filter_by') ) {
1204
- add_action( 'admin_init', 'wpsc_purchlog_filter_by' );
1205
- }
1206
-
1207
- //bulk actions for purchase log
1208
- function wpsc_purchlog_bulk_modify() {
1209
- if ( $_POST['purchlog_multiple_status_change'] != -1 ) {
1210
- if ( is_numeric( $_POST['purchlog_multiple_status_change'] ) && $_POST['purchlog_multiple_status_change'] != 'delete' ) {
1211
- foreach ( (array)$_POST['purchlogids'] as $purchlogid ) {
1212
- wpsc_purchlog_edit_status( $purchlogid, $_POST['purchlog_multiple_status_change'] );
1213
- $updated++;
1214
- }
1215
- } elseif ( $_POST['purchlog_multiple_status_change'] == 'delete' ) {
1216
- foreach ( (array)$_POST['purchlogids'] as $purchlogid ) {
1217
-
1218
- wpsc_delete_purchlog( $purchlogid );
1219
- $deleted++;
1220
- }
1221
- }
1222
- }
1223
- $sendback = wp_get_referer();
1224
- if ( isset( $updated ) ) {
1225
- $sendback = add_query_arg( 'updated', $updated, $sendback );
1226
- }
1227
- if ( isset( $deleted ) ) {
1228
- $sendback = add_query_arg( 'deleted', $deleted, $sendback );
1229
- }
1230
- if ( isset( $_POST['view_purchlogs_by'] ) ) {
1231
- $sendback = add_query_arg( 'view_purchlogs_by', $_POST['view_purchlogs_by'], $sendback );
1232
- }
1233
- if ( isset( $_POST['view_purchlogs_by_status'] ) ) {
1234
- $sendback = add_query_arg( 'view_purchlogs_by_status', $_POST['view_purchlogs_by_status'], $sendback );
1235
- }
1236
- wp_redirect( $sendback );
1237
- exit();
1238
- }
1239
-
1240
- if ( isset( $_REQUEST['wpsc_admin_action2'] ) && ($_REQUEST['wpsc_admin_action2'] == 'purchlog_bulk_modify') ) {
1241
- add_action( 'admin_init', 'wpsc_purchlog_bulk_modify' );
1242
- }
1243
-
1244
- //edit purchase log status function
1245
- function wpsc_purchlog_edit_status( $purchlog_id='', $purchlog_status='' ) {
1246
- global $wpdb;
1247
- if ( ($purchlog_id == '') && ($purchlog_status == '') ) {
1248
- $purchlog_id = absint( $_POST['purchlog_id'] );
1249
- $purchlog_status = absint( $_POST['purchlog_status'] );
1250
- }
1251
-
1252
- $log_data = $wpdb->get_row( "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `id` = '{$purchlog_id}' LIMIT 1", ARRAY_A );
1253
- if ( ($purchlog_id == 2) && function_exists( 'wpsc_member_activate_subscriptions' ) ) {
1254
- wpsc_member_activate_subscriptions( $_POST['id'] );
1255
- }
1256
-
1257
- // if the order is marked as failed, remove the claim on the stock
1258
- if ( $purchlog_status == 5 )
1259
- $wpdb->query( "DELETE FROM `" . WPSC_TABLE_CLAIMED_STOCK . "` WHERE `cart_id` = '{$purchlog_id}' AND `cart_submitted` = '1'" );
1260
-
1261
-
1262
- $wpdb->query( "UPDATE `" . WPSC_TABLE_PURCHASE_LOGS . "` SET processed='{$purchlog_status}' WHERE id='{$purchlog_id}'" );
1263
-
1264
- if ( ($purchlog_id > $log_data['processed']) && ($log_data['processed'] <= 2) && $log_data['email_sent'] == 0 ) {
1265
- transaction_results($log_data['sessionid'],false,null);
1266
- }
1267
- }
1268
-
1269
- if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'purchlog_edit_status') ) {
1270
- add_action( 'admin_init', 'wpsc_purchlog_edit_status' );
1271
- }
1272
-
1273
- function wpsc_save_product_order() {
1274
- global $wpdb;
1275
-
1276
- $products = array( );
1277
-
1278
- foreach ( $_POST['post'] as $product ) {
1279
- $products[] = absint( $product );
1280
- }
1281
-
1282
- print_r( $products );
1283
-
1284
- foreach ( $products as $order => $product_id ) {
1285
-
1286
- $wpdb->query( $wpdb->prepare( "UPDATE `{$wpdb->posts}` SET `menu_order`='%d' WHERE `ID`='%d' LIMIT 1", $order, $product_id ) );
1287
- }
1288
- $success = true;
1289
-
1290
- exit( (string)$success );
1291
- }
1292
-
1293
- if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'save_product_order') ) {
1294
- add_action( 'admin_init', 'wpsc_save_product_order' );
1295
- }
1296
-
1297
- function wpsc_save_checkout_order() {
1298
- global $wpdb;
1299
- $checkoutfields = $_POST['checkout'];
1300
- $order = 1;
1301
- foreach ( $checkoutfields as $checkoutfield ) {
1302
- $checkoutfield = absint( $checkoutfield );
1303
- $wpdb->query( "UPDATE `" . WPSC_TABLE_CHECKOUT_FORMS . "` SET `order` = '" . $order . "' WHERE `id`=" . $checkoutfield );
1304
-
1305
- $order++;
1306
- }
1307
- $success = true;
1308
-
1309
- exit( (string)$success );
1310
- }
1311
- if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'save_checkout_order') )
1312
- add_action( 'admin_init', 'wpsc_save_checkout_order' );
1313
-
1314
- /* Start Order Notes (by Ben) */
1315
- function wpsc_purchlogs_update_notes( $purchlog_id = '', $purchlog_notes = '' ) {
1316
- global $wpdb;
1317
- if ( wp_verify_nonce( $_POST['wpsc_purchlogs_update_notes_nonce'], 'wpsc_purchlogs_update_notes' ) ) {
1318
- if ( ($purchlog_id == '') && ($purchlog_notes == '') ) {
1319
- $purchlog_id = absint( $_POST['purchlog_id'] );
1320
- $purchlog_notes = $wpdb->escape( $_POST['purchlog_notes'] );
1321
- }
1322
- $wpdb->query( "UPDATE `" . WPSC_TABLE_PURCHASE_LOGS . "` SET notes='{$purchlog_notes}' WHERE id='{$purchlog_id}'" );
1323
- }
1324
- }
1325
- if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'purchlogs_update_notes' ) )
1326
- add_action( 'admin_init', 'wpsc_purchlogs_update_notes' );
1327
-
1328
- /* End Order Notes (by Ben) */
1329
-
1330
- //delete a purchase log
1331
- function wpsc_delete_purchlog( $purchlog_id='' ) {
1332
- global $wpdb;
1333
- $deleted = 0;
1334
- if ( $purchlog_id == '' ) {
1335
- $purchlog_id = absint( $_GET['purchlog_id'] );
1336
- check_admin_referer( 'delete_purchlog_' . $purchlog_id );
1337
- }
1338
-
1339
- if ( is_numeric( $purchlog_id ) ) {
1340
- $delete_log_form_sql = "SELECT * FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid`='$purchlog_id'";
1341
- $cart_content = $wpdb->get_results( $delete_log_form_sql, ARRAY_A );
1342
- }
1343
-
1344
- $purchlog_status = $wpdb->get_var( "SELECT `processed` FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `id`=" . $purchlog_id );
1345
- if ( $purchlog_status == 5 || $purchlog_status == 1 ) {
1346
- $wpdb->query( "DELETE FROM `" . WPSC_TABLE_CLAIMED_STOCK . "` WHERE `cart_id` = '{$purchlog_id}' AND `cart_submitted` = '1'" );
1347
- }
1348
-
1349
- $wpdb->query( "DELETE FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid`='$purchlog_id'" );
1350
- $wpdb->query( "DELETE FROM `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` WHERE `log_id` IN ('$purchlog_id')" );
1351
- $wpdb->query( "DELETE FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `id`='$purchlog_id' LIMIT 1" );
1352
-
1353
- $deleted = 1;
1354
-
1355
- if ( is_numeric( $_GET['purchlog_id'] ) ) {
1356
- $sendback = wp_get_referer();
1357
- $sendback = remove_query_arg( 'purchaselog_id', $sendback );
1358
- if ( isset( $deleted ) ) {
1359
- $sendback = add_query_arg( 'deleted', $deleted, $sendback );
1360
- }
1361
- wp_redirect( $sendback );
1362
- exit();
1363
- }
1364
- }
1365
-
1366
- if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'delete_purchlog') ) {
1367
- add_action( 'admin_init', 'wpsc_delete_purchlog' );
1368
- }
1369
-
1370
- /*
1371
- * Get Shipping Form ajax call
1372
- */
1373
-
1374
- function wpsc_ajax_get_shipping_form() {
1375
- global $wpdb, $wpsc_shipping_modules;
1376
- $shippingname = $_REQUEST['shippingname'];
1377
- $_SESSION['previous_shipping_name'] = $shippingname;
1378
- $shipping_data = wpsc_get_shipping_form( $shippingname );
1379
- $html_shipping_name = str_replace( Array( "\n", "\r" ), Array( "\\n", "\\r" ), addslashes( $shipping_data['name'] ) );
1380
- $shipping_form = str_replace( Array( "\n", "\r" ), Array( "\\n", "\\r" ), addslashes( $shipping_data['form_fields'] ) );
1381
- echo "shipping_name_html = '$html_shipping_name'; \n\r";
1382
- echo "shipping_form_html = '$shipping_form'; \n\r";
1383
- echo "has_submit_button = '{$shipping_data['has_submit_button']}'; \n\r";
1384
- exit();
1385
- }
1386
-
1387
- function wpsc_ajax_get_payment_form() {
1388
- global $wpdb, $nzshpcrt_gateways;
1389
- $paymentname = $_REQUEST['paymentname'];
1390
- $_SESSION['previous_payment_name'] = $paymentname;
1391
- $payment_data = wpsc_get_payment_form( $paymentname );
1392
- $html_payment_name = str_replace( Array( "\n", "\r" ), Array( "\\n", "\\r" ), addslashes( $payment_data['name'] ) );
1393
- $payment_form = str_replace( Array( "\n", "\r" ), Array( "\\n", "\\r" ), addslashes( $payment_data['form_fields'] ) );
1394
- echo "payment_name_html = '$html_payment_name'; \n\r";
1395
- echo "payment_form_html = '$payment_form'; \n\r";
1396
- echo "has_submit_button = '{$payment_data['has_submit_button']}'; \n\r";
1397
- exit();
1398
- }
1399
- if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'get_shipping_form') )
1400
- add_action( 'admin_init', 'wpsc_ajax_get_shipping_form' );
1401
-
1402
- if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'get_payment_form') )
1403
- add_action( 'admin_init', 'wpsc_ajax_get_payment_form' );
1404
-
1405
-
1406
- /*
1407
- * Submit Options from Settings Pages,
1408
- * takes an array of options checks to see whether it is empty or the same as the exisiting values
1409
- * and if its not it updates them.
1410
- */
1411
-
1412
- function wpsc_submit_options( $selected='' ) {
1413
- global $wpdb, $wpsc_gateways;
1414
- $updated = 0;
1415
-
1416
- //This is to change the Overall target market selection
1417
- check_admin_referer( 'update-options', 'wpsc-update-options' );
1418
- if ( isset( $_POST['change-settings'] ) ) {
1419
- if ( isset( $_POST['wpsc_also_bought'] ) && $_POST['wpsc_also_bought'] == 'on' )
1420
- update_option( 'wpsc_also_bought', 1 );
1421
- else
1422
- update_option( 'wpsc_also_bought', 0 );
1423
-
1424
- if ( isset( $_POST['display_find_us'] ) && $_POST['display_find_us'] == 'on' )
1425
- update_option( 'display_find_us', 1 );
1426
- else
1427
- update_option( 'display_find_us', 0 );
1428
-
1429
- if ( isset( $_POST['wpsc_share_this'] ) && $_POST['wpsc_share_this'] == 'on' )
1430
- update_option( 'wpsc_share_this', 1 );
1431
- else
1432
- update_option( 'wpsc_share_this', 0 );
1433
-
1434
- }
1435
- if (empty($_POST['countrylist2']) && !empty($_POST['wpsc_options']['currency_sign_location']))
1436
- $selected = 'all';
1437
-
1438
- if ( !isset( $_POST['countrylist2'] ) )
1439
- $_POST['countrylist2'] = '';
1440
- if ( !isset( $_POST['country_id'] ) )
1441
- $_POST['country_id'] = '';
1442
- if ( !isset( $_POST['country_tax'] ) )
1443
- $_POST['country_tax'] = '';
1444
-
1445
- if ( $_POST['countrylist2'] != null || !empty($selected) ) {
1446
- $AllSelected = false;
1447
- if ( $selected == 'all' ) {
1448
- $wpdb->query( "UPDATE `" . WPSC_TABLE_CURRENCY_LIST . "` SET visible = '1'" );
1449
- $AllSelected = true;
1450
- }
1451
- if ( $selected == 'none' ) {
1452
- $wpdb->query( "UPDATE `" . WPSC_TABLE_CURRENCY_LIST . "` SET visible = '0'" );
1453
- $AllSelected = true;
1454
- }
1455
- if ( $AllSelected != true ) {
1456
- $countrylist = $wpdb->get_col( "SELECT id FROM `" . WPSC_TABLE_CURRENCY_LIST . "` ORDER BY country ASC " );
1457
- //find the countries not selected
1458
- $unselectedCountries = array_diff( $countrylist, $_POST['countrylist2'] );
1459
- foreach ( $unselectedCountries as $unselected ) {
1460
- $wpdb->query( "UPDATE `" . WPSC_TABLE_CURRENCY_LIST . "` SET visible = 0 WHERE id = '" . $unselected . "' LIMIT 1" );
1461
- }
1462
-
1463
- //find the countries that are selected
1464
- $selectedCountries = array_intersect( $countrylist, $_POST['countrylist2'] );
1465
- foreach ( $selectedCountries as $selected ) {
1466
- $wpdb->query( "UPDATE `" . WPSC_TABLE_CURRENCY_LIST . "` SET visible = 1 WHERE id = '" . $selected . "' LIMIT 1" );
1467
- }
1468
- }
1469
- }
1470
- $previous_currency = get_option( 'currency_type' );
1471
-
1472
- $regenerate = false;
1473
-
1474
- $regenerate_options = array('single_view_image_height', 'single_view_image_width','wpsc_gallery_image_width','wpsc_gallery_image_height', 'wpsc_crop_thumbnails','product_image_width','product_image_height');
1475
-
1476
- //To update options
1477
-
1478
- if ( isset( $_POST['wpsc_options'] ) ) {
1479
-
1480
- foreach ( $_POST['wpsc_options'] as $key => $value ) {
1481
-
1482
- if ( in_array( $key, $regenerate_options ) && $value != get_option( $key ) ) {
1483
- $regenerate = true;
1484
- }
1485
-
1486
- if ( $value != get_option( $key ) ) {
1487
- update_option( $key, $value );
1488
- $updated++;
1489
-
1490
- }
1491
- }
1492
- }
1493
-
1494
- if ( $previous_currency != get_option( 'currency_type' ) ) {
1495
- $currency_code = $wpdb->get_var( "SELECT `code` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `id` IN ('" . absint( get_option( 'currency_type' ) ) . "')" );
1496
-
1497
- $selected_gateways = get_option( 'custom_gateway_options' );
1498
- $already_changed = array( );
1499
- foreach ( $selected_gateways as $selected_gateway ) {
1500
- if ( isset( $wpsc_gateways[$selected_gateway]['supported_currencies'] ) ) {
1501
- if ( in_array( $currency_code, $wpsc_gateways[$selected_gateway]['supported_currencies']['currency_list'] ) ) {
1502
-
1503
- $option_name = $wpsc_gateways[$selected_gateway]['supported_currencies']['option_name'];
1504
-
1505
- if ( !in_array( $option_name, $already_changed ) ) {
1506
- update_option( $option_name, $currency_code );
1507
- $already_changed[] = $option_name;
1508
- }
1509
- }
1510
- }
1511
- }
1512
- }
1513
-
1514
- foreach ( $GLOBALS['wpsc_shipping_modules'] as $shipping ) {
1515
- if ( is_object( $shipping ) )
1516
- $shipping->submit_form();
1517
- }
1518
-
1519
-
1520
- //This is for submitting shipping details to the shipping module
1521
- if ( !isset( $_POST['update_gateways'] ) )
1522
- $_POST['update_gateways'] = '';
1523
- if ( !isset( $_POST['custom_shipping_options'] ) )
1524
- $_POST['custom_shipping_options'] = null;
1525
- if ( $_POST['update_gateways'] == 'true' ) {
1526
-
1527
- update_option( 'custom_shipping_options', $_POST['custom_shipping_options'] );
1528
-
1529
-
1530
- foreach ( $GLOBALS['wpsc_shipping_modules'] as $shipping ) {
1531
- foreach ( (array)$_POST['custom_shipping_options'] as $shippingoption ) {
1532
- if ( $shipping->internal_name == $shippingoption ) {
1533
- $shipadd++;
1534
- }
1535
- }
1536
- }
1537
- }
1538
-
1539
- $sendback = wp_get_referer();
1540
-
1541
- if ( $regenerate ) {
1542
- $sendback = add_query_arg( array('regenerate' => 'true', 'updated' => $updated), $sendback );
1543
- }
1544
- if ( isset( $updated ) ) {
1545
- $sendback = add_query_arg( 'updated', $updated, $sendback );
1546
- }
1547
- if ( isset( $shipadd ) ) {
1548
- $sendback = add_query_arg( 'shipadd', $shipadd, $sendback );
1549
- }
1550
-
1551
- if ( !isset( $_SESSION['wpsc_settings_curr_page'] ) )
1552
- $_SESSION['wpsc_settings_curr_page'] = '';
1553
- if ( !isset( $_POST['page_title'] ) )
1554
- $_POST['page_title'] = '';
1555
- if ( isset( $_SESSION['wpsc_settings_curr_page'] ) ) {
1556
- $sendback = add_query_arg( 'tab', $_SESSION['wpsc_settings_curr_page'], $sendback );
1557
- }
1558
-
1559
- $sendback = add_query_arg( 'page', 'wpsc-settings', $sendback );
1560
- wp_redirect( $sendback );
1561
- exit();
1562
- }
1563
- if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'submit_options') )
1564
- add_action( 'admin_init', 'wpsc_submit_options' );
1565
-
1566
- function wpsc_change_currency() {
1567
- if ( is_numeric( $_POST['currencyid'] ) ) {
1568
- $currency_data = $wpdb->get_results( "SELECT `symbol`,`symbol_html`,`code` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `id`='" . $_POST['currencyid'] . "' LIMIT 1", ARRAY_A );
1569
- $price_out = null;
1570
- if ( $currency_data[0]['symbol'] != '' ) {
1571
- $currency_sign = $currency_data[0]['symbol_html'];
1572
- } else {
1573
- $currency_sign = $currency_data[0]['code'];
1574
- }
1575
- echo $currency_sign;
1576
- }
1577
- }
1578
- if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'change_currency') )
1579
- add_action( 'admin_init', 'wpsc_change_currency' );
1580
-
1581
- function wpsc_rearrange_images() {
1582
- global $wpdb;
1583
- $images = explode( ",", $_POST['order'] );
1584
- $product_id = absint( $_POST['product_id'] );
1585
- $timestamp = time();
1586
-
1587
- $new_main_image = null;
1588
- $have_set_first_item = false;
1589
- $i = 0;
1590
- foreach ( $images as $image ) {
1591
- if ( $image > 0 ) {
1592
- $wpdb->query( $wpdb->prepare( "UPDATE `{$wpdb->posts}` SET `menu_order`='%d' WHERE `ID`='%d' LIMIT 1", $i, $image ) );
1593
- $i++;
1594
- }
1595
- }
1596
- $output = wpsc_main_product_image_menu( $product_id );
1597
- echo "image_menu = '';\n\r";
1598
- echo "image_id = '" . $new_main_image . "';\n\r";
1599
- exit();
1600
- }
1601
- if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'rearrange_images') )
1602
- add_action( 'admin_init', 'wpsc_rearrange_images' );
1603
-
1604
- /**
1605
- * wpsc_update_page_urls gets the permalinks for products pages and stores them in the options for quick reference
1606
- * @public
1607
- *
1608
- * @since 3.6
1609
- * @param $auto (Boolean) true if coming from WordPress Permalink Page, false otherwise
1610
- * @return nothing
1611
- */
1612
- function wpsc_update_page_urls($auto = false) {
1613
- global $wpdb;
1614
-
1615
- $wpsc_pageurl_option['product_list_url'] = '[productspage]';
1616
- $wpsc_pageurl_option['shopping_cart_url'] = '[shoppingcart]';
1617
- $check_chekout = $wpdb->get_var( "SELECT `guid` FROM `{$wpdb->posts}` WHERE `post_content` LIKE '%[checkout]%' LIMIT 1" );
1618
- if ( $check_chekout != null ) {
1619
- $wpsc_pageurl_option['checkout_url'] = '[checkout]';
1620
- } else {
1621
- $wpsc_pageurl_option['checkout_url'] = '[checkout]';
1622
- }
1623
- $wpsc_pageurl_option['transact_url'] = '[transactionresults]';
1624
- $wpsc_pageurl_option['user_account_url'] = '[userlog]';
1625
- $changes_made = false;
1626
- foreach ( $wpsc_pageurl_option as $option_key => $page_string ) {
1627
- $post_id = $wpdb->get_var( "SELECT `ID` FROM `{$wpdb->posts}` WHERE `post_type` IN('page','post') AND `post_content` LIKE '%$page_string%' LIMIT 1" );
1628
- $the_new_link = get_permalink( $post_id );
1629
- if ( stristr( get_option( $option_key ), "https://" ) ) {
1630
- $the_new_link = str_replace( 'http://', "https://", $the_new_link );
1631
- }
1632
-
1633
- update_option( $option_key, $the_new_link );
1634
- $updated;
1635
- }
1636
-
1637
- if(!$auto){
1638
- $sendback = wp_get_referer();
1639
- if ( isset( $updated ) )
1640
- $sendback = add_query_arg( 'updated', $updated, $sendback );
1641
-
1642
- if ( isset( $_SESSION['wpsc_settings_curr_page'] ) )
1643
- $sendback = add_query_arg( 'tab', $_SESSION['wpsc_settings_curr_page'], $sendback );
1644
-
1645
- wp_redirect( $sendback );
1646
- exit();
1647
- }
1648
- }
1649
- if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'update_page_urls') )
1650
- add_action( 'admin_init', 'wpsc_update_page_urls' );
1651
-
1652
- function wpsc_clean_categories() {
1653
- global $wpdb, $wp_rewrite;
1654
- $sql_query = "SELECT `id`, `name`, `active` FROM `" . WPSC_TABLE_PRODUCT_CATEGORIES . "`";
1655
- $sql_data = $wpdb->get_results( $sql_query, ARRAY_A );
1656
- foreach ( (array)$sql_data as $datarow ) {
1657
- if ( $datarow['active'] == 1 ) {
1658
- $tidied_name = trim( $datarow['name'] );
1659
- $tidied_name = strtolower( $tidied_name );
1660
- $url_name = sanitize_title( $tidied_name );
1661
- $similar_names = $wpdb->get_row( "SELECT COUNT(*) AS `count`, MAX(REPLACE(`nice-name`, '$url_name', '')) AS `max_number` FROM `" . WPSC_TABLE_PRODUCT_CATEGORIES . "` WHERE `nice-name` REGEXP '^($url_name){1}(\d)*$' AND `id` NOT IN ('{$datarow['id']}') ", ARRAY_A );
1662
- $extension_number = '';
1663
- if ( $similar_names['count'] > 0 ) {
1664
- $extension_number = (int)$similar_names['max_number'] + 2;
1665
- }
1666
- $url_name .= $extension_number;
1667
- $wpdb->query( "UPDATE `" . WPSC_TABLE_PRODUCT_CATEGORIES . "` SET `nice-name` = '$url_name' WHERE `id` = '{$datarow['id']}' LIMIT 1 ;" );
1668
- $updated;
1669
- } else if ( $datarow['active'] == 0 ) {
1670
- $wpdb->query( "UPDATE `" . WPSC_TABLE_PRODUCT_CATEGORIES . "` SET `nice-name` = '' WHERE `id` = '{$datarow['id']}' LIMIT 1 ;" );
1671
- $updated;
1672
- }
1673
- }
1674
- $wp_rewrite->flush_rules();
1675
- $sendback = wp_get_referer();
1676
-
1677
- if ( isset( $updated ) ) {
1678
- $sendback = add_query_arg( 'updated', $updated, $sendback );
1679
- }
1680
- if ( isset( $_SESSION['wpsc_settings_curr_page'] ) ) {
1681
- $sendback = add_query_arg( 'tab', $_SESSION['wpsc_settings_curr_page'], $sendback );
1682
- }
1683
- wp_redirect( $sendback );
1684
-
1685
- exit();
1686
- }
1687
- if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'clean_categories') )
1688
- add_action( 'admin_init', 'wpsc_clean_categories' );
1689
-
1690
- //change the regions tax settings
1691
- function wpsc_change_region_tax() {
1692
- global $wpdb;
1693
- if ( is_array( $_POST['region_tax'] ) ) {
1694
- foreach ( $_POST['region_tax'] as $region_id => $tax ) {
1695
- if ( is_numeric( $region_id ) && is_numeric( $tax ) ) {
1696
- $previous_tax = $wpdb->get_var( "SELECT `tax` FROM `" . WPSC_TABLE_REGION_TAX . "` WHERE `id` = '$region_id' LIMIT 1" );
1697
- if ( $tax != $previous_tax ) {
1698
- $wpdb->query( "UPDATE `" . WPSC_TABLE_REGION_TAX . "` SET `tax` = '$tax' WHERE `id` = '$region_id' LIMIT 1" );
1699
- $changes_made = true;
1700
- }
1701
- }
1702
- }
1703
- $sendback = wp_get_referer();
1704
- wp_redirect( $sendback );
1705
- }
1706
- }
1707
- if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'change_region_tax') )
1708
- add_action( 'admin_init', 'wpsc_change_region_tax' );
1709
-
1710
- function wpsc_product_files_existing() {
1711
- global $wpdb;
1712
-
1713
- //List all product_files, with checkboxes
1714
-
1715
- $product_id = absint( $_GET["product_id"] );
1716
- $file_list = wpsc_uploaded_files();
1717
-
1718
- $args = array(
1719
- 'post_type' => 'wpsc-product-file',
1720
- 'post_parent' => $product_id,
1721
- 'numberposts' => -1,
1722
- 'post_status' => 'all'
1723
- );
1724
- $attached_files = (array)get_posts( $args );
1725
-
1726
- foreach ( $attached_files as $key => $attached_file ) {
1727
- $attached_files_by_file[$attached_file->post_title] = & $attached_files[$key];
1728
- }
1729
-
1730
- $output = "<span class='admin_product_notes select_product_note '>" . __( 'Choose a downloadable file for this product:', 'wpsc' ) . "</span><br>";
1731
- $output .= "<form method='post' class='product_upload'>";
1732
- $output .= "<div class='ui-widget-content multiple-select select_product_file'>";
1733
- $num = 0;
1734
- foreach ( (array)$file_list as $file ) {
1735
- $num++;
1736
- $checked_curr_file = "";
1737
- if ( isset( $attached_files_by_file[$file['display_filename']] ) ) {
1738
- $checked_curr_file = "checked='checked'";
1739
- }
1740
-
1741
- $output .= "<p " . ((($num % 2) > 0) ? '' : "class='alt'") . " id='select_product_file_row_$num'>\n";
1742
- $output .= " <input type='checkbox' name='select_product_file[]' value='" . $file['real_filename'] . "' id='select_product_file_$num' " . $checked_curr_file . " />\n";
1743
- $output .= " <label for='select_product_file_$num'>" . $file['display_filename'] . "</label>\n";
1744
- $output .= "</p>\n";
1745
- }
1746
-
1747
- $output .= "</div>";
1748
- $output .= "<input type='hidden' id='hidden_id' value='$product_id' />";
1749
- $output .= "<input type='submit' name='save' name='product_files_submit' class='button-primary prdfil' value='Save Product Files' />";
1750
- $output .= "</form>";
1751
- $output .= "<div class='" . ((is_numeric( $product_id )) ? "edit_" : "") . "select_product_handle'><div></div></div>";
1752
- $output .= "<script type='text/javascript'>\n\r";
1753
- $output .= "var select_min_height = " . (25 * 3) . ";\n\r";
1754
- $output .= "var select_max_height = " . (25 * ($num + 1)) . ";\n\r";
1755
- $output .= "</script>";
1756
-
1757
-
1758
- echo $output;
1759
- }
1760
- if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'product_files_existing') )
1761
- add_action( 'admin_init', 'wpsc_product_files_existing' );
1762
-
1763
- function prod_upload() {
1764
- global $wpdb, $product_id;
1765
- $product_id = absint( $_POST["product_id"] );
1766
-
1767
- foreach ( $_POST["select_product_file"] as $selected_file ) {
1768
- // if we already use this file, there is no point doing anything more.
1769
-
1770
-
1771
- $file_post_data = $wpdb->get_row( "SELECT * FROM $wpdb->posts WHERE post_type = 'wpsc-product-file' AND post_title = '$selected_file'", ARRAY_A );
1772
- $selected_file_path = WPSC_FILE_DIR . basename( $selected_file );
1773
-
1774
- if ( isset( $attached_files_by_file[$selected_file] ) ) {
1775
- $file_is_attached = true;
1776
- }
1777
-
1778
- //if(is_file($selected_file_path)) {
1779
- if ( empty( $file_post_data ) ) {
1780
- $type = wpsc_get_mimetype( $selected_file_path );
1781
- $attachment = array(
1782
- 'post_mime_type' => $type,
1783
- 'post_parent' => $product_id,
1784
- 'post_title' => $selected_file,
1785
- 'post_content' => '',
1786
- 'post_type' => "wpsc-product-file",
1787
- 'post_status' => 'inherit'
1788
- );
1789
- $id = wp_insert_post( $attachment );
1790
- } else {
1791
- $type = $file_post_data["post_mime_type"];
1792
- $url = $file_post_data["guid"];
1793
- $title = $file_post_data["post_title"];
1794
- $content = $file_post_data["post_content"];
1795
- // Construct the attachment
1796
- $attachment = array(
1797
- 'post_mime_type' => $type,
1798
- 'guid' => $url,
1799
- 'post_parent' => absint( $product_id ),
1800
- 'post_title' => $title,
1801
- 'post_content' => $content,
1802
- 'post_type' => "wpsc-product-file",
1803
- 'post_status' => 'inherit'
1804
- );
1805
- // Save the data
1806
- $id = wp_insert_post( $attachment );
1807
- }
1808
- //}
1809
- echo "$id\n";
1810
- }
1811
- }
1812
- if ( isset( $_GET['wpsc_admin_action'] ) && ($_GET['wpsc_admin_action'] == 'product_files_upload') )
1813
- add_action( 'admin_init', 'prod_upload' );
1814
-
1815
- //change the gateway settings
1816
- function wpsc_gateway_settings() {
1817
- global $wpdb;
1818
- //To update options
1819
- if ( isset( $_POST['wpsc_options'] ) ) {
1820
- foreach ( $_POST['wpsc_options'] as $key => $value ) {
1821
- if ( $value != get_option( $key ) ) {
1822
- update_option( $key, $value );
1823
- }
1824
- }
1825
- unset( $_POST['wpsc_options'] );
1826
- }
1827
-
1828
-
1829
-
1830
- if ( isset( $_POST['user_defined_name'] ) && is_array( $_POST['user_defined_name'] ) ) {
1831
- $payment_gateway_names = get_option( 'payment_gateway_names' );
1832
-
1833
- if ( !is_array( $payment_gateway_names ) ) {
1834
- $payment_gateway_names = array( );
1835
- }
1836
- $payment_gateway_names = array_merge( $payment_gateway_names, (array)$_POST['user_defined_name'] );
1837
- update_option( 'payment_gateway_names', $payment_gateway_names );
1838
- }
1839
- $custom_gateways = get_option( 'custom_gateway_options' );
1840
-
1841
- $nzshpcrt_gateways = nzshpcrt_get_gateways();
1842
- foreach ( $nzshpcrt_gateways as $gateway ) {
1843
- if ( in_array( $gateway['internalname'], $custom_gateways ) ) {
1844
- if ( isset( $gateway['submit_function'] ) ) {
1845
- call_user_func_array( $gateway['submit_function'], array( ) );
1846
- $changes_made = true;
1847
- }
1848
- }
1849
- }
1850
- if ( (isset( $_POST['payment_gw'] ) && $_POST['payment_gw'] != null ) ) {
1851
- update_option( 'payment_gateway', $_POST['payment_gw'] );
1852
- }
1853
- $sendback = wp_get_referer();
1854
-
1855
- if ( isset( $updated ) ) {
1856
- $sendback = add_query_arg( 'updated', $updated, $sendback );
1857
- }
1858
- if ( isset( $_SESSION['wpsc_settings_curr_page'] ) ) {
1859
- $sendback = add_query_arg( 'page', 'wpsc-settings', $sendback );
1860
- $sendback = add_query_arg( 'tab', $_SESSION['wpsc_settings_curr_page'], $sendback );
1861
- }
1862
- wp_redirect( $sendback );
1863
- exit();
1864
- }
1865
- if ( isset( $_REQUEST['wpsc_gateway_settings'] ) && ($_REQUEST['wpsc_gateway_settings'] == 'gateway_settings') )
1866
- add_action( 'admin_init', 'wpsc_gateway_settings' );
1867
-
1868
- function wpsc_check_form_options() {
1869
- global $wpdb;
1870
-
1871
- $id = $wpdb->escape( $_POST['form_id'] );
1872
- $sql = 'SELECT `options` FROM `' . WPSC_TABLE_CHECKOUT_FORMS . '` WHERE `id`=' . $id;
1873
- $options = $wpdb->get_var( $sql );
1874
- if ( $options != '' ) {
1875
- $options = maybe_unserialize( $options );
1876
- if ( !is_array( $options ) ) {
1877
- $options = unserialize( $options );
1878
- }
1879
- $output = "<tr class='wpsc_grey'><td></td><td colspan='5'>Please Save your changes before trying to Order your Checkout Forms again.</td></tr>\r\n<tr class='wpsc_grey'><td></td><th>Label</th><th >Value</th><td colspan='3'><a href='' class='wpsc_add_new_checkout_option' title='form_options[" . $id . "]'>+ New Layer</a></td></tr>";
1880
-
1881
- foreach ( (array)$options as $key => $value ) {
1882
- $output .="<tr class='wpsc_grey'><td></td><td><input type='text' value='" . $key . "' name='wpsc_checkout_option_label[" . $id . "][]' /></td><td colspan='4'><input type='text' value='" . $value . "' name='wpsc_checkout_option_value[" . $id . "][]' />&nbsp;<a class='wpsc_delete_option' href='' <img src='" . WPSC_CORE_IMAGES_URL . "/trash.gif' alt='" . __( 'Delete', 'wpsc' ) . "' title='" . __( 'Delete', 'wpsc' ) . "' /></a></td></tr>";
1883
- }
1884
- } else {
1885
- $output = '';
1886
- }
1887
- exit( $output );
1888
- }
1889
- if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'check_form_options') )
1890
- add_action( 'admin_init', 'wpsc_check_form_options' );
1891
-
1892
- //handles the editing and adding of new checkout fields
1893
- function wpsc_checkout_settings() {
1894
- global $wpdb;
1895
- $wpdb->show_errors = true;
1896
- if ( isset( $_POST['wpsc_form_set'] ) ) {
1897
- $filter = $wpdb->escape( $_POST['wpsc_form_set'] );
1898
- } else {
1899
- $filter = 0;
1900
- }
1901
-
1902
- if ( $_POST['new_form_set'] != null ) {
1903
- $new_form_set = $wpdb->escape( stripslashes( $_POST['new_form_set'] ) );
1904
- $checkout_sets = get_option( 'wpsc_checkout_form_sets' );
1905
- $checkout_sets[] = $new_form_set;
1906
- update_option( 'wpsc_checkout_form_sets', $checkout_sets );
1907
- }
1908
-
1909
- /*
1910
- // Save checkout options
1911
- */
1912
- $options = array( );
1913
- if ( is_array( $_POST['wpsc_checkout_option_label'] ) ) {
1914
- foreach ( $_POST['wpsc_checkout_option_label'] as $form_id => $values ) {
1915
- $options = array( );
1916
- foreach ( (array)$values as $key => $form_option ) {
1917
- $form_option = str_ireplace( "'", "", $form_option );
1918
- $form_val = str_ireplace( "'", "", sanitize_title( $_POST['wpsc_checkout_option_value'][$form_id][$key] ) );
1919
- $options[$form_option] = $form_val;
1920
- }
1921
-
1922
- $options = serialize( $options );
1923
- $sql = "UPDATE `" . WPSC_TABLE_CHECKOUT_FORMS . "` SET `options`='" . $options . "' WHERE id=" . $form_id;
1924
- $wpdb->query( $sql );
1925
- }
1926
- }
1927
-
1928
-
1929
- if ( $_POST['form_name'] != null ) {
1930
- foreach ( $_POST['form_name'] as $form_id => $form_name ) {
1931
- $form_name = $wpdb->escape( $form_name );
1932
- $form_type = $wpdb->escape( $_POST['form_type'][$form_id] );
1933
- $form_mandatory = 0;
1934
- if ( isset( $_POST['form_mandatory'][$form_id] ) && ($_POST['form_mandatory'][$form_id] == 1) ) {
1935
- $form_mandatory = 1;
1936
- }
1937
- $form_display_log = 0;
1938
- if ( isset( $_POST['form_display_log'][$form_id] ) && ($_POST['form_display_log'][$form_id] == 1) ) {
1939
- $form_display_log = 1;
1940
- }
1941
- $unique_name = '';
1942
- if ( $_POST['unique_names'][$form_id] != '-1' ) {
1943
- $unique_name = $_POST['unique_names'][$form_id];
1944
- }
1945
- $wpdb->query( "UPDATE `" . WPSC_TABLE_CHECKOUT_FORMS . "` SET `name` = '$form_name', `type` = '$form_type', `mandatory` = '$form_mandatory', `display_log` = '$form_display_log',`unique_name`='" . $unique_name . "' WHERE `id` ='" . $form_id . "' LIMIT 1 ;" );
1946
- }
1947
- }
1948
-
1949
- if ( isset( $_POST['new_form_name'] ) ) {
1950
- foreach ( $_POST['new_form_name'] as $form_id => $form_name ) {
1951
- $form_type = $_POST['new_form_type'][$form_id];
1952
- $form_mandatory = 0;
1953
- if ( $_POST['new_form_mandatory'][$form_id] == 1 ) {
1954
- $form_mandatory = 1;
1955
- }
1956
- $form_display_log = 0;
1957
- if ( isset( $_POST['new_form_display_log'][$form_id] ) && $_POST['new_form_display_log'][$form_id] == 1 ) {
1958
- $form_display_log = 1;
1959
- }
1960
- if ( $_POST['new_form_unique_name'][$form_id] != '-1' ) {
1961
- $form_unique_name = $_POST['new_form_unique_name'][$form_id];
1962
- }
1963
-
1964
- $max_order_sql = "SELECT MAX(`order`) AS `order` FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `active` = '1';";
1965
-
1966
- if ( isset( $_POST['new_form_order'][$form_id] ) && $_POST['new_form_order'][$form_id] != '' ) {
1967
- $order_number = $_POST['new_form_order'][$form_id];
1968
- } else {
1969
- $max_order_sql = $wpdb->get_results( $max_order_sql, ARRAY_A );
1970
- $order_number = $max_order_sql[0]['order'] + 1;
1971
- }
1972
- $wpdb->query( "INSERT INTO `" . WPSC_TABLE_CHECKOUT_FORMS . "` ( `name`, `type`, `mandatory`, `display_log`, `default`, `active`, `order` , `unique_name`, `checkout_set`) VALUES ( '$form_name', '$form_type', '$form_mandatory', '$form_display_log', '', '1','" . $order_number . "','" . $form_unique_name . "','" . $filter . "');" );
1973
- $added++;
1974
- }
1975
- }
1976
-
1977
- if ( isset( $_POST['wpsc_options'] ) ) {
1978
- foreach ( $_POST['wpsc_options'] as $key => $value ) {
1979
- if ( $value != get_option( $key ) ) {
1980
- update_option( $key, $value );
1981
- $updated++;
1982
- }
1983
- }
1984
- }
1985
-
1986
- $sendback = wp_get_referer();
1987
- if ( isset( $form_set_key ) ) {
1988
- $sendback = add_query_arg( 'checkout-set', $form_set_key, $sendback );
1989
- } else if ( isset( $_POST['wpsc_form_set'] ) ) {
1990
- $filter = $_POST['wpsc_form_set'];
1991
- $sendback = add_query_arg( 'checkout-set', $filter, $sendback );
1992
- }
1993
-
1994
- if ( isset( $updated ) ) {
1995
- $sendback = add_query_arg( 'updated', $updated, $sendback );
1996
- }
1997
- if ( isset( $added ) ) {
1998
- $sendback = add_query_arg( 'added', $added, $sendback );
1999
- }
2000
- if ( isset( $_SESSION['wpsc_settings_curr_page'] ) ) {
2001
- $sendback = add_query_arg( 'tab', $_SESSION['wpsc_settings_curr_page'], $sendback );
2002
- }
2003
- $sendback = add_query_arg( 'page', 'wpsc-settings', $sendback );
2004
- wp_redirect( $sendback );
2005
- exit();
2006
- }
2007
- if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'checkout_settings') )
2008
- add_action( 'admin_init', 'wpsc_checkout_settings' );
2009
-
2010
- function wpsc_google_shipping_settings() {
2011
- if ( isset( $_POST['submit'] ) ) {
2012
- foreach ( (array)$_POST['google_shipping'] as $key => $country ) {
2013
- if ( $country == 'on' ) {
2014
- $google_shipping_country[] = $key;
2015
- $updated++;
2016
- }
2017
- }
2018
- update_option( 'google_shipping_country', $google_shipping_country );
2019
- $sendback = wp_get_referer();
2020
- $sendback = remove_query_arg( 'googlecheckoutshipping', $sendback );
2021
-
2022
- if ( isset( $updated ) ) {
2023
- $sendback = add_query_arg( 'updated', $updated, $sendback );
2024
- }
2025
-
2026
- wp_redirect( $sendback );
2027
- exit();
2028
- }
2029
- }
2030
-
2031
- if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'google_shipping_settings') ) {
2032
- add_action( 'admin_init', 'wpsc_google_shipping_settings' );
2033
- }
2034
-
2035
- //for ajax call of settings page tabs
2036
- function wpsc_settings_page_ajax() {
2037
- global $wpdb;
2038
-
2039
- $html = '';
2040
- $modified_page_title = $_POST['page_title'];
2041
- $page_title = str_replace( "tab-", "", $modified_page_title );
2042
-
2043
- check_admin_referer( $modified_page_title );
2044
- switch ( $page_title ) {
2045
- case 'checkout' :
2046
- require_once( 'includes/settings-pages/checkout.php' );
2047
- wpsc_options_checkout();
2048
- break;
2049
-
2050
- case 'gateway' :
2051
- require_once( 'includes/settings-pages/gateway.php' );
2052
- wpsc_options_gateway();
2053
- break;
2054
-
2055
- case 'shipping' :
2056
- require_once( 'includes/settings-pages/shipping.php' );
2057
- wpsc_options_shipping();
2058
- break;
2059
-
2060
- case 'admin' :
2061
- require_once( 'includes/settings-pages/admin.php' );
2062
- wpsc_options_admin();
2063
- break;
2064
-
2065
- case 'presentation' :
2066
- require_once( 'includes/settings-pages/presentation.php' );
2067
- wpsc_options_presentation();
2068
- break;
2069
-
2070
- case 'taxes' :
2071
- wpec_taxes_settings_page(); //see wpec-taxes view
2072
- break;
2073
-
2074
- case 'marketing' :
2075
- require_once( 'includes/settings-pages/marketing.php' );
2076
- wpsc_options_marketing();
2077
- break;
2078
-
2079
- case 'import' :
2080
- require_once( 'includes/settings-pages/import.php' );
2081
- wpsc_options_import();
2082
- break;
2083
-
2084
- case 'general' :
2085
- default;
2086
- require_once( 'includes/settings-pages/general.php' );
2087
- wpsc_options_general();
2088
- break;
2089
- }
2090
-
2091
- $_SESSION['wpsc_settings_curr_page'] = $page_title;
2092
-
2093
- exit( $html );
2094
- }
2095
- if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'settings_page_ajax') )
2096
- add_action( 'admin_init', 'wpsc_settings_page_ajax' );
2097
-
2098
- function wpsc_update_variations() {
2099
- global $wpdb, $user_ID, $wp_query, $wpsc_products, $mode;
2100
-
2101
- //Setup postdata
2102
- $post_data = array( );
2103
- $post_data['edit_var_val'] = $_POST["edit_var_val"];
2104
- $post_data['description'] = $_POST["description"];
2105
- $post_data['additional_description'] = $_POST['additional_description'];
2106
- $post_data['name'] = $_POST["name"];
2107
- $product_id = absint( $_POST["product_id"] );
2108
-
2109
- //Add or delete variations
2110
-
2111
- wpsc_edit_product_variations( $product_id, $post_data );
2112
-
2113
- // return admin table listing
2114
- return wpsc_admin_product_listing( $product_id );
2115
- }
2116
- if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'wpsc_update_variations') )
2117
- add_action( 'admin_init', 'wpsc_update_variations', 50 );
2118
-
2119
- function wpsc_delete_variation_set() {
2120
- global $wpdb;
2121
- check_admin_referer( 'delete-variation' );
2122
-
2123
- if ( is_numeric( $_GET['deleteid'] ) ) {
2124
- $variation_id = absint( $_GET['deleteid'] );
2125
-
2126
- $variation_set = get_term( $variation_id, 'wpsc-variation', ARRAY_A );
2127
-
2128
-
2129
- $variations = get_terms( 'wpsc-variation', array(
2130
- 'hide_empty' => 0,
2131
- 'parent' => $variation_id
2132
- ) );
2133
-
2134
- foreach ( (array)$variations as $variation ) {
2135
- $return_value = wp_delete_term( $variation->term_id, 'wpsc-variation' );
2136
- }
2137
-
2138
- if ( !empty( $variation_set ) ) {
2139
- $return_value = wp_delete_term( $variation_set['term_id'], 'wpsc-variation' );
2140
- }
2141
- $deleted = 1;
2142
- }
2143
-
2144
- $sendback = wp_get_referer();
2145
- if ( isset( $deleted ) ) {
2146
- $sendback = add_query_arg( 'deleted', $deleted, $sendback );
2147
- }
2148
- $sendback = remove_query_arg( array(
2149
- 'deleteid',
2150
- 'variation_id'
2151
- ), $sendback );
2152
-
2153
- wp_redirect( $sendback );
2154
- exit();
2155
- }
2156
-
2157
- function wpsc_force_flush_theme_transients() {
2158
- // Flush transients
2159
- wpsc_flush_theme_transients( true );
2160
-
2161
- // Bounce back
2162
- $sendback = wp_get_referer();
2163
- wp_redirect( $sendback );
2164
-
2165
- exit();
2166
- }
2167
- if ( isset( $_REQUEST['wpsc_flush_theme_transients'] ) && ( $_REQUEST['wpsc_flush_theme_transients'] == 'true' ) )
2168
- add_action( 'admin_init', 'wpsc_force_flush_theme_transients' );
2169
-
2170
- function wpsc_backup_theme() {
2171
- $wp_theme_path = get_stylesheet_directory();
2172
- wpsc_recursive_copy( $wp_theme_path, WPSC_THEME_BACKUP_DIR );
2173
- $_SESSION['wpsc_themes_backup'] = true;
2174
- $sendback = wp_get_referer();
2175
- wp_redirect( $sendback );
2176
-
2177
- exit();
2178
- }
2179
- if ( isset( $_REQUEST['wpsc_admin_action'] ) && ( $_REQUEST['wpsc_admin_action'] == 'backup_themes' ) )
2180
- add_action( 'admin_init', 'wpsc_backup_theme' );
2181
-
2182
-
2183
- function wpsc_delete_coupon(){
2184
- global $wpdb;
2185
-
2186
- check_admin_referer( 'delete-coupon' );
2187
- $coupon_id = (int)$_GET['delete_id'];
2188
-
2189
- if(isset($coupon_id)) {
2190
- $wpdb->query("DELETE FROM `".WPSC_TABLE_COUPON_CODES."` WHERE `id` = '$coupon_id' LIMIT 1;");
2191
-
2192
- $deleted = 1;
2193
- }
2194
- $sendback = wp_get_referer();
2195
- if ( isset( $deleted ) )
2196
- $sendback = add_query_arg( 'deleted', $deleted, $sendback );
2197
-
2198
- $sendback = remove_query_arg( array('deleteid',), $sendback );
2199
- wp_redirect( $sendback );
2200
- exit();
2201
- }
2202
-
2203
-
2204
- function wpsc_delete_category() {
2205
- global $wpdb, $wp_rewrite;
2206
-
2207
- check_admin_referer( 'delete-category' );
2208
-
2209
- if ( is_numeric( $_GET['deleteid'] ) ) {
2210
- $category_id = absint( $_GET['deleteid'] );
2211
- $taxonomy = 'wpsc_product_category';
2212
- if ( $category_id > 0 ) {
2213
- wp_delete_term( $category_id, $taxonomy );
2214
- $wpdb->query( "DELETE FROM `" . WPSC_TABLE_META . "` WHERE object_id = '" . $category_id . "' AND object_type = 'wpsc_category'" );
2215
- }
2216
-
2217
- $wp_rewrite->flush_rules();
2218
-
2219
- $deleted = 1;
2220
- }
2221
-
2222
- $sendback = wp_get_referer();
2223
- if ( isset( $deleted ) ) {
2224
- $sendback = add_query_arg( 'deleted', $deleted, $sendback );
2225
- }
2226
- $sendback = remove_query_arg( array(
2227
- 'deleteid',
2228
- 'category_id'
2229
- ), $sendback );
2230
-
2231
- wp_redirect( $sendback );
2232
- exit();
2233
- }
2234
-
2235
- if ( isset( $_REQUEST['wpsc_admin_action'] ) && ( 'wpsc_add_image' == $_REQUEST['wpsc_admin_action'] ) )
2236
- add_action( 'admin_init', 'wpsc_swfupload_images' );
2237
-
2238
- if ( isset( $_REQUEST['wpsc_admin_action'] ) && ( 'edit_product' == $_REQUEST['wpsc_admin_action'] ) )
2239
- add_action( 'admin_init', 'wpsc_admin_submit_product' );
2240
-
2241
- if ( isset( $_GET['action'] ) && ( 'purchase_log' == $_GET['action'] ) )
2242
- add_action( 'admin_init', 'wpsc_admin_sale_rss' );
2243
-
2244
- if ( isset( $_GET['purchase_log_csv'] ) && ( 'true' == $_GET['purchase_log_csv'] ) )
2245
- add_action( 'admin_init', 'wpsc_purchase_log_csv' );
2246
-
2247
- if ( isset( $_REQUEST['ajax'] ) && isset( $_REQUEST['admin'] ) && ($_REQUEST['ajax'] == "true") && ($_REQUEST['admin'] == "true") )
2248
- add_action( 'admin_init', 'wpsc_admin_ajax' );
2249
-
2250
- // Variation set deleting init code starts here
2251
- if ( isset( $_REQUEST['wpsc_admin_action'] ) && ( 'wpsc-delete-variation-set' == $_REQUEST['wpsc_admin_action'] ) )
2252
- add_action( 'admin_init', 'wpsc_delete_variation_set' );
2253
-
2254
- // Variation set deleting init code starts here
2255
- if ( isset( $_REQUEST['wpsc_admin_action'] ) && ( 'wpsc-delete-category' == $_REQUEST['wpsc_admin_action'] ) )
2256
- add_action( 'admin_init', 'wpsc_delete_category' );
2257
-
2258
- //Delete Coupon
2259
- if ( isset( $_REQUEST['wpsc_admin_action'] ) && ( 'wpsc-delete-coupon' == $_REQUEST['wpsc_admin_action'] ) )
2260
- add_action( 'admin_init', 'wpsc_delete_coupon' );
2261
-
2262
- // Category modification init code starts here
2263
- if ( isset( $_REQUEST['wpsc_admin_action'] ) && ( 'wpsc-category-set' == $_REQUEST['wpsc_admin_action'] ) )
2264
- add_action( 'admin_init', 'wpsc_save_category_set' );
2265
-
2266
- function flat_price( $price ) {
2267
- if ( isset( $price ) && !empty( $price ) && strchr( $price, '-' ) === false && strchr( $price, '+' ) === false && strchr( $price, '%' ) === false )
2268
- return true;
2269
- }
2270
-
2271
- function percentile_price( $price ) {
2272
- if ( isset( $price ) && !empty( $price ) && ( strchr( $price, '-' ) || strchr( $price, '+' ) ) && strchr( $price, '%' ) )
2273
- return true;
2274
- }
2275
-
2276
- function differential_price( $price ) {
2277
- if ( isset( $price ) && !empty( $price ) && ( strchr( $price, '-' ) || strchr( $price, '+' ) ) && strchr( $price, '%' ) === false )
2278
- return true;
2279
- }
2280
-
2281
- /**
2282
- * If it doesn't exist, let's create a multi-dimensional associative array
2283
- * that will contain all of the term/price associations
2284
- *
2285
- * @param <type> $variation
2286
- */
2287
- function variation_price_field( $variation ) {
2288
- $term_prices = get_option( 'term_prices' );
2289
-
2290
- if ( is_object( $variation ) )
2291
- $term_id = $variation->term_id;
2292
-
2293
- if ( empty( $term_prices ) || !is_array( $term_prices ) ) {
2294
-
2295
- $term_prices = array( );
2296
- if ( isset( $term_id ) ) {
2297
- $term_prices[$term_id] = array( );
2298
- $term_prices[$term_id]["price"] = '';
2299
- $term_prices[$term_id]["checked"] = '';
2300
- }
2301
- add_option( 'term_prices', $term_prices );
2302
- }
2303
-
2304
- if ( isset( $term_id ) && is_array( $term_prices ) && array_key_exists( $term_id, $term_prices ) )
2305
- $price = $term_prices[$term_id]["price"];
2306
- else
2307
- $price = '';
2308
-
2309
- if(isset($_GET['action']) && 'add' == $_GET['action']){
2310
- ?>
2311
- <div class="form-field">
2312
- <label for="variation_price"><?php _e( 'Variation Price', 'wpsc' ); ?></label>
2313
-
2314
- <input type="text" name="variation_price" id="variation_price" style="width:50px;" value="<?php echo $price; ?>"><br />
2315
- <span class="description"><?php _e( 'You can list a default price here for this variation. You can list a regular price (18.99), differential price (+1.99 / -2) or even a percentage-based price (+50% / -25%).', 'wpsc' ); ?></span>
2316
- </div>
2317
- <?php
2318
- }else{
2319
- ?>
2320
- <tr class="form-field">
2321
- <th scope="row" valign="top">
2322
- <label for="variation_price"><?php _e( 'Variation Price', 'wpsc' ); ?></label>
2323
- </td>
2324
- <td>
2325
- <input type="text" name="variation_price" id="variation_price" style="width:50px;" value="<?php echo $price; ?>"><br />
2326
- <span class="description"><?php _e( 'You can list a default price here for this variation. You can list a regular price (18.99), differential price (+1.99 / -2) or even a percentage-based price (+50% / -25%).', 'wpsc' ); ?></span>
2327
- </td>
2328
- </tr>
2329
- <?php
2330
- }
2331
-
2332
- }
2333
- add_action( 'wpsc-variation_edit_form_fields', 'variation_price_field' );
2334
- add_action( 'wpsc-variation_add_form_fields', 'variation_price_field' );
2335
-
2336
- function variation_price_field_check( $variation ) {
2337
-
2338
- $term_prices = get_option( 'term_prices' );
2339
-
2340
- if ( is_array( $term_prices ) && array_key_exists( $variation->term_id, $term_prices ) )
2341
- $checked = ($term_prices[$variation->term_id]["checked"] == 'checked') ? 'checked' : '';
2342
- else
2343
- $checked = ''; ?>
2344
-
2345
- <tr class="form-field">
2346
- <th scope="row" valign="top"><label for="apply_to_current"><?php _e( 'Apply to current variations?' ) ?></label></th>
2347
- <td>
2348
- <span class="description"><input type="checkbox" name="apply_to_current" id="apply_to_current" style="width:2%;" <?php echo $checked; ?> /><?php _e( 'By checking this box, the price rule you implement above will be applied to all variations that currently exist. If you leave it unchecked, it will only apply to products that use this variation created or edited from now on. Take note, this will apply this rule to <strong>every</strong> product using this variation. If you need to override it for any reason on a specific product, simply go to that product and change the price.', 'wpsc' ); ?></span>
2349
- </td>
2350
- </tr>
2351
- <?php
2352
- }
2353
- add_action( 'wpsc-variation_edit_form_fields', 'variation_price_field_check' );
2354
-
2355
- /**
2356
- * @todo - Should probably refactor this at some point - very procedural,
2357
- * WAY too many foreach loops for my liking :) But it does the trick
2358
- *
2359
- * @param <type> $term_id
2360
- */
2361
- function save_term_prices( $term_id ) {
2362
-
2363
- // First - Saves options from input
2364
- if ( isset( $_POST['variation_price'] ) || isset( $_POST["apply_to_current"] ) ) {
2365
-
2366
- $term_prices = get_option( 'term_prices' );
2367
-
2368
- $term_prices[$term_id]["price"] = $_POST["variation_price"];
2369
- $term_prices[$term_id]["checked"] = (isset( $_POST["apply_to_current"] )) ? "checked" : "unchecked";
2370
-
2371
- update_option( 'term_prices', $term_prices );
2372
- }
2373
-
2374
- // Second - If box was checked, let's then check whether or not it was flat, differential, or percentile, then let's apply the pricing to every product appropriately
2375
- if ( isset( $_POST["apply_to_current"] ) ) {
2376
-
2377
- //Check for flat, percentile or differential
2378
- $var_price_type = '';
2379
-
2380
- if ( flat_price( $_POST["variation_price"] ) )
2381
- $var_price_type = 'flat';
2382
- elseif ( differential_price( $_POST["variation_price"] ) )
2383
- $var_price_type = 'differential';
2384
- elseif ( percentile_price( $_POST["variation_price"] ) )
2385
- $var_price_type = 'percentile';
2386
-
2387
- //Now, find all products with this term_id, update their pricing structure (terms returned include only parents at this point, we'll grab relevent children soon)
2388
- $products_to_mod = get_objects_in_term( $term_id, "wpsc-variation" );
2389
- $product_parents = array( );
2390
-
2391
- foreach ( (array)$products_to_mod as $get_parent ) {
2392
-
2393
- $post = get_post( $get_parent );
2394
-
2395
- if ( !$post->post_parent )
2396
- $product_parents[] = $post->ID;
2397
- }
2398
-
2399
- //Now that we have all parent IDs with this term, we can get the children (only the ones that are also in $products_to_mod, we don't want to apply pricing to ALL kids)
2400
-
2401
- foreach ( $product_parents as $parent ) {
2402
- $args = array(
2403
- 'post_parent' => $parent,
2404
- 'post_type' => 'wpsc-product'
2405
- );
2406
- $children = get_children( $args, ARRAY_A );
2407
-
2408
- foreach ( $children as $childrens ) {
2409
- $parent = $childrens["post_parent"];
2410
- $children_ids[$parent][] = $childrens["ID"];
2411
- $children_ids[$parent] = array_intersect( $children_ids[$parent], $products_to_mod );
2412
- }
2413
- }
2414
-
2415
- //Got the right kids, let's grab their parent pricing and modify their pricing based on var_price_type
2416
-
2417
- foreach ( (array)$children_ids as $parents => $kids ) {
2418
-
2419
- $kids = array_values( $kids );
2420
- $parent_pricing = get_product_meta( $parents, "price", true );
2421
-
2422
- foreach ( $kids as $kiddos ) {
2423
-
2424
- $child_pricing = get_product_meta( $kiddos, "price", true );
2425
-
2426
- if ( $var_price_type == 'flat' ) {
2427
-
2428
- update_product_meta( $kiddos, "price", floatval( $_POST["variation_price"] ) );
2429
- } elseif ( $var_price_type == 'percentile' ) {
2430
-
2431
- //Are we decreasing or increasing the price?
2432
-
2433
- if ( strchr( $_POST["variation_price"], '-' ) )
2434
- $positive = false;
2435
- else
2436
- $positive = true;
2437
-
2438
- //Now, let's get the parent product price, +/- by the percentage given
2439
- $percentage = (absint( $_POST["variation_price"] ) / 100);
2440
-
2441
- if ( $positive )
2442
- $price = $parent_pricing + ($parent_pricing * $percentage);
2443
- else
2444
- $price = $parent_pricing - ($parent_pricing * $percentage);
2445
-
2446
- update_product_meta( $kiddos, "price", $price );
2447
- } elseif ( $var_price_type == 'differential' ) {
2448
-
2449
- //Are we decreasing or increasing the price?
2450
- if ( strchr( $_POST["variation_price"], '-' ) )
2451
- $positive = false;
2452
- else
2453
- $positive = true;
2454
-
2455
- //Now, let's get the parent product price, +/- by the differential given
2456
- $differential = (absint( $_POST["variation_price"] ));
2457
-
2458
- if ( $positive )
2459
- $price = $parent_pricing + $differential;
2460
- else
2461
- $price = $parent_pricing - $differential;
2462
- update_product_meta( $kiddos, "price", $price );
2463
- }
2464
- }
2465
- }
2466
- }
2467
- }
2468
- add_action( 'edited_wpsc-variation', 'save_term_prices' );
2469
- add_action( 'created_wpsc-variation', 'save_term_prices' );
2470
-
2471
-
2472
-
2473
- ?>
1
+ <?php
2
+
3
+ /**
4
+ * WP eCommerce Admin AJAX functions
5
+ *
6
+ * These are the WPSC Admin AJAX functions
7
+ *
8
+ * @package wp-e-commerce
9
+ * @since 3.7
10
+ */
11
+ function wpsc_ajax_add_tracking() {
12
+ global $wpdb;
13
+ foreach ( $_POST as $key => $value ) {
14
+ $parts = preg_split( '/^wpsc_trackingid/', $key );
15
+ if ( count( $parts ) > '1' ) {
16
+ $id = $parts[1];
17
+ $trackingid = $value;
18
+ $sql = "UPDATE `" . WPSC_TABLE_PURCHASE_LOGS . "` SET `track_id`='" . $trackingid . "' WHERE `id`=" . $id;
19
+ $wpdb->query( $sql );
20
+ }
21
+
22
+ }
23
+ }
24
+
25
+ if ( isset( $_REQUEST['submit'] ) && ($_REQUEST['submit'] == 'Add Tracking ID') ) {
26
+ add_action( 'admin_init', 'wpsc_ajax_add_tracking' );
27
+ }
28
+
29
+ function wpsc_delete_currency_layer() {
30
+ global $wpdb;
31
+ $meta_key = 'currency[' . $_POST['currSymbol'] . ']';
32
+ $sql = "DELETE FROM `" . WPSC_TABLE_PRODUCTMETA . "` WHERE `meta_key`='" . $meta_key . "' LIMIT 1";
33
+ $wpdb->query( $sql );
34
+ }
35
+
36
+ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'delete_currency_layer') ) {
37
+ add_action( 'admin_init', 'wpsc_delete_currency_layer' );
38
+ }
39
+
40
+ function wpsc_purchlog_email_trackid() {
41
+ global $wpdb;
42
+ $id = absint( $_POST['purchlog_id'] );
43
+ $trackingid = $wpdb->get_var( "SELECT `track_id` FROM " . WPSC_TABLE_PURCHASE_LOGS . " WHERE `id`={$id} LIMIT 1" );
44
+
45
+ $message = get_option( 'wpsc_trackingid_message' );
46
+ $message = str_replace( '%trackid%', $trackingid, $message );
47
+ $message = str_replace( '%shop_name%', get_option( 'blogname' ), $message );
48
+
49
+ $email_form_field = $wpdb->get_var( "SELECT `id` FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `type` IN ('email') AND `active` = '1' ORDER BY `checkout_order` ASC LIMIT 1" );
50
+ $email = $wpdb->get_var( "SELECT `value` FROM `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` WHERE `log_id`=" . $id . " AND `form_id` = '$email_form_field' LIMIT 1" );
51
+
52
+
53
+ $subject = get_option( 'wpsc_trackingid_subject' );
54
+ $subject = str_replace( '%shop_name%', get_option( 'blogname' ), $subject );
55
+
56
+ add_filter( 'wp_mail_from', 'wpsc_replace_reply_address', 0 );
57
+ add_filter( 'wp_mail_from_name', 'wpsc_replace_reply_name', 0 );
58
+
59
+ wp_mail( $email, $subject, $message);
60
+
61
+ remove_filter( 'wp_mail_from_name', 'wpsc_replace_reply_name' );
62
+ remove_filter( 'wp_mail_from', 'wpsc_replace_reply_address' );
63
+
64
+ exit( true );
65
+ }
66
+
67
+ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'purchlog_email_trackid') ) {
68
+ add_action( 'admin_init', 'wpsc_purchlog_email_trackid' );
69
+ }
70
+
71
+ function wpsc_ajax_sales_quarterly() {
72
+ global $wpdb;
73
+ $lastdate = $_POST['add_start'];
74
+ $date = preg_split( '/-/', $lastdate );
75
+ if ( !isset( $date[0] ) )
76
+ $date[0] = 0;
77
+ if ( !isset( $date[1] ) )
78
+ $date[1] = 0;
79
+ if ( !isset( $date[2] ) )
80
+ $date[2] = 0;
81
+ $lastquart = mktime( 0, 0, 0, $date[1], $date[2], $date[0] );
82
+ if ( $lastquart != get_option( 'wpsc_last_quarter' ) ) {
83
+ update_option( 'wpsc_last_date', $lastdate );
84
+ update_option( 'wpsc_fourth_quart', $lastquart );
85
+ $thirdquart = mktime( 0, 0, 0, $date[1] - 3, $date[2], $date[0] );
86
+ update_option( 'wpsc_third_quart', $thirdquart );
87
+ $secondquart = mktime( 0, 0, 0, $date[1] - 6, $date[2], $date[0] );
88
+ update_option( 'wpsc_second_quart', $secondquart );
89
+ $firstquart = mktime( 0, 0, 0, $date[1] - 9, $date[2], $date[0] );
90
+ update_option( 'wpsc_first_quart', $firstquart );
91
+ $finalquart = mktime( 0, 0, 0, $date[1], $date[2], $date[0] - 1 );
92
+ update_option( 'wpsc_final_quart', $finalquart );
93
+ }
94
+ }
95
+
96
+ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'wpsc_quarterly') ) {
97
+ add_action( 'admin_init', 'wpsc_ajax_sales_quarterly' );
98
+ }
99
+
100
+
101
+ function wpsc_delete_file() {
102
+ global $wpdb;
103
+ $output = 0;
104
+ $row_number = absint( $_GET['row_number'] );
105
+ $product_id = absint( $_GET['product_id'] );
106
+ $file_name = basename( $_GET['file_name'] );
107
+ check_admin_referer( 'delete_file_' . $file_name );
108
+
109
+
110
+ $product_id_to_delete = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_title = '$file_name' AND post_parent = '$product_id' AND post_type ='wpsc-product-file'" ) );
111
+
112
+ wp_delete_post( $product_id_to_delete, true );
113
+
114
+ if ( $_POST['ajax'] !== 'true' ) {
115
+ $sendback = wp_get_referer();
116
+ wp_redirect( $sendback );
117
+ }
118
+
119
+ echo "jQuery('#select_product_file_row_$row_number').fadeOut('fast',function() {\n";
120
+ echo " jQuery(this).remove();\n";
121
+ echo " jQuery('div.select_product_file p:even').removeClass('alt');\n";
122
+ echo " jQuery('div.select_product_file p:odd').addClass('alt');\n";
123
+ echo "});\n";
124
+
125
+ exit( "" );
126
+ }
127
+
128
+ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'delete_file') ) {
129
+ add_action( 'admin_init', 'wpsc_delete_file' );
130
+ }
131
+
132
+ function wpsc_modify_product_price() {
133
+ global $wpdb;
134
+ $product_data = array_pop( $_POST['product_price'] );
135
+
136
+ $product_id = absint( $product_data['id'] );
137
+ $product_price = $product_data['price'];
138
+ $product_nonce = $product_data['nonce'];
139
+
140
+ if ( wp_verify_nonce( $product_nonce, 'edit-product_price-' . $product_id ) ) {
141
+ $product_price = (float)str_replace( ',','',$product_price );
142
+ if ( update_post_meta( $product_id, '_wpsc_price', $product_price ) ) {
143
+ echo "success = 1;\n\r";
144
+ echo "new_price = '" . wpsc_currency_display( $product_price,array( 'display_as_html' => false ) ) . "';\n\r";
145
+ } else {
146
+ echo "success = 0;\n\r";
147
+ }
148
+ } else {
149
+ echo "success = -1;\n\r";
150
+ }
151
+ exit();
152
+ }
153
+
154
+ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'modify_price') ) {
155
+ add_action( 'admin_init', 'wpsc_modify_product_price' );
156
+ }
157
+
158
+ function wpsc_modify_sales_product_price() {
159
+ global $wpdb;
160
+ $product_data = array_pop( $_POST['sale_product_price'] );
161
+
162
+ $product_id = absint( $product_data['id'] );
163
+ $product_price = $product_data['price'];
164
+ $product_nonce = $product_data['nonce'];
165
+
166
+ if ( wp_verify_nonce( $product_nonce, 'sale-edit-product_price-' . $product_id ) ) {
167
+ $product_price = (float)str_replace( ',','',$product_price );
168
+ if ( update_post_meta( $product_id, '_wpsc_special_price', $product_price ) ) {
169
+ echo "success = 1;\n\r";
170
+ echo "new_price = '" . wpsc_currency_display( $product_price,array( 'display_as_html' => false ) ) . "';\n\r";
171
+ } else {
172
+ echo "success = 0;\n\r";
173
+ }
174
+ } else {
175
+ echo "success = -1;\n\r";
176
+ }
177
+ exit();
178
+ }
179
+
180
+ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'modify_sales_price') ) {
181
+ add_action( 'admin_init', 'wpsc_modify_sales_product_price' );
182
+ }
183
+
184
+ function wpsc_modify_sku() {
185
+ global $wpdb;
186
+ $product_data = array_pop( $_POST['sku_field'] );
187
+
188
+ $product_id = absint( $product_data['id'] );
189
+ $sku = $product_data['sku'];
190
+ $product_nonce = $product_data['nonce'];
191
+
192
+ if ( wp_verify_nonce( $product_nonce, 'edit-sku-' . $product_id ) ) {
193
+ if ( update_post_meta( $product_id, '_wpsc_sku', $sku ) ) {
194
+ echo "success = 1;\n\r";
195
+ echo "new_price = '" . $sku . "';\n\r";
196
+ } else {
197
+ echo "success = 0;\n\r";
198
+ }
199
+ } else {
200
+ echo "success = -1;\n\r";
201
+ }
202
+ exit();
203
+ }
204
+
205
+ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'modify_sku') ) {
206
+ add_action( 'admin_init', 'wpsc_modify_sku' );
207
+ }
208
+
209
+ function wpsc_modify_weight() {
210
+ global $wpdb;
211
+
212
+ $product_data = array_pop( $_POST['weight_field'] );
213
+
214
+ $product_id = absint( $product_data['id'] );
215
+ $product_nonce = $product_data['nonce'];
216
+
217
+ if ( wp_verify_nonce( $product_nonce, 'edit-weight-' . $product_id ) ) {
218
+
219
+ $old_array = get_product_meta( $product_id, 'product_metadata' );
220
+ $old_array = array_pop( $old_array );
221
+
222
+ $weight = wpsc_convert_weight( $product_data['weight'], $old_array["weight_unit"], "gram" );
223
+
224
+ foreach ( $old_array as $key => $value ) {
225
+ if ( $key == 'weight' ) {
226
+ $old_array[$key] = $weight;
227
+ }
228
+ }
229
+
230
+ if ( update_product_meta( $product_id, 'product_metadata', $old_array ) ) {
231
+ echo "success = 1;\n\r";
232
+ echo "new_price = '" . wpsc_convert_weight( $weight, "gram", $old_array["weight_unit"] ) . "';\n\r";
233
+ } else {
234
+ echo "success = 0;\n\r";
235
+ }
236
+ } else {
237
+ echo "success = -1;\n\r";
238
+ }
239
+ exit();
240
+ }
241
+
242
+ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'modify_weight') ) {
243
+ add_action( 'admin_init', 'wpsc_modify_weight' );
244
+ }
245
+
246
+ function wpsc_modify_stock() {
247
+ global $wpdb;
248
+ $product_data = array_pop( $_POST['stock_field'] );
249
+
250
+ $product_id = absint( $product_data['id'] );
251
+ $stock = (int)$product_data['stock'];
252
+ $product_nonce = $product_data['nonce'];
253
+
254
+ if ( wp_verify_nonce( $product_nonce, 'edit-stock-' . $product_id ) ) {
255
+ if ( update_post_meta( $product_id, '_wpsc_stock', $stock ) ) {
256
+ echo "success = 1;\n\r";
257
+ echo "new_price = '" . $stock . "';\n\r";
258
+ } else {
259
+ echo "success = 0;\n\r";
260
+ }
261
+ } else {
262
+ echo "success = -1;\n\r";
263
+ }
264
+ exit();
265
+ }
266
+
267
+ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'modify_stock') ) {
268
+ add_action( 'admin_init', 'wpsc_modify_stock' );
269
+ }
270
+
271
+ /**
272
+ Function and action for publishing or unpublishing single products
273
+ */
274
+ function wpsc_ajax_toggle_published() {
275
+ global $wpdb;
276
+
277
+ $product_id = absint( $_GET['product'] );
278
+ check_admin_referer( 'toggle_publish_' . $product_id );
279
+
280
+ $status = (wpsc_toggle_publish_status( $product_id )) ? ('true') : ('false');
281
+ $sendback = add_query_arg( 'flipped', "1", wp_get_referer() );
282
+ wp_redirect( $sendback );
283
+ exit();
284
+ }
285
+
286
+ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'toggle_publish') ) {
287
+ add_action( 'admin_init', 'wpsc_ajax_toggle_published' );
288
+ }
289
+
290
+ /**
291
+ Function and action for duplicating products,
292
+ Refactored for 3.8
293
+ * Purposely not duplicating stick post status (logically, products are most often duplicated because they share many attributes, where products are generally 'featured' uniquely.)
294
+ */
295
+ function wpsc_duplicate_product() {
296
+ global $wpdb;
297
+
298
+ // Get the original post
299
+ $id = absint( $_GET['product'] );
300
+ $post = wpsc_duplicate_this_dangit( $id );
301
+
302
+ // Copy the post and insert it
303
+ if ( isset( $post ) && $post != null ) {
304
+ $new_id = wpsc_duplicate_product_process( $post );
305
+
306
+ $duplicated = true;
307
+ $sendback = wp_get_referer();
308
+ $sendback = add_query_arg( 'duplicated', (int)$duplicated, $sendback );
309
+
310
+ wp_redirect( $sendback );
311
+ exit();
312
+ } else {
313
+ wp_die( __( 'Sorry, for some reason, we couldn\'t duplicate this product because it could not be found in the database, check there for this ID: ' ) . $id );
314
+ }
315
+ }
316
+
317
+ function wpsc_duplicate_this_dangit( $id ) {
318
+ $post = get_post($id);
319
+ return $post;
320
+ }
321
+
322
+ function wpsc_duplicate_product_process( $post ) {
323
+ global $wpdb, $current_user;
324
+ wp_get_current_user();
325
+ $user_ID = $current_user->ID;
326
+
327
+ $new_post_date = $post->post_date;
328
+ $new_post_date_gmt = get_gmt_from_date( $new_post_date );
329
+
330
+ $new_post_type = $post->post_type;
331
+ $post_content = str_replace( "'", "''", $post->post_content );
332
+ $post_content_filtered = str_replace( "'", "''", $post->post_content_filtered );
333
+ $post_excerpt = str_replace( "'", "''", $post->post_excerpt );
334
+ $post_title = str_replace( "'", "''", $post->post_title ) . " (Duplicate)";
335
+ $post_name = str_replace( "'", "''", $post->post_name );
336
+ $comment_status = str_replace( "'", "''", $post->comment_status );
337
+ $ping_status = str_replace( "'", "''", $post->ping_status );
338
+
339
+ $defaults = array(
340
+ 'post_status' => $post->post_status,
341
+ 'post_type' => $new_post_type,
342
+ 'post_author' => $user_ID,
343
+ 'ping_status' => $ping_status,
344
+ 'post_parent' => $post->post_parent,
345
+ 'menu_order' => $post->menu_order,
346
+ 'to_ping' => $post->to_ping,
347
+ 'pinged' => $post->pinged,
348
+ 'post_excerpt' => $post_excerpt,
349
+ 'post_title' => $post_title,
350
+ 'post_content' => $post_content,
351
+ 'post_content_filtered' => $post_content_filtered,
352
+ 'import_id' => 0
353
+ );
354
+ // Insert the new template in the post table
355
+ $new_post_id = wp_insert_post($defaults);
356
+ //$new_post_id = $wpdb->insert_id;
357
+
358
+ // Copy the taxonomies
359
+ wpsc_duplicate_taxonomies( $post->ID, $new_post_id, $post->post_type );
360
+
361
+ // Copy the meta information
362
+ wpsc_duplicate_product_meta( $post->ID, $new_post_id );
363
+
364
+ // Finds children (Which includes product files AND product images), their meta values, and duplicates them.
365
+ wpsc_duplicate_children( $post->ID, $new_post_id );
366
+
367
+ return $new_post_id;
368
+ }
369
+
370
+ /**
371
+ * Copy the taxonomies of a post to another post
372
+ */
373
+ function wpsc_duplicate_taxonomies( $id, $new_id, $post_type ) {
374
+ global $wpdb;
375
+ if ( isset( $wpdb->terms ) ) {
376
+ // WordPress 2.3
377
+ $taxonomies = get_object_taxonomies( $post_type ); //array("category", "post_tag");
378
+ foreach ( $taxonomies as $taxonomy ) {
379
+ $post_terms = wp_get_object_terms( $id, $taxonomy );
380
+ for ( $i = 0; $i < count( $post_terms ); $i++ ) {
381
+ wp_set_object_terms( $new_id, $post_terms[$i]->slug, $taxonomy, true );
382
+ }
383
+ }
384
+ }
385
+ }
386
+
387
+ /**
388
+ * Copy the meta information of a post to another post
389
+ */
390
+ function wpsc_duplicate_product_meta( $id, $new_id ) {
391
+ global $wpdb;
392
+ $post_meta_infos = $wpdb->get_results( "SELECT meta_key, meta_value FROM $wpdb->postmeta WHERE post_id=$id" );
393
+
394
+ if ( count( $post_meta_infos ) != 0 ) {
395
+ $sql_query = "INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) ";
396
+
397
+ foreach ( $post_meta_infos as $meta_info ) {
398
+ $meta_key = $meta_info->meta_key;
399
+ $meta_value = addslashes( $meta_info->meta_value );
400
+
401
+ $sql_query_sel[] = "SELECT $new_id, '$meta_key', '$meta_value'";
402
+ }
403
+ $sql_query.= implode( " UNION ALL ", $sql_query_sel );
404
+ $wpdb->query( $sql_query );
405
+ }
406
+ }
407
+
408
+ /**
409
+ * Duplicates children product and children meta
410
+ */
411
+ function wpsc_duplicate_children( $old_parent_id, $new_parent_id ) {
412
+ global $wpdb;
413
+
414
+ //Get children products and duplicate them
415
+ $child_posts = $wpdb->get_results( "SELECT * FROM $wpdb->posts WHERE post_parent = $old_parent_id" );
416
+
417
+ foreach ( $child_posts as $child_post ) {
418
+
419
+ $new_post_date = $child_post->post_date;
420
+ $new_post_date_gmt = get_gmt_from_date( $new_post_date );
421
+
422
+ $new_post_type = $child_post->post_type;
423
+ $post_content = str_replace( "'", "''", $child_post->post_content );
424
+ $post_content_filtered = str_replace( "'", "''", $child_post->post_content_filtered );
425
+ $post_excerpt = str_replace( "'", "''", $child_post->post_excerpt );
426
+ $post_title = str_replace( "'", "''", $child_post->post_title );
427
+ $post_name = str_replace( "'", "''", $child_post->post_name );
428
+ $comment_status = str_replace( "'", "''", $child_post->comment_status );
429
+ $ping_status = str_replace( "'", "''", $child_post->ping_status );
430
+
431
+ $wpdb->query(
432
+ "INSERT INTO $wpdb->posts
433
+ (post_author, post_date, post_date_gmt, post_content, post_content_filtered, post_title, post_excerpt, post_status, post_type, comment_status, ping_status, post_password, to_ping, pinged, post_modified, post_modified_gmt, post_parent, menu_order, post_mime_type)
434
+ VALUES
435
+ ('$child_post->post_author', '$new_post_date', '$new_post_date_gmt', '$post_content', '$post_content_filtered', '$post_title', '$post_excerpt', '$child_post->post_status', '$new_post_type', '$comment_status', '$ping_status', '$child_post->post_password', '$child_post->to_ping', '$child_post->pinged', '$new_post_date', '$new_post_date_gmt', '$new_parent_id', '$child_post->menu_order', '$child_post->post_mime_type')" );
436
+
437
+ $old_post_id = $child_post->ID;
438
+ $new_post_id = $wpdb->insert_id;
439
+ $child_meta = $wpdb->get_results( "SELECT post_id, meta_key, meta_value FROM $wpdb->postmeta WHERE post_id = $old_post_id" );
440
+
441
+ foreach ( $child_meta as $child_meta ) {
442
+ $wpdb->query(
443
+ "INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value)
444
+ VALUES('$new_post_id', '$child_meta->meta_key', '$child_meta->meta_value')"
445
+ );
446
+ }
447
+ }
448
+ }
449
+
450
+ if ( isset( $_GET['wpsc_admin_action'] ) && ($_GET['wpsc_admin_action'] == 'duplicate_product') ) {
451
+ add_action( 'admin_init', 'wpsc_duplicate_product' );
452
+ }
453
+
454
+ function wpsc_purchase_log_csv() {
455
+ global $wpdb, $user_level, $wp_rewrite, $wpsc_purchlog_statuses;
456
+ get_currentuserinfo();
457
+ if ( ($_GET['rss_key'] == 'key') && is_numeric( $_GET['start_timestamp'] ) && is_numeric( $_GET['end_timestamp'] ) && ($user_level >= 7) ) {
458
+ $form_sql = "SELECT * FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `active` = '1' AND `display_log` = '1';";
459
+ $form_data = $wpdb->get_results( $form_sql, ARRAY_A );
460
+
461
+ $start_timestamp = $_GET['start_timestamp'];
462
+ $end_timestamp = $_GET['end_timestamp'];
463
+ $data = $wpdb->get_results( "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `date` BETWEEN '$start_timestamp' AND '$end_timestamp' ORDER BY `date` DESC", ARRAY_A );
464
+
465
+ header( 'Content-Type: text/csv' );
466
+ header( 'Content-Disposition: inline; filename="Purchase Log ' . date( "M-d-Y", $start_timestamp ) . ' to ' . date( "M-d-Y", $end_timestamp ) . '.csv"' );
467
+
468
+ foreach ( (array)$data as $purchase ) {
469
+ $country_sql = "SELECT * FROM `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` WHERE `log_id` = '" . $purchase['id'] . "' AND `form_id` = '" . get_option( 'country_form_field' ) . "' LIMIT 1";
470
+ $country_data = $wpdb->get_results( $country_sql, ARRAY_A );
471
+ $country = $country_data[0]['value'];
472
+
473
+ $output .= "\"" . $purchase['totalprice'] . "\",";
474
+
475
+ foreach ( (array)$form_data as $form_field ) {
476
+ $collected_data_sql = "SELECT * FROM `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` WHERE `log_id` = '" . $purchase['id'] . "' AND `form_id` = '" . $form_field['id'] . "' LIMIT 1";
477
+ $collected_data = $wpdb->get_results( $collected_data_sql, ARRAY_A );
478
+ $collected_data = $collected_data[0];
479
+ $output .= "\"" . $collected_data['value'] . "\",";
480
+ }
481
+
482
+ if ( get_option( 'payment_method' ) == 2 ) {
483
+ $gateway_name = '';
484
+ $nzshpcrt_gateways = nzshpcrt_get_gateways();
485
+
486
+ foreach ( $nzshpcrt_gateways as $gateway ) {
487
+ if ( $purchase['gateway'] != 'testmode' ) {
488
+ if ( $gateway['internalname'] == $purchase['gateway'] ) {
489
+ $gateway_name = $gateway['name'];
490
+ }
491
+ } else {
492
+ $gateway_name = "Manual Payment";
493
+ }
494
+ }
495
+ $output .= "\"" . $gateway_name . "\",";
496
+ }
497
+
498
+ if ( $purchase['processed'] < 1 ) {
499
+ $purchase['processed'] = 1;
500
+ }
501
+
502
+ $status_name = wpsc_find_purchlog_status_name( $purchase['processed'] );
503
+ $output .= "\"" . $status_name . "\",";
504
+
505
+ $output .= "\"" . date( "jS M Y", $purchase['date'] ) . "\"";
506
+
507
+ $cartsql = "SELECT * FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid`=" . $purchase['id'] . "";
508
+ $cart = $wpdb->get_results( $cartsql, ARRAY_A );
509
+
510
+ foreach ( (array)$cart as $item ) {
511
+ $output .= ",";
512
+ $product = $wpdb->get_row( "SELECT * FROM `" . $wpdb->posts . "` WHERE `id`=" . $item['prodid'] . " LIMIT 1", ARRAY_A );
513
+ $skuvalue = get_product_meta($item['prodid'], 'sku', true);
514
+ $output .= "\"" . $item['quantity'] . " " . str_replace( '"', '\"', $product['name'] ) . $variation_list . "\"";
515
+ $output .= "," . $skuvalue;
516
+ }
517
+ $output .= "\n"; // terminates the row/line in the CSV file
518
+ }
519
+ echo $output;
520
+ exit();
521
+ }
522
+ }
523
+
524
+ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'wpsc_downloadcsv') ) {
525
+ add_action( 'admin_init', 'wpsc_purchase_log_csv' );
526
+ }
527
+
528
+ function wpsc_admin_ajax() {
529
+ global $wpdb, $user_level, $wp_rewrite;
530
+ get_currentuserinfo();
531
+
532
+ if ( $_POST['action'] == 'product-page-order' ) {
533
+ $current_order = get_option( 'wpsc_product_page_order' );
534
+ $new_order = $_POST['order'];
535
+
536
+ if ( isset( $new_order["advanced"] ) ) {
537
+ $current_order["advanced"] = array_unique( explode( ',', $new_order["advanced"] ) );
538
+ }
539
+ if ( isset( $new_order["side"] ) ) {
540
+ $current_order["side"] = array_unique( explode( ',', $new_order["side"] ) );
541
+ }
542
+
543
+ update_option( 'wpsc_product_page_order', $current_order );
544
+ exit( print_r( $order, 1 ) );
545
+ }
546
+
547
+
548
+ if ( ($_POST['save_image_upload_state'] == "true") && is_numeric( $_POST['image_upload_state'] ) ) {
549
+ $upload_state = (int)(bool)$_POST['image_upload_state'];
550
+ update_option( 'wpsc_use_flash_uploader', $upload_state );
551
+ exit( "done" );
552
+ }
553
+
554
+ if ( ($_POST['remove_variation_value'] == "true") && is_numeric( $_POST['variation_value_id'] ) ) {
555
+ $value_id = absint( $_GET['variation_value_id'] );
556
+ echo wp_delete_term( $value_id, 'wpsc-variation' );
557
+ exit();
558
+ }
559
+
560
+ if ( ($_POST['remove_form_field'] == "true") && is_numeric( $_POST['form_id'] ) ) {
561
+ if ( current_user_can( 'level_7' ) ) {
562
+ $wpdb->query( $wpdb->prepare( "UPDATE `" . WPSC_TABLE_CHECKOUT_FORMS . "` SET `active` = '0' WHERE `id` = %d LIMIT 1 ;", $_POST['form_id'] ) );
563
+ exit( ' ' );
564
+ }
565
+ }
566
+
567
+
568
+ if ( $_POST['hide_ecom_dashboard'] == 'true' ) {
569
+ require_once (ABSPATH . WPINC . '/rss.php');
570
+ $rss = fetch_rss( 'http://www.instinct.co.nz/feed/' );
571
+ $rss->items = array_slice( $rss->items, 0, 5 );
572
+ $rss_hash = sha1( serialize( $rss->items ) );
573
+ update_option( 'wpsc_ecom_news_hash', $rss_hash );
574
+ exit( 1 );
575
+ }
576
+
577
+ if ( ($_POST['remove_meta'] == 'true') && is_numeric( $_POST['meta_id'] ) ) {
578
+ $meta_id = (int)$_POST['meta_id'];
579
+ if ( delete_meta( $meta_id ) ) {
580
+ echo $meta_id;
581
+ exit();
582
+ }
583
+ echo 0;
584
+ exit();
585
+ }
586
+
587
+ if ( ($_REQUEST['log_state'] == "true") && is_numeric( $_POST['id'] ) && is_numeric( $_POST['value'] ) ) {
588
+ $newvalue = $_POST['value'];
589
+ if ( $_REQUEST['suspend'] == 'true' ) {
590
+ if ( $_REQUEST['value'] == 1 ) {
591
+ wpsc_member_dedeactivate_subscriptions( $_POST['id'] );
592
+ } else {
593
+ wpsc_member_deactivate_subscriptions( $_POST['id'] );
594
+ }
595
+ exit();
596
+ } else {
597
+
598
+ $log_data = $wpdb->get_row( "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `id` = '" . $_POST['id'] . "' LIMIT 1", ARRAY_A );
599
+ if ( ($newvalue == 2) && function_exists( 'wpsc_member_activate_subscriptions' ) ) {
600
+ wpsc_member_activate_subscriptions( $_POST['id'] );
601
+ }
602
+
603
+ $update_sql = "UPDATE `" . WPSC_TABLE_PURCHASE_LOGS . "` SET `processed` = '" . $newvalue . "' WHERE `id` = '" . $_POST['id'] . "' LIMIT 1";
604
+ $wpdb->query( $update_sql );
605
+ if ( ($newvalue > $log_data['processed']) && ($log_data['processed'] < 2) ) {
606
+ transaction_results( $log_data['sessionid'], false );
607
+ }
608
+
609
+ $status_name = wpsc_find_purchlog_status_name( $purchase['processed'] );
610
+ echo "document.getElementById(\"form_group_" . $_POST['id'] . "_text\").innerHTML = '" . $status_name . "';\n";
611
+
612
+
613
+ $year = date( "Y" );
614
+ $month = date( "m" );
615
+ $start_timestamp = mktime( 0, 0, 0, $month, 1, $year );
616
+ $end_timestamp = mktime( 0, 0, 0, ($month + 1 ), 0, $year );
617
+
618
+ echo "document.getElementById(\"log_total_month\").innerHTML = '" . addslashes( wpsc_currency_display( admin_display_total_price( $start_timestamp, $end_timestamp ) ) ) . "';\n";
619
+ echo "document.getElementById(\"log_total_absolute\").innerHTML = '" . addslashes( wpsc_currency_display( admin_display_total_price() ) ) . "';\n";
620
+ exit();
621
+ }
622
+ }
623
+
624
+ if ( isset( $_POST['language_setting'] ) && ($_GET['page'] = WPSC_DIR_NAME . '/wpsc-admin/display-options.page.php') ) {
625
+ if ( $user_level >= 7 ) {
626
+ update_option( 'language_setting', $_POST['language_setting'] );
627
+ }
628
+ }
629
+ }
630
+
631
+ function wpsc_admin_sale_rss() {
632
+ global $wpdb;
633
+ if ( ($_GET['rss'] == "true") && ($_GET['rss_key'] == 'key') && ($_GET['action'] == "purchase_log") ) {
634
+ $sql = "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `date`!='' ORDER BY `date` DESC";
635
+ $purchase_log = $wpdb->get_results( $sql, ARRAY_A );
636
+ header( "Content-Type: application/xml; charset=UTF-8" );
637
+ header( 'Content-Disposition: inline; filename="WP_E-Commerce_Purchase_Log.rss"' );
638
+ $output = '';
639
+ $output .= "<?xml version='1.0'?>\n\r";
640
+ $output .= "<rss version='2.0'>\n\r";
641
+ $output .= " <channel>\n\r";
642
+ $output .= " <title>WP e-Commerce Product Log</title>\n\r";
643
+ $output .= " <link>" . get_option( 'siteurl' ) . "/wp-admin/admin.php?page=" . WPSC_DIR_NAME . "/display-log.php</link>\n\r";
644
+ $output .= " <description>This is the WP e-Commerce Product Log RSS feed</description>\n\r";
645
+ $output .= " <generator>WP e-Commerce Plugin</generator>\n\r";
646
+
647
+ foreach ( (array)$purchase_log as $purchase ) {
648
+ $purchase_link = get_option( 'siteurl' ) . "/wp-admin/admin.php?page=" . WPSC_DIR_NAME . "/display-log.php&amp;purchaseid=" . $purchase['id'];
649
+ $output .= " <item>\n\r";
650
+ $output .= " <title>Purchase # " . $purchase['id'] . "</title>\n\r";
651
+ $output .= " <link>$purchase_link</link>\n\r";
652
+ $output .= " <description>This is an entry in the purchase log.</description>\n\r";
653
+ $output .= " <pubDate>" . date( "r", $purchase['date'] ) . "</pubDate>\n\r";
654
+ $output .= " <guid>$purchase_link</guid>\n\r";
655
+ $output .= " </item>\n\r";
656
+ }
657
+ $output .= " </channel>\n\r";
658
+ $output .= "</rss>";
659
+ echo $output;
660
+ exit();
661
+ }
662
+ }
663
+
664
+ function wpsc_swfupload_images() {
665
+ global $wpdb, $current_user, $user_ID;
666
+ $file = $_FILES['async-upload'];
667
+ $product_id = absint( $_POST['product_id'] );
668
+ $nonce = $_POST['_wpnonce'];
669
+ $output = '';
670
+ // Flash often fails to send cookies with the POST or upload, so we need to pass it in GET or POST instead, code is from wp-admin/async-upload.php
671
+ if ( is_ssl() && empty( $_COOKIE[SECURE_AUTH_COOKIE] ) && !empty( $_REQUEST['auth_cookie'] ) ) {
672
+ $_COOKIE[SECURE_AUTH_COOKIE] = $_REQUEST['auth_cookie'];
673
+ } else if ( empty( $_COOKIE[AUTH_COOKIE] ) && !empty( $_REQUEST['auth_cookie'] ) ) {
674
+ $_COOKIE[AUTH_COOKIE] = $_REQUEST['auth_cookie'];
675
+ }
676
+ unset( $current_user );
677
+
678
+ if ( !current_user_can( 'upload_files' ) ) {
679
+ exit( "status=-1;\n" );
680
+ }
681
+
682
+ if ( !wp_verify_nonce( $nonce, 'product-swfupload' ) ) {
683
+ exit( "status=-1;\n" );
684
+ }
685
+
686
+
687
+
688
+ $id = media_handle_upload( 'async-upload', $product_id );
689
+
690
+ if ( !is_wp_error( $id ) ) {
691
+ $src = wp_get_attachment_image_src( $id );
692
+ $output .= "upload_status=1;\n";
693
+ $output .= "image_src='" . $src[0] . "';\n";
694
+ $output .= "image_id='$id';\n";
695
+ $output .= "product_id='$product_id';\n";
696
+ $output .= "replace_existing=0;";
697
+ } else {
698
+ $output .= "status=0;\n";
699
+ }
700
+
701
+
702
+ exit( $output );
703
+ }
704
+
705
+ function wpsc_display_invoice() {
706
+
707
+ global $body_id;
708
+
709
+ $body_id = 'wpsc-packing-slip';
710
+ $purchase_id = (int)$_GET['purchaselog_id'];
711
+ include_once(WPSC_FILE_PATH . "/wpsc-admin/admin-form-functions.php");
712
+ require_once(ABSPATH . 'wp-admin/includes/media.php');
713
+ wp_iframe( 'wpsc_packing_slip', $purchase_id );
714
+ exit();
715
+ }
716
+ //other actions are here
717
+ if ( isset( $_GET['display_invoice'] ) && ( 'true' == $_GET['display_invoice'] ) )
718
+ add_action( 'admin_init', 'wpsc_display_invoice', 0 );
719
+
720
+ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ( 'wpsc_display_invoice' == $_REQUEST['wpsc_admin_action'] ) )
721
+ add_action( 'admin_init', 'wpsc_display_invoice' );
722
+
723
+ /**
724
+ * Purchase log ajax code starts here
725
+ */
726
+ function wpsc_purchlog_resend_email() {
727
+ global $wpdb;
728
+ $log_id = $_GET['email_buyer_id'];
729
+ $wpec_taxes_controller = new wpec_taxes_controller();
730
+ if ( is_numeric( $log_id ) ) {
731
+ $selectsql = "SELECT `sessionid` FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `id`= " . $log_id . " LIMIT 1";
732
+ $purchase_log = $wpdb->get_var( $selectsql );
733
+ transaction_results( $purchase_log, false);
734
+ $sent = true;
735
+ }
736
+ $sendback = wp_get_referer();
737
+ if ( isset( $sent ) ) {
738
+ $sendback = add_query_arg( 'sent', $sent, $sendback );
739
+ }
740
+ wp_redirect( $sendback );
741
+ exit();
742
+ }
743
+
744
+ if ( isset( $_REQUEST['email_buyer_id'] ) && is_numeric( $_REQUEST['email_buyer_id'] ) ) {
745
+ add_action( 'admin_init', 'wpsc_purchlog_resend_email' );
746
+ }
747
+
748
+ function wpsc_purchlog_clear_download_items() {
749
+ global $wpdb;
750
+ if ( is_numeric( $_GET['purchaselog_id'] ) ) {
751
+ $purchase_id = (int)$_GET['purchaselog_id'];
752
+ $downloadable_items = $wpdb->get_results( "SELECT * FROM `" . WPSC_TABLE_DOWNLOAD_STATUS . "` WHERE `purchid` IN ('$purchase_id')", ARRAY_A );
753
+
754
+ $clear_locks_sql = "UPDATE`" . WPSC_TABLE_DOWNLOAD_STATUS . "` SET `ip_number` = '' WHERE `purchid` IN ('$purchase_id')";
755
+ $wpdb->query( $clear_locks_sql );
756
+ $cleared = true;
757
+
758
+ $email_form_field = $wpdb->get_var( "SELECT `id` FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `type` IN ('email') AND `active` = '1' ORDER BY `checkout_order` ASC LIMIT 1" );
759
+ $email_address = $wpdb->get_var( "SELECT `value` FROM `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` WHERE `log_id`='{$purchase_id}' AND `form_id` = '{$email_form_field}' LIMIT 1" );
760
+
761
+ foreach ( (array)$downloadable_items as $downloadable_item ) {
762
+ $download_links .= $siteurl . "?downloadid=" . $downloadable_item['uniqueid'] . "\n";
763
+ }
764
+
765
+
766
+ wp_mail( $email_address, __( 'The administrator has unlocked your file', 'wpsc' ), str_replace( "[download_links]", $download_links, __( 'Dear CustomerWe are pleased to advise you that your order has been updated and your downloads are now active.Please download your purchase using the links provided below.[download_links]Thank you for your custom.', 'wpsc' ) ), "From: " . get_option( 'return_email' ) . "" );
767
+
768
+
769
+ $sendback = wp_get_referer();
770
+
771
+ if ( isset( $cleared ) ) {
772
+ $sendback = add_query_arg( 'cleared', $cleared, $sendback );
773
+ }
774
+ wp_redirect( $sendback );
775
+ exit();
776
+ }
777
+ }
778
+
779
+ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'clear_locks') ) {
780
+ add_action( 'admin_init', 'wpsc_purchlog_clear_download_items' );
781
+ }
782
+
783
+ //call to change view for purchase log
784
+
785
+ function wpsc_purchlog_filter_by() {
786
+ wpsc_change_purchlog_view( $_POST['view_purchlogs_by'], $_POST['view_purchlogs_by_status'] );
787
+ }
788
+
789
+ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'purchlog_filter_by') ) {
790
+ add_action( 'admin_init', 'wpsc_purchlog_filter_by' );
791
+ }
792
+
793
+ //bulk actions for purchase log
794
+ function wpsc_purchlog_bulk_modify() {
795
+ if ( $_POST['purchlog_multiple_status_change'] != -1 ) {
796
+ if ( is_numeric( $_POST['purchlog_multiple_status_change'] ) && $_POST['purchlog_multiple_status_change'] != 'delete' ) {
797
+ foreach ( (array)$_POST['purchlogids'] as $purchlogid ) {
798
+ wpsc_purchlog_edit_status( $purchlogid, $_POST['purchlog_multiple_status_change'] );
799
+ $updated++;
800
+ }
801
+ } elseif ( $_POST['purchlog_multiple_status_change'] == 'delete' ) {
802
+ foreach ( (array)$_POST['purchlogids'] as $purchlogid ) {
803
+
804
+ wpsc_delete_purchlog( $purchlogid );
805
+ $deleted++;
806
+ }
807
+ }
808
+ }
809
+ $sendback = wp_get_referer();
810
+ if ( isset( $updated ) ) {
811
+ $sendback = add_query_arg( 'updated', $updated, $sendback );
812
+ }
813
+ if ( isset( $deleted ) ) {
814
+ $sendback = add_query_arg( 'deleted', $deleted, $sendback );
815
+ }
816
+ if ( isset( $_POST['view_purchlogs_by'] ) ) {
817
+ $sendback = add_query_arg( 'view_purchlogs_by', $_POST['view_purchlogs_by'], $sendback );
818
+ }
819
+ if ( isset( $_POST['view_purchlogs_by_status'] ) ) {
820
+ $sendback = add_query_arg( 'view_purchlogs_by_status', $_POST['view_purchlogs_by_status'], $sendback );
821
+ }
822
+ wp_redirect( $sendback );
823
+ exit();
824
+ }
825
+
826
+ if ( isset( $_REQUEST['wpsc_admin_action2'] ) && ($_REQUEST['wpsc_admin_action2'] == 'purchlog_bulk_modify') ) {
827
+ add_action( 'admin_init', 'wpsc_purchlog_bulk_modify' );
828
+ }
829
+
830
+ //edit purchase log status function
831
+ function wpsc_purchlog_edit_status( $purchlog_id='', $purchlog_status='' ) {
832
+ global $wpdb;
833
+ if ( ($purchlog_id == '') && ($purchlog_status == '') ) {
834
+ $purchlog_id = absint( $_POST['purchlog_id'] );
835
+ $purchlog_status = absint( $_POST['purchlog_status'] );
836
+ }
837
+
838
+ $log_data = $wpdb->get_row( "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `id` = '{$purchlog_id}' LIMIT 1", ARRAY_A );
839
+ if ( ($purchlog_id == 2) && function_exists( 'wpsc_member_activate_subscriptions' ) ) {
840
+ wpsc_member_activate_subscriptions( $_POST['id'] );
841
+ }
842
+
843
+ //in the future when everyone is using the 2.0 merchant api, we should use the merchant class to update the staus,
844
+ // then you can get rid of this hook and have each person overwrite the method that updates the status.
845
+ do_action('wpsc_edit_order_status', array('purchlog_id'=>$purchlog_id, 'purchlog_data'=>$log_data, 'new_status'=>$purchlog_status));
846
+ // if the order is marked as failed, remove the claim on the stock
847
+ if ( $purchlog_status == 5 )
848
+ $wpdb->query( "DELETE FROM `" . WPSC_TABLE_CLAIMED_STOCK . "` WHERE `cart_id` = '{$purchlog_id}' AND `cart_submitted` = '1'" );
849
+
850
+
851
+ $wpdb->query( "UPDATE `" . WPSC_TABLE_PURCHASE_LOGS . "` SET processed='{$purchlog_status}' WHERE id='{$purchlog_id}'" );
852
+
853
+ if ( ($purchlog_id > $log_data['processed']) && ($log_data['processed'] <= 2) && $log_data['email_sent'] == 0 ) {
854
+ transaction_results($log_data['sessionid'],false,null);
855
+ }
856
+ }
857
+
858
+ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'purchlog_edit_status') ) {
859
+ add_action( 'admin_init', 'wpsc_purchlog_edit_status' );
860
+ }
861
+
862
+ function wpsc_save_product_order() {
863
+ global $wpdb;
864
+
865
+ $products = array( );
866
+
867
+ foreach ( $_POST['post'] as $product ) {
868
+ $products[] = absint( $product );
869
+ }
870
+
871
+ print_r( $products );
872
+
873
+ foreach ( $products as $order => $product_id ) {
874
+
875
+ $wpdb->query( $wpdb->prepare( "UPDATE `{$wpdb->posts}` SET `menu_order`='%d' WHERE `ID`='%d' LIMIT 1", $order, $product_id ) );
876
+ }
877
+ $success = true;
878
+
879
+ exit( (string)$success );
880
+ }
881
+
882
+ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'save_product_order') ) {
883
+ add_action( 'admin_init', 'wpsc_save_product_order' );
884
+ }
885
+
886
+ function wpsc_save_checkout_order() {
887
+ global $wpdb;
888
+ $checkoutfields = $_POST['checkout'];
889
+ $order = 1;
890
+ foreach ( $checkoutfields as $checkoutfield ) {
891
+ $checkoutfield = absint( $checkoutfield );
892
+ $wpdb->query( "UPDATE `" . WPSC_TABLE_CHECKOUT_FORMS . "` SET `checkout_order` = '" . $order . "' WHERE `id`=" . $checkoutfield );
893
+
894
+ $order++;
895
+ }
896
+ $success = true;
897
+
898
+ exit( (string)$success );
899
+ }
900
+ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'save_checkout_order') )
901
+ add_action( 'admin_init', 'wpsc_save_checkout_order' );
902
+
903
+ /* Start Order Notes (by Ben) */
904
+ function wpsc_purchlogs_update_notes( $purchlog_id = '', $purchlog_notes = '' ) {
905
+ global $wpdb;
906
+ if ( wp_verify_nonce( $_POST['wpsc_purchlogs_update_notes_nonce'], 'wpsc_purchlogs_update_notes' ) ) {
907
+ if ( ($purchlog_id == '') && ($purchlog_notes == '') ) {
908
+ $purchlog_id = absint( $_POST['purchlog_id'] );
909
+ $purchlog_notes = $wpdb->escape( $_POST['purchlog_notes'] );
910
+ }
911
+ $wpdb->query( "UPDATE `" . WPSC_TABLE_PURCHASE_LOGS . "` SET notes='{$purchlog_notes}' WHERE id='{$purchlog_id}'" );
912
+ }
913
+ }
914
+ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'purchlogs_update_notes' ) )
915
+ add_action( 'admin_init', 'wpsc_purchlogs_update_notes' );
916
+
917
+ /* End Order Notes (by Ben) */
918
+
919
+ //delete a purchase log
920
+ function wpsc_delete_purchlog( $purchlog_id='' ) {
921
+ global $wpdb;
922
+ $deleted = 0;
923
+ if ( $purchlog_id == '' ) {
924
+ $purchlog_id = absint( $_GET['purchlog_id'] );
925
+ check_admin_referer( 'delete_purchlog_' . $purchlog_id );
926
+ }
927
+
928
+ if ( is_numeric( $purchlog_id ) ) {
929
+ $delete_log_form_sql = "SELECT * FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid`='$purchlog_id'";
930
+ $cart_content = $wpdb->get_results( $delete_log_form_sql, ARRAY_A );
931
+ }
932
+
933
+ $purchlog_status = $wpdb->get_var( "SELECT `processed` FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `id`=" . $purchlog_id );
934
+ if ( $purchlog_status == 5 || $purchlog_status == 1 ) {
935
+ $wpdb->query( "DELETE FROM `" . WPSC_TABLE_CLAIMED_STOCK . "` WHERE `cart_id` = '{$purchlog_id}' AND `cart_submitted` = '1'" );
936
+ }
937
+
938
+ $wpdb->query( "DELETE FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid`='$purchlog_id'" );
939
+ $wpdb->query( "DELETE FROM `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` WHERE `log_id` IN ('$purchlog_id')" );
940
+ $wpdb->query( "DELETE FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `id`='$purchlog_id' LIMIT 1" );
941
+
942
+ $deleted = 1;
943
+
944
+ if ( is_numeric( $_GET['purchlog_id'] ) ) {
945
+ $sendback = wp_get_referer();
946
+ $sendback = remove_query_arg( 'purchaselog_id', $sendback );
947
+ if ( isset( $deleted ) ) {
948
+ $sendback = add_query_arg( 'deleted', $deleted, $sendback );
949
+ }
950
+ wp_redirect( $sendback );
951
+ exit();
952
+ }
953
+ }
954
+
955
+ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'delete_purchlog') ) {
956
+ add_action( 'admin_init', 'wpsc_delete_purchlog' );
957
+ }
958
+
959
+ /*
960
+ * Get Shipping Form ajax call
961
+ */
962
+
963
+ function wpsc_ajax_get_shipping_form() {
964
+ global $wpdb, $wpsc_shipping_modules;
965
+ $shippingname = $_REQUEST['shippingname'];
966
+ $_SESSION['previous_shipping_name'] = $shippingname;
967
+ $shipping_data = wpsc_get_shipping_form( $shippingname );
968
+ $html_shipping_name = str_replace( Array( "\n", "\r" ), Array( "\\n", "\\r" ), addslashes( $shipping_data['name'] ) );
969
+ $shipping_form = str_replace( Array( "\n", "\r" ), Array( "\\n", "\\r" ), addslashes( $shipping_data['form_fields'] ) );
970
+ echo "shipping_name_html = '$html_shipping_name'; \n\r";
971
+ echo "shipping_form_html = '$shipping_form'; \n\r";
972
+ echo "has_submit_button = '{$shipping_data['has_submit_button']}'; \n\r";
973
+ exit();
974
+ }
975
+
976
+ function wpsc_ajax_get_payment_form() {
977
+ global $wpdb, $nzshpcrt_gateways;
978
+ $paymentname = $_REQUEST['paymentname'];
979
+ $_SESSION['previous_payment_name'] = $paymentname;
980
+ $payment_data = wpsc_get_payment_form( $paymentname );
981
+ $html_payment_name = str_replace( Array( "\n", "\r" ), Array( "\\n", "\\r" ), addslashes( $payment_data['name'] ) );
982
+ $payment_form = str_replace( Array( "\n", "\r" ), Array( "\\n", "\\r" ), addslashes( $payment_data['form_fields'] ) );
983
+ echo "payment_name_html = '$html_payment_name'; \n\r";
984
+ echo "payment_form_html = '$payment_form'; \n\r";
985
+ echo "has_submit_button = '{$payment_data['has_submit_button']}'; \n\r";
986
+ exit();
987
+ }
988
+ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'get_shipping_form') )
989
+ add_action( 'admin_init', 'wpsc_ajax_get_shipping_form' );
990
+
991
+ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'get_payment_form') )
992
+ add_action( 'admin_init', 'wpsc_ajax_get_payment_form' );
993
+
994
+
995
+ /*
996
+ * Submit Options from Settings Pages,
997
+ * takes an array of options checks to see whether it is empty or the same as the exisiting values
998
+ * and if its not it updates them.
999
+ */
1000
+
1001
+ function wpsc_submit_options( $selected='' ) {
1002
+ global $wpdb, $wpsc_gateways;
1003
+ $updated = 0;
1004
+
1005
+ //This is to change the Overall target market selection
1006
+ check_admin_referer( 'update-options', 'wpsc-update-options' );
1007
+ if ( isset( $_POST['change-settings'] ) ) {
1008
+ if ( isset( $_POST['wpsc_also_bought'] ) && $_POST['wpsc_also_bought'] == 'on' )
1009
+ update_option( 'wpsc_also_bought', 1 );
1010
+ else
1011
+ update_option( 'wpsc_also_bought', 0 );
1012
+
1013
+ if ( isset( $_POST['display_find_us'] ) && $_POST['display_find_us'] == 'on' )
1014
+ update_option( 'display_find_us', 1 );
1015
+ else
1016
+ update_option( 'display_find_us', 0 );
1017
+
1018
+ if ( isset( $_POST['wpsc_share_this'] ) && $_POST['wpsc_share_this'] == 'on' )
1019
+ update_option( 'wpsc_share_this', 1 );
1020
+ else
1021
+ update_option( 'wpsc_share_this', 0 );
1022
+
1023
+ }
1024
+ if (empty($_POST['countrylist2']) && !empty($_POST['wpsc_options']['currency_sign_location']))
1025
+ $selected = 'none';
1026
+
1027
+ if ( !isset( $_POST['countrylist2'] ) )
1028
+ $_POST['countrylist2'] = '';
1029
+ if ( !isset( $_POST['country_id'] ) )
1030
+ $_POST['country_id'] = '';
1031
+ if ( !isset( $_POST['country_tax'] ) )
1032
+ $_POST['country_tax'] = '';
1033
+
1034
+ if ( $_POST['countrylist2'] != null || !empty($selected) ) {
1035
+ $AllSelected = false;
1036
+ if ( $selected == 'all' ) {
1037
+ $wpdb->query( "UPDATE `" . WPSC_TABLE_CURRENCY_LIST . "` SET visible = '1'" );
1038
+ $AllSelected = true;
1039
+ }
1040
+ if ( $selected == 'none' ) {
1041
+ $wpdb->query( "UPDATE `" . WPSC_TABLE_CURRENCY_LIST . "` SET visible = '0'" );
1042
+ $AllSelected = true;
1043
+ }
1044
+ if ( $AllSelected != true ) {
1045
+ $countrylist = $wpdb->get_col( "SELECT id FROM `" . WPSC_TABLE_CURRENCY_LIST . "` ORDER BY country ASC " );
1046
+ //find the countries not selected
1047
+ $unselectedCountries = array_diff( $countrylist, $_POST['countrylist2'] );
1048
+ foreach ( $unselectedCountries as $unselected ) {
1049
+ $wpdb->query( "UPDATE `" . WPSC_TABLE_CURRENCY_LIST . "` SET visible = 0 WHERE id = '" . $unselected . "' LIMIT 1" );
1050
+ }
1051
+
1052
+ //find the countries that are selected
1053
+ $selectedCountries = array_intersect( $countrylist, $_POST['countrylist2'] );
1054
+ foreach ( $selectedCountries as $selected ) {
1055
+ $wpdb->query( "UPDATE `" . WPSC_TABLE_CURRENCY_LIST . "` SET visible = 1 WHERE id = '" . $selected . "' LIMIT 1" );
1056
+ }
1057
+ }
1058
+ }
1059
+ $previous_currency = get_option( 'currency_type' );
1060
+
1061
+ $regenerate = false;
1062
+
1063
+ $regenerate_options = array('single_view_image_height', 'single_view_image_width','wpsc_gallery_image_width','wpsc_gallery_image_height', 'wpsc_crop_thumbnails','product_image_width','product_image_height');
1064
+
1065
+ //To update options
1066
+
1067
+ if ( isset( $_POST['wpsc_options'] ) ) {
1068
+
1069
+ foreach ( $_POST['wpsc_options'] as $key => $value ) {
1070
+
1071
+ if ( in_array( $key, $regenerate_options ) && $value != get_option( $key ) ) {
1072
+ $regenerate = true;
1073
+ }
1074
+
1075
+ if ( $value != get_option( $key ) ) {
1076
+ update_option( $key, $value );
1077
+ $updated++;
1078
+
1079
+ }
1080
+ }
1081
+ }
1082
+
1083
+ if ( $previous_currency != get_option( 'currency_type' ) ) {
1084
+ $currency_code = $wpdb->get_var( "SELECT `code` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `id` IN ('" . absint( get_option( 'currency_type' ) ) . "')" );
1085
+
1086
+ $selected_gateways = get_option( 'custom_gateway_options' );
1087
+ $already_changed = array( );
1088
+ foreach ( $selected_gateways as $selected_gateway ) {
1089
+ if ( isset( $wpsc_gateways[$selected_gateway]['supported_currencies'] ) ) {
1090
+ if ( in_array( $currency_code, $wpsc_gateways[$selected_gateway]['supported_currencies']['currency_list'] ) ) {
1091
+
1092
+ $option_name = $wpsc_gateways[$selected_gateway]['supported_currencies']['option_name'];
1093
+
1094
+ if ( !in_array( $option_name, $already_changed ) ) {
1095
+ update_option( $option_name, $currency_code );
1096
+ $already_changed[] = $option_name;
1097
+ }
1098
+ }
1099
+ }
1100
+ }
1101
+ }
1102
+
1103
+ foreach ( $GLOBALS['wpsc_shipping_modules'] as $shipping ) {
1104
+ if ( is_object( $shipping ) )
1105
+ $shipping->submit_form();
1106
+ }
1107
+
1108
+
1109
+ //This is for submitting shipping details to the shipping module
1110
+ if ( !isset( $_POST['update_gateways'] ) )
1111
+ $_POST['update_gateways'] = '';
1112
+ if ( !isset( $_POST['custom_shipping_options'] ) )
1113
+ $_POST['custom_shipping_options'] = null;
1114
+ if ( $_POST['update_gateways'] == 'true' ) {
1115
+
1116
+ update_option( 'custom_shipping_options', $_POST['custom_shipping_options'] );
1117
+
1118
+
1119
+ foreach ( $GLOBALS['wpsc_shipping_modules'] as $shipping ) {
1120
+ foreach ( (array)$_POST['custom_shipping_options'] as $shippingoption ) {
1121
+ if ( $shipping->internal_name == $shippingoption ) {
1122
+ $shipadd++;
1123
+ }
1124
+ }
1125
+ }
1126
+ }
1127
+
1128
+ $sendback = wp_get_referer();
1129
+
1130
+ if ( $regenerate ) {
1131
+ $sendback = add_query_arg( array('regenerate' => 'true', 'updated' => $updated), $sendback );
1132
+ }
1133
+ if ( isset( $updated ) ) {
1134
+ $sendback = add_query_arg( 'updated', $updated, $sendback );
1135
+ }
1136
+ if ( isset( $shipadd ) ) {
1137
+ $sendback = add_query_arg( 'shipadd', $shipadd, $sendback );
1138
+ }
1139
+
1140
+ if ( !isset( $_SESSION['wpsc_settings_curr_page'] ) )
1141
+ $_SESSION['wpsc_settings_curr_page'] = '';
1142
+ if ( !isset( $_POST['page_title'] ) )
1143
+ $_POST['page_title'] = '';
1144
+ if ( isset( $_SESSION['wpsc_settings_curr_page'] ) ) {
1145
+ $sendback = add_query_arg( 'tab', $_SESSION['wpsc_settings_curr_page'], $sendback );
1146
+ }
1147
+
1148
+ $sendback = add_query_arg( 'page', 'wpsc-settings', $sendback );
1149
+ wp_redirect( $sendback );
1150
+ exit();
1151
+ }
1152
+ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'submit_options') )
1153
+ add_action( 'admin_init', 'wpsc_submit_options' );
1154
+
1155
+ function wpsc_change_currency() {
1156
+ if ( is_numeric( $_POST['currencyid'] ) ) {
1157
+ $currency_data = $wpdb->get_results( "SELECT `symbol`,`symbol_html`,`code` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `id`='" . $_POST['currencyid'] . "' LIMIT 1", ARRAY_A );
1158
+ $price_out = null;
1159
+ if ( $currency_data[0]['symbol'] != '' ) {
1160
+ $currency_sign = $currency_data[0]['symbol_html'];
1161
+ } else {
1162
+ $currency_sign = $currency_data[0]['code'];
1163
+ }
1164
+ echo $currency_sign;
1165
+ }
1166
+ }
1167
+ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'change_currency') )
1168
+ add_action( 'admin_init', 'wpsc_change_currency' );
1169
+
1170
+ function wpsc_rearrange_images() {
1171
+ global $wpdb;
1172
+ $images = explode( ",", $_POST['order'] );
1173
+ $product_id = absint( $_POST['product_id'] );
1174
+ $timestamp = time();
1175
+
1176
+ $new_main_image = null;
1177
+ $have_set_first_item = false;
1178
+ $i = 0;
1179
+ foreach ( $images as $image ) {
1180
+ if ( $image > 0 ) {
1181
+ $wpdb->query( $wpdb->prepare( "UPDATE `{$wpdb->posts}` SET `menu_order`='%d' WHERE `ID`='%d' LIMIT 1", $i, $image ) );
1182
+ $i++;
1183
+ }
1184
+ }
1185
+ $output = wpsc_main_product_image_menu( $product_id );
1186
+ echo "image_menu = '';\n\r";
1187
+ echo "image_id = '" . $new_main_image . "';\n\r";
1188
+ exit();
1189
+ }
1190
+ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'rearrange_images') )
1191
+ add_action( 'admin_init', 'wpsc_rearrange_images' );
1192
+
1193
+ /**
1194
+ * wpsc_update_page_urls gets the permalinks for products pages and stores them in the options for quick reference
1195
+ * @public
1196
+ *
1197
+ * @since 3.6
1198
+ * @param $auto (Boolean) true if coming from WordPress Permalink Page, false otherwise
1199
+ * @return nothing
1200
+ */
1201
+ function wpsc_update_page_urls($auto = false) {
1202
+ global $wpdb;
1203
+
1204
+ $wpsc_pageurl_option['product_list_url'] = '[productspage]';
1205
+ $wpsc_pageurl_option['shopping_cart_url'] = '[shoppingcart]';
1206
+ $check_chekout = $wpdb->get_var( "SELECT `guid` FROM `{$wpdb->posts}` WHERE `post_content` LIKE '%[checkout]%' LIMIT 1" );
1207
+ if ( $check_chekout != null ) {
1208
+ $wpsc_pageurl_option['checkout_url'] = '[checkout]';
1209
+ } else {
1210
+ $wpsc_pageurl_option['checkout_url'] = '[checkout]';
1211
+ }
1212
+ $wpsc_pageurl_option['transact_url'] = '[transactionresults]';
1213
+ $wpsc_pageurl_option['user_account_url'] = '[userlog]';
1214
+ $changes_made = false;
1215
+ foreach ( $wpsc_pageurl_option as $option_key => $page_string ) {
1216
+ $post_id = $wpdb->get_var( "SELECT `ID` FROM `{$wpdb->posts}` WHERE `post_type` IN('page','post') AND `post_content` LIKE '%$page_string%' LIMIT 1" );
1217
+ $the_new_link = get_permalink( $post_id );
1218
+ if ( stristr( get_option( $option_key ), "https://" ) ) {
1219
+ $the_new_link = str_replace( 'http://', "https://", $the_new_link );
1220
+ }
1221
+
1222
+ update_option( $option_key, $the_new_link );
1223
+ $updated;
1224
+ }
1225
+
1226
+ if(!$auto){
1227
+ $sendback = wp_get_referer();
1228
+ if ( isset( $updated ) )
1229
+ $sendback = add_query_arg( 'updated', $updated, $sendback );
1230
+
1231
+ if ( isset( $_SESSION['wpsc_settings_curr_page'] ) )
1232
+ $sendback = add_query_arg( 'tab', $_SESSION['wpsc_settings_curr_page'], $sendback );
1233
+
1234
+ wp_redirect( $sendback );
1235
+ exit();
1236
+ }
1237
+ }
1238
+ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'update_page_urls') )
1239
+ add_action( 'admin_init', 'wpsc_update_page_urls' );
1240
+
1241
+ function wpsc_clean_categories() {
1242
+ global $wpdb, $wp_rewrite;
1243
+ $sql_query = "SELECT `id`, `name`, `active` FROM `" . WPSC_TABLE_PRODUCT_CATEGORIES . "`";
1244
+ $sql_data = $wpdb->get_results( $sql_query, ARRAY_A );
1245
+ foreach ( (array)$sql_data as $datarow ) {
1246
+ if ( $datarow['active'] == 1 ) {
1247
+ $tidied_name = trim( $datarow['name'] );
1248
+ $tidied_name = strtolower( $tidied_name );
1249
+ $url_name = sanitize_title( $tidied_name );
1250
+ $similar_names = $wpdb->get_row( "SELECT COUNT(*) AS `count`, MAX(REPLACE(`nice-name`, '$url_name', '')) AS `max_number` FROM `" . WPSC_TABLE_PRODUCT_CATEGORIES . "` WHERE `nice-name` REGEXP '^($url_name){1}(\d)*$' AND `id` NOT IN ('{$datarow['id']}') ", ARRAY_A );
1251
+ $extension_number = '';
1252
+ if ( $similar_names['count'] > 0 ) {
1253
+ $extension_number = (int)$similar_names['max_number'] + 2;
1254
+ }
1255
+ $url_name .= $extension_number;
1256
+ $wpdb->query( "UPDATE `" . WPSC_TABLE_PRODUCT_CATEGORIES . "` SET `nice-name` = '$url_name' WHERE `id` = '{$datarow['id']}' LIMIT 1 ;" );
1257
+ $updated;
1258
+ } else if ( $datarow['active'] == 0 ) {
1259
+ $wpdb->query( "UPDATE `" . WPSC_TABLE_PRODUCT_CATEGORIES . "` SET `nice-name` = '' WHERE `id` = '{$datarow['id']}' LIMIT 1 ;" );
1260
+ $updated;
1261
+ }
1262
+ }
1263
+ $wp_rewrite->flush_rules();
1264
+ $sendback = wp_get_referer();
1265
+
1266
+ if ( isset( $updated ) ) {
1267
+ $sendback = add_query_arg( 'updated', $updated, $sendback );
1268
+ }
1269
+ if ( isset( $_SESSION['wpsc_settings_curr_page'] ) ) {
1270
+ $sendback = add_query_arg( 'tab', $_SESSION['wpsc_settings_curr_page'], $sendback );
1271
+ }
1272
+ wp_redirect( $sendback );
1273
+
1274
+ exit();
1275
+ }
1276
+ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'clean_categories') )
1277
+ add_action( 'admin_init', 'wpsc_clean_categories' );
1278
+
1279
+ //change the regions tax settings
1280
+ function wpsc_change_region_tax() {
1281
+ global $wpdb;
1282
+ if ( is_array( $_POST['region_tax'] ) ) {
1283
+ foreach ( $_POST['region_tax'] as $region_id => $tax ) {
1284
+ if ( is_numeric( $region_id ) && is_numeric( $tax ) ) {
1285
+ $previous_tax = $wpdb->get_var( "SELECT `tax` FROM `" . WPSC_TABLE_REGION_TAX . "` WHERE `id` = '$region_id' LIMIT 1" );
1286
+ if ( $tax != $previous_tax ) {
1287
+ $wpdb->query( "UPDATE `" . WPSC_TABLE_REGION_TAX . "` SET `tax` = '$tax' WHERE `id` = '$region_id' LIMIT 1" );
1288
+ $changes_made = true;
1289
+ }
1290
+ }
1291
+ }
1292
+ $sendback = wp_get_referer();
1293
+ wp_redirect( $sendback );
1294
+ }
1295
+ }
1296
+ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'change_region_tax') )
1297
+ add_action( 'admin_init', 'wpsc_change_region_tax' );
1298
+
1299
+ function wpsc_product_files_existing() {
1300
+ global $wpdb;
1301
+
1302
+ //List all product_files, with checkboxes
1303
+
1304
+ $product_id = absint( $_GET["product_id"] );
1305
+ $file_list = wpsc_uploaded_files();
1306
+
1307
+ $args = array(
1308
+ 'post_type' => 'wpsc-product-file',
1309
+ 'post_parent' => $product_id,
1310
+ 'numberposts' => -1,
1311
+ 'post_status' => 'all'
1312
+ );
1313
+ $attached_files = (array)get_posts( $args );
1314
+
1315
+ foreach ( $attached_files as $key => $attached_file ) {
1316
+ $attached_files_by_file[$attached_file->post_title] = & $attached_files[$key];
1317
+ }
1318
+
1319
+ $output = "<span class='admin_product_notes select_product_note '>" . __( 'Choose a downloadable file for this product:', 'wpsc' ) . "</span><br>";
1320
+ $output .= "<form method='post' class='product_upload'>";
1321
+ $output .= "<div class='ui-widget-content multiple-select select_product_file'>";
1322
+ $num = 0;
1323
+ foreach ( (array)$file_list as $file ) {
1324
+ $num++;
1325
+ $checked_curr_file = "";
1326
+ if ( isset( $attached_files_by_file[$file['display_filename']] ) ) {
1327
+ $checked_curr_file = "checked='checked'";
1328
+ }
1329
+
1330
+ $output .= "<p " . ((($num % 2) > 0) ? '' : "class='alt'") . " id='select_product_file_row_$num'>\n";
1331
+ $output .= " <input type='checkbox' name='select_product_file[]' value='" . $file['real_filename'] . "' id='select_product_file_$num' " . $checked_curr_file . " />\n";
1332
+ $output .= " <label for='select_product_file_$num'>" . $file['display_filename'] . "</label>\n";
1333
+ $output .= "</p>\n";
1334
+ }
1335
+
1336
+ $output .= "</div>";
1337
+ $output .= "<input type='hidden' id='hidden_id' value='$product_id' />";
1338
+ $output .= "<input type='submit' name='save' name='product_files_submit' class='button-primary prdfil' value='Save Product Files' />";
1339
+ $output .= "</form>";
1340
+ $output .= "<div class='" . ((is_numeric( $product_id )) ? "edit_" : "") . "select_product_handle'><div></div></div>";
1341
+ $output .= "<script type='text/javascript'>\n\r";
1342
+ $output .= "var select_min_height = " . (25 * 3) . ";\n\r";
1343
+ $output .= "var select_max_height = " . (25 * ($num + 1)) . ";\n\r";
1344
+ $output .= "</script>";
1345
+
1346
+
1347
+ echo $output;
1348
+ }
1349
+ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'product_files_existing') )
1350
+ add_action( 'admin_init', 'wpsc_product_files_existing' );
1351
+
1352
+ function prod_upload() {
1353
+ global $wpdb, $product_id;
1354
+ $product_id = absint( $_POST["product_id"] );
1355
+
1356
+ foreach ( $_POST["select_product_file"] as $selected_file ) {
1357
+ // if we already use this file, there is no point doing anything more.
1358
+
1359
+
1360
+ $file_post_data = $wpdb->get_row( "SELECT * FROM $wpdb->posts WHERE post_type = 'wpsc-product-file' AND post_title = '$selected_file'", ARRAY_A );
1361
+ $selected_file_path = WPSC_FILE_DIR . basename( $selected_file );
1362
+
1363
+ if ( isset( $attached_files_by_file[$selected_file] ) ) {
1364
+ $file_is_attached = true;
1365
+ }
1366
+
1367
+ //if(is_file($selected_file_path)) {
1368
+ if ( empty( $file_post_data ) ) {
1369
+ $type = wpsc_get_mimetype( $selected_file_path );
1370
+ $attachment = array(
1371
+ 'post_mime_type' => $type,
1372
+ 'post_parent' => $product_id,
1373
+ 'post_title' => $selected_file,
1374
+ 'post_content' => '',
1375
+ 'post_type' => "wpsc-product-file",
1376
+ 'post_status' => 'inherit'
1377
+ );
1378
+ $id = wp_insert_post( $attachment );
1379
+ } else {
1380
+ $type = $file_post_data["post_mime_type"];
1381
+ $url = $file_post_data["guid"];
1382
+ $title = $file_post_data["post_title"];
1383
+ $content = $file_post_data["post_content"];
1384
+ // Construct the attachment
1385
+ $attachment = array(
1386
+ 'post_mime_type' => $type,
1387
+ 'guid' => $url,
1388
+ 'post_parent' => absint( $product_id ),
1389
+ 'post_title' => $title,
1390
+ 'post_content' => $content,
1391
+ 'post_type' => "wpsc-product-file",
1392
+ 'post_status' => 'inherit'
1393
+ );
1394
+ // Save the data
1395
+ $id = wp_insert_post( $attachment );
1396
+ }
1397
+ //}
1398
+ echo "$id\n";
1399
+ }
1400
+ }
1401
+ if ( isset( $_GET['wpsc_admin_action'] ) && ($_GET['wpsc_admin_action'] == 'product_files_upload') )
1402
+ add_action( 'admin_init', 'prod_upload' );
1403
+
1404
+ //change the gateway settings
1405
+ function wpsc_gateway_settings() {
1406
+ global $wpdb;
1407
+ //To update options
1408
+ if ( isset( $_POST['wpsc_options'] ) ) {
1409
+ foreach ( $_POST['wpsc_options'] as $key => $value ) {
1410
+ if ( $value != get_option( $key ) ) {
1411
+ update_option( $key, $value );
1412
+ }
1413
+ }
1414
+ unset( $_POST['wpsc_options'] );
1415
+ }
1416
+
1417
+
1418
+
1419
+ if ( isset( $_POST['user_defined_name'] ) && is_array( $_POST['user_defined_name'] ) ) {
1420
+ $payment_gateway_names = get_option( 'payment_gateway_names' );
1421
+
1422
+ if ( !is_array( $payment_gateway_names ) ) {
1423
+ $payment_gateway_names = array( );
1424
+ }
1425
+ $payment_gateway_names = array_merge( $payment_gateway_names, (array)$_POST['user_defined_name'] );
1426
+ update_option( 'payment_gateway_names', $payment_gateway_names );
1427
+ }
1428
+ $custom_gateways = get_option( 'custom_gateway_options' );
1429
+
1430
+ $nzshpcrt_gateways = nzshpcrt_get_gateways();
1431
+ foreach ( $nzshpcrt_gateways as $gateway ) {
1432
+ if ( in_array( $gateway['internalname'], $custom_gateways ) ) {
1433
+ if ( isset( $gateway['submit_function'] ) ) {
1434
+ call_user_func_array( $gateway['submit_function'], array( ) );
1435
+ $changes_made = true;
1436
+ }
1437
+ }
1438
+ }
1439
+ if ( (isset( $_POST['payment_gw'] ) && $_POST['payment_gw'] != null ) ) {
1440
+ update_option( 'payment_gateway', $_POST['payment_gw'] );
1441
+ }
1442
+ $sendback = wp_get_referer();
1443
+
1444
+ if ( isset( $updated ) ) {
1445
+ $sendback = add_query_arg( 'updated', $updated, $sendback );
1446
+ }
1447
+ if ( isset( $_SESSION['wpsc_settings_curr_page'] ) ) {
1448
+ $sendback = add_query_arg( 'page', 'wpsc-settings', $sendback );
1449
+ $sendback = add_query_arg( 'tab', $_SESSION['wpsc_settings_curr_page'], $sendback );
1450
+ }
1451
+ wp_redirect( $sendback );
1452
+ exit();
1453
+ }
1454
+ if ( isset( $_REQUEST['wpsc_gateway_settings'] ) && ($_REQUEST['wpsc_gateway_settings'] == 'gateway_settings') )
1455
+ add_action( 'admin_init', 'wpsc_gateway_settings' );
1456
+
1457
+ function wpsc_check_form_options() {
1458
+ global $wpdb;
1459
+
1460
+ $id = $wpdb->escape( $_POST['form_id'] );
1461
+ $sql = 'SELECT `options` FROM `' . WPSC_TABLE_CHECKOUT_FORMS . '` WHERE `id`=' . $id;
1462
+ $options = $wpdb->get_var( $sql );
1463
+ if ( $options != '' ) {
1464
+ $options = maybe_unserialize( $options );
1465
+ if ( !is_array( $options ) ) {
1466
+ $options = unserialize( $options );
1467
+ }
1468
+ $output = "<tr class='wpsc_grey'><td></td><td colspan='5'>Please Save your changes before trying to Order your Checkout Forms again.</td></tr>\r\n<tr class='wpsc_grey'><td></td><th>Label</th><th >Value</th><td colspan='3'><a href='' class='wpsc_add_new_checkout_option' title='form_options[" . $id . "]'>+ New Layer</a></td></tr>";
1469
+
1470
+ foreach ( (array)$options as $key => $value ) {
1471
+ $output .="<tr class='wpsc_grey'><td></td><td><input type='text' value='" . $key . "' name='wpsc_checkout_option_label[" . $id . "][]' /></td><td colspan='4'><input type='text' value='" . $value . "' name='wpsc_checkout_option_value[" . $id . "][]' />&nbsp;<a class='wpsc_delete_option' href='' <img src='" . WPSC_CORE_IMAGES_URL . "/trash.gif' alt='" . __( 'Delete', 'wpsc' ) . "' title='" . __( 'Delete', 'wpsc' ) . "' /></a></td></tr>";
1472
+ }
1473
+ } else {
1474
+ $output = '';
1475
+ }
1476
+ exit( $output );
1477
+ }
1478
+ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'check_form_options') )
1479
+ add_action( 'admin_init', 'wpsc_check_form_options' );
1480
+
1481
+ //handles the editing and adding of new checkout fields
1482
+ function wpsc_checkout_settings() {
1483
+ global $wpdb;
1484
+ $wpdb->show_errors = true;
1485
+ if ( isset( $_POST['wpsc_form_set'] ) ) {
1486
+ $filter = $wpdb->escape( $_POST['wpsc_form_set'] );
1487
+ } else {
1488
+ $filter = 0;
1489
+ }
1490
+
1491
+ if ( $_POST['new_form_set'] != null ) {
1492
+ $new_form_set = $wpdb->escape( stripslashes( $_POST['new_form_set'] ) );
1493
+ $checkout_sets = get_option( 'wpsc_checkout_form_sets' );
1494
+ $checkout_sets[] = $new_form_set;
1495
+ update_option( 'wpsc_checkout_form_sets', $checkout_sets );
1496
+ }
1497
+
1498
+ /*
1499
+ // Save checkout options
1500
+ */
1501
+ $options = array( );
1502
+ if ( isset($_POST['wpsc_checkout_option_label']) && is_array( $_POST['wpsc_checkout_option_label'] ) ) {
1503
+ foreach ( $_POST['wpsc_checkout_option_label'] as $form_id => $values ) {
1504
+ $options = array( );
1505
+ foreach ( (array)$values as $key => $form_option ) {
1506
+ $form_option = str_ireplace( "'", "", $form_option );
1507
+ $form_val = str_ireplace( "'", "", sanitize_title( $_POST['wpsc_checkout_option_value'][$form_id][$key] ) );
1508
+ $options[$form_option] = $form_val;
1509
+ }
1510
+
1511
+ $options = serialize( $options );
1512
+ $sql = "UPDATE `" . WPSC_TABLE_CHECKOUT_FORMS . "` SET `options`='" . $options . "' WHERE id=" . $form_id;
1513
+ $wpdb->query( $sql );
1514
+ }
1515
+ }
1516
+
1517
+
1518
+ if ( $_POST['form_name'] != null ) {
1519
+ foreach ( $_POST['form_name'] as $form_id => $form_name ) {
1520
+ $form_name = $wpdb->escape( $form_name );
1521
+ $form_type = $wpdb->escape( $_POST['form_type'][$form_id] );
1522
+ $form_mandatory = 0;
1523
+ if ( isset( $_POST['form_mandatory'][$form_id] ) && ($_POST['form_mandatory'][$form_id] == 1) ) {
1524
+ $form_mandatory = 1;
1525
+ }
1526
+ $form_display_log = 0;
1527
+ if ( isset( $_POST['form_display_log'][$form_id] ) && ($_POST['form_display_log'][$form_id] == 1) ) {
1528
+ $form_display_log = 1;
1529
+ }
1530
+ $unique_name = '';
1531
+ if ( $_POST['unique_names'][$form_id] != '-1' ) {
1532
+ $unique_name = $_POST['unique_names'][$form_id];
1533
+ }
1534
+ $wpdb->query( "UPDATE `" . WPSC_TABLE_CHECKOUT_FORMS . "` SET `name` = '$form_name', `type` = '$form_type', `mandatory` = '$form_mandatory', `display_log` = '$form_display_log',`unique_name`='" . $unique_name . "' WHERE `id` ='" . $form_id . "' LIMIT 1 ;" );
1535
+ }
1536
+ }
1537
+
1538
+ if ( isset( $_POST['new_form_name'] ) ) {
1539
+ foreach ( $_POST['new_form_name'] as $form_id => $form_name ) {
1540
+ $form_type = $_POST['new_form_type'][$form_id];
1541
+ $form_mandatory = 0;
1542
+ if ( $_POST['new_form_mandatory'][$form_id] == 1 ) {
1543
+ $form_mandatory = 1;
1544
+ }
1545
+ $form_display_log = 0;
1546
+ if ( isset( $_POST['new_form_display_log'][$form_id] ) && $_POST['new_form_display_log'][$form_id] == 1 ) {
1547
+ $form_display_log = 1;
1548
+ }
1549
+ if ( $_POST['new_form_unique_name'][$form_id] != '-1' ) {
1550
+ $form_unique_name = $_POST['new_form_unique_name'][$form_id];
1551
+ }
1552
+
1553
+ $max_order_sql = "SELECT MAX(`checkout_order`) AS `checkout_order` FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `active` = '1';";
1554
+
1555
+ if ( isset( $_POST['new_form_order'][$form_id] ) && $_POST['new_form_order'][$form_id] != '' ) {
1556
+ $order_number = $_POST['new_form_order'][$form_id];
1557
+ } else {
1558
+ $max_order_sql = $wpdb->get_results( $max_order_sql, ARRAY_A );
1559
+ $order_number = $max_order_sql[0]['checkout_order'] + 1;
1560
+ }
1561
+ $wpdb->query( "INSERT INTO `" . WPSC_TABLE_CHECKOUT_FORMS . "` ( `name`, `type`, `mandatory`, `display_log`, `default`, `active`, `checkout_order` , `unique_name`, `checkout_set`) VALUES ( '$form_name', '$form_type', '$form_mandatory', '$form_display_log', '', '1','" . $order_number . "','" . $form_unique_name . "','" . $filter . "');" );
1562
+ $added++;
1563
+ }
1564
+ }
1565
+
1566
+ if ( isset( $_POST['wpsc_options'] ) ) {
1567
+ foreach ( $_POST['wpsc_options'] as $key => $value ) {
1568
+ if ( $value != get_option( $key ) ) {
1569
+ update_option( $key, $value );
1570
+ $updated++;
1571
+ }
1572
+ }
1573
+ }
1574
+
1575
+ $sendback = wp_get_referer();
1576
+ if ( isset( $form_set_key ) ) {
1577
+ $sendback = add_query_arg( 'checkout-set', $form_set_key, $sendback );
1578
+ } else if ( isset( $_POST['wpsc_form_set'] ) ) {
1579
+ $filter = $_POST['wpsc_form_set'];
1580
+ $sendback = add_query_arg( 'checkout-set', $filter, $sendback );
1581
+ }
1582
+
1583
+ if ( isset( $updated ) ) {
1584
+ $sendback = add_query_arg( 'updated', $updated, $sendback );
1585
+ }
1586
+ if ( isset( $added ) ) {
1587
+ $sendback = add_query_arg( 'added', $added, $sendback );
1588
+ }
1589
+ if ( isset( $_SESSION['wpsc_settings_curr_page'] ) ) {
1590
+ $sendback = add_query_arg( 'tab', $_SESSION['wpsc_settings_curr_page'], $sendback );
1591
+ }
1592
+ $sendback = add_query_arg( 'page', 'wpsc-settings', $sendback );
1593
+ wp_redirect( $sendback );
1594
+ exit();
1595
+ }
1596
+ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'checkout_settings') )
1597
+ add_action( 'admin_init', 'wpsc_checkout_settings' );
1598
+
1599
+ function wpsc_google_shipping_settings() {
1600
+ if ( isset( $_POST['submit'] ) ) {
1601
+ foreach ( (array)$_POST['google_shipping'] as $key => $country ) {
1602
+ if ( $country == 'on' ) {
1603
+ $google_shipping_country[] = $key;
1604
+ $updated++;
1605
+ }
1606
+ }
1607
+ update_option( 'google_shipping_country', $google_shipping_country );
1608
+ $sendback = wp_get_referer();
1609
+ $sendback = remove_query_arg( 'googlecheckoutshipping', $sendback );
1610
+
1611
+ if ( isset( $updated ) ) {
1612
+ $sendback = add_query_arg( 'updated', $updated, $sendback );
1613
+ }
1614
+
1615
+ wp_redirect( $sendback );
1616
+ exit();
1617
+ }
1618
+ }
1619
+
1620
+ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'google_shipping_settings') ) {
1621
+ add_action( 'admin_init', 'wpsc_google_shipping_settings' );
1622
+ }
1623
+
1624
+ //for ajax call of settings page tabs
1625
+ function wpsc_settings_page_ajax() {
1626
+ global $wpdb;
1627
+
1628
+ $html = '';
1629
+ $modified_page_title = $_POST['page_title'];
1630
+ $page_title = str_replace( "tab-", "", $modified_page_title );
1631
+
1632
+ check_admin_referer( $modified_page_title );
1633
+ switch ( $page_title ) {
1634
+ case 'checkout' :
1635
+ require_once( 'includes/settings-pages/checkout.php' );
1636
+ wpsc_options_checkout();
1637
+ break;
1638
+
1639
+ case 'gateway' :
1640
+ require_once( 'includes/settings-pages/gateway.php' );
1641
+ wpsc_options_gateway();
1642
+ break;
1643
+
1644
+ case 'shipping' :
1645
+ require_once( 'includes/settings-pages/shipping.php' );
1646
+ wpsc_options_shipping();
1647
+ break;
1648
+
1649
+ case 'admin' :
1650
+ require_once( 'includes/settings-pages/admin.php' );
1651
+ wpsc_options_admin();
1652
+ break;
1653
+
1654
+ case 'presentation' :
1655
+ require_once( 'includes/settings-pages/presentation.php' );
1656
+ wpsc_options_presentation();
1657
+ break;
1658
+
1659
+ case 'taxes' :
1660
+ wpec_taxes_settings_page(); //see wpec-taxes view
1661
+ break;
1662
+
1663
+ case 'marketing' :
1664
+ require_once( 'includes/settings-pages/marketing.php' );
1665
+ wpsc_options_marketing();
1666
+ break;
1667
+
1668
+ case 'import' :
1669
+ require_once( 'includes/settings-pages/import.php' );
1670
+ wpsc_options_import();
1671
+ break;
1672
+
1673
+ case 'general' :
1674
+ default;
1675
+ require_once( 'includes/settings-pages/general.php' );
1676
+ wpsc_options_general();
1677
+ break;
1678
+ }
1679
+
1680
+ $_SESSION['wpsc_settings_curr_page'] = $page_title;
1681
+
1682
+ exit( $html );
1683
+ }
1684
+ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'settings_page_ajax') )
1685
+ add_action( 'admin_init', 'wpsc_settings_page_ajax' );
1686
+
1687
+ function wpsc_update_variations() {
1688
+ //Setup postdata
1689
+ $post_data = array( );
1690
+ $post_data['edit_var_val'] = $_POST["edit_var_val"];
1691
+ $post_data['description'] = $_POST["description"];
1692
+ $post_data['additional_description'] = $_POST['additional_description'];
1693
+ $post_data['name'] = $_POST["name"];
1694
+ $product_id = absint( $_POST["product_id"] );
1695
+
1696
+ //Add or delete variations
1697
+ wpsc_edit_product_variations( $product_id, $post_data );
1698
+ wpsc_admin_product_listing( $product_id );
1699
+ die();
1700
+ }
1701
+ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'wpsc_update_variations') )
1702
+ add_action( 'admin_init', 'wpsc_update_variations', 50 );
1703
+
1704
+ function wpsc_delete_variation_set() {
1705
+ global $wpdb;
1706
+ check_admin_referer( 'delete-variation' );
1707
+
1708
+ if ( is_numeric( $_GET['deleteid'] ) ) {
1709
+ $variation_id = absint( $_GET['deleteid'] );
1710
+
1711
+ $variation_set = get_term( $variation_id, 'wpsc-variation', ARRAY_A );
1712
+
1713
+
1714
+ $variations = get_terms( 'wpsc-variation', array(
1715
+ 'hide_empty' => 0,
1716
+ 'parent' => $variation_id
1717
+ ) );
1718
+
1719
+ foreach ( (array)$variations as $variation ) {
1720
+ $return_value = wp_delete_term( $variation->term_id, 'wpsc-variation' );
1721
+ }
1722
+
1723
+ if ( !empty( $variation_set ) ) {
1724
+ $return_value = wp_delete_term( $variation_set['term_id'], 'wpsc-variation' );
1725
+ }
1726
+ $deleted = 1;
1727
+ }
1728
+
1729
+ $sendback = wp_get_referer();
1730
+ if ( isset( $deleted ) ) {
1731
+ $sendback = add_query_arg( 'deleted', $deleted, $sendback );
1732
+ }
1733
+ $sendback = remove_query_arg( array(
1734
+ 'deleteid',
1735
+ 'variation_id'
1736
+ ), $sendback );
1737
+
1738
+ wp_redirect( $sendback );
1739
+ exit();
1740
+ }
1741
+
1742
+ function wpsc_force_flush_theme_transients() {
1743
+ // Flush transients
1744
+ wpsc_flush_theme_transients( true );
1745
+
1746
+ // Bounce back
1747
+ $sendback = wp_get_referer();
1748
+ wp_redirect( $sendback );
1749
+
1750
+ exit();
1751
+ }
1752
+ if ( isset( $_REQUEST['wpsc_flush_theme_transients'] ) && ( $_REQUEST['wpsc_flush_theme_transients'] == 'true' ) )
1753
+ add_action( 'admin_init', 'wpsc_force_flush_theme_transients' );
1754
+
1755
+ function wpsc_backup_theme() {
1756
+ $wp_theme_path = get_stylesheet_directory();
1757
+ wpsc_recursive_copy( $wp_theme_path, WPSC_THEME_BACKUP_DIR );
1758
+ $_SESSION['wpsc_themes_backup'] = true;
1759
+ $sendback = wp_get_referer();
1760
+ wp_redirect( $sendback );
1761
+
1762
+ exit();
1763
+ }
1764
+ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ( $_REQUEST['wpsc_admin_action'] == 'backup_themes' ) )
1765
+ add_action( 'admin_init', 'wpsc_backup_theme' );
1766
+
1767
+
1768
+ function wpsc_delete_coupon(){
1769
+ global $wpdb;
1770
+
1771
+ check_admin_referer( 'delete-coupon' );
1772
+ $coupon_id = (int)$_GET['delete_id'];
1773
+
1774
+ if(isset($coupon_id)) {
1775
+ $wpdb->query("DELETE FROM `".WPSC_TABLE_COUPON_CODES."` WHERE `id` = '$coupon_id' LIMIT 1;");
1776
+
1777
+ $deleted = 1;
1778
+ }
1779
+ $sendback = wp_get_referer();
1780
+ if ( isset( $deleted ) )
1781
+ $sendback = add_query_arg( 'deleted', $deleted, $sendback );
1782
+
1783
+ $sendback = remove_query_arg( array('deleteid',), $sendback );
1784
+ wp_redirect( $sendback );
1785
+ exit();
1786
+ }
1787
+
1788
+
1789
+ function wpsc_delete_category() {
1790
+ global $wpdb, $wp_rewrite;
1791
+
1792
+ check_admin_referer( 'delete-category' );
1793
+
1794
+ if ( is_numeric( $_GET['deleteid'] ) ) {
1795
+ $category_id = absint( $_GET['deleteid'] );
1796
+ $taxonomy = 'wpsc_product_category';
1797
+ if ( $category_id > 0 ) {
1798
+ wp_delete_term( $category_id, $taxonomy );
1799
+ $wpdb->query( "DELETE FROM `" . WPSC_TABLE_META . "` WHERE object_id = '" . $category_id . "' AND object_type = 'wpsc_category'" );
1800
+ }
1801
+
1802
+ $wp_rewrite->flush_rules();
1803
+
1804
+ $deleted = 1;
1805
+ }
1806
+
1807
+ $sendback = wp_get_referer();
1808
+ if ( isset( $deleted ) ) {
1809
+ $sendback = add_query_arg( 'deleted', $deleted, $sendback );
1810
+ }
1811
+ $sendback = remove_query_arg( array(
1812
+ 'deleteid',
1813
+ 'category_id'
1814
+ ), $sendback );
1815
+
1816
+ wp_redirect( $sendback );
1817
+ exit();
1818
+ }
1819
+
1820
+ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ( 'wpsc_add_image' == $_REQUEST['wpsc_admin_action'] ) )
1821
+ add_action( 'admin_init', 'wpsc_swfupload_images' );
1822
+
1823
+ if ( isset( $_GET['action'] ) && ( 'purchase_log' == $_GET['action'] ) )
1824
+ add_action( 'admin_init', 'wpsc_admin_sale_rss' );
1825
+
1826
+ if ( isset( $_GET['purchase_log_csv'] ) && ( 'true' == $_GET['purchase_log_csv'] ) )
1827
+ add_action( 'admin_init', 'wpsc_purchase_log_csv' );
1828
+
1829
+ if ( isset( $_REQUEST['ajax'] ) && isset( $_REQUEST['admin'] ) && ($_REQUEST['ajax'] == "true") && ($_REQUEST['admin'] == "true") )
1830
+ add_action( 'admin_init', 'wpsc_admin_ajax' );
1831
+
1832
+ // Variation set deleting init code starts here
1833
+ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ( 'wpsc-delete-variation-set' == $_REQUEST['wpsc_admin_action'] ) )
1834
+ add_action( 'admin_init', 'wpsc_delete_variation_set' );
1835
+
1836
+ // Variation set deleting init code starts here
1837
+ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ( 'wpsc-delete-category' == $_REQUEST['wpsc_admin_action'] ) )
1838
+ add_action( 'admin_init', 'wpsc_delete_category' );
1839
+
1840
+ //Delete Coupon
1841
+ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ( 'wpsc-delete-coupon' == $_REQUEST['wpsc_admin_action'] ) )
1842
+ add_action( 'admin_init', 'wpsc_delete_coupon' );
1843
+
1844
+
1845
+ function flat_price( $price ) {
1846
+ if ( isset( $price ) && !empty( $price ) && strchr( $price, '-' ) === false && strchr( $price, '+' ) === false && strchr( $price, '%' ) === false )
1847
+ return true;
1848
+ }
1849
+
1850
+ function percentile_price( $price ) {
1851
+ if ( isset( $price ) && !empty( $price ) && ( strchr( $price, '-' ) || strchr( $price, '+' ) ) && strchr( $price, '%' ) )
1852
+ return true;
1853
+ }
1854
+
1855
+ function differential_price( $price ) {
1856
+ if ( isset( $price ) && !empty( $price ) && ( strchr( $price, '-' ) || strchr( $price, '+' ) ) && strchr( $price, '%' ) === false )
1857
+ return true;
1858
+ }
1859
+
1860
+ /**
1861
+ * If it doesn't exist, let's create a multi-dimensional associative array
1862
+ * that will contain all of the term/price associations
1863
+ *
1864
+ * @param <type> $variation
1865
+ */
1866
+ function variation_price_field( $variation ) {
1867
+ $term_prices = get_option( 'term_prices' );
1868
+
1869
+ if ( is_object( $variation ) )
1870
+ $term_id = $variation->term_id;
1871
+
1872
+ if ( empty( $term_prices ) || !is_array( $term_prices ) ) {
1873
+
1874
+ $term_prices = array( );
1875
+ if ( isset( $term_id ) ) {
1876
+ $term_prices[$term_id] = array( );
1877
+ $term_prices[$term_id]["price"] = '';
1878
+ $term_prices[$term_id]["checked"] = '';
1879
+ }
1880
+ add_option( 'term_prices', $term_prices );
1881
+ }
1882
+
1883
+ if ( isset( $term_id ) && is_array( $term_prices ) && array_key_exists( $term_id, $term_prices ) )
1884
+ $price = $term_prices[$term_id]["price"];
1885
+ else
1886
+ $price = '';
1887
+
1888
+ if( !isset( $_GET['action'] ) ) {
1889
+ ?>
1890
+ <div class="form-field">
1891
+ <label for="variation_price"><?php _e( 'Variation Price', 'wpsc' ); ?></label>
1892
+ <input type="text" name="variation_price" id="variation_price" style="width:50px;" value="<?php echo $price; ?>"><br />
1893
+ <span class="description"><?php _e( 'You can list a default price here for this variation. You can list a regular price (18.99), differential price (+1.99 / -2) or even a percentage-based price (+50% / -25%).', 'wpsc' ); ?></span>
1894
+ </div>
1895
+ <?php
1896
+ } else{
1897
+ ?>
1898
+ <tr class="form-field">
1899
+ <th scope="row" valign="top">
1900
+ <label for="variation_price"><?php _e( 'Variation Price', 'wpsc' ); ?></label>
1901
+ </th>
1902
+ <td>
1903
+ <input type="text" name="variation_price" id="variation_price" style="width:50px;" value="<?php echo $price; ?>"><br />
1904
+ <span class="description"><?php _e( 'You can list a default price here for this variation. You can list a regular price (18.99), differential price (+1.99 / -2) or even a percentage-based price (+50% / -25%).', 'wpsc' ); ?></span>
1905
+ </td>
1906
+ </tr>
1907
+ <?php
1908
+ }
1909
+
1910
+ }
1911
+ add_action( 'wpsc-variation_edit_form_fields', 'variation_price_field' );
1912
+ add_action( 'wpsc-variation_add_form_fields', 'variation_price_field' );
1913
+
1914
+ function variation_price_field_check( $variation ) {
1915
+
1916
+ $term_prices = get_option( 'term_prices' );
1917
+
1918
+ if ( is_array( $term_prices ) && array_key_exists( $variation->term_id, $term_prices ) )
1919
+ $checked = ($term_prices[$variation->term_id]["checked"] == 'checked') ? 'checked' : '';
1920
+ else
1921
+ $checked = ''; ?>
1922
+
1923
+ <tr class="form-field">
1924
+ <th scope="row" valign="top"><label for="apply_to_current"><?php _e( 'Apply to current variations?' ) ?></label></th>
1925
+ <td>
1926
+ <span class="description"><input type="checkbox" name="apply_to_current" id="apply_to_current" style="width:2%;" <?php echo $checked; ?> /><?php _e( 'By checking this box, the price rule you implement above will be applied to all variations that currently exist. If you leave it unchecked, it will only apply to products that use this variation created or edited from now on. Take note, this will apply this rule to <strong>every</strong> product using this variation. If you need to override it for any reason on a specific product, simply go to that product and change the price.', 'wpsc' ); ?></span>
1927
+ </td>
1928
+ </tr>
1929
+ <?php
1930
+ }
1931
+ add_action( 'wpsc-variation_edit_form_fields', 'variation_price_field_check' );
1932
+
1933
+ /**
1934
+ * @todo - Should probably refactor this at some point - very procedural,
1935
+ * WAY too many foreach loops for my liking :) But it does the trick
1936
+ *
1937
+ * @param <type> $term_id
1938
+ */
1939
+ function save_term_prices( $term_id ) {
1940
+
1941
+ // First - Saves options from input
1942
+ if ( isset( $_POST['variation_price'] ) || isset( $_POST["apply_to_current"] ) ) {
1943
+
1944
+ $term_prices = get_option( 'term_prices' );
1945
+
1946
+ $term_prices[$term_id]["price"] = $_POST["variation_price"];
1947
+ $term_prices[$term_id]["checked"] = (isset( $_POST["apply_to_current"] )) ? "checked" : "unchecked";
1948
+
1949
+ update_option( 'term_prices', $term_prices );
1950
+ }
1951
+
1952
+ // Second - If box was checked, let's then check whether or not it was flat, differential, or percentile, then let's apply the pricing to every product appropriately
1953
+ if ( isset( $_POST["apply_to_current"] ) ) {
1954
+
1955
+ //Check for flat, percentile or differential
1956
+ $var_price_type = '';
1957
+
1958
+ if ( flat_price( $_POST["variation_price"] ) )
1959
+ $var_price_type = 'flat';
1960
+ elseif ( differential_price( $_POST["variation_price"] ) )
1961
+ $var_price_type = 'differential';
1962
+ elseif ( percentile_price( $_POST["variation_price"] ) )
1963
+ $var_price_type = 'percentile';
1964
+
1965
+ //Now, find all products with this term_id, update their pricing structure (terms returned include only parents at this point, we'll grab relevent children soon)
1966
+ $products_to_mod = get_objects_in_term( $term_id, "wpsc-variation" );
1967
+ $product_parents = array( );
1968
+
1969
+ foreach ( (array)$products_to_mod as $get_parent ) {
1970
+
1971
+ $post = get_post( $get_parent );
1972
+
1973
+ if ( !$post->post_parent )
1974
+ $product_parents[] = $post->ID;
1975
+ }
1976
+
1977
+ //Now that we have all parent IDs with this term, we can get the children (only the ones that are also in $products_to_mod, we don't want to apply pricing to ALL kids)
1978
+
1979
+ foreach ( $product_parents as $parent ) {
1980
+ $args = array(
1981
+ 'post_parent' => $parent,
1982
+ 'post_type' => 'wpsc-product'
1983
+ );
1984
+ $children = get_children( $args, ARRAY_A );
1985
+
1986
+ foreach ( $children as $childrens ) {
1987
+ $parent = $childrens["post_parent"];
1988
+ $children_ids[$parent][] = $childrens["ID"];
1989
+ $children_ids[$parent] = array_intersect( $children_ids[$parent], $products_to_mod );
1990
+ }
1991
+ }
1992
+
1993
+ //Got the right kids, let's grab their parent pricing and modify their pricing based on var_price_type
1994
+
1995
+ foreach ( (array)$children_ids as $parents => $kids ) {
1996
+
1997
+ $kids = array_values( $kids );
1998
+ $parent_pricing = get_product_meta( $parents, "price", true );
1999
+
2000
+ foreach ( $kids as $kiddos ) {
2001
+
2002
+ $child_pricing = get_product_meta( $kiddos, "price", true );
2003
+
2004
+ if ( $var_price_type == 'flat' ) {
2005
+
2006
+ update_product_meta( $kiddos, "price", floatval( $_POST["variation_price"] ) );
2007
+ } elseif ( $var_price_type == 'percentile' ) {
2008
+
2009
+ //Are we decreasing or increasing the price?
2010
+
2011
+ if ( strchr( $_POST["variation_price"], '-' ) )
2012
+ $positive = false;
2013
+ else
2014
+ $positive = true;
2015
+
2016
+ //Now, let's get the parent product price, +/- by the percentage given
2017
+ $percentage = (absint( $_POST["variation_price"] ) / 100);
2018
+
2019
+ if ( $positive )
2020
+ $price = $parent_pricing + ($parent_pricing * $percentage);
2021
+ else
2022
+ $price = $parent_pricing - ($parent_pricing * $percentage);
2023
+
2024
+ update_product_meta( $kiddos, "price", $price );
2025
+ } elseif ( $var_price_type == 'differential' ) {
2026
+
2027
+ //Are we decreasing or increasing the price?
2028
+ if ( strchr( $_POST["variation_price"], '-' ) )
2029
+ $positive = false;
2030
+ else
2031
+ $positive = true;
2032
+
2033
+ //Now, let's get the parent product price, +/- by the differential given
2034
+ $differential = (absint( $_POST["variation_price"] ));
2035
+
2036
+ if ( $positive )
2037
+ $price = $parent_pricing + $differential;
2038
+ else
2039
+ $price = $parent_pricing - $differential;
2040
+ update_product_meta( $kiddos, "price", $price );
2041
+ }
2042
+ }
2043
+ }
2044
+ }
2045
+ }
2046
+ add_action( 'edited_wpsc-variation', 'save_term_prices' );
2047
+ add_action( 'created_wpsc-variation', 'save_term_prices' );
2048
+
2049
+ ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-admin/css/admin.css CHANGED
@@ -1,1803 +1,1750 @@
1
- /*
2
- * This is the new WPSC Admin CSS file
3
-
4
- */
5
- .wpsc_trackingid_row{
6
- margin-left:20px;
7
- }
8
-
9
- ul.children{
10
- padding-left:5px;
11
- }
12
- .category_indenter{
13
-
14
- float:left;
15
- width:auto;
16
-
17
- }
18
- /**
19
- *Dashboard Widget CSS
20
- *
21
- */
22
- #leftDashboard{
23
- width:45%;
24
- float:left;
25
- text-align:right;
26
- border-right:1px #999999 solid;
27
-
28
- }
29
- #leftDashboard strong{
30
- float:left;
31
- padding-left: 40px;
32
- }
33
- #rightDashboard strong{
34
- float:left;
35
- padding-left: 40px;
36
- }
37
- #rightDashboard{
38
- width:45%;
39
- float:right;
40
- text-align:right;
41
-
42
- }
43
- .pricedisplay, .salespricedisplay{
44
- /* width:40%; */
45
- float:left;
46
- }
47
- .dashboardWidgetSpecial{
48
- font-family:Georgia,"Times New Roman","Bitstream Charter",Times,serif;
49
- color:#21759B;
50
- font-size:15px!important;
51
- margin: 5px 0 5px 0;
52
- }
53
- .dashboardWidget{
54
- color:#777777;
55
- padding-left:10px;
56
- padding-right: 30px;
57
-
58
- }
59
- span.wpsc_quart_left{
60
- width:40%;
61
- float:left;
62
- }
63
- p.atglance{
64
- color:#777777;
65
- font-family:Georgia,"Times New Roman","Bitstream Charter",Times,serif;
66
- font-size:13px;
67
- font-style:italic;
68
- }
69
- span.wpsc_quart_right{
70
- width:60%;
71
- float:right;
72
- text-align: right;
73
- }
74
- #box span{
75
- border-bottom: 1px solid #999999;
76
- }
77
- p.quarterly{
78
- color:#21759B;
79
- font-family:Georgia,"Times New Roman","Bitstream Charter",Times,serif;
80
- font-size:12px;
81
- line-height: 140%;
82
- margin:5px 0;
83
- }
84
- /* end of dashboard widget css */
85
- /*
86
- *Display Purchase log Details CSS is HERE
87
- */
88
- #purchlogs_customfields{
89
- clear:both;
90
- }
91
- th#date{
92
- width:120px;
93
- }
94
- th#purchid{
95
- width:60px;
96
- }
97
- th#details{
98
- width:55px;
99
- }
100
- th#amount{
101
- width:75px;
102
- }
103
- th#name{
104
- width:220px;
105
- }
106
- th#track{
107
- width:75px;
108
- }
109
- th#delete{
110
- width:55px;
111
- }
112
- th#status{
113
- width:120px;
114
- }
115
- .google_checkout_logo{
116
- padding-right:10px;
117
- }
118
- #wpsc_items_ordered{
119
- clear:both;
120
- }
121
- #wpsc_items_ordered h3{
122
- margin-bottom:0em;
123
- }
124
- .wpsc_pushdown_img {
125
- float:left;
126
- }
127
- #wpsc_purchlogitems_links{
128
- clear:both;
129
-
130
- }
131
- #wpsc_purchlog_order_status{
132
- float:right;
133
- width:250px;
134
- }
135
- #wpsc_purchlog_order_status .selector{
136
- margin-top:-.2em;
137
- }
138
-
139
- #wpsc_purchlogitems_links a{
140
- text-decoration:none;
141
- line-height:14pt;
142
- }
143
- #wpsc_purchlogitems_links img{
144
- padding-top:2px;
145
- float:left;
146
- }
147
- #wpsc_shipping_details_box{
148
- width:45%;
149
- float:left;
150
- border:1px #d3d3d3 solid;
151
- margin:.4em;
152
- padding:.6em;
153
- margin-right:5em;
154
- }
155
- #wpsc_billing_details_box{
156
- width:35%;
157
- float:left;
158
- margin:.4em;
159
- padding:.6em;
160
- }
161
- #wpsc_purchlog_searchbox{
162
- width:100%;
163
- text-align:right;
164
-
165
-
166
- }
167
- /*
168
- * Display Purchase log Details CSS ends HERE
169
- * Display Products CSS starts here
170
- */
171
- .tablenav select[name="bulkAction"] {
172
- width:100px;
173
- }
174
- textarea#additional_description{
175
- border: 1px solid #dfdfdf;
176
- /* width:465px !important; */
177
- }
178
- .wpsc-separator {
179
- background:transparent url(../../images/menu-arrows.gif) no-repeat scroll left 5px;
180
- cursor:w-resize;
181
- height:21px;
182
- margin:0;
183
- padding:0;
184
- }
185
-
186
- #poststuff h3.form_heading {
187
- font-size:1.1em;
188
- margin: 40px 0px 10px 0px;
189
- padding-left: 0px;
190
- }
191
-
192
- #poststuff h3.form_heading span {
193
- font-size:0.8em;
194
- }
195
-
196
- div.search-box input#page-search-input {
197
- width: 129px;
198
-
199
- }
200
-
201
-
202
- #wpsc_product_list {
203
- width:100%;
204
- }
205
-
206
- #wpsc_product_list tbody {
207
- width: 400px;
208
- border-collapse:collapse;
209
- }
210
-
211
-
212
- #wpsc_product_list .column-title{
213
- /* width:100%; */
214
- }
215
- #wpsc_product_list .column-cb{
216
- /* width:24px; */
217
- vertical-align: middle;
218
- }
219
- #wpsc_product_list .column-cb input{
220
- /* width:20px; */
221
- /* float:right; */
222
-
223
- }
224
- #wpsc_product_list .column-image, #wpsc_product_list .product-image{
225
- padding-right: 0px;
226
- /* width: 42px; */
227
- }
228
-
229
- #wpsc_product_list .column-price{
230
- width:65px;
231
- }
232
-
233
- #wpsc_product_list .column-sale_price{
234
- width:65px;
235
- }
236
-
237
- #wpsc_product_list .column-categories{
238
- /* width: 70px; */
239
- padding-right:18px;
240
- }
241
-
242
- #wpsc_product_list tbody tr td.column-title {
243
- border-right:none;
244
- }
245
-
246
- #wpsc_product_list tbody tr td.product-image img {
247
- margin-top: 4px;
248
- cursor:move;
249
- }
250
-
251
-
252
- #wpsc_product_list tbody tr td .wpsc-row-actions {
253
- font-size: 10px;
254
- visibility: hidden;
255
- }
256
-
257
-
258
- #wpsc_product_list tbody tr:hover td .wpsc-row-actions {
259
- font-size: 10px;
260
- visibility: visible;
261
- }
262
- .newCurrency{
263
- width:150px;
264
- }
265
- div.wpsc_floatleft{
266
- width:161px;
267
- float:left;
268
- }
269
- div.wpsc_floatleft label {
270
- line-height: 18px;
271
- white-space: nowrap;
272
- }
273
-
274
- /* Sortable product styling*/
275
-
276
- table.product_editform {
277
- width:100%;
278
- }
279
-
280
-
281
- #wpsc_product_list .ui-sortable-helper{
282
- width: 410px;
283
- margin-left: -1px;
284
- background-color: #FEFEFE;
285
- }
286
-
287
- #wpsc_product_list .ui-sortable-helper td, #wpsc_product_list .ui-sortable-helper th{
288
- border-top: 1px solid #DFDFDF;
289
- opacity: .4;
290
- }
291
- #wpsc_product_list tbody tr.ui-sortable-helper td.product-title {
292
- width: 169px;
293
- }
294
- #wpsc_product_list tbody tr.ui-sortable-helper td.product-price {
295
- width: 40px;
296
- }
297
-
298
-
299
- div.price-editing-fields input.the-product-price,
300
- div.sales-price-fields input.the-sale-price,
301
- div.sku-editing-fields input.the-sku-fields {
302
- width: 51px;
303
- }
304
-
305
- div.price-editing-fields,div.sales-price-fields,div.sku-editing-fields, div.weight-editing-fields, div.stock-editing-fields {
306
- display: none;
307
- }
308
-
309
- div.product-placeholder {
310
- border-width: 1px;
311
- border-style: dashed;
312
- z-index: 900;
313
- border-color: #bbb;
314
- background-color: #f5f5f5;
315
- margin: -2px 0 0 -2px;
316
- height: 50px;
317
- }
318
-
319
- tr.product-placeholder {
320
- border-width: 1px;
321
- border-style: dashed;
322
- z-index: 900;
323
- border-color: #bbb;
324
- background-color: #eaeaea !important;
325
- margin: -2px 0 0 -2px;
326
- height: 50px;
327
- }
328
-
329
- /* Product details form styling */
330
-
331
- #wpsc-col-right {
332
- clear: left;
333
- float: left;
334
- margin-right: -340px;
335
- width: 100%;
336
- }
337
- th#image,th#SKU{
338
- width:50px;
339
- }
340
- th#sale_price
341
- {
342
- width:100px
343
- }
344
- th#title{
345
- width:450px;
346
- }
347
- #wpsc-col-right .postbox .inside {
348
- padding-left: 10px;
349
- }
350
- #wpsc-col-right .postbox .publish {
351
- padding-left: 0px;
352
- }
353
-
354
- #wpsc-col-left {
355
- margin:0;
356
- overflow:hidden;
357
- padding:0;
358
- width:100%;
359
-
360
- }
361
- td.product_tags{
362
- padding-left:3.5em;
363
- }
364
-
365
- div#poststuff h4 {
366
- font-size:11px;
367
- margin:0.3em 0;
368
- }
369
-
370
-
371
- div#poststuff table tr td {
372
- vertical-align:top;
373
- }
374
-
375
- div#poststuff textarea {
376
- width: 100%;
377
- }
378
-
379
- div.admin_product_name label {
380
- display: block;
381
- float: left;
382
- }
383
-
384
-
385
- div.admin_product_name {
386
- position: relative;
387
-
388
- height: 30px;
389
- background: #ffffff;
390
-
391
- border: 1px solid #dfdfdf;
392
- -moz-border-radius: 6px;
393
- -khtml-border-radius: 6px;
394
- -webkit-border-radius: 6px;
395
- border-radius: 6px;
396
- }
397
- input.the-weight-fields,
398
- input.the-stock-fields
399
- {
400
- width:35px;
401
- }
402
- input.wpsc_product_name {
403
- float:left;
404
- width:100%;
405
-
406
- background: transparent;
407
- height: 30px;
408
- margin:0px;
409
- padding: 3px 26px 3px 3px;
410
- font-size: 1.7em;
411
- }
412
-
413
- div.admin_product_name input.wpsc_product_name {
414
- border: none;
415
- }
416
-
417
- div.admin_product_name a.shorttag_toggle {
418
- position: absolute;
419
- top: 0px;
420
- right: 0px;
421
- background:url(../../wpsc-core/images/info_icon.jpg) no-repeat scroll 5px 8px;
422
- border-left:1px solid #DFDFDF;
423
- display:block;
424
- height:100%;
425
- padding:0px 3px 0px 3px;
426
- width:18px;
427
- }
428
-
429
- div#icon_card
430
- {
431
- float: left;
432
- height: 36px;
433
- margin: 20px 6px 0px 0px;
434
- width: 36px;
435
- background: url(../../wpsc-core/images/icon32.png) no-repeat center center;
436
- }
437
-
438
- div.admin_product_shorttags {
439
- width:93%;
440
- min-width:396px;
441
- max-width:558px;
442
-
443
- clear: both;
444
- padding: 6px;
445
- font-size: 8pt;
446
- margin:0 0 0 6px !important;
447
- border-left:1px solid #DFDFDF;
448
- border-right:1px solid #DFDFDF;
449
- border-bottom:1px solid #DFDFDF;
450
- /* height: 28px; */
451
- display: none;
452
- _width:396px;
453
- background-color: #ffffff;
454
- }
455
-
456
- #description {
457
- margin:0;
458
- width:100%;
459
- }
460
-
461
-
462
-
463
- h4.product_action_link {
464
- margin:4px 0px 0px 0px;
465
- display:block;
466
- font-weight:bold;
467
- }
468
-
469
-
470
-
471
- /* custom meta styling */
472
- div.product_custom_meta {
473
- display: block;
474
- width: 100%;
475
- vertical-align: top;
476
- }
477
- div#poststuff div.product_custom_meta input, div#poststuff div.product_custom_meta textarea {
478
- width: 100%;
479
- }
480
-
481
-
482
- div.product_custom_meta a.add_more_meta {
483
- display: block;
484
- float: left;
485
- margin-top: 18px;
486
- margin-left: 4px;
487
- }
488
-
489
- div.product_custom_meta a.remove_meta {
490
- display: block;
491
- margin-left: 4px;
492
- }
493
-
494
-
495
- div.product_custom_meta label {
496
- display: block;
497
- width: 170px;
498
- float: left;
499
- }
500
-
501
- div.product_custom_meta label input {
502
- font-size:13px;
503
- width: 160px !important;
504
- margin:1px !important;
505
- padding:3px !important;
506
- display: block;
507
- }
508
-
509
- div.product_custom_meta br {
510
- clear: both;
511
- }
512
-
513
- /* image form styling */
514
- div.flash-image-uploader {
515
- display: none;
516
- }
517
-
518
- #wpbody-content div.flash-image-uploader #media-items {
519
- position: relative;
520
- border: none;
521
- }
522
- #wpbody-content div.flash-image-uploader #media-items .progress{
523
- position: static;
524
- margin:0 0 6px;
525
- height: 16px;
526
- }
527
-
528
-
529
- button#add-product-image {
530
- float: left;
531
- }
532
-
533
- div#swfupload_img_indicator {
534
- float: left;
535
- height: 20px;
536
- width: 20px;
537
- display: none;
538
- }
539
-
540
- div#swfupload_img_indicator img{
541
- margin: 4px 2px 2px 4px;
542
- }
543
-
544
- ul#gallery_list{
545
- clear:both;
546
- list-style-type:none;
547
- list-style-position: inside;
548
- cursor: pointer;
549
- min-height:70px;
550
- _height:70px;
551
- padding-left:0px;
552
- margin: 6px 0px 0px 6px;
553
- }
554
-
555
- ul#gallery_list li{
556
- float:left;
557
- }
558
-
559
- ul#gallery_list li *{
560
- z-index:79;
561
- }
562
- ul#gallery_list li.first *{
563
- z-index:80;
564
- }
565
- .ui-selected {
566
- border:2px dashed #969696;
567
- }
568
-
569
- img.deleteButton {
570
- display:none;
571
- position:absolute;
572
- top:-5px;
573
- right: -1px;
574
- width:16px;
575
- height:16px;
576
- cursor:pointer;
577
- }
578
- a.editButton {
579
- background:#FFFFFF none repeat scroll 0%;
580
- height:20px;
581
- display:none;
582
- position:absolute;
583
- right:0px;
584
- top:0px;
585
- padding-bottom:3px;
586
- padding-left:3px;
587
- cursor:pointer;
588
- }
589
-
590
- div.image_settings_box {
591
- position:absolute;
592
- width:150px;
593
- display:none;
594
- margin: -66px 0px 0px 36px;
595
- _margin: 0px 0px 0px -30px;
596
- padding-top:2px;
597
- width:252px;
598
- z-index:69;
599
- _z-index:80;
600
- }
601
-
602
- a.thickbox img {
603
- border:medium none;
604
- }
605
-
606
- img.previewimage {
607
- cursor:move;
608
- height:60px;
609
- margin-right:4px;
610
- width:60px;
611
- }
612
-
613
- div.lower_settings_box {
614
- width:234px;
615
- background-color:white;
616
- border:1px solid black;
617
- border-top:1px solid #CCCCCC;
618
- float:right;
619
- margin: -1px -6px 0px 0px;
620
- padding: 2px 0 0 4px;
621
- background-color:#EAF3FA;
622
- }
623
-
624
- div.upper_settings_box {
625
- width:250px;
626
- background-color:white;
627
- border:1px solid black;
628
- padding:3px 1px 2px 5px;
629
- }
630
-
631
- div.upper_image {
632
- float:left;
633
- /* border-bottom:1px solid black; */
634
- padding-left:5px;
635
- margin-left:-5px;
636
- _margin-left:-3px;
637
- margin-right:-7px;
638
- padding-bottom:4px;
639
- _padding-bottom:6px;
640
- _margin-bottom:-2px;
641
- }
642
-
643
- div.upper_txt{
644
- padding-left:22px;
645
- color:#666666;
646
- }
647
-
648
- div.previewimage {
649
- position:relative;
650
- }
651
-
652
- tr.edit_product_image *{
653
- z-index:80;
654
- }
655
-
656
- a.closeimagesettings{
657
- cursor:pointer;
658
- margin-left:90px;
659
- }
660
-
661
- div.browser-image-uploader {
662
-
663
- }
664
-
665
- div.browser-image-uploader h4{
666
- margin-bottom: 8px;
667
- }
668
-
669
- div.image_resize_extra_forms {
670
- display: none;
671
- }
672
-
673
- #wpsc_product_category_and_tag_forms table {
674
- width: 100%;
675
- }
676
-
677
- #wpsc_product_category_and_tag_forms table td.itemfirstcol{
678
- padding-left:3pt;
679
- width: 50%;
680
- }
681
-
682
- /* variations CSS starts */
683
-
684
- table.product_variation_listing{
685
- margin-bottom: 12px;
686
- }
687
-
688
- table.product_variation_listing th.variation_name{
689
- color: #71A4C8;
690
- font-style: italic;
691
- text-align: left;
692
- padding-bottom: 1px;
693
- }
694
-
695
- table.product_variation_grid{
696
- margin-top: 12px;
697
- }
698
-
699
- table.product_variation_grid th.variation_name{
700
- color: #71A4C8;
701
- font-style: italic;
702
- text-align: left;
703
- padding-bottom: 1px;
704
- }
705
-
706
- div#edit_variations_container {
707
- margin-top: 12px;
708
- }
709
- table.product_variation_grid {
710
- border-collapse: collapse;
711
- margin-top: 0px;
712
- }
713
-
714
- table.product_variation_grid tr td, table.product_variation_grid tr th {
715
- border: 1px solid #cccccc;
716
- border-collapse: collapse;
717
- text-align: left;
718
- }
719
-
720
- table.product_variation_grid tr th {
721
- border-bottom: 1px solid #969696;
722
- }
723
-
724
- table.product_variation_grid tr th.stock {
725
- border-bottom: 1px solid #969696;
726
- width: 50px;
727
- }
728
-
729
- table.product_variation_grid tr th.price {
730
- width: 78px;
731
- }
732
-
733
- table.product_variation_grid tr td.variations, table.product_variation_grid tr th {
734
- padding: 4px 0px 4px 10px;
735
- }
736
-
737
- table.product_variation_grid tr td.variations, table.product_variation_grid tr th.variations {
738
- width: 300px;
739
- }
740
-
741
-
742
- table.product_variation_grid tr td input{
743
- padding: 0px 3px 0px 3px;
744
- }
745
-
746
- table.product_variation_grid tr.group_boundary td {
747
- border-bottom: 1px solid #969696;
748
- }
749
-
750
- a.about_this_page_sub {
751
- text-decoration:underline;
752
- }
753
-
754
- table.product_variation_grid tr td, table.product_variation_grid tr th {
755
- border: 1px solid #cccccc;
756
- border-collapse: collapse;
757
- text-align: left;
758
- }
759
-
760
- table.product_variation_grid tr.variation_row td {
761
- border-bottom: none;
762
- }
763
-
764
- table.product_variation_grid tr.settings_row td {
765
- border-top: none;
766
- padding: 0px !important;
767
- }
768
-
769
-
770
- table.product_variation_grid tr.settings_row td div.variation_settings {
771
- display: none;
772
- border-top: 1px dotted #cccccc;
773
- width: 100%;
774
- min-height: 30px;
775
- padding: 4px 10px;
776
-
777
- }
778
- table.product_variation_grid tr th {
779
- border-bottom: 1px solid #969696;
780
- }
781
-
782
- table.product_variation_grid tr th.stock {
783
- border-bottom: 1px solid #969696;
784
- width: 50px;
785
- }
786
-
787
- table.product_variation_grid tr th.price {
788
- width: 78px;
789
- }
790
-
791
- table.product_variation_grid tr td.variations, table.product_variation_grid tr th {
792
- padding: 4px 0px 4px 10px;
793
- }
794
-
795
- table.product_variation_grid tr td.variations, table.product_variation_grid tr th.variations {
796
- width: 300px;
797
- }
798
-
799
-
800
- table.product_variation_grid tr td input{
801
- padding: 0px 3px 0px 3px;
802
- }
803
-
804
- table.product_variation_grid tr td input.checkbox{
805
- display: block;
806
- margin:6px auto;
807
- }
808
-
809
- table.product_variation_grid tr.group_boundary td {
810
- border-bottom: 1px solid #969696;
811
- }
812
-
813
- div#add_product_variation_details {
814
- margin: 1ex 0px 0px 0px;
815
- }
816
-
817
- div#add_product_variation_details table.product_variation_grid {
818
- margin: 4px 0px 0px 0px;
819
- }
820
-
821
- div.variation_checkboxes {
822
- margin-bottom: 4px;
823
- }
824
-
825
- div.variation_checkboxes label {
826
- display: block;
827
- margin-bottom: 2px;
828
- }
829
-
830
- div.variation_checkboxes label input {
831
- position: relative;
832
- top: 2px;
833
- margin-right: 3px;
834
- }
835
-
836
- a.variation_edit_button {
837
- display: block;
838
- height: 16px;
839
- width: 16px;
840
- margin: 4px auto 0px auto;
841
-
842
- }
843
-
844
- div.variation_settings div.variation_settings_contents{
845
- padding-left: 10px;
846
- }
847
-
848
- div.select_variation_file {
849
- padding-left: 6px;
850
- }
851
- div.select_variation_file p {
852
- margin:0 0 3px;
853
- }
854
-
855
- div.select_variation_file p {
856
- margin:0 0 3px;
857
- }
858
-
859
- div.select_variation_file p input {
860
- position: relative;
861
- top: 2px;
862
- }
863
-
864
-
865
- label.variation_checkbox {
866
- display: block;
867
- }
868
-
869
- div.variation_set{
870
- }
871
- div.variation{
872
- padding-left: 10px;
873
- }
874
- /* variations CSS ends */
875
-
876
-
877
- div#side-sortables input[type="file"] {
878
- width:250px;
879
- }
880
- div.select_product_file, div.edit_select_product_file {
881
- margin-bottom:0;
882
- margin-top:3px;
883
- overflow-x:hidden;
884
- overflow-y:auto;
885
- padding:2px 2px 6px;
886
- position:relative;
887
- }
888
-
889
- a.file_delete_button {
890
- cursor:pointer;
891
- float:right;
892
- /* margin-top:-17px; */
893
- display: block;
894
- }
895
-
896
- a.delete_button {
897
- border-color:-moz-use-text-color -moz-use-text-color #FF0000;
898
- border-style:none none solid;
899
- border-width:medium medium 1px;
900
- color:#FF0000;
901
- font-size:11px;
902
- padding:1px 2px;
903
- text-decoration:none;
904
- }
905
- .greytext{
906
- color:#666666;
907
- }
908
- span.small_italic{
909
- font-style: italic;
910
- }
911
- /* Product details form styling ends */
912
- /*
913
- * Display Products CSS ends here
914
- */
915
-
916
- /* shipping options start here */
917
- div.wpsc_shipping_options{
918
- width:100%;
919
- padding:3px 0;
920
- }
921
- .wpsc-shipping-actions{
922
- visibility:hidden;
923
- font-size: 10px;
924
- margin:2px 9em 0 0;
925
- float:right;
926
- }
927
- div.wpsc_shipping_options:hover .wpsc-shipping-actions{
928
- font-size:10px;
929
- visibility:visible;
930
- }
931
-
932
- /*
933
- * Product Groups styles start here
934
- */
935
- td.firstcol div.postbox div.inside{
936
- margin: 0px;
937
- padding: 0px;
938
- }
939
-
940
- table#productpage{
941
- width: 100%;
942
- clear: both;
943
- border-collapse: collapse;
944
- }
945
-
946
- table#productpage tr td{
947
- vertical-align: top;
948
- /* padding: 0px 0px 0px 6px; */
949
- }
950
-
951
- table#productpage tr td.secondcol{
952
- /* width: 60%; */
953
- /* margin-left: 20px; */
954
- padding: 0px 2px 0px 16px;
955
-
956
- }
957
-
958
-
959
- table.category-edit {
960
- border-collapse: collapse;
961
- width: 100%;
962
- }
963
-
964
- table.category-edit tr td {
965
- border: none;
966
- }
967
- table.category-edit tr td.column-title {
968
- width: 450px;
969
- }
970
-
971
-
972
- div.category-image-container {
973
- width: 55px;
974
- height: 30px;
975
-
976
- }
977
-
978
- div.category-image-container img {
979
- float: left;
980
- }
981
- div.category-image-container img.category_indenter {
982
- margin-right: 3px;
983
- width:auto;
984
- float:left;
985
- }
986
-
987
-
988
-
989
-
990
-
991
- div#productform{ display: none; width: 99.5%; }
992
-
993
- div#edititem27{ display: none; width: 586px; }
994
-
995
- div#productform table tr td{ height: 11px !important; }
996
-
997
-
998
-
999
-
1000
- div#blank_item{ display: block;}
1001
-
1002
- #poststuff div#blank_item h3{
1003
- margin-top: 0px;
1004
-
1005
- }
1006
-
1007
- div#additem{ display: none;}
1008
-
1009
- div#productform td.itemfirstcol{ padding-left:4px; vertical-align: top; }
1010
-
1011
-
1012
-
1013
-
1014
- div#productform input.text, div#additem input.text{
1015
- width:386px;
1016
- border:1px solid #bbb;
1017
- }
1018
-
1019
-
1020
- table.category_forms {
1021
- width: 100%;
1022
- }
1023
- table.category_forms tr td {
1024
- padding: 0px 8px ;
1025
- }
1026
- table.category_forms tr td textarea {
1027
- width: 386px;
1028
- }
1029
-
1030
- div#edit_variation_values input.text{width:286px !important;border:1px solid #bbb;}
1031
-
1032
- input.image_resize{ position: relative; top: 4px; }
1033
-
1034
- div#additem table.additem input.wpsc_tag{
1035
- width:180px;
1036
- }
1037
- div#additem label{
1038
- font-style: normal;
1039
- font-size: 0.95em;
1040
- }
1041
-
1042
-
1043
-
1044
-
1045
-
1046
- .groupItem{
1047
- border-top:1px solid #bbb;
1048
- width:385px;
1049
- height:35px;
1050
- clear: both;
1051
- /* margin-left:-6px; */
1052
- padding: 0px 0px 4px 0px;
1053
- }
1054
-
1055
- .groupItem .itemHeader{
1056
- width:65px;
1057
- line-height: 15px;
1058
- color: #000;
1059
- padding: 4px;
1060
- cursor: move;
1061
- height: 35px;
1062
- position: relative;
1063
- clear: both;
1064
- }
1065
-
1066
- .groupItem .itemHeader a{
1067
- margin: 4px 0px 4px 0px;
1068
- font-weight: normal;
1069
- font-size: 11px;
1070
- text-decoration: none;
1071
- }
1072
- .sortHelper{
1073
- border: 3px dashed #666;
1074
- width: auto;
1075
- }
1076
- .groupWrapper p{
1077
- height: 1px;
1078
- overflow: hidden;
1079
- margin: 0;
1080
- padding: 0;
1081
- }
1082
-
1083
-
1084
- table#productpage tr td.secondcol.product_groups_page {
1085
- padding-left: 16px;
1086
- }
1087
-
1088
- table#productpage tr td.secondcol.product_groups_page h4 {
1089
- font-family: inherit;
1090
- margin-top: 20px;
1091
- }
1092
-
1093
- td.product_groups_page #additem .inside, td.product_groups_page #productform .inside {
1094
- margin: 0px 0px 15px 0px;
1095
- }
1096
-
1097
- div.editing_this_group {
1098
- margin-top: 8px;
1099
- margin-bottom: 8px;
1100
- /* border-bottom:1px dotted black; */
1101
- width:100%;
1102
- }
1103
-
1104
- td.product_groups_page h4 {
1105
- margin-bottom: 1ex;
1106
- }
1107
- #editorcontainer{
1108
- clear:both;
1109
- }
1110
- td.product_groups_page td.category_presentation_settings {
1111
- padding-bottom: 1ex;
1112
- }
1113
-
1114
- td.column-price .pricedisplay, td.sale_price .salespricedisplay, td.SKU .skudisplay, td.stock .stockdisplay, td.weight .weightdisplay{
1115
- border-bottom: 1px dotted #333;
1116
- }
1117
-
1118
- div.editing_this_group {
1119
- font-size:8pt;
1120
- }
1121
-
1122
- div.editing_this_group p {
1123
- padding:4px 4px 4px 8px;
1124
- }
1125
-
1126
- div.editing_this_group dl {
1127
- padding:4px 4px 4px 8px;
1128
- }
1129
-
1130
-
1131
- #blank_item a.add_category_link{
1132
- display: block;
1133
- margin: 8px 8px 8px 0px;
1134
- text-decoration: underline;
1135
- }
1136
-
1137
- div.product_group {
1138
- margin: 12px 0px 10px 0px;
1139
- }
1140
-
1141
-
1142
- table#wpsc_category_list td div.subcategory img.category_indenter {
1143
- float: left;
1144
- margin: 8px 0px 0px 0px;
1145
- }
1146
-
1147
- table#wpsc_category_list td div.subcategory table.itemlist {
1148
- float: left;
1149
- }
1150
-
1151
-
1152
- label.select_categorisation_group, select#select_categorisation_group, a.add_categorisation_group, a.edit_categorisation_group, #submit_categorisation_form span {
1153
- display: block;
1154
- float: left;
1155
- }
1156
-
1157
- #submit_categorisation_form span {
1158
- display: block;
1159
- float: left;
1160
- margin-left: 10px;
1161
- }
1162
-
1163
- #submit_categorisation_form a span {
1164
- margin-left: 0px;
1165
- }
1166
-
1167
- label.select_categorisation_group {
1168
- padding-top: 4px;
1169
- /* color: #336699; */
1170
- font-size: 11px;
1171
- }
1172
-
1173
- a.add_categorisation_group {
1174
- margin-left: 10px;
1175
- }
1176
-
1177
- a.edit_categorisation_group {
1178
- margin-left: 30px;
1179
- }
1180
-
1181
-
1182
-
1183
- div#add_categorisation, div#edit_categorisation{
1184
- display: none;
1185
- border: 1px solid #BBBBBB;
1186
- padding: 4px;
1187
- margin-top: 6px;
1188
- }
1189
-
1190
- div#add_categorisation br, div#edit_categorisation br{
1191
- clear: both;
1192
- }
1193
-
1194
-
1195
- div#add_categorisation fieldset, div#edit_categorisation fieldset{
1196
- width: 230px;
1197
- float: left;
1198
- border: none;
1199
- }
1200
-
1201
- div#add_categorisation fieldset label, div#edit_categorisation fieldset label{
1202
- display: block;
1203
- }
1204
-
1205
- ul.categorisation_links{
1206
- list-style-type: none;
1207
- clear: both;
1208
- padding: 0px;
1209
- }
1210
- .wpsc_add_new_currency{
1211
- text-decoration: none;
1212
- }
1213
- ul.categorisation_links li{
1214
- display: block;
1215
- float: left;
1216
- list-style-type: none;
1217
- margin: 0px;
1218
- font-size: 14px;
1219
- padding: 4px;
1220
- }
1221
-
1222
- ul.categorisation_links li.selected a{
1223
- color: #D54E21;
1224
- }
1225
-
1226
- .multiple-select {
1227
- background: white none repeat scroll 0px 0px;
1228
- border: 1px solid #DFDFDF;
1229
- display: inline-block;
1230
- height: 120px;
1231
- margin: 10px 0;
1232
- overflow-x: hidden;
1233
- overflow-y: auto;
1234
- padding: 0px;
1235
- position: relative;
1236
- width:98%
1237
- }
1238
-
1239
- table.category_forms a.delete_button {
1240
- display: block;
1241
- margin: 3px 0px 0px 8px;
1242
- float: left;
1243
- }
1244
-
1245
- table.category_forms td.last_row {
1246
- padding: 16px 0px 0px 0px;
1247
- }
1248
-
1249
- .wpsc_gold_float{
1250
- min-width:45%;
1251
- float:left;
1252
- max-width:450px;
1253
- _width:450px;
1254
- }
1255
- .wpsc_gold_side{
1256
- margin-top:90px;
1257
- float:right;
1258
- width:35%;
1259
- }
1260
- .wpsc_gold_text{
1261
- width:70%;
1262
- float:left;
1263
- clear:both;
1264
- }
1265
-
1266
- .wpsc_gold_info{
1267
- width:30%;
1268
- float:right;
1269
- text-align: center;
1270
- font-size:20px;
1271
- }
1272
- .wpsc_gold_module{
1273
- width:100%;
1274
- float:left;
1275
-
1276
- border-bottom: 1px solid #DFDFDF;
1277
- }
1278
- .wpsc_gold_module strong{
1279
- width:auto;
1280
- float:left;
1281
- }
1282
- #visitInstinct{
1283
- float:right;
1284
- margin:5px 20px 0 0;
1285
- }
1286
-
1287
-
1288
- #gold_cart_form .postbox p img{
1289
- padding-bottom:10px;
1290
- }
1291
- #wpsc_gold_options_outside{
1292
- width:400px;
1293
- }
1294
- #gold_cart_form .postbox p{
1295
- padding-left: 4px;
1296
- }
1297
- #gold_cart_form .postbox{
1298
- width:100%;
1299
- max-width:500px;
1300
- }
1301
- #gold_cart_form .postbox p{
1302
- padding-left:10px;
1303
- }
1304
- #gold_cart_form .postbox p label{
1305
- width:80px;
1306
- float:left;
1307
- }
1308
-
1309
- a.admin_download {
1310
- display: block;
1311
- height: 26px;
1312
- border-bottom: none;
1313
- text-decoration: none;
1314
- }
1315
-
1316
- a.admin_download img{
1317
- margin-right: 3px;
1318
- }
1319
-
1320
- a.admin_download span{
1321
- text-decoration: underline;
1322
- }
1323
-
1324
- /*
1325
- * Product Groups styles end here
1326
- */
1327
- .wpsc_td_note{
1328
- padding-bottom:0 !important;
1329
- }
1330
-
1331
- .wpsc_purchaselogs_options {
1332
- margin: 0px 0px 8px 0px;
1333
-
1334
- }
1335
-
1336
-
1337
- .add_new_form_set {
1338
- /* display: block;
1339
- float: left;*/
1340
- text-decoration: underline;
1341
- font-weight: bold;
1342
- font-size:0.9em;
1343
- }
1344
-
1345
-
1346
- p.add_new_form_set_forms {
1347
- display: none;
1348
- }
1349
-
1350
- td.product-image a img.attachment-thumbnail {
1351
- height: 38px;
1352
- width: 38px;
1353
-
1354
- }
1355
-
1356
- #wpsc_product_category_and_tag_forms .tagchecklist {
1357
- font-size:11px;
1358
- }
1359
-
1360
- #categorydiv div{
1361
- margin-top: 4px;
1362
- }
1363
-
1364
- a.variation_handle {
1365
- color: #CCCCCC;
1366
- text-decoration: none;
1367
- font-size: 15px;
1368
- }
1369
-
1370
- .toplevel_page_wpsc-edit-products .wrap h2
1371
- {
1372
- padding-bottom:0px;
1373
- border-bottom:1px solid #CCC;
1374
- }
1375
- #post-body #advanced-sortables
1376
- {
1377
- margin-right:300px
1378
- }
1379
- #media-buttons #add_audio,
1380
- #media-buttons #add_video,
1381
- #media-buttons #add_media {
1382
- display:none;
1383
- }
1384
- .meta-box-sortables-wpec .postbox:hover .handlediv {
1385
- background: transparent url(../../wpsc-core/images/menu-bits.gif) no-repeat scroll 0% -111px;
1386
- }
1387
- /* Main Flora Style Sheet for jQuery UI ui-datepicker */
1388
- #ui-datepicker-div, .ui-datepicker-inline {
1389
- font-family: Arial,Helvetica,sans-serif;
1390
- font-size: 14px;
1391
- padding: 0;
1392
- margin: 0;
1393
- background: #E0F4D7;
1394
- width: 185px;
1395
- }
1396
- #ui-datepicker-div {
1397
- display: none;
1398
- border: 1px solid #21759B;
1399
- z-index: 10;
1400
- }
1401
- .ui-datepicker-inline {
1402
- float: left;
1403
- display: block;
1404
- border: 0;
1405
- }
1406
- .ui-datepicker-rtl {
1407
- direction: rtl;
1408
- }
1409
- .ui-datepicker-dialog {
1410
- padding: 5px !important;
1411
- border: 4px ridge #fff !important;
1412
- }
1413
- button.ui-datepicker-trigger {
1414
- width: 25px;
1415
- }
1416
- img.ui-datepicker-trigger {
1417
- margin: 2px;
1418
- vertical-align: middle;
1419
- }
1420
- .ui-datepicker-prompt {
1421
- float: left;
1422
- padding: 2px;
1423
- background: #fff;
1424
- color: #000;
1425
- }
1426
- *html .ui-datepicker-prompt {
1427
- width: 185px;
1428
- }
1429
- .ui-datepicker-control, .ui-datepicker-links, .ui-datepicker-header, .ui-datepicker {
1430
- clear: both;
1431
- float: left;
1432
- width: 100%;
1433
- color: #FFF;
1434
- }
1435
- .ui-datepicker-control {
1436
- background: #fff;
1437
- padding: 2px 0px;
1438
- display:none;
1439
- }
1440
- .ui-datepicker-links {
1441
- background: #fff;
1442
- padding: 2px 0px;
1443
- }
1444
- .ui-datepicker-control, .ui-datepicker-links {
1445
- font-weight: bold;
1446
- font-size: 80%;
1447
- letter-spacing: 1px;
1448
- }
1449
- .ui-datepicker-links label {
1450
- padding: 2px 5px;
1451
- color: #fff;
1452
- }
1453
- .ui-datepicker-clear, .ui-datepicker-prev {
1454
- float: left;
1455
- width: 34%;
1456
- }
1457
- .ui-datepicker-rtl .ui-datepicker-clear, .ui-datepicker-rtl .ui-datepicker-prev {
1458
- float: right;
1459
- text-align: right;
1460
- }
1461
- .ui-datepicker-current {
1462
- float: left;
1463
- width: 30%;
1464
- text-align: center;
1465
- }
1466
- .ui-datepicker-close, .ui-datepicker-next {
1467
- float: right;
1468
- width: 34%;
1469
- text-align: right;
1470
- }
1471
- .ui-datepicker-rtl .ui-datepicker-close, .ui-datepicker-rtl .ui-datepicker-next {
1472
- float: left;
1473
- text-align: left;
1474
- }
1475
- .ui-datepicker-header {
1476
- padding: 1px 0 3px;
1477
- background: #fff;
1478
- text-align: center;
1479
- font-weight: bold;
1480
- height: 1.3em;
1481
- }
1482
- .ui-datepicker-header select {
1483
- background: #fff;
1484
- color: #000;
1485
- border: 0px;
1486
- font-weight: bold;
1487
- }
1488
- .ui-datepicker {
1489
- background: #fff;
1490
- text-align: center;
1491
- font-size: 100%;
1492
- }
1493
- .ui-datepicker a {
1494
- display: block;
1495
- width: 100%;
1496
- }
1497
- .ui-datepicker-title-row {
1498
- background: #fff;
1499
- color: #000;
1500
- }
1501
- .ui-datepicker-title-row .ui-datepicker-week-end-cell {
1502
- background: #fff;
1503
- }
1504
- .ui-datepicker-days-row {
1505
- background: #FFF;
1506
- color: #666;
1507
- }
1508
- .ui-datepicker-week-col {
1509
- background: #ededed;
1510
- color: #000;
1511
- }
1512
- .ui-datepicker-days-cell {
1513
- color: #000;
1514
- border: 1px solid #DDD;
1515
- }
1516
- .ui-datepicker-days-cell a {
1517
- display: block;
1518
- }
1519
- .ui-datepicker-week-end-cell {
1520
- background: #EAF2FA;
1521
- }
1522
- .ui-datepicker-unselectable {
1523
- color: #888;
1524
- }
1525
- .ui-datepicker-week-over, .ui-datepicker-week-over .ui-datepicker-week-end-cell {
1526
- background: #B1DB87 !important;
1527
- }
1528
- .ui-datepicker-days-cell-over, .ui-datepicker-days-cell-over.ui-datepicker-week-end-cell {
1529
- background: #FFF !important;
1530
- border: 1px solid #777;
1531
- }
1532
- * html .ui-datepicker-title-row .ui-datepicker-week-end-cell {
1533
- background: #ddd !important;
1534
- }
1535
- * html .ui-datepicker-week-end-cell {
1536
- background: #ddd !important;
1537
- border: 1px solid #DDD !important;
1538
- }
1539
- * html .ui-datepicker-days-cell-over {
1540
- background: #FFF !important;
1541
- border: 1px solid #777 !important;
1542
- }
1543
- * html .ui-datepicker-current-day {
1544
- background: #d3d3d3 !important;
1545
- }
1546
- .ui-datepicker-today {
1547
- background: #dddddd !important;
1548
- }
1549
- .ui-datepicker-current-day {
1550
- background: #d3d3d3 !important;
1551
- }
1552
- .ui-datepicker-status {
1553
- background: #fff;
1554
- width: 100%;
1555
- font-size: 80%;
1556
- text-align: center;
1557
- }
1558
- #ui-datepicker-div a, .ui-datepicker-inline a {
1559
- cursor: pointer;
1560
- margin: 0;
1561
- padding: 0;
1562
- background: none;
1563
- color: #000;
1564
- }
1565
- .ui-datepicker-inline .ui-datepicker-links a {
1566
- padding: 0 5px !important;
1567
- }
1568
- .ui-datepicker-control a, .ui-datepicker-links a {
1569
- padding: 2px 5px !important;
1570
- color: #000 !important;
1571
- }
1572
- .ui-datepicker-title-row a {
1573
- color: #000 !important;
1574
- }
1575
- .ui-datepicker-control a:hover {
1576
- background: #f1f1f1 !important;
1577
- color: #333 !important;
1578
- }
1579
- .ui-datepicker-links a:hover, .ui-datepicker-title-row a:hover {
1580
- background: #FFF !important;
1581
- color: #333 !important;
1582
- }
1583
- .ui-datepicker-multi .ui-datepicker {
1584
- /* border: 1px solid #83C948; */
1585
- }
1586
- .ui-datepicker-one-month {
1587
- float: left;
1588
- width: 185px;
1589
- }
1590
- .ui-datepicker-new-row {
1591
- clear: left;
1592
- }
1593
- .ui-datepicker-cover {
1594
- display: none;
1595
- display: block;
1596
- position: absolute;
1597
- z-index: -1;
1598
- filter: mask();
1599
- top: -4px;
1600
- left: -4px;
1601
- width: 193px;
1602
- height: 200px;
1603
- }
1604
- /* marketing / coupon page styling */
1605
-
1606
- div.modify_coupon{ border: 1px solid #eeeeee; display: none; width: 100%; }
1607
- table.coupon_data{
1608
- width: 100%;
1609
- }
1610
- table.add-coupon{width:100%;}
1611
- table.add-coupon tr th{ text-align: left; padding: 2px 5px 0px 5px; border: none;}
1612
- table.add-coupon tr td{ text-align: left; padding: 2px 5px 2px 5px; border: none;}
1613
- table.add-coupon tr td p{padding:0;margin:5px;}
1614
- #table_header{
1615
- font-size:16px;
1616
- margin-top:20px;
1617
- font-weight: bold;
1618
- }
1619
- table.coupon-list{ width: 100%; }
1620
- table.coupon-list th{ text-align:left;}
1621
- table.coupon-list tr.toprow td{ text-align: left; font-weight:bold; }
1622
-
1623
- table.coupon-list tr td{ padding: 5px 5px 10px 10px; vertical-align: middle;}
1624
-
1625
- table.coupon-list tr.alt{ background-color: #eeeeee; }
1626
-
1627
- table.coupon-list tr.alt td{ background-color: #eeeeee; }
1628
- table.coupon-list tr.coupon_edit td{ padding:0; }
1629
- td#order_summary_container{ width: 80px; }
1630
- table.category_forms a.delete_button, span.delete_button {
1631
- color:#FF0000;
1632
- display:block;
1633
- float:left;
1634
- font-size:11px;
1635
- margin:3px 0 0 8px;
1636
- text-decoration:underline;
1637
- }
1638
- p span.input_label{
1639
- font-size:1.2em;
1640
- width:180px;
1641
- float:left;
1642
- }
1643
- a.wpsc_featured_product_toggle {
1644
- display: block;
1645
- height: 18px;
1646
- width: 18px;
1647
- margin: 4px 0px 0px 6px;
1648
- }
1649
-
1650
- a.wpsc_featured_product_toggle img {
1651
- display: block;
1652
- margin: 0px auto 0px auto;
1653
-
1654
- }
1655
-
1656
- div.wpsc_clear {
1657
- clear: both;
1658
- }
1659
-
1660
- .wpsc_featured div.product_grid_display div.product_grid_item {
1661
- width: 100%;
1662
- height: auto !important;
1663
- margin: 4px 90px 8px 0;
1664
- position: relative;
1665
- }
1666
-
1667
-
1668
- .wpsc_featured .item_text {
1669
- float: left;
1670
- height: 240px;
1671
- width: auto;
1672
- }
1673
-
1674
- .wpsc_featured .item_image {
1675
- float: left;
1676
- height: 240px;
1677
- width: 340px;
1678
- margin-left: 20px;
1679
- }
1680
-
1681
- .wpsc_featured .item_image a {
1682
- display: block;
1683
- height: 240px;
1684
- width: 340px;
1685
- border: 1px solid #FEFAF1;
1686
- border-radius: 18px;
1687
- -moz-border-radius: 18px;
1688
- -webkit-border-radius: 18px;
1689
- background-repeat: no-repeat;
1690
- }
1691
-
1692
-
1693
- .wpsc_featured .item_text h3 {
1694
- font-size: 1.4em;
1695
- margin: 0px 0px 8px 0px;
1696
- }
1697
-
1698
- .wpsc_featured .item_text div.pricedisplay {
1699
- color: #9B9A96;
1700
- line-height: normal;
1701
- display: block;
1702
- margin: 0px 0px 4px 0px;
1703
-
1704
- }
1705
-
1706
- .wpsc_featured .item_text .wpsc_description {
1707
- font-size: 1em;
1708
- line-height:24px;
1709
- display:block;
1710
- float:left;
1711
- width: auto;
1712
- color: #9B9A96;
1713
- font-family: Georgia,"Bitstream Charter",serif;
1714
- }
1715
-
1716
- .wpsc_featured .item_text .wpsc_description p {
1717
- margin-bottom: 0px;
1718
- }
1719
-
1720
-
1721
- .wpsc_featured .item_text .wpsc_description a {
1722
- color:#9B9A96;
1723
- }
1724
-
1725
- ul.wpsc_categories {
1726
- clear: both;
1727
- }
1728
-
1729
- a.update_variations, a.update_variations_action
1730
- {
1731
- float:left;
1732
- margin:10px;
1733
- }
1734
- a.update_variations_action {
1735
- display:none;
1736
- }
1737
- #search-products{
1738
- width:auto;
1739
- float:right;
1740
- }
1741
- .productnav{
1742
- height: 30px;
1743
- margin: 6px 0px 4px;
1744
- vertical-align: middle;
1745
- }
1746
-
1747
- .wpsc_stock_control_forms .edit_stock {
1748
- margin-top:0.5em;
1749
- line-height:16px;
1750
- }
1751
- .wpsc_stock_control_forms .unpublish_when_none_left {
1752
- margin:0.5em 0;
1753
- }
1754
- #media-upload form p.help {
1755
- text-align:left;
1756
- clear:both;
1757
- }
1758
- ul#category_list_li, ul.poll-options {
1759
- }
1760
- ul#category_list_li li div,
1761
- ul#category_list_li li div ul li div {
1762
- }
1763
- ul#category_list_li li div div,
1764
- ul#category_list_li li div ul li div div {
1765
-
1766
- }
1767
- ul#category_list_li li div:hover div{
1768
- }
1769
-
1770
- ul#category_list_li li div ul li div:hover div {
1771
- }
1772
- ul#category_list_li li {
1773
- }
1774
- ul#category_list_li li:hover span.handle {
1775
- cursor: move;
1776
- }
1777
- .edit{
1778
- }
1779
- ul#category_list_li li span.handle {
1780
- float:left;
1781
-
1782
- padding: 5px;
1783
-
1784
- }
1785
-
1786
- .category_admin_list_img a.row-title{
1787
- text-decoration: none;
1788
- }
1789
-
1790
-
1791
- .category_admin_list_img:hover div.row-actions {
1792
- visibility:visible;
1793
- }
1794
-
1795
- ul#category_list_li ul {
1796
- margin-left:15px;
1797
- }
1798
-
1799
- .row-title img{
1800
- width:30px;
1801
- float:left;
1802
- padding-right:10px;
1803
- }
1
+ /*
2
+ * This is the new WPSC Admin CSS file
3
+
4
+ */
5
+ .wpsc_trackingid_row{
6
+ margin-left:20px;
7
+ }
8
+
9
+ ul.children{
10
+ padding-left:5px;
11
+ }
12
+ .category_indenter{
13
+
14
+ float:left;
15
+ width:auto;
16
+
17
+ }
18
+ /**
19
+ *Dashboard Widget CSS
20
+ *
21
+ */
22
+ #leftDashboard{
23
+ width:45%;
24
+ float:left;
25
+ text-align:right;
26
+ border-right:1px #999999 solid;
27
+
28
+ }
29
+ #leftDashboard strong{
30
+ float:left;
31
+ padding-left: 40px;
32
+ }
33
+ #rightDashboard strong{
34
+ float:left;
35
+ padding-left: 40px;
36
+ }
37
+ #rightDashboard{
38
+ width:45%;
39
+ float:right;
40
+ text-align:right;
41
+
42
+ }
43
+ .pricedisplay, .salespricedisplay{
44
+ /* width:40%; */
45
+ float:left;
46
+ }
47
+ .dashboardWidgetSpecial{
48
+ font-family:Georgia,"Times New Roman","Bitstream Charter",Times,serif;
49
+ color:#21759B;
50
+ font-size:15px!important;
51
+ margin: 5px 0 5px 0;
52
+ }
53
+ .dashboardWidget{
54
+ color:#777777;
55
+ padding-left:10px;
56
+ padding-right: 30px;
57
+
58
+ }
59
+ span.wpsc_quart_left{
60
+ width:40%;
61
+ float:left;
62
+ }
63
+ p.atglance{
64
+ color:#777777;
65
+ font-family:Georgia,"Times New Roman","Bitstream Charter",Times,serif;
66
+ font-size:13px;
67
+ font-style:italic;
68
+ }
69
+ span.wpsc_quart_right{
70
+ width:60%;
71
+ float:right;
72
+ text-align: right;
73
+ }
74
+ #box span{
75
+ border-bottom: 1px solid #999999;
76
+ }
77
+ p.quarterly{
78
+ color:#21759B;
79
+ font-family:Georgia,"Times New Roman","Bitstream Charter",Times,serif;
80
+ font-size:12px;
81
+ line-height: 140%;
82
+ margin:5px 0;
83
+ }
84
+ /* end of dashboard widget css */
85
+ /*
86
+ *Display Purchase log Details CSS is HERE
87
+ */
88
+ #purchlogs_customfields{
89
+ clear:both;
90
+ }
91
+ th#date{
92
+ width:120px;
93
+ }
94
+ th#purchid{
95
+ width:60px;
96
+ }
97
+ th#details{
98
+ width:55px;
99
+ }
100
+ th#amount{
101
+ width:75px;
102
+ }
103
+ th#name{
104
+ /* width:220px; */
105
+ }
106
+ th#track{
107
+ width:75px;
108
+ }
109
+ th#delete{
110
+ width:55px;
111
+ }
112
+ th#status{
113
+ width:120px;
114
+ }
115
+ .google_checkout_logo{
116
+ padding-right:10px;
117
+ }
118
+ #wpsc_items_ordered{
119
+ clear:both;
120
+ }
121
+ #wpsc_items_ordered h3{
122
+ margin-bottom:0em;
123
+ }
124
+ .wpsc_pushdown_img {
125
+ float:left;
126
+ }
127
+ #wpsc_purchlogitems_links{
128
+ clear:both;
129
+
130
+ }
131
+ #wpsc_purchlog_order_status{
132
+ float:right;
133
+ width:250px;
134
+ }
135
+ #wpsc_purchlog_order_status .selector{
136
+ margin-top:-.2em;
137
+ }
138
+
139
+ #wpsc_purchlogitems_links a{
140
+ text-decoration:none;
141
+ line-height:14pt;
142
+ }
143
+ #wpsc_purchlogitems_links img{
144
+ padding-top:2px;
145
+ float:left;
146
+ }
147
+ #wpsc_shipping_details_box{
148
+ width:45%;
149
+ float:left;
150
+ border:1px #d3d3d3 solid;
151
+ margin:.4em;
152
+ padding:.6em;
153
+ margin-right:5em;
154
+ }
155
+ #wpsc_billing_details_box{
156
+ width:35%;
157
+ float:left;
158
+ margin:.4em;
159
+ padding:.6em;
160
+ }
161
+ #wpsc_purchlog_searchbox{
162
+ width:100%;
163
+ text-align:right;
164
+
165
+
166
+ }
167
+ /*
168
+ * Display Purchase log Details CSS ends HERE
169
+ * Display Products CSS starts here
170
+ */
171
+ .tablenav select[name="bulkAction"] {
172
+ width:100px;
173
+ }
174
+ textarea#additional_description{
175
+ border: 1px solid #dfdfdf;
176
+ /* width:465px !important; */
177
+ }
178
+ .wpsc-separator {
179
+ background:transparent url(../../images/menu-arrows.gif) no-repeat scroll left 5px;
180
+ cursor:w-resize;
181
+ height:21px;
182
+ margin:0;
183
+ padding:0;
184
+ }
185
+
186
+ #poststuff h3.form_heading {
187
+ font-size:1.1em;
188
+ margin: 40px 0px 10px 0px;
189
+ padding-left: 0px;
190
+ }
191
+
192
+ #poststuff h3.form_heading span {
193
+ font-size:0.8em;
194
+ }
195
+
196
+ div.search-box input#page-search-input {
197
+ width: 129px;
198
+
199
+ }
200
+
201
+
202
+ #wpsc_product_list,
203
+ table.widefat {
204
+ width:100%;
205
+ }
206
+
207
+ table.widefat .column-hidden_alerts {
208
+ display:none;
209
+ }
210
+
211
+ #wpsc_product_list .column-cb,
212
+ table.widefat .column-cb {
213
+ /* width:24px; */
214
+ vertical-align: middle;
215
+ }
216
+ #wpsc_product_list .column-image, #wpsc_product_list .product-image,
217
+ table.widefat .column-image, table.widefat .product-image {
218
+ padding-right: 0px;
219
+ /* width: 42px; */
220
+ }
221
+
222
+ #wpsc_product_list .column-categories,
223
+ table.widefat .column-categories{
224
+ /* width: 70px; */
225
+ padding-right:18px;
226
+ }
227
+
228
+ #wpsc_product_list tbody tr td.column-title,
229
+ table.widefat tbody tr td.column-title {
230
+ border-right:none;
231
+ }
232
+
233
+ #wpsc_product_list tbody tr td.product-image img,
234
+ table.widefat tbody tr td.product-image img {
235
+ margin-top: 4px;
236
+ cursor:move;
237
+ }
238
+
239
+ .newCurrency{
240
+ width:150px;
241
+ }
242
+ div.wpsc_floatleft{
243
+ width:161px;
244
+ float:left;
245
+ }
246
+ div.wpsc_floatleft label {
247
+ line-height: 18px;
248
+ white-space: nowrap;
249
+ }
250
+
251
+ /* Sortable product styling*/
252
+
253
+ table.product_editform {
254
+ width:100%;
255
+ }
256
+
257
+
258
+ #wpsc_product_list .ui-sortable-helper,
259
+ table.widefat .ui-sortable-helper {
260
+ width: 410px;
261
+ margin-left: -1px;
262
+ background-color: #FEFEFE;
263
+ }
264
+
265
+ #wpsc_product_list .ui-sortable-helper td, #wpsc_product_list .ui-sortable-helper th,
266
+ table.widefat .ui-sortable-helper td, table.widefat .ui-sortable-helper th{
267
+ border-top: 1px solid #DFDFDF;
268
+ opacity: .4;
269
+ }
270
+ .product-placeholder {
271
+ border-width: 1px;
272
+ border-style: dashed;
273
+ z-index: 900;
274
+ border-color: #bbb;
275
+ background-color: #eaeaea !important;
276
+ margin: -2px 0 0 -2px;
277
+ height: 50px;
278
+ }
279
+
280
+ div#poststuff table tr td {
281
+ vertical-align:top;
282
+ }
283
+
284
+ div#poststuff textarea {
285
+ width: 100%;
286
+ }
287
+
288
+ div.admin_product_name label {
289
+ display: block;
290
+ float: left;
291
+ }
292
+
293
+ div.admin_product_name {
294
+ position: relative;
295
+
296
+ height: 30px;
297
+ background: #ffffff;
298
+
299
+ border: 1px solid #dfdfdf;
300
+ -moz-border-radius: 6px;
301
+ -khtml-border-radius: 6px;
302
+ -webkit-border-radius: 6px;
303
+ border-radius: 6px;
304
+ }
305
+ div.admin_product_name input.wpsc_product_name {
306
+ border: none;
307
+ }
308
+
309
+ div.admin_product_name a.shorttag_toggle {
310
+ position: absolute;
311
+ top: 0px;
312
+ right: 0px;
313
+ background:url(../../wpsc-core/images/info_icon.jpg) no-repeat scroll 5px 8px;
314
+ border-left:1px solid #DFDFDF;
315
+ display:block;
316
+ height:100%;
317
+ padding:0px 3px 0px 3px;
318
+ width:18px;
319
+ }
320
+
321
+ div#icon_card
322
+ {
323
+ float: left;
324
+ height: 36px;
325
+ margin: 20px 6px 0px 0px;
326
+ width: 36px;
327
+ background: url(../../wpsc-core/images/icon32.png) no-repeat center center;
328
+ }
329
+
330
+ div.admin_product_shorttags {
331
+ width:93%;
332
+ min-width:396px;
333
+ max-width:558px;
334
+
335
+ clear: both;
336
+ padding: 6px;
337
+ font-size: 8pt;
338
+ margin:0 0 0 6px !important;
339
+ border-left:1px solid #DFDFDF;
340
+ border-right:1px solid #DFDFDF;
341
+ border-bottom:1px solid #DFDFDF;
342
+ /* height: 28px; */
343
+ display: none;
344
+ _width:396px;
345
+ background-color: #ffffff;
346
+ }
347
+
348
+ #description {
349
+ margin:0;
350
+ /* width:100%; */
351
+ }
352
+
353
+ h4.product_action_link {
354
+ margin:4px 0px 0px 0px;
355
+ display:block;
356
+ font-weight:bold;
357
+ }
358
+
359
+
360
+
361
+ /* custom meta styling */
362
+ div.product_custom_meta {
363
+ display: block;
364
+ width: 100%;
365
+ vertical-align: top;
366
+ }
367
+ div#poststuff div.product_custom_meta input, div#poststuff div.product_custom_meta textarea {
368
+ width: 100%;
369
+ }
370
+
371
+
372
+ div.product_custom_meta a.add_more_meta {
373
+ display: block;
374
+ float: left;
375
+ margin-top: 18px;
376
+ margin-left: 4px;
377
+ }
378
+
379
+ div.product_custom_meta a.remove_meta {
380
+ display: block;
381
+ margin-left: 4px;
382
+ }
383
+
384
+
385
+ div.product_custom_meta label {
386
+ display: block;
387
+ width: 170px;
388
+ float: left;
389
+ }
390
+
391
+ div.product_custom_meta label input {
392
+ font-size:13px;
393
+ width: 160px !important;
394
+ margin:1px !important;
395
+ padding:3px !important;
396
+ display: block;
397
+ }
398
+
399
+ div.product_custom_meta br {
400
+ clear: both;
401
+ }
402
+
403
+ /* image form styling */
404
+ div.flash-image-uploader {
405
+ display: none;
406
+ }
407
+
408
+ #wpbody-content div.flash-image-uploader #media-items {
409
+ position: relative;
410
+ border: none;
411
+ }
412
+ #wpbody-content div.flash-image-uploader #media-items .progress{
413
+ position: static;
414
+ margin:0 0 6px;
415
+ height: 16px;
416
+ }
417
+
418
+
419
+ button#add-product-image {
420
+ float: left;
421
+ }
422
+
423
+ div#swfupload_img_indicator {
424
+ float: left;
425
+ height: 20px;
426
+ width: 20px;
427
+ display: none;
428
+ }
429
+
430
+ div#swfupload_img_indicator img{
431
+ margin: 4px 2px 2px 4px;
432
+ }
433
+
434
+ ul#gallery_list{
435
+ clear:both;
436
+ list-style-type:none;
437
+ list-style-position: inside;
438
+ cursor: pointer;
439
+ min-height:70px;
440
+ _height:70px;
441
+ padding-left:0px;
442
+ margin: 6px 0px 0px 6px;
443
+ }
444
+
445
+ ul#gallery_list li{
446
+ float:left;
447
+ }
448
+
449
+ ul#gallery_list li *{
450
+ z-index:79;
451
+ }
452
+ ul#gallery_list li.first *{
453
+ z-index:80;
454
+ }
455
+ .ui-selected {
456
+ border:2px dashed #969696;
457
+ }
458
+
459
+ img.deleteButton {
460
+ display:none;
461
+ position:absolute;
462
+ top:-5px;
463
+ right: -1px;
464
+ width:16px;
465
+ height:16px;
466
+ cursor:pointer;
467
+ }
468
+ a.editButton {
469
+ background:#FFFFFF none repeat scroll 0%;
470
+ height:20px;
471
+ display:none;
472
+ position:absolute;
473
+ right:0px;
474
+ top:0px;
475
+ padding-bottom:3px;
476
+ padding-left:3px;
477
+ cursor:pointer;
478
+ }
479
+
480
+ div.image_settings_box {
481
+ position:absolute;
482
+ width:150px;
483
+ display:none;
484
+ margin: -66px 0px 0px 36px;
485
+ _margin: 0px 0px 0px -30px;
486
+ padding-top:2px;
487
+ width:252px;
488
+ z-index:69;
489
+ _z-index:80;
490
+ }
491
+
492
+ a.thickbox img {
493
+ border:medium none;
494
+ }
495
+
496
+ img.previewimage {
497
+ cursor:move;
498
+ height:60px;
499
+ margin-right:4px;
500
+ width:60px;
501
+ }
502
+
503
+ div.lower_settings_box {
504
+ width:234px;
505
+ background-color:white;
506
+ border:1px solid black;
507
+ border-top:1px solid #CCCCCC;
508
+ float:right;
509
+ margin: -1px -6px 0px 0px;
510
+ padding: 2px 0 0 4px;
511
+ background-color:#EAF3FA;
512
+ }
513
+
514
+ div.upper_settings_box {
515
+ width:250px;
516
+ background-color:white;
517
+ border:1px solid black;
518
+ padding:3px 1px 2px 5px;
519
+ }
520
+
521
+ div.upper_image {
522
+ float:left;
523
+ /* border-bottom:1px solid black; */
524
+ padding-left:5px;
525
+ margin-left:-5px;
526
+ _margin-left:-3px;
527
+ margin-right:-7px;
528
+ padding-bottom:4px;
529
+ _padding-bottom:6px;
530
+ _margin-bottom:-2px;
531
+ }
532
+
533
+ div.upper_txt{
534
+ padding-left:22px;
535
+ color:#666666;
536
+ }
537
+
538
+ div.previewimage {
539
+ position:relative;
540
+ }
541
+
542
+ tr.edit_product_image *{
543
+ z-index:80;
544
+ }
545
+
546
+ a.closeimagesettings{
547
+ cursor:pointer;
548
+ margin-left:90px;
549
+ }
550
+
551
+ div.browser-image-uploader {
552
+
553
+ }
554
+
555
+ div.browser-image-uploader h4{
556
+ margin-bottom: 8px;
557
+ }
558
+
559
+ div.image_resize_extra_forms {
560
+ display: none;
561
+ }
562
+
563
+ #wpsc_product_category_and_tag_forms table {
564
+ width: 100%;
565
+ }
566
+
567
+ #wpsc_product_category_and_tag_forms table td.itemfirstcol{
568
+ padding-left:3pt;
569
+ width: 50%;
570
+ }
571
+
572
+ /* variations CSS starts */
573
+
574
+ table.product_variation_listing{
575
+ margin-bottom: 12px;
576
+ }
577
+
578
+ table.product_variation_listing th.variation_name{
579
+ color: #71A4C8;
580
+ font-style: italic;
581
+ text-align: left;
582
+ padding-bottom: 1px;
583
+ }
584
+
585
+ table.product_variation_grid{
586
+ margin-top: 12px;
587
+ }
588
+
589
+ table.product_variation_grid th.variation_name{
590
+ color: #71A4C8;
591
+ font-style: italic;
592
+ text-align: left;
593
+ padding-bottom: 1px;
594
+ }
595
+
596
+ div#edit_variations_container {
597
+ margin-top: 12px;
598
+ }
599
+ table.product_variation_grid {
600
+ border-collapse: collapse;
601
+ margin-top: 0px;
602
+ }
603
+
604
+ table.product_variation_grid tr td, table.product_variation_grid tr th {
605
+ border: 1px solid #cccccc;
606
+ border-collapse: collapse;
607
+ text-align: left;
608
+ }
609
+
610
+ table.product_variation_grid tr th {
611
+ border-bottom: 1px solid #969696;
612
+ }
613
+
614
+ table.product_variation_grid tr th.stock {
615
+ border-bottom: 1px solid #969696;
616
+ width: 50px;
617
+ }
618
+
619
+ table.product_variation_grid tr th.price {
620
+ width: 78px;
621
+ }
622
+
623
+ table.product_variation_grid tr td.variations, table.product_variation_grid tr th {
624
+ padding: 4px 0px 4px 10px;
625
+ }
626
+
627
+ table.product_variation_grid tr td.variations, table.product_variation_grid tr th.variations {
628
+ width: 300px;
629
+ }
630
+
631
+
632
+ table.product_variation_grid tr td input{
633
+ padding: 0px 3px 0px 3px;
634
+ }
635
+
636
+ table.product_variation_grid tr.group_boundary td {
637
+ border-bottom: 1px solid #969696;
638
+ }
639
+
640
+ a.about_this_page_sub {
641
+ text-decoration:underline;
642
+ }
643
+
644
+ table.product_variation_grid tr td, table.product_variation_grid tr th {
645
+ border: 1px solid #cccccc;
646
+ border-collapse: collapse;
647
+ text-align: left;
648
+ }
649
+
650
+ table.product_variation_grid tr.variation_row td {
651
+ border-bottom: none;
652
+ }
653
+
654
+ table.product_variation_grid tr.settings_row td {
655
+ border-top: none;
656
+ padding: 0px !important;
657
+ }
658
+
659
+
660
+ table.product_variation_grid tr.settings_row td div.variation_settings {
661
+ display: none;
662
+ border-top: 1px dotted #cccccc;
663
+ width: 100%;
664
+ min-height: 30px;
665
+ padding: 4px 10px;
666
+
667
+ }
668
+ table.product_variation_grid tr th {
669
+ border-bottom: 1px solid #969696;
670
+ }
671
+
672
+ table.product_variation_grid tr th.stock {
673
+ border-bottom: 1px solid #969696;
674
+ width: 50px;
675
+ }
676
+
677
+ table.product_variation_grid tr th.price {
678
+ width: 78px;
679
+ }
680
+
681
+ table.product_variation_grid tr td.variations, table.product_variation_grid tr th {
682
+ padding: 4px 0px 4px 10px;
683
+ }
684
+
685
+ table.product_variation_grid tr td.variations, table.product_variation_grid tr th.variations {
686
+ width: 300px;
687
+ }
688
+
689
+
690
+ table.product_variation_grid tr td input{
691
+ padding: 0px 3px 0px 3px;
692
+ }
693
+
694
+ table.product_variation_grid tr td input.checkbox{
695
+ display: block;
696
+ margin:6px auto;
697
+ }
698
+
699
+ table.product_variation_grid tr.group_boundary td {
700
+ border-bottom: 1px solid #969696;
701
+ }
702
+
703
+ div#add_product_variation_details {
704
+ margin: 1ex 0px 0px 0px;
705
+ }
706
+
707
+ div#add_product_variation_details table.product_variation_grid {
708
+ margin: 4px 0px 0px 0px;
709
+ }
710
+
711
+ div.variation_checkboxes {
712
+ margin-bottom: 4px;
713
+ }
714
+
715
+ div.variation_checkboxes label {
716
+ display: block;
717
+ margin-bottom: 2px;
718
+ }
719
+
720
+ div.variation_checkboxes label input {
721
+ position: relative;
722
+ top: 2px;
723
+ margin-right: 3px;
724
+ }
725
+
726
+ a.variation_edit_button {
727
+ display: block;
728
+ height: 16px;
729
+ width: 16px;
730
+ margin: 4px auto 0px auto;
731
+
732
+ }
733
+
734
+ div.variation_settings div.variation_settings_contents{
735
+ padding-left: 10px;
736
+ }
737
+
738
+ div.select_variation_file {
739
+ padding-left: 6px;
740
+ }
741
+ div.select_variation_file p {
742
+ margin:0 0 3px;
743
+ }
744
+
745
+ div.select_variation_file p {
746
+ margin:0 0 3px;
747
+ }
748
+
749
+ div.select_variation_file p input {
750
+ position: relative;
751
+ top: 2px;
752
+ }
753
+
754
+
755
+ label.variation_checkbox {
756
+ display: block;
757
+ }
758
+
759
+ div.variation_set{
760
+ }
761
+ div.variation{
762
+ padding-left: 10px;
763
+ }
764
+ /* variations CSS ends */
765
+
766
+
767
+ div#side-sortables input[type="file"] {
768
+ width:250px;
769
+ }
770
+ div.select_product_file, div.edit_select_product_file {
771
+ margin-bottom:0;
772
+ margin-top:3px;
773
+ overflow-x:hidden;
774
+ overflow-y:auto;
775
+ padding:2px 2px 6px;
776
+ position:relative;
777
+ }
778
+
779
+ a.file_delete_button {
780
+ cursor:pointer;
781
+ float:right;
782
+ /* margin-top:-17px; */
783
+ display: block;
784
+ }
785
+
786
+ a.delete_button {
787
+ border-color:-moz-use-text-color -moz-use-text-color #FF0000;
788
+ border-style:none none solid;
789
+ border-width:medium medium 1px;
790
+ color:#FF0000;
791
+ font-size:11px;
792
+ padding:1px 2px;
793
+ text-decoration:none;
794
+ }
795
+ .greytext{
796
+ color:#666666;
797
+ }
798
+ span.small_italic{
799
+ font-style: italic;
800
+ }
801
+ /* Product details form styling ends */
802
+ /*
803
+ * Display Products CSS ends here
804
+ */
805
+
806
+ /* shipping options start here */
807
+ div.wpsc_shipping_options{
808
+ width:100%;
809
+ padding:3px 0;
810
+ }
811
+ .wpsc-shipping-actions{
812
+ visibility:hidden;
813
+ font-size: 10px;
814
+ margin:2px 9em 0 0;
815
+ float:right;
816
+ }
817
+ div.wpsc_shipping_options:hover .wpsc-shipping-actions{
818
+ font-size:10px;
819
+ visibility:visible;
820
+ }
821
+
822
+ /*
823
+ * Product Groups styles start here
824
+ */
825
+ td.firstcol div.postbox div.inside{
826
+ margin: 0px;
827
+ padding: 0px;
828
+ }
829
+
830
+ table#productpage{
831
+ width: 100%;
832
+ clear: both;
833
+ border-collapse: collapse;
834
+ }
835
+
836
+ table#productpage tr td{
837
+ vertical-align: top;
838
+ /* padding: 0px 0px 0px 6px; */
839
+ }
840
+
841
+ table#productpage tr td.secondcol{
842
+ /* width: 60%; */
843
+ /* margin-left: 20px; */
844
+ padding: 0px 2px 0px 16px;
845
+
846
+ }
847
+
848
+
849
+ table.category-edit {
850
+ border-collapse: collapse;
851
+ width: 100%;
852
+ }
853
+
854
+ table.category-edit tr td {
855
+ border: none;
856
+ }
857
+ table.category-edit tr td.column-title {
858
+ width: 450px;
859
+ }
860
+
861
+
862
+ div.category-image-container {
863
+ width: 55px;
864
+ height: 30px;
865
+
866
+ }
867
+
868
+ div.category-image-container img {
869
+ float: left;
870
+ }
871
+ div.category-image-container img.category_indenter {
872
+ margin-right: 3px;
873
+ width:auto;
874
+ float:left;
875
+ }
876
+
877
+
878
+
879
+
880
+
881
+ div#productform{ display: none; width: 99.5%; }
882
+
883
+ div#edititem27{ display: none; width: 586px; }
884
+
885
+ div#productform table tr td{ height: 11px !important; }
886
+
887
+
888
+
889
+
890
+ div#blank_item{ display: block;}
891
+
892
+ #poststuff div#blank_item h3{
893
+ margin-top: 0px;
894
+
895
+ }
896
+
897
+ div#additem{ display: none;}
898
+
899
+ div#productform td.itemfirstcol{ padding-left:4px; vertical-align: top; }
900
+
901
+
902
+
903
+
904
+ div#productform input.text, div#additem input.text{
905
+ width:386px;
906
+ border:1px solid #bbb;
907
+ }
908
+
909
+
910
+ table.category_forms {
911
+ width: 100%;
912
+ }
913
+ table.category_forms tr td {
914
+ padding: 0px;
915
+ padding-right: 8px;
916
+ }
917
+ table.category_forms tr td textarea {
918
+ width: 386px;
919
+ }
920
+
921
+ div#edit_variation_values input.text{width:286px !important;border:1px solid #bbb;}
922
+
923
+ input.image_resize{ position: relative; top: 4px; }
924
+
925
+ div#additem table.additem input.wpsc_tag{
926
+ width:180px;
927
+ }
928
+ div#additem label{
929
+ font-style: normal;
930
+ font-size: 0.95em;
931
+ }
932
+
933
+
934
+
935
+
936
+
937
+ .groupItem{
938
+ border-top:1px solid #bbb;
939
+ width:385px;
940
+ height:35px;
941
+ clear: both;
942
+ /* margin-left:-6px; */
943
+ padding: 0px 0px 4px 0px;
944
+ }
945
+
946
+ .groupItem .itemHeader{
947
+ width:65px;
948
+ line-height: 15px;
949
+ color: #000;
950
+ padding: 4px;
951
+ cursor: move;
952
+ height: 35px;
953
+ position: relative;
954
+ clear: both;
955
+ }
956
+
957
+ .groupItem .itemHeader a{
958
+ margin: 4px 0px 4px 0px;
959
+ font-weight: normal;
960
+ font-size: 11px;
961
+ text-decoration: none;
962
+ }
963
+ .sortHelper{
964
+ border: 3px dashed #666;
965
+ width: auto;
966
+ }
967
+ .groupWrapper p{
968
+ height: 1px;
969
+ overflow: hidden;
970
+ margin: 0;
971
+ padding: 0;
972
+ }
973
+
974
+
975
+ table#productpage tr td.secondcol.product_groups_page {
976
+ padding-left: 16px;
977
+ }
978
+
979
+ table#productpage tr td.secondcol.product_groups_page h4 {
980
+ font-family: inherit;
981
+ margin-top: 20px;
982
+ }
983
+
984
+ td.product_groups_page #additem .inside, td.product_groups_page #productform .inside {
985
+ margin: 0px 0px 15px 0px;
986
+ }
987
+
988
+ div.editing_this_group {
989
+ margin-top: 8px;
990
+ margin-bottom: 8px;
991
+ /* border-bottom:1px dotted black; */
992
+ width:100%;
993
+ }
994
+
995
+ td.product_groups_page h4 {
996
+ margin-bottom: 1ex;
997
+ }
998
+ #editorcontainer{
999
+ clear:both;
1000
+ }
1001
+ td.product_groups_page td.category_presentation_settings {
1002
+ padding-bottom: 1ex;
1003
+ }
1004
+
1005
+ div.editing_this_group {
1006
+ font-size:8pt;
1007
+ }
1008
+
1009
+ div.editing_this_group p {
1010
+ padding:4px 4px 4px 8px;
1011
+ }
1012
+
1013
+ div.editing_this_group dl {
1014
+ padding:4px 4px 4px 8px;
1015
+ }
1016
+
1017
+
1018
+ #blank_item a.add_category_link{
1019
+ display: block;
1020
+ margin: 8px 8px 8px 0px;
1021
+ text-decoration: underline;
1022
+ }
1023
+
1024
+ div.product_group {
1025
+ margin: 12px 0px 10px 0px;
1026
+ }
1027
+
1028
+
1029
+ table#wpsc_category_list td div.subcategory img.category_indenter {
1030
+ float: left;
1031
+ margin: 8px 0px 0px 0px;
1032
+ }
1033
+
1034
+ table#wpsc_category_list td div.subcategory table.itemlist {
1035
+ float: left;
1036
+ }
1037
+
1038
+
1039
+ label.select_categorisation_group, select#select_categorisation_group, a.add_categorisation_group, a.edit_categorisation_group, #submit_categorisation_form span {
1040
+ display: block;
1041
+ float: left;
1042
+ }
1043
+
1044
+ #submit_categorisation_form span {
1045
+ display: block;
1046
+ float: left;
1047
+ margin-left: 10px;
1048
+ }
1049
+
1050
+ #submit_categorisation_form a span {
1051
+ margin-left: 0px;
1052
+ }
1053
+
1054
+ label.select_categorisation_group {
1055
+ padding-top: 4px;
1056
+ /* color: #336699; */
1057
+ font-size: 11px;
1058
+ }
1059
+
1060
+ a.add_categorisation_group {
1061
+ margin-left: 10px;
1062
+ }
1063
+
1064
+ a.edit_categorisation_group {
1065
+ margin-left: 30px;
1066
+ }
1067
+
1068
+
1069
+
1070
+ div#add_categorisation, div#edit_categorisation{
1071
+ display: none;
1072
+ border: 1px solid #BBBBBB;
1073
+ padding: 4px;
1074
+ margin-top: 6px;
1075
+ }
1076
+
1077
+ div#add_categorisation br, div#edit_categorisation br{
1078
+ clear: both;
1079
+ }
1080
+
1081
+
1082
+ div#add_categorisation fieldset, div#edit_categorisation fieldset{
1083
+ width: 230px;
1084
+ float: left;
1085
+ border: none;
1086
+ }
1087
+
1088
+ div#add_categorisation fieldset label, div#edit_categorisation fieldset label{
1089
+ display: block;
1090
+ }
1091
+
1092
+ ul.categorisation_links{
1093
+ list-style-type: none;
1094
+ clear: both;
1095
+ padding: 0px;
1096
+ }
1097
+ .wpsc_add_new_currency{
1098
+ text-decoration: none;
1099
+ }
1100
+ ul.categorisation_links li{
1101
+ display: block;
1102
+ float: left;
1103
+ list-style-type: none;
1104
+ margin: 0px;
1105
+ font-size: 14px;
1106
+ padding: 4px;
1107
+ }
1108
+
1109
+ ul.categorisation_links li.selected a{
1110
+ color: #D54E21;
1111
+ }
1112
+
1113
+ .multiple-select {
1114
+ background: white none repeat scroll 0px 0px;
1115
+ border: 1px solid #DFDFDF;
1116
+ display: inline-block;
1117
+ height: 120px;
1118
+ margin: 10px 0;
1119
+ overflow-x: hidden;
1120
+ overflow-y: auto;
1121
+ padding: 0px;
1122
+ position: relative;
1123
+ width:98%
1124
+ }
1125
+
1126
+ table.category_forms a.delete_button {
1127
+ display: block;
1128
+ margin: 3px 0px 0px 8px;
1129
+ float: left;
1130
+ }
1131
+
1132
+ table.category_forms td.last_row {
1133
+ padding: 16px 0px 0px 0px;
1134
+ }
1135
+
1136
+ .wpsc_gold_float{
1137
+ min-width:45%;
1138
+ float:left;
1139
+ max-width:450px;
1140
+ _width:450px;
1141
+ }
1142
+ .wpsc_gold_side{
1143
+ margin-top:90px;
1144
+ float:right;
1145
+ width:35%;
1146
+ }
1147
+ .wpsc_gold_text{
1148
+ width:70%;
1149
+ float:left;
1150
+ clear:both;
1151
+ }
1152
+
1153
+ .wpsc_gold_info{
1154
+ width:30%;
1155
+ float:right;
1156
+ text-align: center;
1157
+ font-size:20px;
1158
+ }
1159
+ .wpsc_gold_module{
1160
+ width:100%;
1161
+ float:left;
1162
+
1163
+ border-bottom: 1px solid #DFDFDF;
1164
+ }
1165
+ .wpsc_gold_module strong{
1166
+ width:auto;
1167
+ float:left;
1168
+ }
1169
+ #visitInstinct{
1170
+ float:right;
1171
+ margin:5px 20px 0 0;
1172
+ }
1173
+
1174
+
1175
+ #gold_cart_form .postbox p img{
1176
+ padding-bottom:10px;
1177
+ }
1178
+ #wpsc_gold_options_outside{
1179
+ width:400px;
1180
+ }
1181
+ #gold_cart_form .postbox p{
1182
+ padding-left: 4px;
1183
+ }
1184
+ #gold_cart_form .postbox{
1185
+ width:100%;
1186
+ max-width:500px;
1187
+ }
1188
+ #gold_cart_form .postbox p{
1189
+ padding-left:10px;
1190
+ }
1191
+ #gold_cart_form .postbox p label{
1192
+ width:80px;
1193
+ float:left;
1194
+ }
1195
+
1196
+ a.admin_download {
1197
+ display: block;
1198
+ height: 26px;
1199
+ border-bottom: none;
1200
+ text-decoration: none;
1201
+ }
1202
+
1203
+ a.admin_download img{
1204
+ margin-right: 3px;
1205
+ }
1206
+
1207
+ a.admin_download span{
1208
+ text-decoration: underline;
1209
+ }
1210
+
1211
+ /*
1212
+ * Product Groups styles end here
1213
+ */
1214
+ .wpsc_td_note{
1215
+ padding-bottom:0 !important;
1216
+ }
1217
+
1218
+ .wpsc_purchaselogs_options {
1219
+ margin: 0px 0px 8px 0px;
1220
+
1221
+ }
1222
+
1223
+
1224
+ .add_new_form_set {
1225
+ /* display: block;
1226
+ float: left;*/
1227
+ text-decoration: underline;
1228
+ font-weight: bold;
1229
+ font-size:0.9em;
1230
+ }
1231
+
1232
+
1233
+ p.add_new_form_set_forms {
1234
+ display: none;
1235
+ }
1236
+
1237
+ td.product-image a img.attachment-thumbnail {
1238
+ height: 38px;
1239
+ width: 38px;
1240
+
1241
+ }
1242
+
1243
+ #wpsc_product_category_and_tag_forms .tagchecklist {
1244
+ font-size:11px;
1245
+ }
1246
+
1247
+ #categorydiv div{
1248
+ margin-top: 4px;
1249
+ }
1250
+
1251
+ a.variation_handle {
1252
+ color: #CCCCCC;
1253
+ text-decoration: none;
1254
+ font-size: 15px;
1255
+ }
1256
+
1257
+ .toplevel_page_wpsc-edit-products .wrap h2
1258
+ {
1259
+ padding-bottom:0px;
1260
+ border-bottom:1px solid #CCC;
1261
+ }
1262
+ #post-body #advanced-sortables
1263
+ {
1264
+ margin-right:300px
1265
+ }
1266
+ #media-buttons #add_audio,
1267
+ #media-buttons #add_video,
1268
+ #media-buttons #add_media {
1269
+ display:none;
1270
+ }
1271
+ .meta-box-sortables-wpec .postbox:hover .handlediv {
1272
+ background: transparent url(../../wpsc-core/images/menu-bits.gif) no-repeat scroll 0% -111px;
1273
+ }
1274
+ /* Main Flora Style Sheet for jQuery UI ui-datepicker */
1275
+ #ui-datepicker-div, .ui-datepicker-inline {
1276
+ font-family: Arial,Helvetica,sans-serif;
1277
+ font-size: 14px;
1278
+ padding: 0;
1279
+ margin: 0;
1280
+ background: #E0F4D7;
1281
+ width: 185px;
1282
+ }
1283
+ #ui-datepicker-div {
1284
+ display: none;
1285
+ border: 1px solid #21759B;
1286
+ z-index: 10;
1287
+ }
1288
+ .ui-datepicker-inline {
1289
+ float: left;
1290
+ display: block;
1291
+ border: 0;
1292
+ }
1293
+ .ui-datepicker-rtl {
1294
+ direction: rtl;
1295
+ }
1296
+ .ui-datepicker-dialog {
1297
+ padding: 5px !important;
1298
+ border: 4px ridge #fff !important;
1299
+ }
1300
+ button.ui-datepicker-trigger {
1301
+ width: 25px;
1302
+ }
1303
+ img.ui-datepicker-trigger {
1304
+ margin: 2px;
1305
+ vertical-align: middle;
1306
+ }
1307
+ .ui-datepicker-prompt {
1308
+ float: left;
1309
+ padding: 2px;
1310
+ background: #fff;
1311
+ color: #000;
1312
+ }
1313
+ *html .ui-datepicker-prompt {
1314
+ width: 185px;
1315
+ }
1316
+ .ui-datepicker-control, .ui-datepicker-links, .ui-datepicker-header, .ui-datepicker {
1317
+ clear: both;
1318
+ float: left;
1319
+ width: 100%;
1320
+ color: #FFF;
1321
+ }
1322
+ .ui-datepicker-control {
1323
+ background: #fff;
1324
+ padding: 2px 0px;
1325
+ display:none;
1326
+ }
1327
+ .ui-datepicker-links {
1328
+ background: #fff;
1329
+ padding: 2px 0px;
1330
+ }
1331
+ .ui-datepicker-control, .ui-datepicker-links {
1332
+ font-weight: bold;
1333
+ font-size: 80%;
1334
+ letter-spacing: 1px;
1335
+ }
1336
+ .ui-datepicker-links label {
1337
+ padding: 2px 5px;
1338
+ color: #fff;
1339
+ }
1340
+ .ui-datepicker-clear, .ui-datepicker-prev {
1341
+ float: left;
1342
+ width: 34%;
1343
+ }
1344
+ .ui-datepicker-rtl .ui-datepicker-clear, .ui-datepicker-rtl .ui-datepicker-prev {
1345
+ float: right;
1346
+ text-align: right;
1347
+ }
1348
+ .ui-datepicker-current {
1349
+ float: left;
1350
+ width: 30%;
1351
+ text-align: center;
1352
+ }
1353
+ .ui-datepicker-close, .ui-datepicker-next {
1354
+ float: right;
1355
+ width: 34%;
1356
+ text-align: right;
1357
+ }
1358
+ .ui-datepicker-rtl .ui-datepicker-close, .ui-datepicker-rtl .ui-datepicker-next {
1359
+ float: left;
1360
+ text-align: left;
1361
+ }
1362
+ .ui-datepicker-header {
1363
+ padding: 1px 0 3px;
1364
+ background: #fff;
1365
+ text-align: center;
1366
+ font-weight: bold;
1367
+ height: 1.3em;
1368
+ }
1369
+ .ui-datepicker-header select {
1370
+ background: #fff;
1371
+ color: #000;
1372
+ border: 0px;
1373
+ font-weight: bold;
1374
+ }
1375
+ .ui-datepicker {
1376
+ background: #fff;
1377
+ text-align: center;
1378
+ font-size: 100%;
1379
+ }
1380
+ .ui-datepicker a {
1381
+ display: block;
1382
+ width: 100%;
1383
+ }
1384
+ .ui-datepicker-title-row {
1385
+ background: #fff;
1386
+ color: #000;
1387
+ }
1388
+ .ui-datepicker-title-row .ui-datepicker-week-end-cell {
1389
+ background: #fff;
1390
+ }
1391
+ .ui-datepicker-days-row {
1392
+ background: #FFF;
1393
+ color: #666;
1394
+ }
1395
+ .ui-datepicker-week-col {
1396
+ background: #ededed;
1397
+ color: #000;
1398
+ }
1399
+ .ui-datepicker-days-cell {
1400
+ color: #000;
1401
+ border: 1px solid #DDD;
1402
+ }
1403
+ .ui-datepicker-days-cell a {
1404
+ display: block;
1405
+ }
1406
+ .ui-datepicker-week-end-cell {
1407
+ background: #EAF2FA;
1408
+ }
1409
+ .ui-datepicker-unselectable {
1410
+ color: #888;
1411
+ }
1412
+ .ui-datepicker-week-over, .ui-datepicker-week-over .ui-datepicker-week-end-cell {
1413
+ background: #B1DB87 !important;
1414
+ }
1415
+ .ui-datepicker-days-cell-over, .ui-datepicker-days-cell-over.ui-datepicker-week-end-cell {
1416
+ background: #FFF !important;
1417
+ border: 1px solid #777;
1418
+ }
1419
+ * html .ui-datepicker-title-row .ui-datepicker-week-end-cell {
1420
+ background: #ddd !important;
1421
+ }
1422
+ * html .ui-datepicker-week-end-cell {
1423
+ background: #ddd !important;
1424
+ border: 1px solid #DDD !important;
1425
+ }
1426
+ * html .ui-datepicker-days-cell-over {
1427
+ background: #FFF !important;
1428
+ border: 1px solid #777 !important;
1429
+ }
1430
+ * html .ui-datepicker-current-day {
1431
+ background: #d3d3d3 !important;
1432
+ }
1433
+ .ui-datepicker-today {
1434
+ background: #dddddd !important;
1435
+ }
1436
+ .ui-datepicker-current-day {
1437
+ background: #d3d3d3 !important;
1438
+ }
1439
+ .ui-datepicker-status {
1440
+ background: #fff;
1441
+ width: 100%;
1442
+ font-size: 80%;
1443
+ text-align: center;
1444
+ }
1445
+ #ui-datepicker-div a, .ui-datepicker-inline a {
1446
+ cursor: pointer;
1447
+ margin: 0;
1448
+ padding: 0;
1449
+ background: none;
1450
+ color: #000;
1451
+ }
1452
+ .ui-datepicker-inline .ui-datepicker-links a {
1453
+ padding: 0 5px !important;
1454
+ }
1455
+ .ui-datepicker-control a, .ui-datepicker-links a {
1456
+ padding: 2px 5px !important;
1457
+ color: #000 !important;
1458
+ }
1459
+ .ui-datepicker-title-row a {
1460
+ color: #000 !important;
1461
+ }
1462
+ .ui-datepicker-control a:hover {
1463
+ background: #f1f1f1 !important;
1464
+ color: #333 !important;
1465
+ }
1466
+ .ui-datepicker-links a:hover, .ui-datepicker-title-row a:hover {
1467
+ background: #FFF !important;
1468
+ color: #333 !important;
1469
+ }
1470
+ .ui-datepicker-multi .ui-datepicker {
1471
+ /* border: 1px solid #83C948; */
1472
+ }
1473
+ .ui-datepicker-one-month {
1474
+ float: left;
1475
+ width: 185px;
1476
+ }
1477
+ .ui-datepicker-new-row {
1478
+ clear: left;
1479
+ }
1480
+ .ui-datepicker-cover {
1481
+ display: none;
1482
+ display: block;
1483
+ position: absolute;
1484
+ z-index: -1;
1485
+ filter: mask();
1486
+ top: -4px;
1487
+ left: -4px;
1488
+ width: 193px;
1489
+ height: 200px;
1490
+ }
1491
+ /* marketing / coupon page styling */
1492
+
1493
+ div.modify_coupon{ border: 1px solid #eeeeee; display: none; width: 100%; }
1494
+ table.coupon_data{
1495
+ width: 100%;
1496
+ }
1497
+ table.add-coupon{width:100%;}
1498
+ table.add-coupon tr th{ text-align: left; padding: 2px 5px 0px 5px; border: none;}
1499
+ table.add-coupon tr td{ text-align: left; padding: 2px 5px 2px 5px; border: none;}
1500
+ table.add-coupon tr td p{padding:0;margin:5px;}
1501
+ #table_header{
1502
+ font-size:16px;
1503
+ margin-top:20px;
1504
+ font-weight: bold;
1505
+ }
1506
+ table.coupon-list{ width: 100%; }
1507
+ table.coupon-list th{ text-align:left;}
1508
+ table.coupon-list tr.toprow td{ text-align: left; font-weight:bold; }
1509
+
1510
+ table.coupon-list tr td{ padding: 5px 5px 10px 10px; vertical-align: middle;}
1511
+
1512
+ table.coupon-list tr.alt{ background-color: #eeeeee; }
1513
+
1514
+ table.coupon-list tr.alt td{ background-color: #eeeeee; }
1515
+ table.coupon-list tr.coupon_edit td{ padding:0; }
1516
+ td#order_summary_container{ width: 80px; }
1517
+ table.category_forms a.delete_button, span.delete_button {
1518
+ color:#FF0000;
1519
+ display:block;
1520
+ float:left;
1521
+ font-size:11px;
1522
+ margin:3px 0 0 8px;
1523
+ text-decoration:underline;
1524
+ }
1525
+ p span.input_label{
1526
+ font-size:1.2em;
1527
+ width:180px;
1528
+ float:left;
1529
+ }
1530
+ a.wpsc_featured_product_toggle {
1531
+ display: block;
1532
+ height: 18px;
1533
+ width: 18px;
1534
+ margin: 4px 0px 0px 6px;
1535
+ }
1536
+
1537
+ a.wpsc_featured_product_toggle img {
1538
+ display: block;
1539
+ margin: 0px auto 0px auto;
1540
+
1541
+ }
1542
+
1543
+ div.wpsc_clear {
1544
+ clear: both;
1545
+ }
1546
+
1547
+ .wpsc_featured div.product_grid_display div.product_grid_item {
1548
+ width: 100%;
1549
+ height: auto !important;
1550
+ margin: 4px 90px 8px 0;
1551
+ position: relative;
1552
+ }
1553
+
1554
+
1555
+ .wpsc_featured .item_text {
1556
+ float: left;
1557
+ height: 240px;
1558
+ width: auto;
1559
+ }
1560
+
1561
+ .wpsc_featured .item_image {
1562
+ float: left;
1563
+ height: 240px;
1564
+ width: 340px;
1565
+ margin-left: 20px;
1566
+ }
1567
+
1568
+ .wpsc_featured .item_image a {
1569
+ display: block;
1570
+ height: 240px;
1571
+ width: 340px;
1572
+ border: 1px solid #FEFAF1;
1573
+ border-radius: 18px;
1574
+ -moz-border-radius: 18px;
1575
+ -webkit-border-radius: 18px;
1576
+ background-repeat: no-repeat;
1577
+ }
1578
+
1579
+
1580
+ .wpsc_featured .item_text h3 {
1581
+ font-size: 1.4em;
1582
+ margin: 0px 0px 8px 0px;
1583
+ }
1584
+
1585
+ .wpsc_featured .item_text div.pricedisplay {
1586
+ color: #9B9A96;
1587
+ line-height: normal;
1588
+ display: block;
1589
+ margin: 0px 0px 4px 0px;
1590
+
1591
+ }
1592
+
1593
+ .wpsc_featured .item_text .wpsc_description {
1594
+ font-size: 1em;
1595
+ line-height:24px;
1596
+ display:block;
1597
+ float:left;
1598
+ width: auto;
1599
+ color: #9B9A96;
1600
+ font-family: Georgia,"Bitstream Charter",serif;
1601
+ }
1602
+
1603
+ .wpsc_featured .item_text .wpsc_description p {
1604
+ margin-bottom: 0px;
1605
+ }
1606
+
1607
+
1608
+ .wpsc_featured .item_text .wpsc_description a {
1609
+ color:#9B9A96;
1610
+ }
1611
+
1612
+ ul.wpsc_categories {
1613
+ clear: both;
1614
+ }
1615
+
1616
+ a.update_variations, a.update_variations_action
1617
+ {
1618
+ float:left;
1619
+ margin:10px;
1620
+ }
1621
+ a.update_variations_action {
1622
+ display:none;
1623
+ }
1624
+ #search-products{
1625
+ width:auto;
1626
+ float:right;
1627
+ }
1628
+ .productnav{
1629
+ height: 30px;
1630
+ margin: 6px 0px 4px;
1631
+ vertical-align: middle;
1632
+ }
1633
+
1634
+ .wpsc_stock_control_forms .edit_stock {
1635
+ margin-top:0.5em;
1636
+ line-height:16px;
1637
+ }
1638
+ .wpsc_stock_control_forms .unpublish_when_none_left {
1639
+ margin:0.5em 0;
1640
+ }
1641
+ #media-upload form p.help {
1642
+ text-align:left;
1643
+ clear:both;
1644
+ }
1645
+ ul#category_list_li, ul.poll-options {
1646
+ }
1647
+ ul#category_list_li li div,
1648
+ ul#category_list_li li div ul li div {
1649
+ }
1650
+ ul#category_list_li li div div,
1651
+ ul#category_list_li li div ul li div div {
1652
+
1653
+ }
1654
+ ul#category_list_li li div:hover div{
1655
+ }
1656
+
1657
+ ul#category_list_li li div ul li div:hover div {
1658
+ }
1659
+ ul#category_list_li li {
1660
+ }
1661
+ ul#category_list_li li:hover span.handle {
1662
+ cursor: move;
1663
+ }
1664
+ .edit{
1665
+ }
1666
+ ul#category_list_li li span.handle {
1667
+ float:left;
1668
+
1669
+ padding: 5px;
1670
+
1671
+ }
1672
+
1673
+ .category_admin_list_img a.row-title{
1674
+ text-decoration: none;
1675
+ }
1676
+
1677
+
1678
+ .category_admin_list_img:hover div.row-actions {
1679
+ visibility:visible;
1680
+ }
1681
+
1682
+ ul#category_list_li ul {
1683
+ margin-left:15px;
1684
+ }
1685
+
1686
+ .row-title img {
1687
+ width:30px;
1688
+ float:left;
1689
+ padding-right:10px;
1690
+ }
1691
+ .row-title {
1692
+ margin-right:5px;
1693
+ }
1694
+ body.edit-php form#posts-filter {
1695
+ min-width:830px;
1696
+ }
1697
+ div#wpsc-variationdiv {
1698
+ display:none;
1699
+ }
1700
+ input.wpsc_cat_image_size {
1701
+ width:40px
1702
+ }
1703
+ input.wpsc_cat_box {
1704
+ width:auto;
1705
+ margin:6px;
1706
+ }
1707
+ .wpsc_ie_field, .wpsc_inline_actions {
1708
+ display:none;
1709
+ }
1710
+ .wpsc_ie_field{
1711
+ width:100%;
1712
+ }
1713
+ .wpsc_inline_actions .loading_indicator {
1714
+ position:relative;
1715
+ top:3px;
1716
+ left:2px;
1717
+ visibility: hidden;
1718
+ }
1719
+ table.tags th#image {
1720
+ width:60px;
1721
+ }
1722
+ /* quick edit product */
1723
+ fieldset.wpsc-cols {
1724
+ width:30% !important;
1725
+ float:left !important;
1726
+ }
1727
+
1728
+ .inline-edit-col-left {
1729
+ width:38% !important;
1730
+ }
1731
+
1732
+ .wpsc-quick-edit {
1733
+ width: 30%;
1734
+ float:left;
1735
+ }
1736
+
1737
+ textarea.tax_input_product_tag {
1738
+ width:50% !important;
1739
+ height: 95px !important;
1740
+ }
1741
+
1742
+ ul.wpsc_product_category-checklist {
1743
+ height: 280px;
1744
+ }
1745
+
1746
+ span.wpsc-quick-edit{
1747
+ width:75px;
1748
+ display: block;
1749
+ float: left;
1750
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-admin/css/settingspage.css CHANGED
@@ -96,9 +96,9 @@ table#gateway_options {
96
  width:100%;
97
  }
98
  /* admin checkout page css */
99
- div#form_field_form_container{ padding: 0px; margin: 0px; }
100
 
101
- div#form_field_form_container div, div#form_field_form_container div table{ padding: 0px; margin: 0px; width: 100%; border-collapse: collapse; }
102
  table#form_field_table tr td.namecol{ }
103
 
104
  table#form_field_table tr *.namecol{ width: 170px; padding-right: 8px; }
96
  width:100%;
97
  }
98
  /* admin checkout page css */
99
+ div#form_field_form_container{ padding: 0px; margin: 0px; }
100
 
101
+ div#form_field_form_container div, div#form_field_form_container div table{ padding: 0px; margin: 0px; width: 100%; border-collapse: collapse; }
102
  table#form_field_table tr td.namecol{ }
103
 
104
  table#form_field_table tr *.namecol{ width: 170px; padding-right: 8px; }
wpsc-admin/display-coupons.php CHANGED
@@ -2,7 +2,6 @@
2
 
3
  function wpsc_display_coupons_page() {
4
  global $wpdb;
5
-
6
  if ( isset( $_POST ) && is_array( $_POST ) && !empty( $_POST ) ) {
7
 
8
  if ( isset( $_POST['add_coupon'] ) && ($_POST['add_coupon'] == 'true') && (!isset( $_POST['is_edit_coupon'] ) || !($_POST['is_edit_coupon'] == 'true')) ) {
2
 
3
  function wpsc_display_coupons_page() {
4
  global $wpdb;
 
5
  if ( isset( $_POST ) && is_array( $_POST ) && !empty( $_POST ) ) {
6
 
7
  if ( isset( $_POST['add_coupon'] ) && ($_POST['add_coupon'] == 'true') && (!isset( $_POST['is_edit_coupon'] ) || !($_POST['is_edit_coupon'] == 'true')) ) {
wpsc-admin/display-groups.page.php CHANGED
@@ -1,541 +1,7 @@
1
  <?php
2
- /**
3
- * WP eCommerce edit and add product category page functions
4
- *
5
- * These are the main WPSC Admin functions
6
- *
7
- * @package wp-e-commerce
8
- * @since 3.7
9
- */
10
-
11
- function wpsc_ajax_set_category_order(){
12
- global $wpdb;
13
- $sort_order = $_POST['sort_order'];
14
- $parent_id = $_POST['parent_id'];
15
-
16
- $result = true;
17
- foreach($sort_order as $key=>$value){
18
- if(!wpsc_update_meta($value, 'sort_order', $key, 'wpsc_category')){
19
- $result = false;
20
- }
21
- }
22
- }
23
-
24
-
25
- /**
26
- * wpsc_display_categories_page, assembles the category page
27
- * @param nothing
28
- * @return nothing
29
- */
30
-
31
- function wpsc_display_categories_page() {
32
- $output = "";
33
- $columns = array(
34
- 'img' => __('Image', 'wpsc'),
35
- 'title' => __('Name', 'wpsc')
36
- );
37
- register_column_headers('display-categories-list', $columns);
38
-
39
- ?>
40
- <script language='javascript' type='text/javascript'>
41
- function conf() {
42
- var check = confirm("<?php _e('Are you sure you want to delete this category?', 'wpsc');?>");
43
- if(check) {
44
- return true;
45
- } else {
46
- return false;
47
- }
48
- }
49
- function categorySort(order, parent){
50
- var data = {
51
- action: 'category_sort_order',
52
- sort_order: order,
53
- parent_id: parent
54
- };
55
-
56
- var id = '#debugData_';
57
- // Send an Ajax Request to get the WinRetail SQL Dump good for Debugging
58
- jQuery.post(ajaxurl, data, function(response) {
59
- jQuery(id).append(response);
60
- });
61
- return false;
62
- }
63
-
64
- </script>
65
- <noscript></noscript>
66
-
67
- <div class="wrap">
68
-
69
- <h2><?php echo esc_html( __('Product Categories', 'wpsc') );
70
- if ( isset( $_GET["category_id"] ) ) {
71
- $sendback = remove_query_arg('category_id');
72
- echo "<a class='button add-new-h2' href='".$sendback."' title='Add New'>".__('Add New', 'wpsc')."</a>";
73
- }
74
- ?> </h2>
75
-
76
- <?php if (isset($_GET['deleted']) || isset($_GET['message'])) { ?>
77
- <div id="message" class="updated fade">
78
- <p>
79
- <?php
80
- if ( isset($_GET['deleted']) ) {
81
- _e("Thanks, the category has been deleted", 'wpsc');
82
- remove_query_arg('deleted');
83
- unset($_GET['deleted']);
84
- }
85
-
86
-
87
- if ( isset($_GET['message']) ) {
88
- if ( 'empty_term_name' == $_GET['message'] )
89
- _e("Please give a category name", 'wpsc');
90
- elseif( 'term_exists' == $_GET['message'])
91
- _e('A term with the name provided already exists with this parent.','wpsc');
92
- else
93
- _e("Thanks, the category has been edited", 'wpsc');
94
- unset($_GET['message']);
95
- remove_query_arg('message');
96
- }
97
-
98
- $sendback = remove_query_arg( array('deleted', 'message'), $sendback );
99
- ?>
100
- </p>
101
- </div>
102
- <?php } ?>
103
-
104
- <div id="col-container">
105
-
106
- <div id="col-right" style="width:39%">
107
- <div class="col-wrap">
108
- <?php wpsc_admin_category_group_list();?>
109
- </div>
110
- </div>
111
-
112
- <div id="col-left" style="width:59%">
113
- <div class="col-wrap">
114
- <div class="form-wrap">
115
-
116
- <?php if ( isset( $_GET["category_id"] ) ) {
117
-
118
- $product = get_term($_GET["category_id"], "wpsc_product_category" );
119
-
120
- $output .= "<h3 class='hndle'>".str_replace("[categorisation]", (stripslashes($product->name)), __('You are editing the &quot;[categorisation]&quot; Category', 'wpsc'))."</h3>\n\r";
121
- echo $output;
122
- }else{
123
- echo "<h3>" . __('Add New Category', 'wpsc')."</h3>";
124
- } ?>
125
- <form id="modify-category-groups" method="post" action="" enctype="multipart/form-data" >
126
- <?php
127
- $category_id = null;
128
- if (isset($_GET['category_id']))
129
- $category_id = $_GET['category_id'];
130
- wpsc_admin_category_forms($category_id);
131
- ?>
132
- </form>
133
- <?php if ( isset( $category_id ) ) { echo "</div>";} ?>
134
- </div>
135
- </div><!-- form-wrap -->
136
- </div><!-- col-wrap" -->
137
- </div><!-- col-left -->
138
- </div> <!-- col-container -->
139
- <?php
140
- }
141
-
142
- /**
143
- * wpsc_admin_category_group_list, prints the right hand side of the edit categories page
144
- * @param nothing
145
- * @return nothing
146
- */
147
-
148
- function wpsc_admin_category_group_list() {
149
- global $wpdb;
150
- $category_list = wpsc_admin_get_category_array();
151
-
152
- ?>
153
- <script type="text/javascript">
154
- jQuery(document).ready(function(){
155
- jQuery('#category_list_li').sortable({
156
- axis: 'y',
157
- containment: 'parent',
158
- handle: '.handle',
159
- tolerance: 'pointer',
160
- update: function(event, ui){
161
- categorySort(jQuery('#category_list_li').sortable('toArray'), 0);
162
- }
163
- });
164
- });
165
- </script>
166
- <div id='poststuff' class='postbox'>
167
- <h3 class='hndle'><?php _e('Product Categories', 'wpsc'); ?></h3>
168
- <div class="inside">
169
- <ul id='category_list_li' class='ui-sortable'>
170
- <?php
171
-
172
- print wpsc_admin_list_category_array($category_list); ?>
173
- </ul>
174
- </div>
175
- </div>
176
- <?php
177
- }
178
-
179
- /**
180
- * Create the actual drag and drop list used for the admin category view
181
- *
182
- * @param array $categories
183
- * @param int $level
184
- * @return string $output
185
- */
186
- function wpsc_admin_list_category_array($categories, $level = 0){
187
- $output = '';
188
- foreach($categories as $cat){
189
-
190
- $output .= "<li id='".$cat['id']."'>";
191
- $output .= "<div id='category-".$cat['id']."-container'>";
192
-
193
- $output .= "<div class='category_admin_list_img' id='category-".$cat['id']."-imgs'>";
194
- $output .= "<span title='click and drag to move' class='handle'>↕</span>";
195
- if($level > 0){
196
- $output .= "<img class='category_indenter' src='".WPSC_CORE_IMAGES_URL."/indenter.gif' alt='' title='' />";
197
- }
198
- $output .= "<a class='row-title' href='".add_query_arg('category_id', $cat['id'])."'>";
199
- if(isset($cat['image'])){
200
- $output .= "<img src=\"".WPSC_CATEGORY_URL.stripslashes($cat['image'])."\" title='".$cat['name']."' alt='".$cat['name']."' width='30' height='30' />";
201
- }else{
202
- $output .= "<img src='".WPSC_CORE_IMAGES_URL."/no-image-uploaded.gif' title='".$cat['name']."' alt='".$cat['name']."' width='30' height='30' />";
203
- }
204
- $output .= stripslashes($cat['name'])."</a>";
205
-
206
- $output .= "<div class='row-actions'><span class='edit'><a class='edit-product' style='cursor:pointer;' title='Edit This Category' href='".add_query_arg('category_id', $cat['id'])."'>". __('Edit', 'wpsc')."</a>";
207
- $output .= "</span> | <span class='edit'>";
208
- $nonced_url = wp_nonce_url("admin.php?wpsc_admin_action=wpsc-delete-category&amp;deleteid={$cat['id']}", 'delete-category');
209
- $output .= "<a class='delete_button' style='text-decoration:none;' href='".$nonced_url."' onclick=\"return conf();\" >". __('Delete', 'wpsc')."</a>";
210
- $output .= "</span></div>";
211
- $output .= "</div>";
212
- if(is_array($cat['children'])){
213
- $newhandle = "category-".$cat['id']."-children";
214
- $output .= <<<EOT
215
- <script type="text/javascript">
216
- jQuery(document).ready(function(){
217
- jQuery('#{$newhandle}').sortable({
218
- axis: 'y',
219
- containment: 'parent',
220
- handle: '.handle',
221
- tolerance: 'pointer',
222
- update: function(event, ui){
223
- categorySort(jQuery('#{$newhandle}').sortable('toArray'), 0);
224
- }
225
- });
226
- });
227
- </script>
228
- EOT;
229
- $output .= "<ul id='{$newhandle}' class='ui-sortable'>";
230
- $output .= wpsc_admin_list_category_array($cat['children'], ($level + 1));
231
- $output .= "</ul>";
232
- }
233
- $output .= "</div></li>";
234
-
235
- }
236
- return $output;
237
- }
238
-
239
- /**
240
- * wpsc_admin_get_category_array
241
- * Recursively step through the categories and return it in a clean multi demensional array
242
- * for use in other list functions
243
- * @param int $parent_id
244
- */
245
- function wpsc_admin_get_category_array($parent_id = null){
246
- global $wpdb;
247
-
248
- $orderedList = array();
249
- if(!isset($parent_id)) $parent_id = 0;
250
- $category_list = get_terms('wpsc_product_category','hide_empty=0&parent='.$parent_id);
251
- if(!is_array($category_list)){
252
- return false;
253
- }
254
- foreach($category_list as $category){
255
- $category_order = wpsc_get_categorymeta($category->term_id, 'order');
256
- $category_image = wpsc_get_categorymeta($category->term_id, 'image');
257
- if(!isset($category_order) || $category_order == 0) $category_order = (count($orderedList) +1);
258
- print "<!-- setting category Order number to ".$category_order."-->";
259
- $orderedList[$category_order]['id'] = $category->term_id;
260
- $orderedList[$category_order]['name'] = $category->name;
261
- $orderedList[$category_order]['image'] = $category_image;
262
- $orderedList[$category_order]['parent_id'] = $parent_id;
263
- $orderedList[$category_order]['children'] = wpsc_admin_get_category_array($category->term_id);
264
- }
265
-
266
- ksort($orderedList);
267
- return($orderedList);
268
- }
269
-
270
-
271
-
272
  /*
273
- * wpsc_admin_category_group_list, prints the left hand side of the edit categories page
274
- * @param int $category_id the category ID
275
- * nothing returned
276
  */
277
- function wpsc_admin_category_forms($category_id = null) {
278
- global $wpdb;
279
- $category_value_count = 0;
280
- $category_name = '';
281
- $category = array();
282
-
283
- if($category_id > 0 ) {
284
- $category_id = absint($category_id);
285
-
286
- $category = get_term($category_id, 'wpsc_product_category', ARRAY_A);
287
- $category['nice-name'] = wpsc_get_categorymeta($category['term_id'], 'nice-name');
288
- $category['description'] = wpsc_get_categorymeta($category['term_id'], 'description');
289
- $category['image'] = wpsc_get_categorymeta($category['term_id'], 'image');
290
- $category['fee'] = wpsc_get_categorymeta($category['term_id'], 'fee');
291
- $category['active'] = wpsc_get_categorymeta($category['term_id'], 'active');
292
- $category['order'] = wpsc_get_categorymeta($category['term_id'], 'order');
293
- $category['display_type'] = wpsc_get_categorymeta($category['term_id'], 'display_type');
294
- $category['image_height'] = wpsc_get_categorymeta($category['term_id'], 'image_height');
295
- $category['image_width'] = wpsc_get_categorymeta($category['term_id'], 'image_width');
296
- }
297
-
298
- ?>
299
-
300
- <div class="form-field">
301
- <label for="tag-name"><?php _e('Name', 'wpsc'); ?></label>
302
- <input type='text' class="text" size='40' name='name' value='<?php if(isset($category['name'])) echo $category['name']; ?>' />
303
- </div>
304
-
305
- <div class="form-field">
306
- <label for="cat-parent"><?php _e('Description', 'wpsc'); ?></label>
307
- <textarea name='description' cols='40' rows='8' ><?php if (isset($category['description'])) echo stripslashes($category['description']); ?></textarea>
308
- </div>
309
-
310
- <div class="form-field">
311
- <label for="parent"><?php _e('Category Parent', 'wpsc'); ?></label><?php
312
- $taxonomies = array('wpsc_product_category');
313
- $args = array('orderby'=>'name', 'hide_empty' => 0);
314
- $parent = '';
315
- $current_term_id = '';
316
-
317
- if (isset($category['parent']))
318
- $parent = $category['parent'];
319
-
320
- if (isset($category['term_id']))
321
- $current_term_id = $category['term_id'];
322
-
323
- $select = wpsc_parent_category_list($taxonomies, $args,$parent,$current_term_id);
324
- echo $select;?>
325
- </div>
326
-
327
- <h3><?php _e('Advanced Settings', 'wpsc'); ?></h3>
328
-
329
- <div id="poststuff" class="postbox">
330
- <h3 class="hndle"><?php _e('Presentation Settings'); ?></h3>
331
-
332
- <div class="inside">
333
- <input type='file' name='image' value='' /><br /><br />
334
-
335
- <tr>
336
- <td>
337
- <?php _e('Catalog View', 'wpsc'); ?>
338
- </td>
339
- <td>
340
- <?php
341
- if (!isset($category['display_type'])) $category['display_type'] = '';
342
-
343
- if ($category['display_type'] == 'grid') {
344
- $display_type1="selected='selected'";
345
- } else if ($category['display_type'] == 'default') {
346
- $display_type2="selected='selected'";
347
- }
348
-
349
- switch($category['display_type']) {
350
- case "default":
351
- $category_view1 = "selected ='selected'";
352
- break;
353
-
354
- case "grid":
355
- if(function_exists('product_display_grid')) {
356
- $category_view3 = "selected ='selected'";
357
- break;
358
- }
359
-
360
- case "list":
361
- if(function_exists('product_display_list')) {
362
- $category_view2 = "selected ='selected'";
363
- break;
364
- }
365
-
366
- default:
367
- $category_view0 = "selected ='selected'";
368
- break;
369
- }?>
370
- <span class='small'><?php _e('To over-ride the presentation settings for this group you can enter in your prefered settings here', 'wpsc'); ?></span><br /><br />
371
-
372
- <select name='display_type'>
373
- <option value=''<?php echo $category_view0; ?> ><?php _e('Please select', 'wpsc'); ?></option>
374
- <option value='default' <?php if (isset($category_view1)) echo $category_view1; ?> ><?php _e('Default View', 'wpsc'); ?></option>
375
-
376
- <?php if(function_exists('product_display_list')) {?>
377
- <option value='list' <?php echo $category_view2; ?>><?php _e('List View', 'wpsc'); ?></option>
378
- <?php } else { ?>
379
- <option value='list' disabled='disabled' <?php if (isset($category_view2)) echo $category_view2; ?>><?php _e('List View', 'wpsc'); ?></option>
380
- <?php } ?>
381
- <?php if(function_exists('product_display_grid')) { ?>
382
- <option value='grid' <?php if (isset($category_view3)) echo $category_view3; ?>><?php _e('Grid View', 'wpsc'); ?></option>
383
- <?php } else { ?>
384
- <option value='grid' disabled='disabled' <?php if (isset($category_view3)) echo $category_view3; ?>><?php _e('Grid View', 'wpsc'); ?></option>
385
- <?php } ?>
386
- </select><br /><br />
387
- </td>
388
- </tr>
389
-
390
-
391
- <?php if(function_exists("getimagesize")) { ?>
392
- <tr>
393
- <td>
394
- <?php _e('Thumbnail&nbsp;Size', 'wpsc'); ?>
395
- </td>
396
- <td>
397
- <?php _e('Height', 'wpsc'); ?> <input type='text' value='<?php if (isset($category['image_height'])) echo $category['image_height']; ?>' name='image_height' size='6'/>
398
- <?php _e('Width', 'wpsc'); ?> <input type='text' value='<?php if (isset($category['image_width'])) echo $category['image_width']; ?>' name='image_width' size='6'/> <br/>
399
- </td>
400
- </tr>
401
- <?php }
402
- _e('Delete Image', 'wpsc'); ?><input type='checkbox' name='deleteimage' value='1' /><br/><br/>
403
- </div>
404
- </div>
405
-
406
- <!-- SHORT CODE META BOX only display if product has been created -->
407
-
408
- <?php if ( isset( $_GET["category_id"] ) ) {?>
409
-
410
- <div id="poststuff" class="postbox">
411
- <h3 class="hndle"><?php _e('Shortcodes and Template Tags'); ?></h3>
412
- <div class="inside">
413
- <?php
414
- $output = '';
415
- $product = get_term($_GET["category_id"], "wpsc_product_category" );
416
- $output .= " <span class='wpscsmall description'>Template tags and Shortcodes are used to display a particular category or group within your theme / template or any wordpress page or post.</span>\n\r";
417
- $output .="<div class='inside'>\n\r";
418
- $output .="<div class='editing_this_group form_table'>";
419
- $output .="<dl>\n\r";
420
- $output .="<dt>Display Category Shortcode: </dt>\n\r";
421
- $output .="<dd> [wpsc_products category_url_name='{$product->slug}']</dd>\n\r";
422
- $output .="<dt>Display Category Template Tag: </dt>\n\r";
423
- $output .="<dd> &lt;?php echo wpsc_display_products_page(array('category_url_name'=>'{$product->slug}')); ?&gt;</dd>\n\r";
424
- $output .="</dl>\n\r";
425
- $output .= "</div></div>";
426
- $output .= "</div>";
427
- $output .= "</div>";
428
- echo $output;
429
- }?>
430
-
431
- <!-- START OF TARGET MARKET SELECTION -->
432
- <div id="poststuff" class="postbox">
433
- <h3 class="hndle"><?php _e('Target Market Restrictions'); ?></h3>
434
- <div class="inside"><?php
435
- $category_id = '';
436
- if (isset($_GET["category_id"])) $category_id = $_GET["category_id"];
437
- $countrylist = $wpdb->get_results("SELECT id,country,visible FROM `".WPSC_TABLE_CURRENCY_LIST."` ORDER BY country ASC ",ARRAY_A);
438
- $selectedCountries = wpsc_get_meta($category_id,'target_market','wpsc_category');
439
- $output = '';
440
- $output .= " <tr>\n\r";
441
- $output .= " <td>\n\r";
442
- $output .= __('Target Markets', 'wpsc').":\n\r";
443
- $output .= " </td>\n\r";
444
- $output .= " <td>\n\r";
445
-
446
- if(@extension_loaded('suhosin')) {
447
- $output .= "<em>".__("The Target Markets feature has been disabled because you have the Suhosin PHP extension installed on this server. If you need to use the Target Markets feature then disable the suhosin extension, if you can not do this, you will need to contact your hosting provider.
448
- ",'wpsc')."</em>";
449
-
450
- } else {
451
- $output .= "<span>Select: <a href='' class='wpsc_select_all'>All</a>&nbsp; <a href='' class='wpsc_select_none'>None</a></span><br />";
452
- $output .= " <div id='resizeable' class='ui-widget-content multiple-select'>\n\r";
453
- foreach($countrylist as $country){
454
- if(in_array($country['id'], (array)$selectedCountries)){
455
- $output .= " <input type='checkbox' name='countrylist2[]' value='".$country['id']."' checked='".$country['visible']."' />".$country['country']."<br />\n\r";
456
- } else {
457
- $output .= " <input type='checkbox' name='countrylist2[]' value='".$country['id']."' />".$country['country']."<br />\n\r";
458
- }
459
- }
460
- $output .= " </div><br /><br />";
461
- $output .= " <span class='wpscsmall description'>Select the markets you are selling this category to.<span>\n\r";
462
- }
463
- $output .= " </td>\n\r";
464
- $output .= " </tr>\n\r";
465
-
466
- echo $output;
467
- ?>
468
- </div>
469
- </div>
470
-
471
- <!-- Checkout settings -->
472
- <div id="poststuff" class="postbox">
473
- <h3 class="hndle"><?php _e('Checkout Settings', 'wpsc'); ?></h3>
474
- <div class="inside">
475
- <table class='category_forms'>
476
- <?php
477
- if (!isset($category['term_id'])) $category['term_id'] = '';
478
- $used_additonal_form_set = wpsc_get_categorymeta($category['term_id'], 'use_additonal_form_set'); ?>
479
- <tr>
480
- <td>
481
- <?php _e("This category requires additional checkout form fields",'wpsc'); ?>
482
- </td>
483
- <td>
484
- <select name='use_additonal_form_set'>
485
- <option value=''><?php _e("None",'wpsc'); ?></option>
486
- <?php
487
- $checkout_sets = get_option('wpsc_checkout_form_sets');
488
- unset($checkout_sets[0]);
489
-
490
- foreach((array)$checkout_sets as $key => $value) {
491
- $selected_state = "";
492
- if($used_additonal_form_set == $key)
493
- $selected_state = "selected='selected'";
494
- ?>
495
- <option <?php echo $selected_state; ?> value='<?php echo $key; ?>'><?php echo stripslashes($value); ?></option>
496
- <?php
497
- }
498
- ?>
499
- </select>
500
- </td>
501
- </tr>
502
- <?php $uses_billing_address = (bool)wpsc_get_categorymeta($category['term_id'], 'uses_billing_address'); ?>
503
- <tr>
504
- <td>
505
- <?php _e("Products in this category use the billing address to calculate shipping",'wpsc'); ?>
506
- </td>
507
- <td>
508
- <input type='radio' value='1' name='uses_billing_address' <?php echo (($uses_billing_address == true) ? "checked='checked'" : ""); ?> /><?php _e("Yes",'wpsc'); ?>
509
- <input type='radio' value='0' name='uses_billing_address' <?php echo (($uses_billing_address != true) ? "checked='checked'" : ""); ?> /><?php _e("No",'wpsc'); ?>
510
- </td>
511
- </tr>
512
- </table>
513
- </div>
514
- </div>
515
-
516
- <table class="category_forms">
517
- <tr>
518
- <td>
519
- <?php wp_nonce_field('edit-category', 'wpsc-edit-category'); ?>
520
- <input type='hidden' name='wpsc_admin_action' value='wpsc-category-set' />
521
-
522
- <?php if($category_id > 0) { ?>
523
- <?php
524
- $nonced_url = wp_nonce_url("admin.php?wpsc_admin_action=wpsc-delete-category&amp;deleteid={$category_id}", 'delete-category');
525
- ?>
526
- <input type='hidden' name='category_id' value='<?php echo $category_id; ?>' />
527
- <input type='hidden' name='submit_action' value='edit' />
528
- <input class='button-primary' style='float:left;' type='submit' name='submit' value='<?php _e('Edit Category', 'wpsc'); ?>' />
529
- <a class='delete_button' style="text-decoration:none;" href='<?php echo $nonced_url; ?>' onclick="return conf();" ><?php _e('Delete', 'wpsc'); ?></a>
530
- <?php } else { ?>
531
- <input type='hidden' name='submit_action' value='add' />
532
- <input class='button-primary' type='submit' name='submit' value='<?php _e('Add Category', 'wpsc');?>' />
533
- <?php } ?>
534
- </td>
535
- </tr>
536
- </table>
537
- <?php
538
- }
539
-
540
 
541
  ?>
1
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  /*
3
+ * Deprecated file
4
+ * @since 3.8
 
5
  */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
 
7
  ?>
wpsc-admin/display-items.page.php CHANGED
@@ -1,610 +1,363 @@
1
- <?php
2
- /**
3
- * WP eCommerce edit and add product page functions
4
- *
5
- * These are the main WPSC Admin functions
6
- *
7
- * @package wp-e-commerce
8
- * @since 3.7
9
- */
10
- require_once(WPSC_FILE_PATH . '/wpsc-admin/includes/products.php');
11
-
12
- function wpsc_display_edit_products_page() {
13
- global $wpdb, $wp_query, $wpsc_products;
14
-
15
- $category_id = 0;
16
- if ( isset( $_GET['category_id'] ) )
17
- $category_id = absint( $_GET['category_id'] );
18
-
19
- $columns = array(
20
- 'cb' => '<input type="checkbox" />',
21
- 'image' => '',
22
- 'title' => __('Name'),
23
- 'weight' => __('Weight'),
24
- 'stock' => __('Stock'),
25
- 'price' => __('Price'),
26
- 'sale_price' => __('Sale Price'),
27
- 'SKU' => __('SKU'),
28
- 'categories' => __('Categories'),
29
- 'featured' => __('Featured'),
30
- );
31
- if ( isset( $_GET["product"] ) && $_GET["product"] != '' ) {
32
- unset( $columns["categories"] );
33
- }
34
- $columns = apply_filters( 'manage_display-product-list_columns', $columns );
35
-
36
- register_column_headers( 'display-product-list', $columns );
37
-
38
- $baseurl = includes_url( 'js/tinymce' );
39
- ?>
40
- <div class="wrap">
41
- <div id="icon_card"><br /></div>
42
- <h2>
43
- <a href="admin.php?page=wpsc-edit-products" class="nav-tab nav-tab-active" id="manage"><?php echo esc_html( __( 'Manage Products', 'wpsc' ) ); ?></a>
44
- <a href="<?php echo wp_nonce_url( "admin.php?page=wpsc-edit-products&amp;action=wpsc_add_edit", "_add_product" ); ?>" class="nav-tab" id="add"><?php _e( 'Add New', 'wpsc' ); ?></a>
45
- </h2>
46
- <?php if ( isset( $_GET['ErrMessage'] ) && isset( $_SESSION['product_error_messages'] ) && is_array( $_SESSION['product_error_messages'] ) ) { ?>
47
- <div id="message" class="error fade">
48
- <p>
49
- <?php
50
- foreach ( $_SESSION['product_error_messages'] as $error ) {
51
- echo $error;
52
- }
53
- ?>
54
- </p>
55
- </div>
56
- <?php unset( $_GET['ErrMessage'] ); ?>
57
- <?php $_SESSION['product_error_messages'] = ''; ?>
58
- <?php } ?>
59
-
60
- <?php if ( isset( $_GET['addedgroup'] ) || isset( $_GET['published'] ) || isset( $_GET['skipped'] ) || isset( $_GET['updated'] ) || isset( $_GET['deleted'] ) || isset( $_GET['message'] ) || isset( $_GET['duplicated'] ) ) {
61
- ?>
62
- <div id="message" class="updated fade">
63
- <p>
64
- <?php
65
- if ( isset( $_GET['updated'] ) ) {
66
- printf( _n( '%s product updated.', '%s products updated.', $_GET['updated'] ), number_format_i18n( $_GET['updated'] ) );
67
- unset( $_GET['updated'] );
68
- }
69
-
70
- if ( isset( $_GET['addedgroup'] ) ) {
71
- if(is_numeric($_GET['addedgroup']) && $_GET['addedgroup'] > 0){
72
- printf( _n( '%s product updated.', '%s products updated.', $_GET['addedgroup'] ), number_format_i18n( $_GET['addedgroup'] ) );
73
- }else{
74
- printf( __( 'Invalid Category Selected.', 'wpsc') );
75
- }
76
- unset( $_GET['addedgroup'] );
77
- }
78
-
79
- if ( isset( $_GET['published'] ) ) {
80
- printf( _n( '%s product updated.', '%s products updated.', $_GET['published'] ), number_format_i18n( $_GET['published'] ) );
81
- unset( $_GET['published'] );
82
- }
83
-
84
-
85
- if ( isset( $_GET['skipped'] ) ) {
86
- unset( $_GET['skipped'] );
87
- }
88
-
89
- if ( isset( $_GET['deleted'] ) ) {
90
- printf( _n( 'Product deleted.', '%s products deleted.', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) );
91
- unset( $_GET['deleted'] );
92
- }
93
- if ( isset( $_GET['trashed'] ) && isset( $_GET['deleted'] ) ) {
94
- printf( _n( 'Product trashed.', '%s products deleted.', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) );
95
- unset( $_GET['trashed'] );
96
- }
97
-
98
- if ( isset( $_GET['duplicated'] ) ) {
99
- printf( _n( 'Product duplicated.', '%s products duplicated.', $_GET['duplicated'] ), number_format_i18n( $_GET['duplicated'] ) );
100
- unset( $_GET['duplicated'] );
101
- }
102
-
103
- if ( isset( $_GET['message'] ) ) {
104
- $message = absint( $_GET['message'] );
105
- $messages[1] = __( 'Product updated.' );
106
- echo $messages[$message];
107
- unset( $_GET['message'] );
108
- }
109
-
110
- $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'locked', 'skipped', 'updated', 'deleted', 'message', 'duplicated', 'trashed' ), $_SERVER['REQUEST_URI'] );
111
- ?>
112
- </p>
113
- </div>
114
- <?php } ?>
115
-
116
- <?php
117
- $unwriteable_directories = Array( );
118
-
119
- if ( !is_writable( WPSC_FILE_DIR ) ) {
120
- $unwriteable_directories[] = WPSC_FILE_DIR;
121
- }
122
-
123
- if ( !is_writable( WPSC_PREVIEW_DIR ) ) {
124
- $unwriteable_directories[] = WPSC_PREVIEW_DIR;
125
- }
126
-
127
- if ( !is_writable( WPSC_IMAGE_DIR ) ) {
128
- $unwriteable_directories[] = WPSC_IMAGE_DIR;
129
- }
130
-
131
- if ( !is_writable( WPSC_THUMBNAIL_DIR ) ) {
132
- $unwriteable_directories[] = WPSC_THUMBNAIL_DIR;
133
- }
134
-
135
- if ( !is_writable( WPSC_CATEGORY_DIR ) ) {
136
- $unwriteable_directories[] = WPSC_CATEGORY_DIR;
137
- }
138
-
139
- if ( !is_writable( WPSC_UPGRADES_DIR ) ) {
140
- $unwriteable_directories[] = WPSC_UPGRADES_DIR;
141
- }
142
-
143
- if ( count( $unwriteable_directories ) > 0 ) {
144
- // remember the user that the uploads directory needs to be writable
145
- echo "<div class='error fade'>".WPSC_UPLOAD_ERR."<br/>";
146
-
147
- echo str_replace( ":directory:", "<ul><li>" . implode( $unwriteable_directories, "</li><li>" ) . "</li></ul>", __( 'The following directories are not writable: :directory: You won&#39;t be able to upload any images or files here. You will need to change the permissions on these directories to make them writable.', 'wpsc' ) ) . "</div>";
148
- }
149
- // class='stuffbox'
150
- // Justin Sainton - 5.7.2010 - Re-ordered columns, applying jQuery to toggle divs on click.
151
- ?>
152
- <script type="text/javascript">
153
- /* <![CDATA[ */
154
- (function($){
155
- $(document).ready(function(){
156
-
157
- $('#doaction, #doaction2').click(function(){
158
- if ( $('select[name^="action"]').val() == 'delete' ) {
159
- var m = '<?php echo esc_js( __( "You are about to delete the selected products.\n 'Cancel' to stop, 'OK' to delete." ) ); ?>';
160
- return showNotice.warn(m);
161
- }
162
- });
163
- $('form#filt_cat').insertAfter('input#doaction').css("display", "inline");
164
-
165
- });
166
- })(jQuery);
167
- /* ]]> */
168
- </script>
169
- <?php
170
- if ( !isset( $_GET["action"] ) )
171
- $_GET["action"] = '';
172
- if ( ($_GET["action"] != "wpsc_add_edit" ) ) {
173
- ?>
174
- <div id="wpsc-col-left">
175
- <div class="col-wrap">
176
- <?php
177
- wpsc_admin_products_list( $category_id );
178
- ?>
179
- </div>
180
- </div>
181
- <?php } else { ?>
182
- <script type="text/javascript">
183
- /* <![CDATA[ */
184
- (function($){
185
- $(document).ready(function(){
186
-
187
- jQuery('#wpsc-col-left').hide();
188
- <?php
189
- if(isset($_GET['product']) && $_GET['product'] <= 0){?>
190
- jQuery('a#add').addClass('nav-tab-active');
191
- jQuery('a#manage').removeClass('nav-tab-active');
192
- <?php
193
- } ?>
194
- });
195
- })(jQuery);
196
- /* ]]> */
197
- </script>
198
- <div id="wpsc-col-right">
199
- <?php
200
- global $screen_layout_columns;
201
- wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
202
- wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
203
- ?>
204
- <div id="poststuff" class="metabox-holder<?php echo 2 == $screen_layout_columns ? ' has-right-sidebar' : ''; ?>">
205
- <form id="modify-products" method="post" action="" enctype="multipart/form-data" >
206
- <?php
207
- $product_id = 0;
208
- if ( isset( $_GET['product'] ) )
209
- $product_id = absint( $_GET['product'] );
210
- wpsc_display_product_form( $product_id );
211
- ?>
212
- </form>
213
- </div>
214
- </div>
215
- <?php } ?>
216
- </div>
217
-
218
- <?php
219
- }
220
-
221
- /*
222
- * wpsc_edit_variations_request_sql function, modifies the wp-query SQL statement for displaying variations
223
- * @todo will need refinement later to work with pagionation
224
- * @param $sql
225
- * @returns string - SQL statement
226
- */
227
-
228
- function wpsc_edit_variations_request_sql( $sql ) {
229
- global $wpdb;
230
-
231
- if ( is_numeric( $_GET['product'] ) ) {
232
- $parent_product = absint( $_GET['product'] );
233
- $product_term_data = wp_get_object_terms( $parent_product, 'wpsc-variation' );
234
-
235
- $parent_terms = array( );
236
- $child_terms = array( );
237
- foreach ( $product_term_data as $product_term_row ) {
238
- if ( $product_term_row->parent == 0 ) {
239
- $parent_terms[] = $product_term_row->term_id;
240
- } else {
241
- $child_terms[] = $product_term_row->term_id;
242
- }
243
- }
244
-
245
- if ( count( $parent_terms ) > 0 ) {
246
- $term_count = count( $parent_terms );
247
- $child_terms = implode( ", ", $child_terms );
248
-
249
- $parent_terms = implode( ", ", $parent_terms );
250
- $new_sql = "SELECT posts.*, COUNT(tr.object_id) AS `count`
251
- FROM {$wpdb->term_relationships} AS tr
252
- INNER JOIN {$wpdb->posts} AS posts
253
- ON posts.ID = tr.object_id
254
- INNER JOIN {$wpdb->term_taxonomy} AS tt
255
- ON tr.term_taxonomy_id = tt.term_taxonomy_id
256
- WHERE tt.taxonomy IN ('wpsc-variation')
257
- AND tt.parent IN ({$parent_terms})
258
- AND tt.term_id IN ({$child_terms})
259
- AND posts.post_parent = {$parent_product}
260
-
261
- GROUP BY tr.object_id
262
- HAVING `count` = {$term_count}";
263
- return $new_sql;
264
- }
265
- }
266
-
267
-
268
- return $sql;
269
- }
270
-
271
- function wpsc_admin_products_list( $category_id = 0 ) {
272
- global $wp_query, $wpdb, $_wp_column_headers;
273
- // set is_sortable to false to start with
274
- $is_sortable = false;
275
- $search_sql = '';
276
- $page = null;
277
- // Justin Sainton - 5.11.2010 - Re-included these variables from 3.7.6.1, as they appear to have been removed. Necessary for pagination. Also re-wrote query for new table structure.
278
- $itempp = 20;
279
- if ( isset( $_REQUEST['product'] ) && (is_numeric( $_REQUEST['product'] )) )
280
- $parent_product = absint( $_REQUEST['product'] );
281
-
282
- $search_input = '';
283
- if ( isset( $_REQUEST['search'] ) ) {
284
- $search_input = stripslashes( $_REQUEST['search'] );
285
-
286
- $search_string = "%" . $wpdb->escape( $search_input ) . "%";
287
-
288
- $search_sql = "AND (`products`.`name` LIKE '" . $search_string . "' OR `products`.`description` LIKE '" . $search_string . "')";
289
- } else {
290
- $search_sql = '';
291
- }
292
-
293
- $search_sql = apply_filters( 'wpsc_admin_products_list_search_sql', $search_sql );
294
-
295
- if ( isset( $_REQUEST['pageno'] ) && ($_REQUEST['pageno'] > 0) ) {
296
- $page = absint( $_REQUEST['pageno'] );
297
- } else {
298
- $page = 1;
299
- }
300
- $start = (int)($page * $itempp) - $itempp;
301
- $all_products = '';
302
- $trash_products = '';
303
- $draft_products = '';
304
- if(!isset($_REQUEST['post_status']))
305
- $post_status = '';
306
- else
307
- $post_status = $_REQUEST['post_status'];
308
- if('trash' == $post_status){
309
- $post_status = 'trash';
310
- $trash_products = 'class="current"';
311
- }elseif('draft' == $post_status){
312
- $post_status = 'draft';
313
- $draft_products = 'class="current"';
314
-
315
- }else{
316
- $all_products = 'class="current"';
317
- $post_status = 'published inherit';
318
- }
319
-
320
- $query = array(
321
- 'post_type' => 'wpsc-product',
322
- 'orderby' => 'menu_order post_title',
323
- 'order' => "ASC",
324
- 'post_status' => $post_status,
325
- 'posts_per_page' => $itempp,
326
- 'offset' => $start
327
- );
328
-
329
- if( function_exists('wpec_post_parent_in') ) {
330
- $query["post_parent"] = '';
331
- add_filter( 'posts_where', 'wpec_post_parent_in' );
332
- }
333
- else {
334
- $query["post_parent"] = 0;
335
- }
336
- if ( isset( $_REQUEST['category'] ) ) {
337
- $category_id = $_REQUEST['category'];
338
- $query['wpsc_product_category'] = $category_id;
339
- }
340
-
341
-
342
- if ( isset( $_REQUEST['search'] ) && (strlen( $_REQUEST['search'] ) > 0 ) ) {
343
- $search = $_REQUEST['search'];
344
- $query['s'] = $search;
345
- }
346
- $wp_query = new WP_Query( $query );
347
-
348
- if ( isset( $itempp ) )
349
- $num_pages = ceil( $wp_query->found_posts / $itempp );
350
-
351
- remove_filter( 'posts_request', 'wpsc_edit_variations_request_sql' );
352
-
353
- if ( $page !== null ) {
354
- $page_query['base'] =add_query_arg( 'pageno', '%#%' );
355
- $page_query['format'] = '';
356
- $page_query['prev_text'] = __( '&laquo;' );
357
- $page_query['next_text'] = __( '&raquo;' );
358
- $page_query['total'] = $num_pages;
359
- $page_query['current'] = $page;
360
-
361
- $page_links = paginate_links( $page_query );
362
- }
363
-
364
-
365
- $is_trash = isset( $_POST['post_status'] ) && $_POST['post_status'] == 'trash';
366
-
367
- // Justin Sainton - 5.7.2010 - Added conditional code below as blank space would show up if $page_links was NULL. Now the area only shows up if page links exist.
368
- ?>
369
-
370
- <?php if ( $page_links && get_option( 'wpsc_sort_by' ) != 'dragndrop' ) {
371
- ?>
372
- <div class="tablenav">
373
- <div class="tablenav-pages">
374
- <?php
375
- echo $page_links;
376
- ?>
377
- </div>
378
- </div>
379
- <?php } ?>
380
- <form action="admin.php?page=wpsc-edit-products" method="post" id="filt_cat">
381
- <?php if(isset($search)){
382
- echo "<input type='hidden' name='search' value='{$search}' />";
383
- }
384
- if(isset($category_id)){
385
- echo "<input type='hidden' name='category' value='{$category_id}' />";
386
- echo "<input type='hidden' name='category_id' value='{$category_id}' />";
387
- }
388
- if(isset($page)){
389
- echo "<input type='hidden' name='page' value='{$page}' />";
390
- }
391
- echo wpsc_admin_category_dropdown();
392
- ?>
393
- </form>
394
- <form id="search-products" action="admin.php?page=wpsc-edit-products" method="post">
395
- <div class="alignright search-box">
396
- <input type='hidden' name='page' value='wpsc-edit-products' />
397
- <input type="text" class="search-input" id="page-search-input" name="search" value="<?php echo $search_input; ?>" />
398
- <input type="submit" name='wpsc_search' value="<?php _e( 'Search Products' ); ?>" class="button" />
399
- </div>
400
- </form>
401
- <form id="posts-filter" action="admin.php?page=wpsc-edit-products" method="post">
402
- <ul class='subsubsub'>
403
- <li><a <?php echo $all_products; ?> href='<?php echo add_query_arg('post_status','all'); ?>' title='View All Products'><?php _e('All','wpsc'); ?></a></li>
404
- <li> | </li>
405
- <li><a <?php echo $draft_products; ?> href='<?php echo add_query_arg('post_status','draft'); ?>' title='View Draft Products'><?php _e('Draft','wpsc'); ?></a></li>
406
- <li> | </li>
407
- <li><a <?php echo $trash_products; ?> href='<?php echo add_query_arg('post_status','trash'); ?>' title='View Trashed Products'><?php _e('Trash','wpsc'); ?></a></li>
408
- </ul>
409
- <br />
410
- <br />
411
- <div class="productnav">
412
- <div class="alignleft actions">
413
-
414
- <select id="bulkaction" name="bulkAction">
415
- <option value="-1" selected="selected"><?php _e( 'Bulk Actions' ); ?></option>
416
- <option value="addgroup"><?php _e( 'Add To Group' ); ?></option>
417
- <option value="publish"><?php _e( 'Publish', 'wpsc' ); ?></option>
418
- <option value="unpublish"><?php _e( 'Unpublish', 'wpsc' ); ?></option>
419
- <?php if ( $is_trash ) { ?>
420
- <option value="untrash"><?php _e( 'Restore' ); ?></option>
421
- <?php } ?>
422
- <option value="delete"><?php _e( 'Delete Permanently' ); ?></option>
423
-
424
- <option value="trash"><?php _e( 'Move to Trash' ); ?></option>
425
-
426
-
427
-
428
- </select>
429
- <?php
430
- $options = "<option selected='selected' value=''>" . __( 'Select a Category', 'wpsc' ) . "</option>\r\n";
431
- $options .= wpsc_list_categories( 'wpsc_admin_category_options_byid' );
432
- echo "<select name='bulk_category' id='category_select'>" . $options . "</select>\r\n";
433
- ?>
434
-
435
- <input type='hidden' name='wpsc_admin_action' value='bulk_modify' />
436
- <?php if(isset($search)){
437
- echo "<input type='hidden' name='search' value='{$search}' />";
438
- }
439
- if(isset($category_id)){
440
- echo "<input type='hidden' name='category' value='{$category_id}' />";
441
- echo "<input type='hidden' name='category_id' value='{$category_id}' />";
442
- }
443
- if(isset($page)){
444
- echo "<input type='hidden' name='page' value='{$page}' />";
445
- }
446
- ?>
447
-
448
- <input type="submit" value="<?php _e( 'Apply' ); ?>" name="doaction" id="doaction" class="button-secondary action" />
449
- <?php wp_nonce_field( 'bulk-products', 'wpsc-bulk-products' ); ?>
450
- </div>
451
-
452
-
453
- </div>
454
-
455
- <input type='hidden' id='products_page_category_id' name='category_id' value='<?php echo $category_id; ?>' />
456
- <table class="widefat page" id='wpsc_product_list' cellspacing="0">
457
- <thead>
458
- <tr>
459
- <?php print_column_headers( 'display-product-list' ); ?>
460
- </tr>
461
- </thead>
462
-
463
- <tfoot>
464
- <tr>
465
- <?php print_column_headers( 'display-product-list', false ); ?>
466
- </tr>
467
- </tfoot>
468
-
469
- <tbody>
470
- <?php
471
- if ( !isset( $parent_product_data ) )
472
- $parent_product_data = null;
473
-
474
- wpsc_admin_product_listing( $parent_product_data );
475
- if ( count( $wp_query->posts ) < 1 ) {
476
- ?>
477
- <tr>
478
- <td colspan='5'>
479
- <?php _e( "You have no products added." ); ?>
480
- </td>
481
- </tr>
482
- <?php
483
- }
484
- ?>
485
- </tbody>
486
- </table>
487
- </form>
488
- <?php
489
- }
490
-
491
- function wpsc_admin_category_dropdown() {
492
- global $wpdb, $category_data;
493
- $siteurl = get_option( 'siteurl' );
494
- $category_slug = '';
495
- $concat = '';
496
- if ( isset( $_POST['category'] ) )
497
- $category_slug = $_POST['category'];
498
-
499
- $selected ='';
500
- if(empty($category_slug))
501
- $selected = 'selected="selected"';
502
- $url = urlencode( remove_query_arg( array( 'product_id', 'category_id' ) ) );
503
-
504
- $options = "<option {$selected} value=''>" . __( 'View All Categories', 'wpsc' ) . "</option>\r\n";
505
-
506
- $options .= wpsc_list_categories( 'wpsc_admin_category_options', $category_slug );
507
- if(isset($_POST['page']))
508
- $concat .= "<input type='hidden' name='page' value='{$_POST['page']}' />\r\n";
509
- $concat .= "<select name='category' id='category_select'>" . $options . "</select>\r\n";
510
- $concat .= "<input type='submit' value='Filter' class='button-secondary action' id='post-query-submit' />\r\n";
511
- return $concat;
512
- }
513
-
514
- /*
515
- * Displays the category forms for adding and editing products
516
- * Recurses to generate the branched view for subcategories
517
- */
518
-
519
- function wpsc_admin_category_options( $category, $subcategory_level = 0, $category_slug = null ) {
520
-
521
- if ( $category_slug == $category->slug ) {
522
-
523
- $selected = "selected='selected'";
524
-
525
- } else {
526
-
527
- $selected = '';
528
-
529
- }
530
-
531
- $output = "<option $selected value='{$category->slug}'>" . str_repeat( "-", $subcategory_level ) . stripslashes( $category->name ) . "</option>\n";
532
-
533
- return $output;
534
- }
535
- /*
536
- * Displays the category forms for adding and editing products
537
- * Recurses to generate the branched view for subcategories
538
- */
539
-
540
- function wpsc_admin_category_options_byid( $category, $subcategory_level = 0 ) {
541
-
542
-
543
- $output = "<option value='{$category->term_id}'>" . str_repeat( "-", $subcategory_level ) . stripslashes( $category->name ) . "</option>\n";
544
-
545
- return $output;
546
- }
547
-
548
- /**
549
- * wpsc_update_featured_products function.
550
- *
551
- * @access public
552
- * @return void
553
- */
554
- function wpsc_update_featured_products() {
555
- global $wpdb;
556
- $is_ajax = (int)(bool)$_POST['ajax'];
557
- $product_id = absint( $_GET['product_id'] );
558
- check_admin_referer( 'feature_product_' . $product_id );
559
- $status = get_option( 'sticky_products' );
560
-
561
- $new_status = (in_array( $product_id, $status )) ? false : true;
562
-
563
- if ( $new_status ) {
564
-
565
- $status[] = $product_id;
566
- } else {
567
- $status = array_diff( $status, array( $product_id ) );
568
- $status = array_values( $status );
569
- }
570
- update_option( 'sticky_products', $status );
571
-
572
- if ( $is_ajax == true ) {
573
- if ( $new_status == true ) : ?>
574
- jQuery('.featured_toggle_<?php echo $product_id; ?>').html("<img class='gold-star' src='<?php echo WPSC_CORE_IMAGES_URL; ?>/gold-star.gif' alt='<?php _e( 'Unmark as Featured', 'wpsc' ); ?>' title='<?php _e( 'Unmark as Featured', 'wpsc' ); ?>' />");
575
- <?php else: ?>
576
- jQuery('.featured_toggle_<?php echo $product_id; ?>').html("<img class='grey-star' src='<?php echo WPSC_CORE_IMAGES_URL; ?>/grey-star.gif' alt='<?php _e( 'Mark as Featured', 'wpsc' ); ?>' title='<?php _e( 'Mark as Featured', 'wpsc' ); ?>' />");
577
- <?php
578
- endif;
579
- exit();
580
- }
581
- wp_redirect( wp_get_referer() );
582
- exit();
583
- }
584
-
585
- if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'update_featured_product') ) {
586
- add_action( 'admin_init', 'wpsc_update_featured_products' );
587
- }
588
-
589
- /**
590
- * wpsc_featured_products_toggle function.
591
- *
592
- * @access public
593
- * @param mixed $product_id
594
- * @return void
595
- */
596
- function wpsc_featured_products_toggle( $product_id ) {
597
- global $wpdb;
598
- $featured_product_url = wp_nonce_url( "index.php?wpsc_admin_action=update_featured_product&amp;product_id=$product_id", 'feature_product_' . $product_id );
599
- ?>
600
- <a class="wpsc_featured_product_toggle featured_toggle_<?php echo $product_id; ?>" href='<?php echo $featured_product_url; ?>' >
601
- <?php if ( in_array( $product_id, (array)get_option( 'sticky_products' ) ) ) : ?>
602
- <img class='gold-star' src='<?php echo WPSC_CORE_IMAGES_URL; ?>/gold-star.gif' alt='<?php _e( 'Unmark as Featured', 'wpsc' ); ?>' title='<?php _e( 'Unmark as Featured', 'wpsc' ); ?>' />
603
- <?php else: ?>
604
- <img class='grey-star' src='<?php echo WPSC_CORE_IMAGES_URL; ?>/grey-star.gif' alt='<?php _e( 'Mark as Featured', 'wpsc' ); ?>' title='<?php _e( 'Mark as Featured', 'wpsc' ); ?>' />
605
- <?php endif; ?>
606
- </a>
607
- <?php
608
- }
609
- add_action( 'manage_posts_featured_column', 'wpsc_featured_products_toggle', 10, 1 );
610
- ?>
1
+ <?php
2
+ /**
3
+ * WP eCommerce edit and add product page functions
4
+ *
5
+ * These are the main WPSC Admin functions
6
+ *
7
+ * @package wp-e-commerce
8
+ * @since 3.7
9
+ */
10
+
11
+
12
+ /**
13
+ * wpsc_is_admin function.
14
+ *
15
+ * @access public
16
+ * @return void
17
+ * General use function for checking if user is on WPSC admin pages
18
+ */
19
+
20
+ require_once(WPSC_FILE_PATH . '/wpsc-admin/includes/products.php');
21
+
22
+ function wpsc_is_admin() {
23
+ global $pagenow, $current_screen;
24
+
25
+ if( 'post.php' == $pagenow && 'wpsc-product' == $current_screen->post_type ) return true;
26
+
27
+ return false;
28
+
29
+ }
30
+
31
+ /**
32
+ * wpsc_additional_column_names function.
33
+ *
34
+ * @access public
35
+ * @param (array) $columns
36
+ * @return (array) $columns
37
+ *
38
+ */
39
+ function wpsc_additional_column_names( $columns ){
40
+ $columns = array();
41
+
42
+ $columns['cb'] = '<input type="checkbox">';
43
+ $columns['image'] = '';
44
+ $columns['title'] = __('Name', 'wpsc');
45
+ $columns['weight'] = __('Weight', 'wpsc');
46
+ $columns['stock'] = __('Stock', 'wpsc');
47
+ $columns['price'] = __('Price', 'wpsc');
48
+ $columns['sale_price'] = __('Sale Price', 'wpsc');
49
+ $columns['SKU'] = __('SKU', 'wpsc');
50
+ $columns['cats'] = __('Categories', 'wpsc');
51
+ $columns['featured'] = __('Featured', 'wpsc');
52
+ $columns['hidden_alerts'] = '';
53
+ $columns['date'] = __('Date', 'wpsc');
54
+
55
+ return $columns;
56
+ }
57
+ function wpsc_additional_sortable_column_names( $columns ){
58
+
59
+ $columns['stock'] = __('Stock', 'wpsc');
60
+ $columns['price'] = __('Price', 'wpsc');
61
+ $columns['sale_price'] = __('Sale Price', 'wpsc');
62
+ $columns['SKU'] = __('SKU', 'wpsc');
63
+
64
+ return $columns;
65
+ }
66
+ function wpsc_additional_column_name_variations( $columns ){
67
+ global $post;
68
+ if( $post->post_parent != '0' )
69
+ remove_meta_box( 'wpsc_product_variation_forms', 'wpsc-product', 'normal' );
70
+
71
+ $columns['image'] = '';
72
+ $columns['title'] = __('Name', 'wpsc');
73
+ $columns['weight'] = __('Weight', 'wpsc');
74
+ $columns['stock'] = __('Stock', 'wpsc');
75
+ $columns['price'] = __('Price', 'wpsc');
76
+ $columns['sale_price'] = __('Sale Price', 'wpsc');
77
+ $columns['SKU'] = __('SKU', 'wpsc');
78
+ $columns['hidden_alerts'] = '';
79
+
80
+ //For BC for 3.0 (hoping to remove for WPEC 3.9)
81
+ register_column_headers( 'wpsc-product_variants', $columns );
82
+
83
+ return apply_filters( 'wpsc_variation_column_headers', $columns);
84
+ }
85
+
86
+ /**
87
+ * wpsc_additional_column_data.
88
+ *
89
+ * @access public
90
+ * @param (array) $column
91
+ * @return void
92
+ * @todo Need to check titles / alt tags ( I don't think thumbnails have any in this code )
93
+ * @desc Switch function to generate columns the right way...no more UI hacking!
94
+ *
95
+ */
96
+ function wpsc_additional_column_data( $column ) {
97
+ global $post, $wpdb;
98
+
99
+ $is_parent = ( bool )wpsc_product_has_children($post->ID);
100
+ switch ( $column ) :
101
+
102
+ case 'image' :
103
+
104
+ $attached_images = get_posts( array(
105
+ 'post_type' => 'attachment',
106
+ 'numberposts' => 1,
107
+ 'post_parent' => $post->ID,
108
+ 'orderby' => 'menu_order',
109
+ 'order' => 'ASC'
110
+ ) );
111
+
112
+ if( isset( $post->ID ) && has_post_thumbnail( $post->ID ) )
113
+ echo get_the_post_thumbnail( $post->ID, 'admin-product-thumbnails' );
114
+ else if( !empty( $attached_images ) ) {
115
+ $attached_image = $attached_images[0];
116
+ $src = wp_get_attachment_url( $attached_image->ID );
117
+ ?>
118
+ <div style='width:38px; height:38px; overflow:hidden;'>
119
+ <img title='<?php _e( 'Drag to a new position' ); ?>' src='<?php echo $src; ?>' alt='<?php echo $title; ?>' width='38' height='38' />
120
+ </div>
121
+ <?php
122
+ } else {
123
+ $image_url = WPSC_CORE_IMAGES_URL . "/no-image-uploaded.gif";
124
+ ?>
125
+ <img title='<?php _e( 'Drag to a new position' ); ?>' src='<?php echo $image_url; ?>' alt='<?php echo $title; ?>' width='38' height='38' />
126
+ <?php
127
+ }
128
+ break;
129
+ case 'weight' :
130
+
131
+ if( $is_parent ) :
132
+ _e( 'N/A', 'wpsc' );
133
+ else :
134
+ $product_data['meta'] = array();
135
+ $product_data['meta'] = get_post_meta( $post->ID, '' );
136
+ foreach( $product_data['meta'] as $meta_name => $meta_value )
137
+ $product_data['meta'][$meta_name] = maybe_unserialize( array_pop( $meta_value ) );
138
+
139
+ $product_data['transformed'] = array();
140
+ if( !isset( $product_data['meta']['_wpsc_product_metadata']['weight'] ) )
141
+ $product_data['meta']['_wpsc_product_metadata']['weight'] = "";
142
+ if( !isset( $product_data['meta']['_wpsc_product_metadata']['weight_unit'] ) )
143
+ $product_data['meta']['_wpsc_product_metadata']['weight_unit'] = "";
144
+
145
+ $product_data['transformed']['weight'] = wpsc_convert_weight( $product_data['meta']['_wpsc_product_metadata']['weight'], "gram", $product_data['meta']['_wpsc_product_metadata']['weight_unit'] );
146
+
147
+ $weight = $product_data['transformed']['weight'];
148
+ if( $weight == '' )
149
+ $weight = '0';
150
+
151
+ $unit = $product_data['meta']['_wpsc_product_metadata']['weight_unit'];
152
+
153
+ switch( $unit ) {
154
+ case "pound":
155
+ $unit = " lbs.";
156
+ break;
157
+ case "ounce":
158
+ $unit = " oz.";
159
+ break;
160
+ case "gram":
161
+ $unit = " g";
162
+ break;
163
+ case "kilograms":
164
+ case "kilogram":
165
+ $unit = " kgs.";
166
+ break;
167
+ }
168
+ echo $weight.$unit;
169
+ echo '<div id="inline_' . $post->ID . '_weight" class="hidden">' . $weight . '</div>';
170
+
171
+ endif;
172
+ break;
173
+ case 'stock' :
174
+ $stock = get_post_meta( $post->ID, '_wpsc_stock', true );
175
+ if( $stock == '' )
176
+ $stock = 'N/A';
177
+ if( !$is_parent ) {
178
+ echo $stock;
179
+ echo '<div id="inline_' . $post->ID . '_stock" class="hidden">' . $stock . '</div>';
180
+ }
181
+ else
182
+ echo '~'.wpsc_variations_stock_remaining( $post->ID );
183
+ break;
184
+ case 'price' :
185
+ $price = get_post_meta( $post->ID, '_wpsc_price', true );
186
+ if( !$is_parent ) {
187
+ echo wpsc_currency_display( $price );
188
+ echo '<div id="inline_' . $post->ID . '_price" class="hidden">' . $price . '</div>';
189
+ }
190
+ else
191
+ echo wpsc_product_variation_price_available( $post->ID ).'+';
192
+ break;
193
+ case 'sale_price' :
194
+ $price = get_post_meta( $post->ID, '_wpsc_special_price', true );
195
+ if( !$is_parent ) {
196
+ echo wpsc_currency_display( $price );
197
+ echo '<div id="inline_' . $post->ID . '_sale_price" class="hidden">' . $price . '</div>';
198
+ } else
199
+ echo wpsc_product_variation_price_available( $post->ID ).'+';
200
+ break;
201
+ case 'SKU' :
202
+ $sku = get_post_meta( $post->ID, '_wpsc_sku', true );
203
+ if( $sku == '' )
204
+ $sku = 'N/A';
205
+
206
+ echo $sku;
207
+ echo '<div id="inline_' . $post->ID . '_sku" class="hidden">' . $sku . '</div>';
208
+ break;
209
+ case 'cats' :
210
+ $categories = get_the_product_category( $post->ID );
211
+ if ( !empty( $categories ) ) {
212
+ $out = array();
213
+ foreach ( $categories as $c )
214
+ $out[] = "<a href='?post_type=wpsc-product&amp;wpsc_product_category={$c->slug}'> " . esc_html( sanitize_term_field( 'name', $c->name, $c->term_id, 'category', 'display' ) ) . "</a>";
215
+ echo join( ', ', $out );
216
+ } else {
217
+ _e('Uncategorized');
218
+ }
219
+ break;
220
+ case 'featured' :
221
+ $featured_product_url = wp_nonce_url( "index.php?wpsc_admin_action=update_featured_product&amp;product_id=$post->ID", 'feature_product_' . $post->ID);
222
+ ?>
223
+ <a class="wpsc_featured_product_toggle featured_toggle_<?php echo $post->ID; ?>" href='<?php echo $featured_product_url; ?>' >
224
+ <?php if ( in_array( $post->ID, (array)get_option( 'sticky_products' ) ) ) : ?>
225
+ <img class='gold-star' src='<?php echo WPSC_CORE_IMAGES_URL; ?>/gold-star.gif' alt='<?php _e( 'Unmark as Featured', 'wpsc' ); ?>' title='<?php _e( 'Unmark as Featured', 'wpsc' ); ?>' />
226
+ <?php else: ?>
227
+ <img class='grey-star' src='<?php echo WPSC_CORE_IMAGES_URL; ?>/grey-star.gif' alt='<?php _e( 'Mark as Featured', 'wpsc' ); ?>' title='<?php _e( 'Mark as Featured', 'wpsc' ); ?>' />
228
+ <?php endif; ?>
229
+ </a>
230
+ <?php
231
+ break;
232
+ case 'hidden_alerts' :
233
+ $product_alert = apply_filters( 'wpsc_product_alert', array( false, '' ), $post );
234
+ if( !empty( $product_alert['messages'] ) )
235
+ $product_alert['messages'] = implode( "\n",( array )$product_alert['messages'] );
236
+
237
+ if( $product_alert['state'] === true ) {
238
+ ?>
239
+ <img alt='<?php echo $product_alert['messages'];?>' title='<?php echo $product_alert['messages'];?>' class='product-alert-image' src='<?php echo WPSC_CORE_IMAGES_URL;?>/product-alert.jpg' alt='' />
240
+ <?php
241
+ }
242
+
243
+ // If a product alert has stuff to display, show it.
244
+ // Can be used to add extra icons etc
245
+ if ( !empty( $product_alert['display'] ) )
246
+ echo $product_alert['display'];
247
+ break;
248
+ endswitch;
249
+
250
+ }
251
+ function wpsc_column_sql_orderby( $orderby, $wp_query ) {
252
+ global $wpdb;
253
+
254
+ $wp_query->query = wp_parse_args( $wp_query->query );
255
+
256
+ switch ( $wp_query->query['orderby'] ) :
257
+ case 'stock' :
258
+ $orderby = "(SELECT meta_value FROM $wpdb->postmeta WHERE post_id = $wpdb->posts.ID AND meta_key = '_wpsc_stock') " . $wp_query->get('order');
259
+ break;
260
+ case 'price' :
261
+ $orderby = "(SELECT meta_value FROM $wpdb->postmeta WHERE post_id = $wpdb->posts.ID AND meta_key = '_wpsc_price') " . $wp_query->get('order');
262
+ break;
263
+ case 'sale_price' :
264
+ $orderby = "(SELECT meta_value FROM $wpdb->postmeta WHERE post_id = $wpdb->posts.ID AND meta_key = '_wpsc_special_price') " . $wp_query->get('order');
265
+ break;
266
+ case 'SKU' :
267
+ $orderby = "(SELECT meta_value FROM $wpdb->postmeta WHERE post_id = $wpdb->posts.ID AND meta_key = '_wpsc_sku') " . $wp_query->get('order');
268
+ break;
269
+ endswitch;
270
+
271
+ return $orderby;
272
+ }
273
+ function wpsc_cats_restrict_manage_posts() {
274
+ global $typenow;
275
+
276
+ if ( $typenow == 'wpsc-product' ) {
277
+
278
+ $filters = array( 'wpsc_product_category' );
279
+
280
+ foreach ( $filters as $tax_slug ) {
281
+ // retrieve the taxonomy object
282
+ $tax_obj = get_taxonomy( $tax_slug );
283
+ $tax_name = $tax_obj->labels->name;
284
+ // retrieve array of term objects per taxonomy
285
+ $terms = get_terms( $tax_slug );
286
+
287
+ // output html for taxonomy dropdown filter
288
+ echo "<select name='$tax_slug' id='$tax_slug' class='postform'>";
289
+ echo "<option value=''>Show All $tax_name</option>";
290
+ foreach ( $terms as $term )
291
+ echo '<option value='. $term->slug, $_GET[$tax_slug] == $term->slug ? ' selected="selected"' : '','>' . $term->name .' (' . $term->count .')</option>';
292
+ echo "</select>";
293
+ }
294
+ }
295
+ }
296
+
297
+ /**
298
+ * wpsc no minors allowed
299
+ * Restrict the products page to showing only parent products and not variations.
300
+ * @since 3.8
301
+ */
302
+ function wpsc_no_minors_allowed( $vars ) {
303
+ global $current_screen;
304
+
305
+ if( $current_screen->post_type != 'wpsc-product' )
306
+ return $vars;
307
+
308
+ $vars['post_parent'] = 0;
309
+
310
+ return $vars;
311
+ }
312
+
313
+ add_filter( 'request', 'wpsc_no_minors_allowed' );
314
+ add_action( 'admin_head', 'wpsc_additional_column_name_variations' );
315
+ add_action( 'restrict_manage_posts', 'wpsc_cats_restrict_manage_posts' );
316
+ add_action( 'manage_pages_custom_column', 'wpsc_additional_column_data', 10, 2 );
317
+ add_filter( 'manage_edit-wpsc-product_sortable_columns', 'wpsc_additional_sortable_column_names' );
318
+ add_filter( 'manage_edit-wpsc-product_columns', 'wpsc_additional_column_names' );
319
+ add_filter( 'manage_wpsc-product_posts_columns', 'wpsc_additional_column_names' );
320
+ add_filter( 'posts_orderby', 'wpsc_column_sql_orderby', 10, 2 );
321
+
322
+
323
+ /**
324
+ * wpsc_update_featured_products function.
325
+ *
326
+ * @access public
327
+ * @todo Should be refactored to e
328
+ * @return void
329
+ */
330
+ function wpsc_update_featured_products() {
331
+ global $wpdb;
332
+ $is_ajax = (int)(bool)$_POST['ajax'];
333
+ $product_id = absint( $_GET['product_id'] );
334
+ check_admin_referer( 'feature_product_' . $product_id );
335
+ $status = get_option( 'sticky_products' );
336
+
337
+ $new_status = (in_array( $product_id, $status )) ? false : true;
338
+
339
+ if ( $new_status ) {
340
+
341
+ $status[] = $product_id;
342
+ } else {
343
+ $status = array_diff( $status, array( $product_id ) );
344
+ $status = array_values( $status );
345
+ }
346
+ update_option( 'sticky_products', $status );
347
+
348
+ if ( $is_ajax == true ) {
349
+ if ( $new_status == true ) : ?>
350
+ jQuery('.featured_toggle_<?php echo $product_id; ?>').html("<img class='gold-star' src='<?php echo WPSC_CORE_IMAGES_URL; ?>/gold-star.gif' alt='<?php _e( 'Unmark as Featured', 'wpsc' ); ?>' title='<?php _e( 'Unmark as Featured', 'wpsc' ); ?>' />");
351
+ <?php else: ?>
352
+ jQuery('.featured_toggle_<?php echo $product_id; ?>').html("<img class='grey-star' src='<?php echo WPSC_CORE_IMAGES_URL; ?>/grey-star.gif' alt='<?php _e( 'Mark as Featured', 'wpsc' ); ?>' title='<?php _e( 'Mark as Featured', 'wpsc' ); ?>' />");
353
+ <?php
354
+ endif;
355
+ exit();
356
+ }
357
+ wp_redirect( wp_get_referer() );
358
+ exit();
359
+ }
360
+
361
+ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'update_featured_product') ) {
362
+ add_action( 'admin_init', 'wpsc_update_featured_products' );
363
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-admin/display-options-settings.page.php CHANGED
@@ -225,7 +225,7 @@ function wpsc_get_payment_form( $paymentname ,$selected_gateway_data='') {
225
  </td>
226
  <td style='border-top: none;'>";
227
 
228
- if ( isset($payment_gateway_names[$paymentname]) && !empty($selected_gateway_data['image']) ) {
229
  $display_name = $payment_gateway_names[$paymentname];
230
  } elseif(!empty($selected_gateway_data['display_name'])){
231
  $display_name =$selected_gateway_data['display_name'];
225
  </td>
226
  <td style='border-top: none;'>";
227
 
228
+ if (isset($payment_gateway_names[$paymentname]) ) {
229
  $display_name = $payment_gateway_names[$paymentname];
230
  } elseif(!empty($selected_gateway_data['display_name'])){
231
  $display_name =$selected_gateway_data['display_name'];
wpsc-admin/display-sales-logs.php CHANGED
@@ -628,13 +628,13 @@ function wpsc_custom_checkout_fields(){
628
  $value['value'] = maybe_unserialize($value['value']);
629
  if(is_array($value['value'])){
630
  ?>
631
- <p><strong><?php echo $key; ?> :</strong> <?php echo implode($value['value'], ','); ?></p>
632
  <?php
633
 
634
 
635
  }else{
636
  ?>
637
- <p><strong><?php echo $key; ?> :</strong> <?php echo $value['value']; ?></p>
638
  <?php
639
  }
640
  }
628
  $value['value'] = maybe_unserialize($value['value']);
629
  if(is_array($value['value'])){
630
  ?>
631
+ <p><strong><?php echo $key; ?> :</strong> <?php echo implode(stripslashse($value['value']), ','); ?></p>
632
  <?php
633
 
634
 
635
  }else{
636
  ?>
637
+ <p><strong><?php echo $key; ?> :</strong> <?php echo stripslashes($value['value']); ?></p>
638
  <?php
639
  }
640
  }
wpsc-admin/display-update.page.php CHANGED
@@ -1,98 +1,97 @@
1
- <?php
2
- /**
3
- * WP eCommerce database updating page functions
4
- *
5
- * These are the main WPSC Admin functions
6
- *
7
- * @package wp-e-commerce
8
- * @since 3.8
9
- */
10
-
11
- global $show_update_page, $wpdb;
12
-
13
- $show_update_page = 1;
14
-
15
- // if there's nothing in the children variation cache, refresh it, just to make sure.
16
- if ( 0 == count( get_option( 'wpsc-variation_children' ) ) ) {
17
- delete_option( 'wpsc-variation_children' );
18
- _get_term_hierarchy( 'wpsc-variation' );
19
- }
20
-
21
- // if there's nothing in the children variation cache, refresh it, just to make sure.
22
- if ( 0 == count( get_option( 'wpsc_product_category_children' ) ) ) {
23
- delete_option( 'wpsc_product_category_children' );
24
- _get_term_hierarchy( 'wpsc_product_category_children' );
25
- }
26
-
27
- // If database is already updated, then no need to update
28
- if ( get_option( 'wpsc_version' ) >= 3.8 ) {
29
- $show_update_page = 0;
30
- }
31
-
32
- // Check to see if there are any products.
33
- // if they don't have any, they don't need to update
34
- if ( get_option( 'wpsc_version' ) < 3.8 || !get_option( 'wpsc_version' ) ) {
35
-
36
- $product_count = $wpdb->get_var( "SELECT COUNT(*) FROM " . WPSC_TABLE_PRODUCT_LIST );
37
-
38
- if ( $product_count > 0 ) {
39
-
40
- $show_update_page = 0;
41
-
42
- function wpsc_display_update_notice() {
43
- echo "<div id='wpsc-warning' class='error fade'><p><strong>" . __( 'WP e-Commerce is almost ready.' ) . "</strong> " . sprintf( __( 'You must <a href="%1$s">update your database</a> to import all of your products.' ), "admin.php?page=wpsc-update") . "</p></div>";
44
- }
45
-
46
- if ( isset( $_GET['page'] ) && $_GET['page'] != 'wpsc-update' )
47
- add_action( 'admin_notices', 'wpsc_display_update_notice' );
48
-
49
- // There weren't any products, so mark the update as complete
50
- } else {
51
- update_option( 'wpsc_version', '3.8' );
52
- }
53
- }
54
-
55
- function wpsc_display_update_page() { ?>
56
-
57
- <div class="wrap">
58
- <h2><?php echo esc_html( __('Update WP e-Commerce', 'wpsc') ); ?> </h2>
59
- <br />
60
-
61
- <?php
62
- if ( isset( $_POST['run_updates'] ) ) :
63
- echo 'Updating Categories...';
64
- wpsc_convert_category_groups();
65
- echo '<br />Updating Variations...';
66
- wpsc_convert_variation_sets();
67
- echo '<br />Updating Products...';
68
- wpsc_convert_products_to_posts();
69
- echo '<br />Updating Child Products...';
70
- wpsc_convert_variation_combinations();
71
- echo '<br />Updating Product Files...';
72
- wpsc_update_files();
73
- echo '<br />Updating Database...';
74
- wpsc_update_database();
75
- echo '<br /><br /><strong>WP e-Commerce updated successfully!</strong>';
76
- update_option('wpsc_version', 3.8);
77
- else:
78
-
79
-
80
- _e('Your WP e-Commerce database needs to be updated for WP e-Commerce 3.8. To perform this update, press the button below. It is highly recommended that you back up your database before performing this update.','wpsc');
81
- ?> <br />
82
- <br />
83
- <em><?php _e('Note: If the server times out or runs out of memory, just reload this page, the server will pick up where it left off.','wpsc'); ?></em>
84
- <br />
85
-
86
- <form action="" method="post" id="setup">
87
- <input type="hidden" name="run_updates" value="true" id="run_updates">
88
- <p class="step"><input type="submit" class="button" value="Update WP e-Commerce" name="Submit"></p>
89
- </form>
90
- <?php
91
- endif;
92
- ?>
93
- </div>
94
-
95
- <?php
96
- }
97
-
98
- ?>
1
+ <?php
2
+ /**
3
+ * WP eCommerce database updating page functions
4
+ *
5
+ * These are the main WPSC Admin functions
6
+ *
7
+ * @package wp-e-commerce
8
+ * @since 3.8
9
+ */
10
+
11
+ global $wpdb,$wp_version;
12
+ $show_update_page = 1;
13
+
14
+ // if there's nothing in the children variation cache, refresh it, just to make sure.
15
+ if ( 0 == count( get_option( 'wpsc-variation_children' ) ) ) {
16
+ delete_option( 'wpsc-variation_children' );
17
+ _get_term_hierarchy( 'wpsc-variation' );
18
+ }
19
+
20
+ // if there's nothing in the children variation cache, refresh it, just to make sure.
21
+ if ( 0 == count( get_option( 'wpsc_product_category_children' ) ) ) {
22
+ delete_option( 'wpsc_product_category_children' );
23
+ _get_term_hierarchy( 'wpsc_product_category_children' );
24
+ }
25
+
26
+ // If database is already updated, then no need to update
27
+ if ( get_option( 'wpsc_version' ) >= 3.8 ) {
28
+ $show_update_page = 0;
29
+ }
30
+
31
+ // Check to see if there are any products.
32
+ // if they don't have any, they don't need to update
33
+ if ( get_option( 'wpsc_version' ) < 3.8 || !get_option( 'wpsc_version' ) ) {
34
+
35
+ $product_count = $wpdb->get_var( "SELECT COUNT(*) FROM " . WPSC_TABLE_PRODUCT_LIST );
36
+
37
+ if ( $product_count > 0 ) {
38
+
39
+ function wpsc_display_update_notice() {
40
+ echo "<div id='wpsc-warning' class='error fade'><p><strong>" . __( 'WP e-Commerce is almost ready.' ) . "</strong> " . sprintf( __( 'You must <a href="%1$s">update your database</a> to import all of your products.' ), "admin.php?page=wpsc-update") . "</p></div>";
41
+ }
42
+
43
+ if ( isset( $_GET['page'] ) && $_GET['page'] != 'wpsc-update' )
44
+ add_action( 'admin_notices', 'wpsc_display_update_notice' );
45
+
46
+ // There weren't any products, so mark the update as complete
47
+ } else {
48
+ update_option( 'wpsc_version', '3.8' );
49
+ }
50
+ }
51
+
52
+ function wpsc_display_update_page() { ?>
53
+
54
+ <div class="wrap">
55
+ <h2><?php echo esc_html( __('Update WP e-Commerce', 'wpsc') ); ?> </h2>
56
+ <br />
57
+
58
+ <?php
59
+ if ( isset( $_POST['run_updates'] ) ) :
60
+ echo 'Updating Categories...';
61
+ wpsc_convert_category_groups();
62
+ echo '<br />Updating Variations...';
63
+ wpsc_convert_variation_sets();
64
+ echo '<br />Updating Products...';
65
+ wpsc_convert_products_to_posts();
66
+ echo '<br />Updating Child Products...';
67
+ wpsc_convert_variation_combinations();
68
+ echo '<br />Updating Product Files...';
69
+ wpsc_update_files();
70
+ echo '<br />Updating Database...';
71
+ wpsc_create_or_update_tables();
72
+ wpsc_update_database();
73
+ echo '<br /><br /><strong>WP e-Commerce updated successfully!</strong>';
74
+ update_option('wpsc_version', 3.8);
75
+ update_option('wpsc_hide_update', true);
76
+ else:
77
+
78
+
79
+ _e('Your WP e-Commerce database needs to be updated for WP e-Commerce 3.8. To perform this update, press the button below. It is highly recommended that you back up your database before performing this update.','wpsc');
80
+ ?> <br />
81
+ <br />
82
+ <em><?php _e('Note: If the server times out or runs out of memory, just reload this page, the server will pick up where it left off.','wpsc'); ?></em>
83
+ <br />
84
+
85
+ <form action="" method="post" id="setup">
86
+ <input type="hidden" name="run_updates" value="true" id="run_updates">
87
+ <p class="step"><input type="submit" class="button" value="Update WP e-Commerce" name="Submit"></p>
88
+ </form>
89
+ <?php
90
+ endif;
91
+ ?>
92
+ </div>
93
+
94
+ <?php
95
+ }
96
+
97
+ ?>
 
wpsc-admin/display-upgrades.page.php CHANGED
@@ -1,157 +1,157 @@
1
- <?php
2
-
3
- function wpsc_display_upgrades_page() {
4
-
5
- do_action( 'wpsc_gold_module_activation' ); ?>
6
-
7
- <div class='wrap'>
8
- <div class='metabox-holder wpsc_gold_side'>
9
- <strong><?php _e( 'WP e-Commerce Upgrades', 'wpsc' ); ?></strong><br />
10
- <span><?php _e( 'Add more functionality to your e-Commerce site. Prices may be subject to change.', 'wpsc' ); ?><input type='button' class='button-primary' onclick='window.open ("http://getshopped.org/extend/premium-upgrades/","mywindow"); ' value='Buy Now' id='visitInstinct' name='visitInstinct' /></span>
11
-
12
- <br />
13
- <div class='wpsc_gold_module'>
14
- <br />
15
- <a href="http://getshopped.org/extend/premium-upgrades/premium-upgrades/gold-cart-plugin/" target="_blank"><strong><?php _e( 'Pure Gold', 'wpsc' ); ?></strong></a>
16
- <p class='wpsc_gold_text'>Add product search, multiple image upload, gallery view, Grid View and multiple payment gateway options to your shop</p>
17
- <span class='wpsc_gold_info'>$40</span>
18
- </div>
19
-
20
- <div class='wpsc_gold_module'>
21
- <br />
22
- <a href="http://getshopped.org/extend/premium-upgrades/premium-upgrades/dropshop-2010/" target="_blank"><strong><?php _e( 'DropShop', 'wpsc' ); ?></strong></a>
23
- <p class='wpsc_gold_text'>Impress your customers with our AJAX powered DropShop that lets your customers drag and drop products into their shopping cart</p>
24
- <span class='wpsc_gold_info'>$75</span>
25
- </div>
26
-
27
- <div class='wpsc_gold_module'>
28
- <br />
29
- <a href="http://getshopped.org/extend/premium-upgrades/premium-upgrades/mp3-audio-player/" target="_blank"><strong><?php _e( 'MP3 Player', 'wpsc' ); ?></strong></a>
30
- <p class='wpsc_gold_text'>Adding this module lets you upload and manage MP3 preview files that can be associated with your digital downloads.</p>
31
- <span class='wpsc_gold_info'>$10</span>
32
- </div>
33
-
34
- <div class='wpsc_gold_module'>
35
- <br />
36
- <a href="http://getshopped.org/extend/premium-upgrades/premium-upgrades/members-only-module/" target="_blank"><strong><?php _e( 'Members Only Module', 'wpsc' ); ?></strong></a>
37
- <p class='wpsc_gold_text'>The Members modules lets you set private pages and posts that are only available to paying customers. Activating this module also adds a new option under "WordPress Users" menu that shop owners can use to manage their subscribers.</p>
38
- <span class='wpsc_gold_info'>$25</span>
39
- </div>
40
-
41
- <div class='wpsc_gold_module'>
42
- <br />
43
- <a href="http://getshopped.org/extend/premium-upgrades/premium-upgrades/product-slider-2010/" target="_blank"><strong><?php _e( 'Product Slider', 'wpsc' ); ?> </strong></a>
44
- <p class='wpsc_gold_text'>Display your products in a new and fancy way using the "Product Slider" module.</p>
45
- <span class='wpsc_gold_info'>$25</span>
46
- </div>
47
-
48
- <div class='wpsc_gold_module'>
49
- <br />
50
- <a href="http://getshopped.org/extend/premium-upgrades/premium-upgrades/nextgen-gallery-buy-now1/" target="_blank"><strong><?php _e( 'NextGen Gallery Buy Now Buttons', 'wpsc' ); ?> </strong></a>
51
- <p class='wpsc_gold_text'>Make your Online photo gallery into an e-Commerce solution.</p>
52
- <span class='wpsc_gold_info'>$10</span>
53
- </div>
54
- </div>
55
-
56
- <h2><?php _e( 'Upgrades', 'wpsc' ); ?></h2>
57
- <div class='wpsc_gold_float'>
58
- <p><?php _e( 'Enter your API Username and API Key below.', 'wpsc' ); ?></p>
59
- <p><a href="http://getshopped.org/resources/docs/installation/gold-files/"><?php _e( 'For more information visit our documentation page.', 'wpsc' ); ?></a></p>
60
-
61
- <div class='metabox-holder'>
62
- <form method='post' id='gold_cart_form' action=''>
63
-
64
- <?php
65
- if ( defined( 'WPSC_GOLD_MODULE_PRESENT' ) && ( true == WPSC_GOLD_MODULE_PRESENT ) ) {
66
- do_action( 'wpsc_gold_module_activation_forms' );
67
- } else {
68
- ?>
69
-
70
- <div id='wpsc_gold_options_outside'>
71
- <div class='form-wrap' >
72
- <p>
73
- <?php _e( "You don't have any Upgrades yet!", 'wpsc' ); ?>
74
- </p>
75
- </div>
76
-
77
- <h2><?php _e( 'API Key Reset', 'wpsc' ); ?></h2>
78
- <div class='form-wrap' >
79
- <p>
80
- <?php _e( 'Enter your API name and key to release it from an old site that you no longer use.', 'wpsc' ); ?> <br /><br />
81
- </p>
82
- </div>
83
- </div>
84
-
85
- <div class='postbox'>
86
- <h3 class='hndle'><?php _e( 'API Key Reset', 'wpsc' ); ?></h3>
87
- <p>
88
- <label for='activation_name'><?php _e( 'Name', 'wpsc' ); ?>:</label>
89
- <input class='text' type='text' size='40' value='<?php echo get_option( 'activation_name' ); ?>' name='activation_name' id='activation_name' />
90
- </p>
91
- <p>
92
- <label for='activation_key'><?php _e( 'API Key', 'wpsc' ); ?>:</label>
93
- <input class='text' type='text' size='40' value='<?php echo get_option( 'activation_key' ); ?>' name='activation_key' id='activation_key' />
94
- </p>
95
- <p>
96
- <input type='hidden' value='true' name='reset_api_key' />
97
- <input type='submit' class='button-primary' value='<?php _e( 'Reset API Key', 'wpsc' ); ?>' name='submit_values' />
98
- </p>
99
- </div>
100
-
101
- <?php } ?>
102
- </form>
103
- </div>
104
- </div>
105
- </div>
106
-
107
- <?php
108
- }
109
-
110
- function wpsc_reset_api_key() {
111
- if ( isset( $_POST['reset_api_key'] ) && ( $_POST['reset_api_key'] == 'true' ) ) {
112
- if ( $_POST['activation_name'] != null ) {
113
- $target = "http://instinct.co.nz/wp-goldcart-api/api_register.php?name=" . $_POST['activation_name'] . "&key=" . $_POST['activation_key'] . "&url=" . get_option( 'siteurl' ) . "";
114
-
115
- $remote_access_fail = false;
116
- $useragent = 'WP e-Commerce plugin';
117
-
118
- $activation_name = urlencode( $_POST['activation_name'] );
119
- $activation_key = urlencode( $_POST['activation_key'] );
120
- $activation_state = update_option( 'activation_state', "false" );
121
-
122
- $siteurl = urlencode( get_option( 'siteurl' ) );
123
- $request = '';
124
-
125
- $http_request = "GET /wp-goldcart-api/api_register.php?name=$activation_name&key=&url=$siteurl HTTP/1.0\r\n";
126
- $http_request .= "Host: instinct.co.nz\r\n";
127
- $http_request .= "Content-Type: application/x-www-form-urlencoded; charset=" . get_option( 'blog_charset' ) . "\r\n";
128
- $http_request .= "Content-Length: " . strlen( $request ) . "\r\n";
129
- $http_request .= "User-Agent: $useragent\r\n";
130
- $http_request .= "\r\n";
131
- $http_request .= $request;
132
-
133
- $response = '';
134
-
135
- if ( false != ( $fs = @fsockopen( 'instinct.co.nz', 80, $errno, $errstr, 10 ) ) ) {
136
- fwrite( $fs, $http_request );
137
-
138
- while ( !feof( $fs ) )
139
- $response .= fgets( $fs, 1160 ); // One TCP-IP packet
140
-
141
- fclose( $fs );
142
- }
143
-
144
- $response = explode( "\r\n\r\n", $response, 2 );
145
- $returned_value = (int)trim( $response[1] );
146
-
147
- update_option( 'activation_name', '' );
148
- update_option( 'activation_key', '' );
149
-
150
- echo "<div class='updated'><p align='center'>" . __( 'Your API key has been Reset', 'wpsc' ) . "</p></div>";
151
- }
152
- }
153
- }
154
-
155
- add_action( 'wpsc_gold_module_activation', 'wpsc_reset_api_key' );
156
-
157
  ?>
1
+ <?php
2
+
3
+ function wpsc_display_upgrades_page() {
4
+
5
+ do_action( 'wpsc_gold_module_activation' ); ?>
6
+
7
+ <div class='wrap'>
8
+ <div class='metabox-holder wpsc_gold_side'>
9
+ <strong><?php _e( 'WP e-Commerce Upgrades', 'wpsc' ); ?></strong><br />
10
+ <span><?php _e( 'Add more functionality to your e-Commerce site. Prices may be subject to change.', 'wpsc' ); ?><input type='button' class='button-primary' onclick='window.open ("http://getshopped.org/extend/premium-upgrades/","mywindow"); ' value='Buy Now' id='visitInstinct' name='visitInstinct' /></span>
11
+
12
+ <br />
13
+ <div class='wpsc_gold_module'>
14
+ <br />
15
+ <a href="http://getshopped.org/extend/premium-upgrades/premium-upgrades/gold-cart-plugin/" target="_blank"><strong><?php _e( 'Pure Gold', 'wpsc' ); ?></strong></a>
16
+ <p class='wpsc_gold_text'>Add product search, multiple image upload, gallery view, Grid View and multiple payment gateway options to your shop</p>
17
+ <span class='wpsc_gold_info'>$40</span>
18
+ </div>
19
+
20
+ <div class='wpsc_gold_module'>
21
+ <br />
22
+ <a href="http://getshopped.org/extend/premium-upgrades/premium-upgrades/dropshop-2010/" target="_blank"><strong><?php _e( 'DropShop', 'wpsc' ); ?></strong></a>
23
+ <p class='wpsc_gold_text'>Impress your customers with our AJAX powered DropShop that lets your customers drag and drop products into their shopping cart</p>
24
+ <span class='wpsc_gold_info'>$75</span>
25
+ </div>
26
+
27
+ <div class='wpsc_gold_module'>
28
+ <br />
29
+ <a href="http://getshopped.org/extend/premium-upgrades/premium-upgrades/mp3-audio-player/" target="_blank"><strong><?php _e( 'MP3 Player', 'wpsc' ); ?></strong></a>
30
+ <p class='wpsc_gold_text'>Adding this module lets you upload and manage MP3 preview files that can be associated with your digital downloads.</p>
31
+ <span class='wpsc_gold_info'>$10</span>
32
+ </div>
33
+
34
+ <div class='wpsc_gold_module'>
35
+ <br />
36
+ <a href="http://getshopped.org/extend/premium-upgrades/premium-upgrades/members-only-module/" target="_blank"><strong><?php _e( 'Members Only Module', 'wpsc' ); ?></strong></a>
37
+ <p class='wpsc_gold_text'>The Members modules lets you set private pages and posts that are only available to paying customers. Activating this module also adds a new option under "WordPress Users" menu that shop owners can use to manage their subscribers.</p>
38
+ <span class='wpsc_gold_info'>$25</span>
39
+ </div>
40
+
41
+ <div class='wpsc_gold_module'>
42
+ <br />
43
+ <a href="http://getshopped.org/extend/premium-upgrades/premium-upgrades/product-slider-2010/" target="_blank"><strong><?php _e( 'Product Slider', 'wpsc' ); ?> </strong></a>
44
+ <p class='wpsc_gold_text'>Display your products in a new and fancy way using the "Product Slider" module.</p>
45
+ <span class='wpsc_gold_info'>$25</span>
46
+ </div>
47
+
48
+ <div class='wpsc_gold_module'>
49
+ <br />
50
+ <a href="http://getshopped.org/extend/premium-upgrades/premium-upgrades/nextgen-gallery-buy-now1/" target="_blank"><strong><?php _e( 'NextGen Gallery Buy Now Buttons', 'wpsc' ); ?> </strong></a>
51
+ <p class='wpsc_gold_text'>Make your Online photo gallery into an e-Commerce solution.</p>
52
+ <span class='wpsc_gold_info'>$10</span>
53
+ </div>
54
+ </div>
55
+
56
+ <h2><?php _e( 'Upgrades', 'wpsc' ); ?></h2>
57
+ <div class='wpsc_gold_float'>
58
+ <p><?php _e( 'Enter your API Username and API Key below.', 'wpsc' ); ?></p>
59
+ <p><a href="http://getshopped.org/resources/docs/installation/gold-files/"><?php _e( 'For more information visit our documentation page.', 'wpsc' ); ?></a></p>
60
+
61
+ <div class='metabox-holder'>
62
+ <form method='post' id='gold_cart_form' action=''>
63
+
64
+ <?php
65
+ if ( defined( 'WPSC_GOLD_MODULE_PRESENT' ) && ( true == WPSC_GOLD_MODULE_PRESENT ) ) {
66
+ do_action( 'wpsc_gold_module_activation_forms' );
67
+ } else {
68
+ ?>
69
+
70
+ <div id='wpsc_gold_options_outside'>
71
+ <div class='form-wrap' >
72
+ <p>
73
+ <?php _e( "You don't have any Upgrades yet!", 'wpsc' ); ?>
74
+ </p>
75
+ </div>
76
+
77
+ <h2><?php _e( 'API Key Reset', 'wpsc' ); ?></h2>
78
+ <div class='form-wrap' >
79
+ <p>
80
+ <?php _e( 'Enter your API name and key to release it from an old site that you no longer use.', 'wpsc' ); ?> <br /><br />
81
+ </p>
82
+ </div>
83
+ </div>
84
+
85
+ <div class='postbox'>
86
+ <h3 class='hndle'><?php _e( 'API Key Reset', 'wpsc' ); ?></h3>
87
+ <p>
88
+ <label for='activation_name'><?php _e( 'Name', 'wpsc' ); ?>:</label>
89
+ <input class='text' type='text' size='40' value='<?php echo get_option( 'activation_name' ); ?>' name='activation_name' id='activation_name' />
90
+ </p>
91
+ <p>
92
+ <label for='activation_key'><?php _e( 'API Key', 'wpsc' ); ?>:</label>
93
+ <input class='text' type='text' size='40' value='<?php echo get_option( 'activation_key' ); ?>' name='activation_key' id='activation_key' />
94
+ </p>
95
+ <p>
96
+ <input type='hidden' value='true' name='reset_api_key' />
97
+ <input type='submit' class='button-primary' value='<?php _e( 'Reset API Key', 'wpsc' ); ?>' name='submit_values' />
98
+ </p>
99
+ </div>
100
+
101
+ <?php } ?>
102
+ </form>
103
+ </div>
104
+ </div>
105
+ </div>
106
+
107
+ <?php
108
+ }
109
+
110
+ function wpsc_reset_api_key() {
111
+ if ( isset( $_POST['reset_api_key'] ) && ( $_POST['reset_api_key'] == 'true' ) ) {
112
+ if ( $_POST['activation_name'] != null ) {
113
+ $target = "http://instinct.co.nz/wp-goldcart-api/api_register.php?name=" . $_POST['activation_name'] . "&key=" . $_POST['activation_key'] . "&url=" . get_option( 'siteurl' ) . "";
114
+
115
+ $remote_access_fail = false;
116
+ $useragent = 'WP e-Commerce plugin';
117
+
118
+ $activation_name = urlencode( $_POST['activation_name'] );
119
+ $activation_key = urlencode( $_POST['activation_key'] );
120
+ $activation_state = update_option( 'activation_state', "false" );
121
+
122
+ $siteurl = urlencode( get_option( 'siteurl' ) );
123
+ $request = '';
124
+
125
+ $http_request = "GET /wp-goldcart-api/api_register.php?name=$activation_name&key=&url=$siteurl HTTP/1.0\r\n";
126
+ $http_request .= "Host: instinct.co.nz\r\n";
127
+ $http_request .= "Content-Type: application/x-www-form-urlencoded; charset=" . get_option( 'blog_charset' ) . "\r\n";
128
+ $http_request .= "Content-Length: " . strlen( $request ) . "\r\n";
129
+ $http_request .= "User-Agent: $useragent\r\n";
130
+ $http_request .= "\r\n";
131
+ $http_request .= $request;
132
+
133
+ $response = '';
134
+
135
+ if ( false != ( $fs = @fsockopen( 'instinct.co.nz', 80, $errno, $errstr, 10 ) ) ) {
136
+ fwrite( $fs, $http_request );
137
+
138
+ while ( !feof( $fs ) )
139
+ $response .= fgets( $fs, 1160 ); // One TCP-IP packet
140
+
141
+ fclose( $fs );
142
+ }
143
+
144
+ $response = explode( "\r\n\r\n", $response, 2 );
145
+ $returned_value = (int)trim( $response[1] );
146
+
147
+ update_option( 'activation_name', '' );
148
+ update_option( 'activation_key', '' );
149
+
150
+ echo "<div class='updated'><p align='center'>" . __( 'Your API key has been Reset', 'wpsc' ) . "</p></div>";
151
+ }
152
+ }
153
+ }
154
+
155
+ add_action( 'wpsc_gold_module_activation', 'wpsc_reset_api_key' );
156
+
157
  ?>
wpsc-admin/display-variations.page.php CHANGED
@@ -1,241 +1,241 @@
1
- <?php
2
- /**
3
- * WP eCommerce edit and add variation group page functions
4
- *
5
- * These are the main WPSC Admin functions
6
- *
7
- * @package wp-e-commerce
8
- * @since 3.7
9
- */
10
-
11
- function wpsc_display_variations_page() {
12
- $columns = array(
13
- 'title' => __('Name', 'wpsc'),
14
- 'edit' => __('Edit', 'wpsc')
15
- );
16
- register_column_headers('display-variations-list', $columns);
17
-
18
- ?>
19
- <script language='javascript' type='text/javascript'>
20
- function conf() {
21
- var check = confirm("<?php _e('Are you sure you want to delete this product?', 'wpsc');?>");
22
- if(check) {
23
- return true;
24
- } else {
25
- return false;
26
- }
27
- }
28
-
29
- <?php
30
-
31
- ?>
32
- </script><noscript>
33
- </noscript>
34
-
35
- <div class="wrap">
36
- <h2><?php echo esc_html( __('Display Variations', 'wpsc') ); ?> </h2>
37
- <p>
38
- <?php _e('A variation can be anything "optional" about a product. ie: Size, Color, etc <br />For example: if you are selling t-shirts you might setup a variation set called size with the values small, medium, large...', 'wpsc');?>
39
- </p>
40
-
41
-
42
- <?php if (isset($_GET['deleted']) || isset($_GET['message'])) { ?>
43
- <div id="message" class="updated fade">
44
- <p>
45
- <?php
46
- if (isset($_GET['message']) ) {
47
- $message = absint( $_GET['message'] );
48
- $messages[1] = __( 'Product updated.', 'wpsc');
49
- echo $messages[$message];
50
- unset($_GET['message']);
51
- }
52
-
53
- $_SERVER['REQUEST_URI'] = remove_query_arg( array('deleted', 'message'), $_SERVER['REQUEST_URI'] );
54
- ?>
55
- </p>
56
- </div>
57
- <?php } ?>
58
-
59
- <div id="col-container" class=''>
60
- <div id="col-right">
61
- <div id='poststuff' class="col-wrap">
62
- <form id="modify-variation-groups" method="post" action="" enctype="multipart/form-data" >
63
- <?php
64
- wpsc_admin_variation_forms($_GET['variation_id']);
65
- ?>
66
- </form>
67
- </div>
68
- </div>
69
-
70
- <div id="col-left">
71
- <div class="col-wrap">
72
- <?php
73
- wpsc_admin_variation_group_list($category_id);
74
- ?>
75
- </div>
76
- </div>
77
- </div>
78
-
79
-
80
- </div>
81
- <?php
82
- }
83
-
84
-
85
- /*
86
- * wpsc_admin_variation_group_list, prints the left hand side of the edit variations page
87
- * no parameters
88
- * nothing returned
89
- */
90
-
91
- function wpsc_admin_variation_group_list() {
92
- global $wpdb;
93
- ?>
94
- <table class="widefat page" id='wpsc_variation_list' cellspacing="0">
95
- <thead>
96
- <tr>
97
- <?php print_column_headers('display-variations-list'); ?>
98
- </tr>
99
- </thead>
100
-
101
- <tfoot>
102
- <tr>
103
- <?php print_column_headers('display-variations-list', false); ?>
104
- </tr>
105
- </tfoot>
106
-
107
- <tbody>
108
- <?php
109
- $variations = get_terms('wpsc-variation', array(
110
- 'hide_empty'=> 0,
111
- 'parent' => 0
112
- ));
113
- foreach((array)$variations as $variation) {
114
- ?>
115
- <tr class="variation-edit" id="variation-<?php echo $variation->term_id; ?>">
116
- <td class="variation-name"><?php echo htmlentities($variation->name, ENT_QUOTES, 'UTF-8'); ?></td>
117
- <td class="edit-variation">
118
- <a href='<?php echo add_query_arg('variation_id', $variation->term_id); ?>'><?php _e('Edit', 'wpsc'); ?></a>
119
- </td>
120
- </tr>
121
- <?php
122
- }
123
- ?>
124
- </tbody>
125
- </table>
126
- <?php
127
- }
128
-
129
-
130
- /*
131
- * wpsc_admin_variation_group_list, prints the right hand side of the edit variations page
132
- * @param int $variation_id the variation ID
133
- * nothing returned
134
- */
135
- function wpsc_admin_variation_forms($variation_id = null) {
136
- global $wpdb;
137
- $variation_value_count = 0;
138
- $variation_name = '';
139
- if($variation_id > 0 ) {
140
- $variation_id = absint($variation_id);
141
- $variation_set = get_term($variation_id, 'wpsc-variation', ARRAY_A);
142
- $variations = get_terms('wpsc-variation', array(
143
- 'hide_empty' => 0,
144
- 'parent' => $variation_id
145
- ));
146
- $variation_count = count($variations);
147
- }
148
- if(($_GET['valuecount'] > 0)) {
149
- $value_form_count = absint($_GET['valuecount']);
150
- } else {
151
- $value_form_count = 3;
152
- remove_query_arg( array('valuecount'), $_SERVER['REQUEST_URI'] );
153
- }
154
- if($variation_name != '') {
155
- ?>
156
- <h3><?php _e('Edit Variation Set', 'wpsc'); ?><span> (<a href="admin.php?page=wpsc-edit-variations">Add new Variation Set</a>)</span></h3>
157
- <?php
158
- } else {
159
- ?>
160
- <h3><?php _e('Add Variation Set', 'wpsc'); ?></h3>
161
- <?php
162
- }
163
- ?>
164
- <table class='category_forms'>
165
- <tr>
166
- <td>
167
- <?php _e('Name', 'wpsc'); ?>:
168
- </td>
169
- <td>
170
- <input type='text' class="text" name='name' value='<?php echo $variation_set['name']; ?>' />
171
- </td>
172
- </tr>
173
- <tr>
174
- <td>
175
- <?php _e('Variation Values', 'wpsc'); ?>:
176
- </td>
177
- <td>
178
- <div id='variation_values'>
179
- <?php
180
- if($variation_count > 0) {
181
- $num = 0;
182
- foreach($variations as $variation) {
183
- $delete_url = wp_nonce_url("admin.php?wpsc_admin_action=wpsc-variation-set&amp;delete_value=true&amp;variation_id={$variation_id}&amp;value_id={$variation->term_id}", "delete-variation-{$variation->term_id}");
184
- ?>
185
- <div class='variation_value' id='variation_row_<?php echo $variation->term_id; ?>'>
186
- <a class='variation_handle' href="#">&equiv;</a>
187
- <input type='text' class='text' name='variation_values[<?php echo $variation->term_id; ?>]' value='<?php echo htmlentities($variation->name, ENT_QUOTES, 'UTF-8'); ?>' />
188
- <input type='hidden' class='variation_values_id' name='variation_values_id[]' value='<?php echo $variation->term_id; ?>' />
189
- <?php if($variation_count > 1): ?>
190
- <a class='image_link delete_variation_value' href='<?php echo $delete_url; ?>' >
191
- <img src='<?php echo WPSC_CORE_IMAGES_URL; ?>/trash.gif' alt='<?php _e('Delete', 'wpsc'); ?>' title='<?php _e('Delete', 'wpsc'); ?>' />
192
- </a>
193
- <?php endif; ?>
194
- </div>
195
- <?php
196
- $num++;
197
- }
198
- } else {
199
- for($i = 0; $i <= $value_form_count; $i++) {
200
- ?>
201
- <div class='variation_value'>
202
- <input type='text' class="text" name='new_variation_values[]' value='' />
203
- <a class='image_link delete_variation_value' href='#'>
204
- <img src='<?php echo WPSC_CORE_IMAGES_URL; ?>/trash.gif' alt='<?php _e('Delete', 'wpsc'); ?>' title='<?php _e('Delete', 'wpsc'); ?>' />
205
- </a>
206
- </div>
207
- <?php
208
- }
209
- }
210
- ?>
211
- </div>
212
- <a href='#' class='add_variation_item_form'>+ <?php _e('Add Value'); ?></a>
213
- </td>
214
- </tr>
215
- <tr>
216
- <td>
217
- </td>
218
- <td>
219
- <?php wp_nonce_field('edit-variation', 'wpsc-edit-variation'); ?>
220
- <input type='hidden' name='wpsc_admin_action' value='wpsc-variation-set' />
221
-
222
- <?php if($variation_id > 0) { ?>
223
- <?php
224
- $nonced_url = wp_nonce_url("admin.php?wpsc_admin_action=wpsc-delete-variation-set&amp;deleteid={$variation_id}", 'delete-variation');
225
- ?>
226
- <input type='hidden' name='variation_id' value='<?php echo $variation_id; ?>' />
227
- <input type='hidden' name='submit_action' value='edit' />
228
- <input class='button' style='float:left;' type='submit' name='submit' value='<?php _e('Edit', 'wpsc'); ?>' />
229
- <a class='button delete_button' href='<?php echo $nonced_url; ?>' onclick="return conf();" ><?php _e('Delete', 'wpsc'); ?></a>
230
- <?php } else { ?>
231
- <input type='hidden' name='submit_action' value='add' />
232
- <input class='button' type='submit' name='submit' value='<?php _e('Add', 'wpsc');?>' />
233
- <?php } ?>
234
- </td>
235
- </tr>
236
- </table>
237
- <?php
238
- }
239
-
240
-
241
  ?>
1
+ <?php
2
+ /**
3
+ * WP eCommerce edit and add variation group page functions
4
+ *
5
+ * These are the main WPSC Admin functions
6
+ *
7
+ * @package wp-e-commerce
8
+ * @since 3.7
9
+ */
10
+
11
+ function wpsc_display_variations_page() {
12
+ $columns = array(
13
+ 'title' => __('Name', 'wpsc'),
14
+ 'edit' => __('Edit', 'wpsc')
15
+ );
16
+ register_column_headers('display-variations-list', $columns);
17
+
18
+ ?>
19
+ <script language='javascript' type='text/javascript'>
20
+ function conf() {
21
+ var check = confirm("<?php _e('Are you sure you want to delete this product?', 'wpsc');?>");
22
+ if(check) {
23
+ return true;
24
+ } else {
25
+ return false;
26
+ }
27
+ }
28
+
29
+ <?php
30
+
31
+ ?>
32
+ </script><noscript>
33
+ </noscript>
34
+
35
+ <div class="wrap">
36
+ <h2><?php echo esc_html( __('Display Variations', 'wpsc') ); ?> </h2>
37
+ <p>
38
+ <?php _e('A variation can be anything "optional" about a product. ie: Size, Color, etc <br />For example: if you are selling t-shirts you might setup a variation set called size with the values small, medium, large...', 'wpsc');?>
39
+ </p>
40
+
41
+
42
+ <?php if (isset($_GET['deleted']) || isset($_GET['message'])) { ?>
43
+ <div id="message" class="updated fade">
44
+ <p>
45
+ <?php
46
+ if (isset($_GET['message']) ) {
47
+ $message = absint( $_GET['message'] );
48
+ $messages[1] = __( 'Product updated.', 'wpsc');
49
+ echo $messages[$message];
50
+ unset($_GET['message']);
51
+ }
52
+
53
+ $_SERVER['REQUEST_URI'] = remove_query_arg( array('deleted', 'message'), $_SERVER['REQUEST_URI'] );
54
+ ?>
55
+ </p>
56
+ </div>
57
+ <?php } ?>
58
+
59
+ <div id="col-container" class=''>
60
+ <div id="col-right">
61
+ <div id='poststuff' class="col-wrap">
62
+ <form id="modify-variation-groups" method="post" action="" enctype="multipart/form-data" >
63
+ <?php
64
+ wpsc_admin_variation_forms($_GET['variation_id']);
65
+ ?>
66
+ </form>
67
+ </div>
68
+ </div>
69
+
70
+ <div id="col-left">
71
+ <div class="col-wrap">
72
+ <?php
73
+ wpsc_admin_variation_group_list($category_id);
74
+ ?>
75
+ </div>
76
+ </div>
77
+ </div>
78
+
79
+
80
+ </div>
81
+ <?php
82
+ }
83
+
84
+
85
+ /*
86
+ * wpsc_admin_variation_group_list, prints the left hand side of the edit variations page
87
+ * no parameters
88
+ * nothing returned
89
+ */
90
+
91
+ function wpsc_admin_variation_group_list() {
92
+ global $wpdb;
93
+ ?>
94
+ <table class="widefat page" id='wpsc_variation_list' cellspacing="0">
95
+ <thead>
96
+ <tr>
97
+ <?php print_column_headers('display-variations-list'); ?>
98
+ </tr>
99
+ </thead>
100
+
101
+ <tfoot>
102
+ <tr>
103
+ <?php print_column_headers('display-variations-list', false); ?>
104
+ </tr>
105
+ </tfoot>
106
+
107
+ <tbody>
108
+ <?php
109
+ $variations = get_terms('wpsc-variation', array(
110
+ 'hide_empty'=> 0,
111
+ 'parent' => 0
112
+ ));
113
+ foreach((array)$variations as $variation) {
114
+ ?>
115
+ <tr class="variation-edit" id="variation-<?php echo $variation->term_id; ?>">
116
+ <td class="variation-name"><?php echo htmlentities($variation->name, ENT_QUOTES, 'UTF-8'); ?></td>
117
+ <td class="edit-variation">
118
+ <a href='<?php echo add_query_arg('variation_id', $variation->term_id); ?>'><?php _e('Edit', 'wpsc'); ?></a>
119
+ </td>
120
+ </tr>
121
+ <?php
122
+ }
123
+ ?>
124
+ </tbody>
125
+ </table>
126
+ <?php
127
+ }
128
+
129
+
130
+ /*
131
+ * wpsc_admin_variation_group_list, prints the right hand side of the edit variations page
132
+ * @param int $variation_id the variation ID
133
+ * nothing returned
134
+ */
135
+ function wpsc_admin_variation_forms($variation_id = null) {
136
+ global $wpdb;
137
+ $variation_value_count = 0;
138
+ $variation_name = '';
139
+ if($variation_id > 0 ) {
140
+ $variation_id = absint($variation_id);
141
+ $variation_set = get_term($variation_id, 'wpsc-variation', ARRAY_A);
142
+ $variations = get_terms('wpsc-variation', array(
143
+ 'hide_empty' => 0,
144
+ 'parent' => $variation_id
145
+ ));
146
+ $variation_count = count($variations);
147
+ }
148
+ if(($_GET['valuecount'] > 0)) {
149
+ $value_form_count = absint($_GET['valuecount']);
150
+ } else {
151
+ $value_form_count = 3;
152
+ remove_query_arg( array('valuecount'), $_SERVER['REQUEST_URI'] );
153
+ }
154
+ if($variation_name != '') {
155
+ ?>
156
+ <h3><?php _e('Edit Variation Set', 'wpsc'); ?><span> (<a href="admin.php?page=wpsc-edit-variations">Add new Variation Set</a>)</span></h3>
157
+ <?php
158
+ } else {
159
+ ?>
160
+ <h3><?php _e('Add Variation Set', 'wpsc'); ?></h3>
161
+ <?php
162
+ }
163
+ ?>
164
+ <table class='category_forms'>
165
+ <tr>
166
+ <td>
167
+ <?php _e('Name', 'wpsc'); ?>:
168
+ </td>
169
+ <td>
170
+ <input type='text' class="text" name='name' value='<?php echo $variation_set['name']; ?>' />
171
+ </td>
172
+ </tr>
173
+ <tr>
174
+ <td>
175
+ <?php _e('Variation Values', 'wpsc'); ?>:
176
+ </td>
177
+ <td>
178
+ <div id='variation_values'>
179
+ <?php
180
+ if($variation_count > 0) {
181
+ $num = 0;
182
+ foreach($variations as $variation) {
183
+ $delete_url = wp_nonce_url("admin.php?wpsc_admin_action=wpsc-variation-set&amp;delete_value=true&amp;variation_id={$variation_id}&amp;value_id={$variation->term_id}", "delete-variation-{$variation->term_id}");
184
+ ?>
185
+ <div class='variation_value' id='variation_row_<?php echo $variation->term_id; ?>'>
186
+ <a class='variation_handle' href="#">&equiv;</a>
187
+ <input type='text' class='text' name='variation_values[<?php echo $variation->term_id; ?>]' value='<?php echo htmlentities($variation->name, ENT_QUOTES, 'UTF-8'); ?>' />
188
+ <input type='hidden' class='variation_values_id' name='variation_values_id[]' value='<?php echo $variation->term_id; ?>' />
189
+ <?php if($variation_count > 1): ?>
190
+ <a class='image_link delete_variation_value' href='<?php echo $delete_url; ?>' >
191
+ <img src='<?php echo WPSC_CORE_IMAGES_URL; ?>/trash.gif' alt='<?php _e('Delete', 'wpsc'); ?>' title='<?php _e('Delete', 'wpsc'); ?>' />
192
+ </a>
193
+ <?php endif; ?>
194
+ </div>
195
+ <?php
196
+ $num++;
197
+ }
198
+ } else {
199
+ for($i = 0; $i <= $value_form_count; $i++) {
200
+ ?>
201
+ <div class='variation_value'>
202
+ <input type='text' class="text" name='new_variation_values[]' value='' />
203
+ <a class='image_link delete_variation_value' href='#'>
204
+ <img src='<?php echo WPSC_CORE_IMAGES_URL; ?>/trash.gif' alt='<?php _e('Delete', 'wpsc'); ?>' title='<?php _e('Delete', 'wpsc'); ?>' />
205
+ </a>
206
+ </div>
207
+ <?php
208
+ }
209
+ }
210
+ ?>
211
+ </div>
212
+ <a href='#' class='add_variation_item_form'>+ <?php _e('Add Value'); ?></a>
213
+ </td>
214
+ </tr>
215
+ <tr>
216
+ <td>
217
+ </td>
218
+ <td>
219
+ <?php wp_nonce_field('edit-variation', 'wpsc-edit-variation'); ?>
220
+ <input type='hidden' name='wpsc_admin_action' value='wpsc-variation-set' />
221
+
222
+ <?php if($variation_id > 0) { ?>
223
+ <?php
224
+ $nonced_url = wp_nonce_url("admin.php?wpsc_admin_action=wpsc-delete-variation-set&amp;deleteid={$variation_id}", 'delete-variation');
225
+ ?>
226
+ <input type='hidden' name='variation_id' value='<?php echo $variation_id; ?>' />
227
+ <input type='hidden' name='submit_action' value='edit' />
228
+ <input class='button' style='float:left;' type='submit' name='submit' value='<?php _e('Edit', 'wpsc'); ?>' />
229
+ <a class='button delete_button' href='<?php echo $nonced_url; ?>' onclick="return conf();" ><?php _e('Delete', 'wpsc'); ?></a>
230
+ <?php } else { ?>
231
+ <input type='hidden' name='submit_action' value='add' />
232
+ <input class='button' type='submit' name='submit' value='<?php _e('Add', 'wpsc');?>' />
233
+ <?php } ?>
234
+ </td>
235
+ </tr>
236
+ </table>
237
+ <?php
238
+ }
239
+
240
+
241
  ?>
wpsc-admin/includes/display-items-functions.php CHANGED
@@ -55,572 +55,40 @@ $wpsc_product_defaults = array(
55
  ),
56
  ),
57
  );
58
- // Justin Sainton - 5.8.2010 - Adding this function for backwards_compatible array_replace
59
 
60
- if ( !function_exists( 'array_replace_recursive' ) ) {
61
-
62
- function array_replace_recursive( $array, $array1 ) {
63
-
64
- function recurse( $array, $array1 ) {
65
- foreach ( $array1 as $key => $value ) {
66
- // create new key in $array, if it is empty or not an array
67
- if ( !isset( $array[$key] ) || (isset( $array[$key] ) && !is_array( $array[$key] )) ) {
68
- $array[$key] = array( );
69
- }
70
-
71
- // overwrite the value in the base array
72
- if ( is_array( $value ) ) {
73
- $value = recurse( $array[$key], $value );
74
- }
75
- $array[$key] = $value;
76
- }
77
- return $array;
78
- }
79
-
80
- // handle the arguments, merge one by one
81
- $args = func_get_args();
82
- $array = $args[0];
83
- if ( !is_array( $array ) ) {
84
- return $array;
85
- }
86
- for ( $i = 1; $i < count( $args ); $i++ ) {
87
- if ( is_array( $args[$i] ) ) {
88
- $array = recurse( $array, $args[$i] );
89
- }
90
- }
91
- return $array;
92
- }
93
-
94
- }
95
-
96
- function wpsc_populate_product_data( $product_id, $wpsc_product_defaults ) {
97
- global $wpdb, $product;
98
-
99
- $tt_ids = array( );
100
- $term_ids = array( );
101
- $product = get_post( $product_id );
102
-
103
- $product_data['id'] = $product->ID;
104
- $product_data['name'] = $product->post_title;
105
- $product_data['post_type'] = $product->post_type;
106
- $product_data['post_status'] = $product->post_status;
107
- $product_data['description'] = $product->post_content;
108
- $product_data['additional_description'] = $product->post_excerpt;
109
- // get the list of categories this Product is associated with
110
-
111
- $product_data['categories'] = wp_get_product_categories( $product->ID );
112
- $product_data['tags'] = wp_get_product_tags( $product->ID );
113
- $product_data['category_ids'] = array( );
114
-
115
- $product_data['product_object'] = $product;
116
-
117
- foreach ( (array)$product_data['categories'] as $category_item ) {
118
- $product_data['category_ids'][] = (int)$category_item->term_id;
119
- }
120
-
121
-
122
- // Meta Values come straight from the meta table
123
- $product_data['meta'] = array( );
124
- $product_data['meta'] = get_post_meta( $product->ID, '' );
125
- if ( is_array( $product_data['meta'] ) ) {
126
- foreach ( $product_data['meta'] as $meta_name => $meta_value ) {
127
- $product_data['meta'][$meta_name] = maybe_unserialize( array_pop( $meta_value ) );
128
- }
129
- }
130
- $product_data['dimensions'] = get_product_meta( $product_id, 'dimensions', true );
131
-
132
- // Transformed Values have been altered in some way since being extracted from some data source
133
- $product_data['transformed'] = array( );
134
- $product_data['transformed']['weight'] = wpsc_convert_weight( $product_data['meta']['_wpsc_product_metadata']['weight'], "gram", $product_data['meta']['_wpsc_product_metadata']['display_weight_as'] );
135
-
136
- if ( function_exists( 'wp_insert_term' ) ) {
137
- $term_relationships = $wpdb->get_results( "SELECT * FROM `{$wpdb->term_relationships}` WHERE object_id = '{$product_data['id']}'", ARRAY_A );
138
-
139
- foreach ( (array)$term_relationships as $term_relationship ) {
140
- $tt_ids[] = $term_relationship['term_taxonomy_id'];
141
- }
142
- foreach ( (array)$tt_ids as $tt_id ) {
143
- $term_ids[] = $wpdb->get_var( "SELECT `term_id` FROM `{$wpdb->term_taxonomy}` WHERE `term_taxonomy_id` = '{$tt_id}' AND `taxonomy` = 'product_tag' LIMIT 1" );
144
- }
145
- foreach ( (array)$term_ids as $term_id ) {
146
- if ( $term_id != NULL ) {
147
- $tags[] = $wpdb->get_var( "SELECT `name` FROM `{$wpdb->terms}` WHERE `term_id`='{$term_id}' LIMIT 1" );
148
- }
149
- }
150
- if ( isset( $tags ) ) {
151
- $imtags = implode( ',', $tags );
152
- }
153
- }
154
- return $product_data;
155
- }
156
-
157
- function wpsc_display_product_form( $product_id = 0 ) {
158
- global $wpdb, $wpsc_product_defaults;
159
- $product_id = absint( $product_id );
160
-
161
- if ( $product_id > 0 ) {
162
- $product_data = wpsc_populate_product_data( $product_id, $wpsc_product_defaults );
163
- } else {
164
- if ( isset( $_SESSION['wpsc_failed_product_post_data'] ) && (count( $_SESSION['wpsc_failed_product_post_data'] ) > 0 ) ) {
165
- $product_data = array_merge( $wpsc_product_defaults, $_SESSION['wpsc_failed_product_post_data'] );
166
- $_SESSION['wpsc_failed_product_post_data'] = null;
167
- } else {
168
- $product_data = $wpsc_product_defaults;
169
- }
170
- }
171
-
172
- $current_user = wp_get_current_user();
173
-
174
- // we put the closed postboxes array into the Product data to propagate it to each form without having it global.
175
- $product_data['closed_postboxes'] = (array)get_user_meta( $current_user->ID, 'closedpostboxes_products_page_wpsc-edit-products' );
176
- $product_data['hidden_postboxes'] = (array)get_user_meta( $current_user->ID, 'metaboxhidden_products_page_wpsc-edit-products' );
177
- if ( count( $product_data ) > 0 ) {
178
- wpsc_product_basic_details_form( $product_data );
179
-
180
- }
181
-
182
- }
183
-
184
- /*
185
- Stop-gap function replicating native WP functionality
186
- */
187
-
188
- function add_new_product_id() {
189
- global $wpdb;
190
- $prod_id = $wpdb->get_var( $wpdb->prepare( "SELECT MAX( ID ) FROM $wpdb->posts" ) );
191
- $prod_id = $prod_id + 1;
192
-
193
- $wpdb->query( $wpdb->prepare( "INSERT INTO $wpdb->posts ( post_author, post_date, post_date_gmt, post_title, post_status, post_parent, post_type)
194
- VALUES ( %d, %s, %s, %s, %s, %d, %s )",
195
- 1, 'CURDATE()', 'CURDATE()', 'stopgap', 'inherit', $prod_id, 'attachment' ) );
196
-
197
- return $prod_id;
198
- }
199
-
200
- function delete_stopgap() {
201
- global $wpdb;
202
- $wpdb->query( "DELETE FROM $wpdb->posts WHERE post_parent = $uploading_iframe_ID AND post_title = 'stopgap'" );
203
- }
204
-
205
- if ( isset( $product_data['id'] ) && $product_data['id'] > 0 ) {
206
- add_action( 'transition_post_status', 'delete_stopgap' );
207
- }
208
-
209
- function wpsc_product_basic_details_form( &$product_data ) {
210
- global $wpdb, $nzshpcrt_imagesize_info, $user_ID;
211
-
212
- if ( !isset( $product_data['product_object'] ) )
213
- $product_data['product_object'] = new stdClass();
214
- $product = $product_data['product_object'];
215
- $post_ID = (int)$product_data["id"];
216
- ?>
217
- <h3 class='form_heading' style="display:none;">
218
- <?php
219
-
220
- if ( !isset( $_GET["product"] ) || $_GET["product"] <= 0 )
221
- $product_data["id"] = $_GET["product"] = add_new_product_id();
222
-
223
- $form_extra = '';
224
- if ( !isset( $product->post_status ) )
225
- $product->post_status = '';
226
- if ( 'auto-draft' == $product->post_status ) {
227
- if ( 'edit' == $action )
228
- $product->post_title = '';
229
- $autosave = false;
230
- $form_extra .= "<input type='hidden' id='auto_draft' name='auto_draft' value='1' />";
231
- } else {
232
- $autosave = wp_get_post_autosave( $product_data["id"] );
233
- }
234
- if ( !isset( $product->post_type ) )
235
- $product->post_type = '';
236
- $nonce_action = 'update-' . $product->post_type . '_' . $product_data["id"];
237
- $form_extra .= "<input type='hidden' id='post_ID' name='post_ID' value='" . esc_attr( $product_data["id"] ) . "' />";
238
- ?>
239
- </h3>
240
- <div id="side-info-column" class="inner-sidebar">
241
- <div id="side-sortables" class='meta-box-sortables-wpec ui-sortable'>
242
- <?php
243
- wp_nonce_field( $nonce_action );
244
- if ( !isset( $form_action ) )
245
- $form_action = '';
246
- if ( !isset( $product->post_author ) )
247
- $product->post_author = '';
248
- if ( !isset( $product->post_type ) )
249
- $product->post_type = '';
250
- if ( !isset( $product->post_status ) )
251
- $product->post_status = '';
252
- if ( !isset( $product->ID ) )
253
- $product->ID = 0;
254
-
255
- ?>
256
- <input type="hidden" id="user-id" name="user_ID" value="<?php echo (int)$user_ID ?>" />
257
- <input type="hidden" id="hiddenaction" name="action" value="<?php echo esc_attr( $form_action ) ?>" />
258
- <input type="hidden" id="originalaction" name="originalaction" value="<?php echo esc_attr( $form_action ) ?>" />
259
- <input type="hidden" id="post_author" name="post_author" value="<?php echo esc_attr( $product->post_author ); ?>" />
260
- <input type="hidden" id="post_type" name="post_type" value="<?php echo esc_attr( $product->post_type ) ?>" />
261
- <input type="hidden" id="original_post_status" name="original_post_status" value="<?php echo esc_attr( $product->post_status ) ?>" />
262
- <input type="hidden" id="referredby" name="referredby" value="<?php echo esc_url( stripslashes( wp_get_referer() ) ); ?>" />
263
- <?php
264
- if ( 'draft' != $product->post_status )
265
- wp_original_referer_field( true, 'previous' );
266
-
267
- echo $form_extra;
268
-
269
- wp_nonce_field( 'autosave', 'autosavenonce', false );
270
- ?>
271
- <input type='hidden' name='product_id' id='product_id' value='<?php echo (int)$product_data["id"]; ?>' />
272
- <input type='hidden' name='wpsc_admin_action' value='edit_product' />
273
- <?php wp_nonce_field( 'edit-product', 'wpsc-edit-product' ); ?>
274
- <div id="submitdiv" class="postbox">
275
- <div class="handlediv" title="Click to toggle"><br></div>
276
- <h3 class="hndle"><span>Publish</span></h3>
277
- <div class="inside publish">
278
- <div class="submitbox" id="submitpost"><br />
279
- <div id="minor-publishing">
280
- <div id="minor-publishing-actions">
281
- <div id="save-action">
282
- <?php if ( ($product->post_status == 'draft') || ($product->post_status == null) ) : ?>
283
- <input type='submit' value='<?php _e( 'Save Draft', 'wpsc' ); ?>' class='button button-highlighted' id="save-post" name='save' />
284
- <?php else : ?>
285
- <input type='submit' value='<?php _e( 'Unpublish', 'wpsc' ); ?>' class='button button-highlighted' id='save-post' name='unpublish' />
286
- <?php endif; ?>
287
- </div>
288
- <div id="preview-action">
289
- <a class="preview button" target='_blank' href="<?php echo wpsc_product_url( $product->ID ); ?>"><?php _e( 'View Product' ) ?></a>
290
- </div>
291
- <div class="clear"></div>
292
- </div>
293
- </div>
294
- <div id="major-publishing-actions">
295
- <div id="delete-action">
296
- <a class='submitdelete deletion' title='<?php echo esc_attr( __( 'Delete this Product' ) ); ?>' href='<?php echo wp_nonce_url( admin_url("admin.php?wpsc_admin_action=trash&amp;product={$product_data['id']}&product_parent"), 'delete_product_' . $product_data['id'] ); ?>' onclick="if ( confirm(' <?php echo esc_js( sprintf( __( "You are about to delete this Product '%s'\n 'Cancel' to stop, 'OK' to delete." ), $product_data['name'] ) ) ?>') ) { return true;}return false;"><?php _e( 'Move to Trash' ) ?>
297
- </a><br />
298
- </div>
299
- <div id="publishing-action">
300
- <?php if ( ($product->post_status == 'draft') || ($product->post_status == null) ) : ?>
301
- <input type='submit' value='<?php _e( 'Publish', 'wpsc' ); ?>' id='publish' class='button-primary' name='publish' />
302
- <?php else : ?>
303
- <input type='submit' value='<?php _e( 'Update', 'wpsc' ); ?>' id='publish' class='button-primary' name='save' />
304
- <?php endif; ?>
305
- </div>
306
- <div class="clear"></div>
307
- </div>
308
- </div>
309
- </div>
310
- </div>
311
- <?php
312
- $default_order = array(
313
- "advanced" => array(
314
- "wpsc_product_shipping_forms",
315
- "wpsc_product_variation_forms",
316
- "wpsc_product_external_link_forms",
317
- "wpsc_product_advanced_forms"
318
- ),
319
- "side" => array(
320
- "wpsc_product_category_and_tag_forms",
321
- "wpsc_product_tag_forms",
322
- "wpsc_price_control_forms",
323
- "wpsc_stock_control_forms",
324
- "wpsc_product_taxes_forms",
325
- "wpsc_product_image_forms",
326
- "wpsc_product_download_forms"
327
- ),
328
- "closedboxes" => array(
329
- "wpsc_product_shipping_forms" => 1,
330
- "wpsc_product_tag_forms" => 1,
331
- "wpsc_product_variation_forms" => 1,
332
- "wpsc_product_external_link_forms" => 1,
333
- "wpsc_product_advanced_forms" => 1,
334
- "wpsc_product_category_and_tag_forms" => 1,
335
- "wpsc_price_control_forms" => 1,
336
- "wpsc_stock_control_forms" => 1,
337
- "wpsc_product_taxes_forms" => 1,
338
- "wpsc_product_image_forms" => 1,
339
- "wpsc_product_download_forms" => 1
340
- ),
341
- "hiddenboxes" => array(
342
- "wpsc_product_shipping_forms" => 1,
343
- "wpsc_product_tag_forms" => 1,
344
- "wpsc_product_variation_forms" => 1,
345
- "wpsc_product_external_link_forms" => 1,
346
- "wpsc_product_advanced_forms" => 1,
347
- "wpsc_product_category_and_tag_forms" => 1,
348
- "wpsc_price_control_forms" => 1,
349
- "wpsc_stock_control_forms" => 1,
350
- "wpsc_product_taxes_forms" => 1,
351
- "wpsc_product_image_forms" => 1,
352
- "wpsc_product_download_forms" => 1
353
- )
354
- );
355
-
356
- $order = get_option( 'wpsc_product_page_order' );
357
- $order = apply_filters( 'wpsc_products_page_forms', $order );
358
- if ( ( $order == '' ) || ( count( $order, COUNT_RECURSIVE ) < 32 ) || ( count( $order ) == count( $order, COUNT_RECURSIVE ) ) ) {
359
- $order = $default_order;
360
- }
361
-
362
- foreach ( $order as $key => $values ) {
363
- $check_missing_items = array_diff( (array)$default_order[$key], (array)$values );
364
-
365
- if ( count( $check_missing_items ) > 0 ) {
366
- $order[$key] = array_merge( $check_missing_items, (array)$order[$key] );
367
- }
368
- }
369
- $check_missing_items = array_diff( $default_order, $order );
370
-
371
- if ( count( $check_missing_items ) > 0 ) {
372
- $order = array_merge( $check_missing_items, $order );
373
- }
374
-
375
- update_option( 'wpsc_product_page_order', $order );
376
-
377
- // if this is a child Product, we need to filter out the variations box here
378
- if(isset($product_data['product_object']->post_parent) && $product_data['product_object']->post_parent > 0) {
379
- foreach($order as $key => $values){
380
- $variation_box_key = array_search('wpsc_product_variation_forms', $values);
381
- if(count($variation_box_key) > 0)
382
- unset($order[$key][$variation_box_key]);
383
-
384
- $category_box_key = array_search('wpsc_product_category_and_tag_forms', $values);
385
- if(is_numeric($category_box_key) && isset($order[$key][$category_box_key]))
386
- unset($order[$key][$category_box_key]);
387
- }
388
-
389
- }
390
-
391
- foreach ( (array)$order["side"] as $key => $box_function_name ) {
392
- if ( function_exists( $box_function_name ) ) {
393
- echo call_user_func( $box_function_name, $product_data );
394
- }
395
- }
396
-
397
- ?>
398
- </div>
399
- </div>
400
- <script type="text/javascript">
401
- var makeSlugeditClickable;
402
- makeSlugeditClickable = null;
403
- //<![CDATA[
404
- jQuery(document).ready( function($) {
405
- <?php
406
- $closed_boxes = $order["closedboxes"];
407
- foreach ( $closed_boxes as $key => $val ) {
408
- if ( $val == 0 ) {
409
- ?>
410
- $('div#<?php echo $key; ?>').addClass('closed');
411
- <?php
412
- }
413
- }
414
- ?>
415
- $('#poststuff .postbox h3, .postbox div.handlediv').click( function() {
416
- $(this).parent().toggleClass('closed');
417
- wpsc_save_postboxes_state('toplevel_page_wpsc-edit-products', '#poststuff');
418
- });
419
-
420
- <?php
421
- $hidden_boxes = $order["hiddenboxes"];
422
- foreach ( $hidden_boxes as $key => $val ) {
423
- if ( $val == 0 ) {
424
- ?>
425
- $('div#<?php echo $key; ?>').css('display', 'none');
426
- $('div.metabox-prefs label input[value=<?php echo $key; ?>]').attr('checked', false);
427
- <?php
428
- } elseif ( $val == 1 ) {
429
- ?>
430
- $('div.metabox-prefs label input[value=<?php echo $key; ?>]').attr('checked', true);
431
-
432
- <?php
433
- }
434
- }
435
- ?>
436
-
437
- $('div.variation input, div.variation_set input').click(function(){
438
- $('a.update_variations_action').show();
439
- });
440
- });
441
- //]]>
442
- </script>
443
- <?php
444
- if ( isset( $_GET["product_parent"] ) && ($_GET["product_parent"] != '') ) {
445
- $parent_link = add_query_arg( array( 'page' => 'wpsc-edit-products', 'action' => 'wpsc_add_edit', 'product' => $_GET["product_parent"] ) );
446
- $parent_link = wp_nonce_url( $parent_link, 'edit-product_' . $product->ID );
447
- }
448
-
449
- if ( isset( $_GET["product_parent"] ) && ($_GET["product_parent"] != '') && ($_GET["product_parent"] != $_GET["product"]) ) : ?>
450
-
451
- <a class="button preview update_variations" href="<?php echo $parent_link ?>">Back to Main Product</a>
452
-
453
- <?php endif; ?>
454
-
455
- <!-- Start of post body -->
456
- <div id="post-body" class="has-sidebar">
457
- <div id="post-body-content">
458
- <table class='product_editform' >
459
- <tr>
460
- <td colspan='2' class='itemfirstcol'>
461
-
462
- <div class='admin_product_name'>
463
- <input id='title' class='wpsc_product_name text' size='15' type='text' name='post_title' value='<?php echo htmlentities( stripslashes( $product_data['name'] ), ENT_QUOTES, 'UTF-8' ); ?>' />
464
- <a href='#' class='shorttag_toggle'></a>
465
- </div>
466
- <div class='admin_product_shorttags'>
467
- <h4>
468
- <?php _e( 'Shortcodes', 'wpsc' ); global $wpsc_product_defaults; ?></h4>
469
-
470
- <dl>
471
- <dt><?php _e( 'Display Product Shortcode', 'wpsc' ); ?>: </dt><dd>[wpsc_products product_id='<?php echo $product_data['id']; ?>']</dd>
472
- <dt><?php _e( 'Buy Now Shortcode', 'wpsc' ); ?>: </dt><dd>[buy_now_button=<?php echo $product_data['id']; ?>]</dd>
473
- <dt><?php _e( 'Add to Cart Shortcode', 'wpsc' ); ?>: </dt><dd>[add_to_cart=<?php echo $product_data['id']; ?>]</dd>
474
- </dl>
475
-
476
- <h4><?php _e( 'Template Tags', 'wpsc' ); ?></h4>
477
-
478
- <dl>
479
- <dt><?php _e( 'Display Product Template Tag', 'wpsc' ); ?>: </dt><dd> &lt;?php echo wpsc_display_products('product_id=<?php echo $product_data['id']; ?>'); ?&gt;</dd>
480
- <dt><?php _e( 'Buy Now PHP', 'wpsc' ); ?>: </dt><dd>&lt;?php echo wpsc_buy_now_button(<?php echo $product_data['id']; ?>); ?&gt;</dd>
481
- <dt><?php _e( 'Add to Cart PHP', 'wpsc' ); ?>: </dt><dd>&lt;?php echo wpsc_add_to_cart_button(<?php echo $product_data['id']; ?>); ?&gt;</dd>
482
- <dt><?php _e( 'Display Product SKU', 'wpsc' ); ?>: </dt><dd>&lt;?php echo wpsc_product_sku(<?php echo $product_data['id']; ?>); ?&gt;</dd>
483
- </dl>
484
-
485
- <?php if ( $product_data['id'] > 0 ) : ?>
486
- <p><a href="<?php echo wpsc_product_url( $product_data['id'] ); ?>" target="_blank" class="button">View Products</a></p>
487
- <?php endif; ?>
488
-
489
- </div>
490
- <div style='clear:both; height: 0px; margin-bottom: 15px;'></div>
491
- </td>
492
- </tr>
493
- <tr>
494
- <td colspan='2'>
495
- <div id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>" class="postarea" >
496
 
497
- <?php wpsc_the_editor( $product_data['description'], 'content', true, true ); ?>
498
-
499
- <table id="post-status-info" cellspacing="0">
500
- <tbody>
501
- <tr>
502
- <td id="wp-word-count"></td>
503
- <td class="autosave-info">
504
- <span id="autosave">&nbsp;</span>
505
- </td>
506
- </tr>
507
- </tbody>
508
- </table>
509
- </div>
510
- </td>
511
- </tr>
512
- </table>
513
- </div>
514
- <div id="advanced-sortables" class="meta-box-sortables-wpec ui-sortable">
515
- <div class="postbox">
516
- <div class="handlediv" title="Click to toggle"><br /></div>
517
- <h3 class='hndle'><?php _e( 'Additional Description', 'wpsc' ); ?></h3>
518
- <div class="inside">
519
-
520
- <textarea name='additional_description' id='additional_description' cols='40' rows='5' ><?php echo stripslashes( $product_data['additional_description'] ); ?></textarea>
521
- </div>
522
- </div>
523
- <?php
524
- foreach ( (array)$order["advanced"] as $key => $box_function_name ) {
525
- if ( function_exists( $box_function_name ) ) {
526
- echo call_user_func( $box_function_name, $product_data );
527
- }
528
- }
529
- ?>
530
- </div>
531
- </div>
532
- <?php
533
- do_meta_boxes('wpsc-product', 'side', $product_data);
534
  }
535
 
536
- function wpsc_product_tag_forms( $product_data='' ) {
537
- global $closed_postboxes, $wpdb, $variations_processor;
538
- $output = '';
539
- $tag_array = array( );
540
-
541
- if ( !isset( $product_data['tags'] ) )
542
- $product_data['tags'] = array( );
543
-
544
- foreach ( (array)$product_data['tags'] as $tag )
545
- $tag_array[] = $tag->name;
546
-
547
- if ( $product_data == 'empty' )
548
- $display = "style='visibility:hidden;'";
549
-
550
- $output .= "<div id='wpsc_product_tag_forms' class=' postbox " . ((array_search( 'wpsc_product_tag_forms', $product_data['closed_postboxes'] ) !== false) ? 'closed' : '') . "'><div class=\"handlediv\" title=\"Click to toggle\"><br></div>";
551
-
552
- if ( IS_WP27 )
553
- $output .= "<h3 class='hndle'>";
554
- else
555
- $output .= "<h3><a class='togbox'>+</a>";
556
-
557
- $output .= __( 'Product Tags', 'wpsc' );
558
-
559
- $output .= "</h3>
560
- <div class='inside'>";
561
- $output .= "
562
- <p id='jaxtag'>
563
- <label for='tags-input' class='hidden'>" . __( 'Product Tags', 'wpsc' ) . "</label>
564
- <input type='text' value='" . implode( ',', $tag_array ) . "' tabindex='3' size='20' id='tags-input' class='tags-input' name='product_tags'/>
565
- <span class='howto'>" . __( 'Separate tags with commas' ) . "</span>
566
- </p>
567
- <div id='tagchecklist' class='tagchecklist' onload='tag_update_quickclicks();'></div>";
568
- $output .= "
569
- </div>
570
- </div>";
571
-
572
- $output = apply_filters( 'wpsc_product_tag_forms_output', $output );
573
-
574
- return $output;
575
  }
 
 
 
 
576
 
577
- function wpsc_product_category_and_tag_forms( $product_data='' ) {
578
- global $closed_postboxes, $wpdb, $variations_processor;
579
-
580
- $output = '';
581
- $tag_array = array();
582
-
583
- if ( !isset( $product_data['tags'] ) )
584
- $product_data['tags'] = array( );
585
-
586
- foreach ( (array)$product_data['tags'] as $tag )
587
- $tag_array[] = $tag->name;
588
-
589
- if ( $product_data == 'empty' )
590
- $display = "style='visibility:hidden;'";
591
-
592
- $output .= "<div id='wpsc_product_category_and_tag_forms' class=' postbox " . ((array_search( 'wpsc_product_category_and_tag_forms', $product_data['closed_postboxes'] ) !== false) ? 'closed' : '') . "'><div class=\"handlediv\" title=\"Click to toggle\"><br></div>";
593
-
594
- if ( IS_WP27 )
595
- $output .= "<h3 class='hndle'>";
596
- else
597
- $output .= "<h3><a class='togbox'>+</a>";
598
-
599
- $output .= __( 'Categories', 'wpsc' );
600
 
601
- $output .= "</h3>
602
- <div class='inside'>";
603
 
604
- $output .= "<div id='categorydiv' >";
605
-
606
- $search_sql = apply_filters( 'wpsc_product_category_and_tag_forms_group_search_sql', '' );
607
-
608
- $output .= wpsc_category_list( $product_data, 0, $product_data['id'], 'edit_' );
609
-
610
- $output .= "</div>";
611
-
612
- $output .= "</div>
613
- </div>";
614
-
615
- $output = apply_filters( 'wpsc_product_category_and_tag_forms_output', $output );
616
-
617
- return $output;
618
- }
619
- function wpsc_price_control_forms($product_data){
620
- global $closed_postboxes, $wpdb, $variations_processor, $wpsc_product_defaults;
621
- $product_meta = &$product_data['meta']['_wpsc_product_metadata'];
622
  if( isset( $product_data['meta']['_wpsc_currency']))
623
- $product_alt_currency = $product_data['meta']['_wpsc_currency'];
624
 
625
  if ( !isset( $product_data['meta']['_wpsc_table_rate_price'] ) )
626
  $product_data['meta']['_wpsc_table_rate_price'] = $wpsc_product_defaults['meta']['table_rate_price'];
@@ -646,15 +114,14 @@ function wpsc_price_control_forms($product_data){
646
 
647
  $currency_data = $wpdb->get_results( "SELECT * FROM `" . WPSC_TABLE_CURRENCY_LIST . "` ORDER BY `country` ASC", ARRAY_A );
648
  ?>
649
-
650
- <div id='wpsc_price_control_forms' class='wpsc_price_control_forms postbox <?php if(array_search( 'wpsc_price_control_forms', $product_data['closed_postboxes'] ) !== false) echo 'closed'; else echo ''; ?>' <?php if(array_search( 'wpsc_price_control_forms', $product_data['hidden_postboxes'] ) !== false) echo 'style="display: none;"'; else echo '';?> ><div class="handlediv" title="Click to toggle"><br></div>
651
-
652
- <h3 class='hndle'><?php _e( 'Price Control', 'wpsc' ); ?></h3>
653
- <div class="inside">
654
- <?php /* Check product if a product has variations */ ?>
655
- <?php if( wpsc_product_has_children($product_data['id']) ) : ?>
656
- <?php $price = wpsc_product_variation_price_available($product_data['id']); ?>
657
- <p><?php printf( __( 'This Product has variations, to edit the price please use the %1s Variation Controls %2s below.' , 'wpsc' ), '<a href="#variation_control">','</a>' ); ?></p>
658
  <p><?php printf( __( 'Price: %s and above.' ,'wpsc' ) , $price ); ?></p>
659
  <?php else: ?>
660
 
@@ -694,7 +161,8 @@ function wpsc_price_control_forms($product_data){
694
  $i = 0;
695
  foreach ($product_alt_currency as $iso => $alt_price ) {
696
  $i++; ?>
697
- <br /><label for='newCurrency[]'><?php _e( 'Currency type', 'wpsc' ); ?>:</label><br />
 
698
  <select name='newCurrency[]' class='newCurrency' style='width:42%'> <?php
699
  foreach ( $currency_data as $currency ) {
700
  if ( $iso == $currency['isocode'] )
@@ -707,9 +175,9 @@ function wpsc_price_control_forms($product_data){
707
  } ?>
708
  </select>
709
  <?php _e( 'Price', 'wpsc' ); ?>: <input type='text' class='text' size='8' name='newCurrPrice[]' value='<?php echo $alt_price; ?>' style=' display:inline' />
710
- <a href='' class='wpsc_delete_currency_layer' rel='<?php echo $iso; ?>'><img src='<?php echo WPSC_CORE_IMAGES_URL; ?>/cross.png' /></a><br />
711
  <?php }
712
-
713
  endif;
714
 
715
  echo "<br style='clear:both' />
@@ -752,22 +220,23 @@ function wpsc_price_control_forms($product_data){
752
  </table>
753
  </div>
754
  <?php endif; ?>
755
- </div>
756
- </div>
757
  <?php
758
  }
759
- function wpsc_stock_control_forms( $product_data='' ) {
760
- global $closed_postboxes, $wpdb, $variations_processor, $wpsc_product_defaults;
761
- $product_meta = &$product_data['meta']['_wpsc_product_metadata'];
 
 
 
 
 
 
 
762
 
763
  if ( !isset( $product_meta['unpublish_when_none_left'] ) )
764
  $product_meta['unpublish_when_none_left'] = ''; ?>
765
 
766
- <div id='wpsc_stock_control_forms' class='wpsc_stock_control_forms postbox <?php if(array_search( 'wpsc_stock_control_forms', $product_data['closed_postboxes'] ) !== false) echo 'closed'; else echo ''; ?>' <?php if(array_search( 'wpsc_stock_control_forms', $product_data['hidden_postboxes'] ) !== false) echo 'style="display: none;"'; else echo ''; ?> >
767
- <div class="handlediv" title="<?php _e('Click to toggle', 'wpsc'); ?>"><br /></div>
768
- <h3 class='hndle'><?php _e( 'Stock Control', 'wpsc' ); ?></h3>
769
- <div class="inside">
770
- <label for="wpsc_sku"><abbr title="<?php _e( 'Stock Keeping Unit', 'wpsc' ); ?>">SKU:</abbr></label>
771
  <?php
772
  if ( !isset( $product_data['meta']['_wpsc_sku'] ) )
773
  $product_data['meta']['_wpsc_sku'] = $wpsc_product_defaults['meta']['sku']; ?><br />
@@ -779,14 +248,14 @@ function wpsc_stock_control_forms( $product_data='' ) {
779
  <br /><input class='limited_stock_checkbox' id='add_form_quantity_limited' type='checkbox' value='yes' <?php if(is_numeric( $product_data['meta']['_wpsc_stock'] )) echo 'checked="checked"'; else echo ''; ?> name='meta[_wpsc_limited_stock]' />
780
  <label for='add_form_quantity_limited' class='small'><?php _e( 'I have limited stock for this Product', 'wpsc' ); ?></label>
781
  <?php
782
- if ( $product_data['id'] > 0 ){
783
  if ( is_numeric( $product_data['meta']['_wpsc_stock'] ) ){?>
784
  <div class='edit_stock' style='display: block;'> <?php
785
  } else { ?>
786
  <div class='edit_stock' style='display: none;'><?php
787
  } ?>
788
- <?php if( wpsc_product_has_children($product_data['id']) ) : ?>
789
- <?php $stock = wpsc_variations_stock_remaining($product_data['id']); ?>
790
  <p><?php _e( 'This Product has variations, to edit the quantity please use the Variation Controls below.' , 'wpsc' ); ?></p>
791
  <p><?php printf(_n("%s variant item in stock.", "%s variant items in stock.", $stock), $stock); ?></p>
792
  <?php else: ?>
@@ -808,21 +277,23 @@ function wpsc_stock_control_forms( $product_data='' ) {
808
  </div><?php
809
  }
810
  ?>
811
- </div>
812
- </div>
813
  <?php
814
  }
815
- function wpsc_product_taxes_forms($product_data=''){
816
- global $closed_postboxes, $wpdb, $variations_processor, $wpsc_product_defaults;
817
- $product_meta = &$product_data['meta']['_wpsc_product_metadata'];
 
 
818
 
819
  if ( !isset( $product_data['meta']['_wpsc_custom_tax'] ) )
820
  $product_data['meta']['_wpsc_custom_tax'] = '';
821
  $custom_tax = $product_data['meta']['_wpsc_custom_tax'];
822
 
823
 
824
- if ( !isset( $product_meta['custom_tax'] ) )
825
- $product_meta['custom_tax'] = 0.00;
 
 
826
  //Add New WPEC-Taxes Bands Here
827
  $wpec_taxes_controller = new wpec_taxes_controller();
828
 
@@ -833,48 +304,71 @@ function wpsc_product_taxes_forms($product_data=''){
833
  'label' => __( 'Custom Tax Band' )
834
  );
835
  $wpec_taxes_band = '';
836
- if(isset($product_meta['wpec_taxes_band']))
837
- $wpec_taxes_band = $product_meta['wpec_taxes_band'];
 
 
 
 
 
 
 
 
 
 
 
 
838
 
839
- echo "<div id='wpsc_product_taxes_forms' class='wpsc_product_taxes_forms postbox " . ((array_search( 'wpsc_product_taxes_forms', $product_data['closed_postboxes'] ) !== false) ? 'closed' : '') . "' " . ((array_search( 'wpsc_product_taxes_forms', $product_data['hidden_postboxes'] ) !== false) ? 'style="display: none;"' : '') . " ><div class=\"handlediv\" title=\"Click to toggle\"><br></div>"; ?>
840
- <h3 class="hndle"><?php _e( 'Taxes' ); ?></h3>
841
- <div class="inside">
 
 
 
 
 
 
 
 
 
 
 
 
 
842
  <p>
843
- <?php echo $wpec_taxes_controller->wpec_taxes_display_tax_bands( $band_select_settings, $wpec_taxes_band ); ?>
 
 
844
  </p>
845
- </div>
846
- </div>
847
  <?php
848
  }
 
 
849
 
850
- function wpsc_product_variation_forms( $product_data = '' ) {
851
- global $closed_postboxes, $variations_processor, $wp_query;
 
 
 
 
 
 
 
852
 
853
  $siteurl = get_option( 'siteurl' );
854
  $output = '';
855
 
856
- // Hide if there is no Product data
857
- if ( 'empty' == $product_data )
858
- $display = "style='display:none;'";
859
-
860
  // Get variation data from WP Terms
861
- $product_term_data = wp_get_object_terms( $product_data['id'], 'wpsc-variation' );
862
  if ( !empty( $product_term_data ) ) {
863
  foreach ( $product_term_data as $product_term )
864
  $product_terms[] = $product_term->term_id;
865
  } else {
866
  $product_terms = array();
867
  }
868
-
869
- $form_classes = array_search( 'wpsc_product_variation_forms', $product_data['closed_postboxes'] ) !== false ? 'closed' : '';
870
- $form_style = array_search( 'wpsc_product_variation_forms', $product_data['hidden_postboxes'] ) !== false ? 'style="display: none;"' : ''
871
- ?>
872
-
873
- <div id="wpsc_product_variation_forms" class="postbox <?php echo $form_classes; ?>" <?php echo $form_style; ?>>
874
- <div class="handlediv" title="Click to toggle"><br></div>
875
- <h3 class="hndle"><?php _e( 'Variation Control', 'wpsc' ); ?></h3>
876
- <div class="inside">
877
- <?php if( empty( $product_data['name'] ) ) : ?>
878
  <p><?php _e( 'You must first save this Product as a Draft before adding variations', 'wpsc' ); ?></p>
879
  <?php else : ?>
880
  <div id="product_variations">
@@ -927,21 +421,20 @@ function wpsc_product_variation_forms( $product_data = '' ) {
927
  <?php endforeach; ?>
928
 
929
  </div>
930
- <!-- <a href='<?php echo add_query_arg( array( 'page' => 'wpsc-edit-products', 'parent_product' => $product_data['id'] ), "admin.php" ); ?>'><?php _e( 'Edit Variations Products', 'wpsc' ); ?></a> -->
931
- <a class="preview button update_variations_action" href='#'><?php _e( 'Update Variations &rarr;', 'wpsc' ); ?></a>
932
 
933
  </div>
934
  <?php
935
- $parent_product = $product_data['id'];
936
 
937
  $query = array(
938
  'post_type' => 'wpsc-product',
939
  'orderby' => 'menu_order post_title',
940
  'post_parent' => $parent_product,
941
- 'post_status' => 'all',
942
  'order' => "ASC"
943
  );
944
-
945
  $args = array(
946
  'post_type' => 'attachment',
947
  'numberposts' => 1,
@@ -954,36 +447,36 @@ function wpsc_product_variation_forms( $product_data = '' ) {
954
  $image_data = (array)get_posts( $args );
955
  $parent_product_data['image'] = array_shift( $image_data );
956
 
957
- add_filter( 'posts_request', 'wpsc_edit_variations_request_sql' );
 
 
958
  ?>
959
 
960
  <p><a name='variation_control'>&nbsp;</a><?php _e( 'Check or uncheck variation boxes and then click Update Variations to add or remove variations.' ) ?></p>
961
- <table class="widefat page" id='wpsc_product_list' cellspacing="0">
 
962
  <thead>
963
  <tr>
964
- <?php print_column_headers( 'display-product-list' ); ?>
965
  </tr>
966
  </thead>
967
 
968
  <tfoot>
969
  <tr>
970
- <?php print_column_headers( 'display-product-list', false ); ?>
971
  </tr>
972
  </tfoot>
973
 
974
  <tbody>
975
- <?php
976
- $wp_query = new WP_Query( $query );
977
-
978
- if ( !isset( $parent_product_data ) )
979
- $parent_product_data = null;
980
-
981
  wpsc_admin_product_listing( $parent_product_data );
982
- if ( count( $wp_query->posts ) < 1 ) :
983
- ?>
 
 
984
  <tr>
985
  <td colspan="8">
986
- <?php _e( 'You have no Products added.', 'wpsc' ); ?>
987
  </td>
988
  </tr>
989
 
@@ -991,57 +484,415 @@ function wpsc_product_variation_forms( $product_data = '' ) {
991
  </tbody>
992
 
993
  </table>
994
-
995
- <?php endif; ?>
996
-
997
- </div>
998
- </div>
999
-
1000
- <?php
1001
- }
1002
-
1003
- /**
1004
- * Adding function to change text for media buttons
1005
- */
1006
- function change_context() {
1007
- return __( 'Upload Image%s' );
1008
  }
 
 
1009
 
1010
- // Since we're hacking this all together anyway until the complete integration of
1011
- // custom_post_types, we'll go ahead and add the attachment to the db here as well.
1012
- function change_link( $product_data='' ) {
1013
- $uploading_iframe_ID = $_GET["product"];
1014
- $media_upload_iframe_src = "media-upload.php?post_id=$uploading_iframe_ID";
1015
 
1016
- return $media_upload_iframe_src . "&amp;type=image&parent_page=wpsc-edit-products";
1017
- }
1018
 
1019
- if ( !isset( $_GET["product"] ) )
1020
- $_GET["product"] = '';
1021
 
1022
- $uploading_iframe_ID = $_GET["product"];
 
 
1023
 
1024
- //Justin Sainton - 5.19.2010 - Adding filters/actions for the media goodness :) Conditions important to not kill media functionality elsewhere
1025
- if ( isset( $_GET["page"] ) && ($_GET["page"] == "wpsc-edit-products" ) ) {
1026
- add_filter( 'media_buttons_context', 'change_context' );
1027
- add_filter( 'image_upload_iframe_src', "change_link" );
1028
- }
1029
 
1030
- /*
1031
- * Modifications to Media Gallery
1032
- */
1033
 
1034
- if ( (isset( $_REQUEST['parent_page'] ) && ( $_REQUEST['parent_page'] == 'wpsc-edit-products' ) ) ) {
1035
- add_filter( 'media_upload_tabs', 'wpsc_media_upload_tab_gallery', 12 );
1036
- add_filter( 'attachment_fields_to_save', 'wpsc_save_attachment_fields', 9, 2 );
1037
- add_filter( 'media_upload_form_url', 'wpsc_media_upload_url', 9, 1 );
1038
- add_action( 'admin_head', 'wpsc_gallery_css_mods' );
1039
- }
1040
- add_filter( 'gettext','wpsc_filter_delete_text',12 , 3 );
1041
- add_filter( 'attachment_fields_to_edit', 'wpsc_attachment_fields', 11, 2 );
1042
- add_filter( 'gettext','wpsc_filter_feature_image_text', 12, 3 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1043
 
1044
- if( isset( $_REQUEST["save"] ) && is_array($_REQUEST["attachments"]) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1045
  wpsc_regenerate_thumbnails();
1046
  }
1047
 
@@ -1063,7 +914,6 @@ function wpsc_filter_feature_image_text($translation, $text, $domain) {
1063
  }
1064
  return $translation;
1065
  }
1066
-
1067
  function wpsc_attachment_fields($form_fields, $post) {
1068
 
1069
  $parent_post = get_post($post->post_parent);
@@ -1147,8 +997,7 @@ function wpsc_attachment_fields($form_fields, $post) {
1147
  }
1148
  return $form_fields;
1149
 
1150
- }
1151
-
1152
  function wpsc_save_attachment_fields($post, $attachment) {
1153
 
1154
  if ( isset ( $attachment['wpsc_custom_thumb_w']) )
@@ -1162,7 +1011,6 @@ function wpsc_save_attachment_fields($post, $attachment) {
1162
 
1163
  return $post;
1164
  }
1165
-
1166
  function wpsc_media_upload_url($form_action_url) {
1167
 
1168
  $form_action_url = esc_url(add_query_arg(array('parent_page'=>'wpsc-edit-products')));
@@ -1170,7 +1018,6 @@ function wpsc_media_upload_url($form_action_url) {
1170
  return $form_action_url;
1171
 
1172
  }
1173
-
1174
  function wpsc_gallery_css_mods() {
1175
 
1176
  print '<style type="text/css">
@@ -1219,8 +1066,6 @@ function wpsc_gallery_css_mods() {
1219
 
1220
  </script>';
1221
  }
1222
-
1223
-
1224
  function wpsc_media_upload_tab_gallery($tabs) {
1225
 
1226
  unset($tabs['gallery']);
@@ -1228,7 +1073,6 @@ function wpsc_media_upload_tab_gallery($tabs) {
1228
 
1229
  return $tabs;
1230
  }
1231
-
1232
  function wpsc_filter_delete_text($translation, $text, $domain){
1233
 
1234
  if( 'Delete' == $text && isset( $_REQUEST['post_id'] ) && isset( $_REQUEST["parent_page"] ) ){
@@ -1237,574 +1081,138 @@ function wpsc_filter_delete_text($translation, $text, $domain){
1237
  }
1238
  return $translation;
1239
  }
1240
-
1241
-
1242
- function wpsc_product_shipping_forms( $product_data='' ) {
1243
- global $closed_postboxes;
1244
-
1245
- $output = '';
1246
- $product_meta = &$product_data['meta']['_wpsc_product_metadata'];
1247
-
1248
- if ( $product_data == 'empty' ) {
1249
- $display = "style='display:none;'";
1250
- }
1251
- $output .= "<div class='postbox " . ((array_search( 'wpsc_product_shipping_forms', $product_data['closed_postboxes'] ) !== false) ? 'closed' : '') . "' " . ((array_search( 'wpsc_product_shipping_forms', $product_data['hidden_postboxes'] ) !== false) ? 'style="display: none;"' : '') . " id='wpsc_product_shipping_forms'><div class=\"handlediv\" title=\"Click to toggle\"><br></div>";
1252
-
1253
- if ( IS_WP27 )
1254
- $output .= "<h3 class='hndle'>";
1255
- else
1256
- $output .= "<h3><a class='togbox'>+</a>";
1257
-
1258
- $output .= __( 'Shipping Details', 'wpsc' );
1259
-
1260
- if ( !isset( $product_data['transformed']['weight'] ) )
1261
- $product_data['transformed']['weight'] = '';
1262
-
1263
- $output .= "</h3>
1264
- <div class='inside'>
1265
- <table>
1266
-
1267
- <!--USPS shipping changes-->
1268
- <tr>
1269
- <td>
1270
- " . __( 'Weight', 'wpsc' ) . "
1271
- </td>
1272
- <td>
1273
- <input type='text' size='5' name='meta[_wpsc_product_metadata][weight]' value='" . $product_data['transformed']['weight'] . "' />
1274
- <select name='meta[_wpsc_product_metadata][weight_unit]'>
1275
- <option value='pound' " . (($product_meta['display_weight_as'] == 'pound') ? 'selected="selected"' : '') . ">Pounds</option>
1276
- <option value='ounce' " . ((preg_match( "/o(u)?nce/", $product_meta['display_weight_as'] )) ? 'selected="selected"' : '') . ">Ounces</option>
1277
- <option value='gram' " . (($product_meta['display_weight_as'] == 'gram') ? 'selected="selected"' : '') . ">Grams</option>
1278
- <option value='kilogram' " . (($product_meta['display_weight_as'] == 'kilogram' || $product_meta['display_weight_as'] == 'kilograms') ? 'selected="selected"' : '') . ">Kilograms</option>
1279
- </select>
1280
- </td>
1281
- </tr>
1282
- <!--dimension-->
1283
- <tr>
1284
- <td>
1285
- Height
1286
- </td>
1287
- <td>
1288
- <input type='text' size='5' name='meta[_wpsc_product_metadata][dimensions][height]' value='" . $product_meta['dimensions']['height'] . "'>
1289
- <select name='meta[_wpsc_product_metadata][dimensions][height_unit]'>
1290
- <option value='in' " . (($product_meta['dimensions']['height_unit'] == 'in') ? 'selected' : '') . ">inches</option>
1291
- <option value='cm' " . (($product_meta['dimensions']['height_unit'] == 'cm') ? 'selected' : '') . ">cm</option>
1292
- <option value='meter' " . (($product_meta['dimensions']['height_unit'] == 'meter') ? 'selected' : '') . ">meter</option>
1293
- </select>
1294
- </td>
1295
- </tr>
1296
- <tr>
1297
- <td>
1298
- Width
1299
- </td>
1300
- <td>
1301
- <input type='text' size='5' name='meta[_wpsc_product_metadata][dimensions][width]' value='" . $product_meta['dimensions']['width'] . "'>
1302
- <select name='meta[_wpsc_product_metadata][dimensions][width_unit]'>
1303
- <option value='in' " . (($product_meta['dimensions']['width_unit'] == 'in') ? 'selected' : '') . ">inches</option>
1304
- <option value='cm' " . (($product_meta['dimensions']['width_unit'] == 'cm') ? 'selected' : '') . ">cm</option>
1305
- <option value='meter' " . (($product_meta['dimensions']['width_unit'] == 'meter') ? 'selected' : '') . ">meter</option>
1306
- </select>
1307
- </td>
1308
- </tr>
1309
- <tr>
1310
- <td>
1311
- Length
1312
- </td>
1313
- <td>
1314
- <input type='text' size='5' name='meta[_wpsc_product_metadata][dimensions][length]' value='" . $product_meta['dimensions']['length'] . "'>
1315
- <select name='meta[_wpsc_product_metadata][dimensions][length_unit]'>
1316
- <option value='in' " . (($product_meta['dimensions']['length_unit'] == 'in') ? 'selected' : '') . ">inches</option>
1317
- <option value='cm' " . (($product_meta['dimensions']['length_unit'] == 'cm') ? 'selected' : '') . ">cm</option>
1318
- <option value='meter' " . (($product_meta['dimensions']['length_unit'] == 'meter') ? 'selected' : '') . ">meter</option>
1319
- </select>
1320
- </td>
1321
- </tr>
1322
-
1323
- <!--//dimension-->
1324
- <!--USPS shipping changes ends-->
1325
- <tr>
1326
- <td colspan='2'>
1327
- <strong>" . __( 'Flat Rate Settings', 'wpsc' ) . "</strong>
1328
- </td>
1329
- </tr>
1330
- <tr>
1331
- <td>
1332
- " . __( 'Local Shipping Fee', 'wpsc' ) . "
1333
- </td>
1334
- <td>
1335
- <input type='text' size='10' name='meta[_wpsc_product_metadata][shipping][local]' value='" . number_format( $product_meta['shipping']['local'], 2, '.', '' ) . "' />
1336
- </td>
1337
- </tr>
1338
-
1339
- <tr>
1340
- <td>
1341
- " . __( 'International Shipping Fee', 'wpsc' ) . "
1342
- </td>
1343
- <td>
1344
- <input type='text' size='10' name='meta[_wpsc_product_metadata][shipping][international]' value='" . number_format( $product_meta['shipping']['international'], 2, '.', '' ) . "' />
1345
- </td>
1346
- </tr>
1347
- <tr>
1348
- <td>
1349
- <br />
1350
- <input id='add_form_no_shipping' type='checkbox' name='meta[_wpsc_product_metadata][no_shipping]' value='1' " . (($product_meta['no_shipping'] == 1) ? 'checked="checked"' : '') . "/>&nbsp;<label for='add_form_no_shipping'>" . __( 'Disregard Shipping for this Product', 'wpsc' ) . "</label>
1351
- </td>
1352
- </tr>
1353
- </table>
1354
- </div></div>";
1355
-
1356
- return $output;
1357
- }
1358
-
1359
- function wpsc_product_advanced_forms( $product_data='' ) {
1360
- global $closed_postboxes, $wpdb;
1361
-
1362
- $product_meta = &$product_data['meta']['_wpsc_product_metadata'];
1363
-
1364
- $custom_fields = $wpdb->get_results( "
1365
- SELECT
1366
- `meta_id`, `meta_key`, `meta_value`
1367
- FROM
1368
- `{$wpdb->postmeta}`
1369
- WHERE
1370
- `post_id` = {$product_data['id']}
1371
- AND
1372
- `meta_key` NOT LIKE '\_%'
1373
- ORDER BY
1374
- LOWER(meta_key)", ARRAY_A
1375
- );
1376
-
1377
- $output = '';
1378
-
1379
- if ( $product_data == 'empty' )
1380
- $display = "style='display:none;'";
1381
-
1382
- $output .= "<div id='wpsc_product_advanced_forms' class='postbox " . ((array_search( 'wpsc_product_advanced_forms', $product_data['closed_postboxes'] ) !== false) ? 'closed' : '') . "' " . ((array_search( 'wpsc_product_advanced_forms', $product_data['hidden_postboxes'] ) !== false) ? 'style="display: none;"' : '') . "><div class=\"handlediv\" title=\"Click to toggle\"><br /></div>";
1383
-
1384
- $output .= "<h3 class='hndle'>";
1385
- $output .= __( 'Advanced Options', 'wpsc' );
1386
- $output .= "</h3>
1387
- <div class='inside'>
1388
- <table>";
1389
-
1390
- $output .= "<tr>
1391
- <td colspan='2' class='itemfirstcol'>
1392
- <strong>" . __( 'Custom Meta', 'wpsc' ) . ":</strong><br />
1393
- <a href='#' class='add_more_meta' onclick='return add_more_meta(this)'> + " . __( 'Add Custom Meta', 'wpsc' ) . "</a><br /><br />";
1394
-
1395
- foreach ( (array)$custom_fields as $custom_field ) {
1396
- $i = $custom_field['meta_id'];
1397
- // for editing, the container needs an id, I can find no other tidyish method of passing a way to target this object through an ajax request
1398
- $output .= "
1399
- <div class='product_custom_meta' id='custom_meta_$i'>
1400
- " . __( 'Name', 'wpsc' ) . "
1401
- <input type='text' class='text' value='{$custom_field['meta_key']}' name='custom_meta[$i][name]' id='custom_meta_name_$i'>
1402
-
1403
- " . __( 'Value', 'wpsc' ) . "
1404
- <textarea class='text' name='custom_meta[$i][value]' id='custom_meta_value_$i'>{$custom_field['meta_value']}</textarea>
1405
- <a href='#' class='remove_meta' onclick='return remove_meta(this, $i)'>" . __( 'Delete' ) . "</a>
1406
- <br />
1407
- </div>";
1408
- }
1409
-
1410
- $output .= "
1411
- <div class='product_custom_meta'>
1412
- " . __( 'Name', 'wpsc' ) . ": <br />
1413
- <input type='text' name='new_custom_meta[name][]' value='' class='text'/><br />
1414
- " . __( 'Description', 'wpsc' ) . ": <br />
1415
- <textarea name='new_custom_meta[value][]' cols='40' rows='10' class='text' ></textarea>
1416
- <br />
1417
- </div>
1418
- </td>
1419
- </tr>";
1420
-
1421
- $output .= "
1422
- <tr>
1423
- <td class='itemfirstcol' colspan='2'><br /> <strong>" . __( 'Merchant Notes', 'wpsc' ) . ":</strong><br />
1424
-
1425
- <textarea cols='40' rows='3' name='meta[_wpsc_product_metadata][merchant_notes]' id='merchant_notes'>";
1426
- if ( isset( $product_meta['merchant_notes'] ) )
1427
- $output .= stripslashes( $product_meta['merchant_notes'] );
1428
-
1429
- $output .= "</textarea>
1430
- <small>" . __( 'These notes are only available here.', 'wpsc' ) . "</small>
1431
- </td>
1432
- </tr>";
1433
-
1434
- $output .="
1435
- <tr>
1436
- <td class='itemfirstcol' colspan='2'><br />
1437
- <strong>" . __( 'Personalisation Options', 'wpsc' ) . ":</strong><br />
1438
- <input type='hidden' name='meta[_wpsc_product_metadata][engraved]' value='0' />
1439
- <input type='checkbox' name='meta[_wpsc_product_metadata][engraved]' " . (($product_meta['engraved'] == true) ? 'checked="checked"' : '') . " id='add_engrave_text' />
1440
- <label for='add_engrave_text'> " . __( 'Users can personalize this Product by leaving a message on single product page', 'wpsc' ) . "</label>
1441
- <br />
1442
- </td>
1443
- </tr>
1444
- <tr>
1445
- <td class='itemfirstcol' colspan='2'>
1446
- <input type='hidden' name='meta[_wpsc_product_metadata][can_have_uploaded_image]' value='0' />
1447
- <input type='checkbox' name='meta[_wpsc_product_metadata][can_have_uploaded_image]' " . (($product_meta['can_have_uploaded_image'] == true) ? 'checked="checked"' : '') . " id='can_have_uploaded_image' />
1448
- <label for='can_have_uploaded_image'> " . __( 'Users can upload images on single product page to purchase logs.', 'wpsc' ) . "</label>
1449
- <br />
1450
- </td>
1451
- </tr>";
1452
-
1453
- if ( get_option( 'payment_gateway' ) == 'google' ) {
1454
- $output .= "
1455
- <tr>
1456
- <td class='itemfirstcol' colspan='2'>
1457
-
1458
- <input type='checkbox' " . $product_meta['google_prohibited'] . " name='meta[_wpsc_product_metadata][google_prohibited]' id='add_google_prohibited' /> <label for='add_google_prohibited'>
1459
- " . __( 'Prohibited', 'wpsc' ) . "
1460
- <a href='http://checkout.google.com/support/sell/bin/answer.py?answer=75724'>by Google?</a></label><br />
1461
- </td>
1462
- </tr>";
1463
- }
1464
-
1465
- ob_start();
1466
- do_action( 'wpsc_add_advanced_options', $product_data['id'] );
1467
- $output .= ob_get_contents();
1468
- ob_end_clean();
1469
-
1470
- $output .= "
1471
- <tr>
1472
- <td class='itemfirstcol' colspan='2'><br />
1473
- <strong>" . __( 'Enable Comments', 'wpsc' ) . ":</strong><br />
1474
- <select name='meta[_wpsc_product_metadata][enable_comments]'>
1475
- <option value='' " . ((isset( $product_meta['enable_comments'] ) && $product_meta['enable_comments'] == '' ) ? 'selected' : '') . ">Use Default</option>
1476
- <option value='1' " . ((isset( $product_meta['enable_comments'] ) && $product_meta['enable_comments'] == '1') ? 'selected' : '') . ">Yes</option>
1477
- <option value='0' " . ((isset( $product_meta['enable_comments'] ) && $product_meta['enable_comments'] == '0') ? 'selected' : '') . ">No</option>
1478
- </select>
1479
- <br/>" . __( 'Allow users to comment on this Product.', 'wpsc' ) . "
1480
- </td>
1481
- </tr>";
1482
-
1483
- $output .= "
1484
- </table></div></div>";
1485
-
1486
- return $output;
1487
- }
1488
-
1489
- function wpsc_product_external_link_forms( $product_data = '' ) {
1490
-
1491
- global $closed_postboxes, $wpdb;
1492
-
1493
- $product_meta = &$product_data['meta']['_wpsc_product_metadata'];
1494
-
1495
- $output = '';
1496
-
1497
- if ( $product_data == 'empty' )
1498
- $display = "style='display:none;'";
1499
-
1500
- // Get External Link Values
1501
- $external_link_value = isset( $product_meta['external_link'] ) ? $product_meta['external_link'] : '';
1502
- $external_link_text_value = isset( $product_meta['external_link_text'] ) ? $product_meta['external_link_text'] : '';
1503
- $external_link_target_value = isset( $product_meta['external_link_target'] ) ? $product_meta['external_link_target'] : '';
1504
- $external_link_target_value_selected[$external_link_target_value] = ' selected="selected"';
1505
- if( !isset($external_link_target_value_selected['_self']) ) $external_link_target_value_selected['_self'] = '';
1506
- if( !isset($external_link_target_value_selected['_blank']) ) $external_link_target_value_selected['_blank'] = '';
1507
- $output .= "<div id='wpsc_product_external_link_forms' class='postbox " . ((array_search( 'wpsc_product_external_link_forms', $product_data['closed_postboxes'] ) !== false) ? 'closed' : '') . "' " . ((array_search( 'wpsc_product_external_link_forms', $product_data['hidden_postboxes'] ) !== false) ? 'style="display: none;"' : '') . "><div class=\"handlediv\" title=\"Click to toggle\"><br></div>";
1508
-
1509
- $output .= "<h3 class='hndle'>";
1510
- $output .= __( 'Off Site Product Link', 'wpsc' );
1511
- $output .= '</h3>
1512
- <div class="inside">
1513
- <p>' . __( 'If this product is for sale on another website enter the link here. For instance if your product is an MP3 file for sale on itunes you could put the link here. This option overrides the buy now and add to cart links and takes you to the site linked here. You can also customise the Buy Now text and choose to open the link in a new window.', 'wpsc' ) . '</p>
1514
- <table class="form-table" style="width: 100%;" cellspacing="2" cellpadding="5">
1515
- <tbody><tr class="form-field">
1516
- <th valign="top" scope="row"><label for="external_link">' . __( 'External Link', 'wpsc' ) . '</label></th>
1517
- <td><input type="text" name="meta[_wpsc_product_metadata][external_link]" id="external_link" value="' . $external_link_value . '" size="50" style="width: 95%"></td>
1518
- </tr>
1519
- <tr class="form-field">
1520
- <th valign="top" scope="row"><label for="external_link_text">' . __( 'External Link Text', 'wpsc' ) . '</label></th>
1521
- <td><input type="text" name="meta[_wpsc_product_metadata][external_link_text]" id="external_link_text" value="' . $external_link_text_value . '" size="50" style="width: 95%"></td>
1522
- </tr>
1523
- <tr class="form-field">
1524
- <th valign="top" scope="row"><label for="external_link_target">' . __( 'External Link Target', 'wpsc' ) . '</label></th>
1525
- <td>
1526
- <select id="external_link_target" name="meta[_wpsc_product_metadata][external_link_target]">
1527
- <option value="">Default (set by theme)</option>
1528
- <option value="_self"' . $external_link_target_value_selected['_self'] . '>Open link in the same window</option>
1529
- <option value="_blank"' . $external_link_target_value_selected['_blank'] . '>Open link in a new window</option>
1530
- </select>
1531
- </td>
1532
- </tr>
1533
- </tbody></table>
1534
- </div></div>';
1535
-
1536
- return $output;
1537
-
1538
- }
1539
-
1540
- function wpsc_product_image_forms( $product_data = '' ) {
1541
- global $closed_postboxes;
1542
-
1543
- if ( $product_data == 'empty' )
1544
- $display = "style='display:none;'";
1545
- ?>
1546
- <div id='wpsc_product_image_forms' class='postbox <?php echo ((array_search( 'wpsc_product_image_forms', $product_data['closed_postboxes'] ) !== false) ? 'closed' : ''); ?>' <?php echo ((array_search( 'wpsc_product_image_forms', $product_data['hidden_postboxes'] ) !== false) ? 'style="display: none;"' : ''); ?> ><div class="handlediv" title="Click to toggle"><br></div>
1547
- <h3 class='hndle'> <?php _e( 'Product Images', 'wpsc' ); ?></h3>
1548
- <div class='inside'>
1549
-
1550
- <?php edit_multiple_image_gallery( $product_data ); ?>
1551
-
1552
- <p><strong <?php if ( isset( $display ) ) echo $display; ?>><a href="media-upload.php?parent_page=wpsc-edit-products&post_id=<?php echo $product_data['id']; ?>&type=image&tab=gallery&TB_iframe=1&width=640&height=566" class="thickbox" title="Manage Your Product Images"><?php _e( 'Manage Product Images', 'wpsc' ); ?></a></strong></p>
1553
- </div>
1554
-
1555
- <div style='clear:both'></div>
1556
-
1557
- </div>
1558
- <?php
1559
- }
1560
-
1561
- function wpsc_product_download_forms( $product_data='' ) {
1562
- global $wpdb, $closed_postboxes;
1563
-
1564
- if ( $product_data == 'empty' )
1565
- $display = "style='display:none;'";
1566
-
1567
- $output = '';
1568
- $upload_max = wpsc_get_max_upload_size();
1569
- $output .= "<div id='wpsc_product_download_forms' class='postbox " . ((array_search( 'wpsc_product_download_forms', $product_data['closed_postboxes'] ) !== false) ? 'closed' : '') . "' " . ((array_search( 'wpsc_product_download_forms', $product_data['hidden_postboxes'] ) !== false) ? 'style="display: none;"' : '') . "><div class=\"handlediv\" title=\"Click to toggle\"><br></div>";
1570
-
1571
- $output .= "<h3 class='hndle'>" . __( 'Product Downloads', 'wpsc' ) . "</h3>";
1572
- $output .= "<div class='inside'>";
1573
-
1574
- $output .= wpsc_select_product_file( $product_data['id'] );
1575
-
1576
- $output .= "<h4>" . __( 'Upload New File', 'wpsc' ) . ":</h4>";
1577
- $output .= "<input type='file' name='file' value='' /><br />" . __( 'Max Upload Size', 'wpsc' ) . " : <span>" . $upload_max . "</span><br /><br />";
1578
- $output .= "<h4>" . __( '<a href="admin.php?wpsc_admin_action=product_files_existing&product_id=' . $product_data['id'] . '" class="thickbox" title="Select all downloadable files for ' . $product_data['name'] . '">'.__("Select from existing files").'</a>', 'wpsc' ) . "</h4>";
1579
-
1580
- if ( function_exists( "make_mp3_preview" ) || function_exists( "wpsc_media_player" ) ) {
1581
-
1582
- $output .= "<br />";
1583
- $output .="<h4>" . __( "Select an MP3 file to upload as a preview" ) . "</h4>";
1584
-
1585
- $output .= "<input type='file' name='preview_file' value='' /><br />";
1586
- $output .= "<br />";
1587
- }
1588
- $output = apply_filters('wpsc_downloads_metabox', $output);
1589
- $output .="</div></div>";
1590
-
1591
- return $output;
1592
- }
1593
-
1594
- function wpsc_product_label_forms() {
1595
- global $closed_postboxes;
1596
- ?>
1597
- <div id='wpsc_product_label_forms' class='postbox <?php echo ((array_search( 'wpsc_product_label_forms', $product_data['closed_postboxes'] ) !== false) ? 'closed' : ''); ?>'><div class="handlediv" title="Click to toggle"><br></div>
1598
- <h3 class="<?php if ( function_exists( 'add_object_page' ) ) : ?>hndle<?php endif; ?>">
1599
- <?php if ( !function_exists( 'add_object_page' ) ) : ?>
1600
-
1601
- <a class='togbox'>+</a>
1602
-
1603
- <?php endif; ?>
1604
-
1605
- <?php _e( 'Label Control', 'wpsc' ); ?>
1606
- </h3>
1607
- <div class='inside'>
1608
- <table>
1609
- <tr>
1610
- <td colspan='2'>
1611
- <?php _e( 'Add Label', 'wpsc' ); ?> :
1612
- <a id='add_label'><?php _e( 'Add Label', 'wpsc' ); ?></a>
1613
- </td>
1614
- </tr>
1615
- <tr>
1616
- <td colspan='2'>
1617
- <div id="labels">
1618
- <table>
1619
- <tr>
1620
- <td><?php _e( 'Label', 'wpsc' ) ?> :</td>
1621
- <td><input type="text" name="productmeta_values[labels][]"></td>
1622
- </tr>
1623
- <tr>
1624
- <td><?php _e( 'Label Description', 'wpsc' ) ?> :</td>
1625
- <td><textarea name="productmeta_values[labels_desc][]"></textarea></td>
1626
- </tr>
1627
- <tr>
1628
- <td><?php _e( 'Life Number', 'wpsc' ) ?> :</td>
1629
- <td><input type="text" name="productmeta_values[life_number][]"></td>
1630
- </tr>
1631
- <tr>
1632
- <td><?php _e( 'Item Number', 'wpsc' ) ?> :</td>
1633
- <td><input type="text" name="productmeta_values[item_number][]"></td>
1634
- </tr>
1635
- <tr>
1636
- <td><?php _e( 'Product Code', 'wpsc' ) ?> :</td>
1637
- <td><input type="text" name="productmeta_values[product_code][]"></td>
1638
- </tr>
1639
- <tr>
1640
- <td><?php _e( 'PDF', 'wpsc' ) ?> :</td>
1641
- <td><input type="file" name="pdf[]"></td>
1642
- </tr>
1643
- </table>
1644
- </div>
1645
- </td>
1646
- </tr>
1647
- </table>
1648
- </div>
1649
- </div>
1650
-
1651
- <?php
1652
- }
1653
-
1654
- function edit_multiple_image_gallery( $product_data ) {
1655
  global $wpdb;
1656
-
1657
  $siteurl = get_option( 'siteurl' );
1658
-
1659
- if ( $product_data['id'] > 0 ) {
 
 
 
1660
  $args = array(
1661
  'post_type' => 'attachment',
1662
  'numberposts' => -1,
1663
  'post_status' => null,
1664
- 'post_parent' => $product_data['id'],
1665
  'orderby' => 'menu_order',
1666
  'order' => 'ASC'
1667
  );
1668
 
1669
  $attached_images = (array)get_posts( $args );
1670
-
1671
- if ( has_post_thumbnail( $product_data['id'] ) )
1672
- echo get_the_post_thumbnail( $product_data['id'], 'admin-product-thumbnails' );
 
 
 
 
 
1673
  }
1674
  }
1675
 
1676
  /**
1677
- * Displays the category forms for adding and editing Products
1678
- * Recurses to generate the branched view for subcategories
1679
- */
1680
- function wpsc_category_list( &$product_data, $group_id, $unique_id = '', $category_id = null ) {
1681
- global $wpdb;
1682
- static $iteration = 0;
1683
-
1684
- $iteration++;
1685
-
1686
- $output = '';
1687
- $selected = '';
1688
-
1689
- if ( is_numeric( $category_id ) )
1690
- $values = get_terms( 'wpsc_product_category', "hide_empty=0&parent=" . $category_id, ARRAY_A );
1691
- else
1692
- $values = get_terms( 'wpsc_product_category', "hide_empty=0&parent=" . $group_id, ARRAY_A );
1693
 
1694
- if ( $category_id < 1 ){
1695
- $output .= "<ul class='list:category categorychecklist form-no-clear'>\n\r";
1696
- $indenter = "";
1697
- }elseif ( (count( $values ) > 0 ) ){
1698
- $output .= "<ul class='children'>\n\r";
1699
- $indenter = "<img class='category_indenter' src='".WPSC_CORE_IMAGES_URL."/indenter.gif' alt='' title='' />";
1700
 
1701
- }
 
1702
 
1703
- foreach ( (array)$values as $option ) {
1704
- $option = (array)$option;
 
 
1705
 
1706
- if ( isset( $product_data['category_ids'] ) && count( $product_data['category_ids'] ) > 0 ) {
1707
- if ( in_array( $option['term_id'], $product_data['category_ids'] ) ) {
1708
- $selected = "checked='checked'";
1709
- }
1710
- }
1711
 
1712
- $output .= " <li id='category-" . $option['term_id'] . "'>\n\r";
1713
- $output .= $indenter." <label class='selectit'>\n\r";
1714
- $output .= " <input id='" . $unique_id . "category_form_" . $option['term_id'] . "' type='checkbox' {$selected} name='category[]' value='" . $option['term_id'] . "' /></label>\n\r";
1715
- $output .= " <label for='" . $unique_id . "category_form_" . $option['term_id'] . "' class='greytext' >" . stripslashes( $option['name'] ) . "</label>\n\r";
1716
- $output .= wpsc_category_list( $product_data, $group_id, $unique_id, $option['term_id'] );
1717
-
1718
- $output .= " </li>\n\r";
1719
-
1720
- $selected = "";
1721
- }
1722
 
1723
- if ( (count( $values ) > 0 ) )
1724
- $output .= "</ul>\n\r";
 
 
 
 
 
1725
 
1726
- return $output;
1727
  }
1728
 
1729
  /**
1730
- * Slightly modified copy of the Wordpress the_editor function
1731
- *
1732
- * We have to use a modified version because the wordpress one calls javascript that uses document.write
1733
- * When this javascript runs after being loaded through AJAX, it replaces the whole page.
1734
- *
1735
- * The amount of rows the text area will have for the content has to be between
1736
- * 3 and 100 or will default at 12. There is only one option used for all users,
1737
- * named 'default_post_edit_rows'.
1738
- *
1739
- * If the user can not use the rich editor (TinyMCE), then the switch button
1740
- * will not be displayed.
1741
- *
1742
- * @since 3.7
1743
- *
1744
- * @param string $content Textarea content.
1745
- * @param string $id HTML ID attribute value.
1746
- * @param string $prev_id HTML ID name for switching back and forth between visual editors.
1747
- * @param bool $media_buttons Optional, default is true. Whether to display media buttons.
1748
- * @param int $tab_index Optional, default is 2. Tabindex for textarea element.
1749
- */
1750
- function wpsc_the_editor( $content, $id = 'content', $prev_id = 'title', $media_buttons = true, $tab_index = 2 ) {
1751
- $rows = get_option( 'default_post_edit_rows' );
1752
- if ( ($rows < 3) || ($rows > 100) )
1753
- $rows = 12;
1754
-
1755
- if ( !current_user_can( 'upload_files' ) )
1756
- $media_buttons = false;
1757
-
1758
- $richedit = user_can_richedit();
1759
- $class = '';
1760
-
1761
- if ( $richedit || $media_buttons ) {
1762
- ?>
1763
- <div id="editor-toolbar">
1764
- <?php
1765
- if ( $richedit ) {
1766
- $wp_default_editor = wp_default_editor(); ?>
1767
- <div class="zerosize"><input accesskey="e" type="button" onclick="switchEditors.go('<?php echo $id; ?>')" /></div>
1768
- <?php if ( 'html' == $wp_default_editor ) {
1769
- add_filter( 'the_editor_content', 'wp_htmledit_pre' ); ?>
1770
- <a id="edButtonHTML" class="active hide-if-no-js" onclick="switchEditors.go('<?php echo $id; ?>', 'html');"><?php _e( 'HTML' ); ?></a>
1771
- <a id="edButtonPreview" class="hide-if-no-js" onclick="switchEditors.go('<?php echo $id; ?>', 'tinymce');"><?php _e( 'Visual' ); ?></a>
1772
- <?php
1773
- } else {
1774
- $class = " class='theEditor'";
1775
- add_filter( 'the_editor_content', 'wp_richedit_pre' ); ?>
1776
- <a id="edButtonHTML" class="hide-if-no-js" onclick="switchEditors.go('<?php echo $id; ?>', 'html');"><?php _e( 'HTML' ); ?></a>
1777
- <a id="edButtonPreview" class="active hide-if-no-js" onclick="switchEditors.go('<?php echo $id; ?>', 'tinymce');"><?php _e( 'Visual' ); ?></a>
1778
- <?php
1779
- }
1780
- }
1781
-
1782
- if ( $media_buttons ) {
1783
- ?>
1784
- <div id="media-buttons" class="hide-if-no-js">
1785
- <?php do_action( 'media_buttons' ); ?>
1786
- </div>
1787
- <?php } ?>
1788
- </div>
1789
- <?php
1790
- }
1791
- ?>
1792
- <div id="quicktags"><?php wp_print_scripts( 'quicktags' ); ?>
1793
- <div id="ed_toolbar">
1794
- </div>
1795
- <script type="text/javascript" defer="defer'">wpsc_edToolbar()</script>
1796
- </div>
1797
-
1798
- <?php
1799
- $the_editor = apply_filters( 'the_editor', "<div id='editorcontainer'><textarea rows='$rows'$class cols='40' name='$id' tabindex='$tab_index' id='$id'>%s</textarea></div>\n" );
1800
- $the_editor_content = apply_filters( 'the_editor_content', $content );
1801
 
1802
- printf( $the_editor, $the_editor_content );
1803
- ?>
1804
- <script type="text/javascript">
1805
- edCanvas = document.getElementById('<?php echo $id; ?>');
1806
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1807
  <?php
1808
  }
1809
 
 
 
 
 
1810
  ?>
55
  ),
56
  ),
57
  );
58
+ add_action('admin_head', 'wpsc_css_header');
59
 
60
+ function wpsc_redirect_variation_update($location, $post_id){
61
+ global $post;
62
+ if($post->post_parent > 0)
63
+ wp_redirect(admin_url('post.php?post='.$post->post_parent.'&action=edit'));
64
+ else
65
+ return $location;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  }
68
 
69
+ add_filter('redirect_post_location','wpsc_redirect_variation_update', 10, 2);
70
+ function wpsc_css_header() {
71
+ global $post_type;
72
+ ?>
73
+ <style>
74
+ <?php if (($_GET['post_type'] == 'wpsc-product') || ($post_type == 'wpsc-product')) : ?>
75
+ #icon-edit { background:transparent url('<?php echo WPSC_CORE_IMAGES_URL.'/icon32.png';?>') no-repeat; }
76
+ <?php endif; ?>
77
+ </style>
78
+ <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  }
80
+ function wpsc_price_control_forms(){
81
+ global $post, $wpdb, $variations_processor, $wpsc_product_defaults;
82
+ $product_data = get_post_custom( $post->ID );
83
+ $product_data['meta'] = maybe_unserialize( $product_data );
84
 
85
+ foreach( $product_data['meta'] as $meta_key => $meta_value )
86
+ $product_data['meta'][$meta_key] = $meta_value[0];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
 
88
+ $product_meta = maybe_unserialize( $product_data["_wpsc_product_metadata"][0] );
 
89
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  if( isset( $product_data['meta']['_wpsc_currency']))
91
+ $product_alt_currency = maybe_unserialize( $product_data['meta']['_wpsc_currency'] );
92
 
93
  if ( !isset( $product_data['meta']['_wpsc_table_rate_price'] ) )
94
  $product_data['meta']['_wpsc_table_rate_price'] = $wpsc_product_defaults['meta']['table_rate_price'];
114
 
115
  $currency_data = $wpdb->get_results( "SELECT * FROM `" . WPSC_TABLE_CURRENCY_LIST . "` ORDER BY `country` ASC", ARRAY_A );
116
  ?>
117
+ <input type="hidden" id="parent_post" name="parent_post" value="<?php echo $post->post_parent; ?>" />
118
+ <?php /* Lots of tedious work is avoided with this little line. */ ?>
119
+ <input type="hidden" id="product_id" name="product_id" value="<?php echo $post->ID; ?>" />
120
+
121
+ <?php /* Check product if a product has variations (Wording doesn't make sense. If Variations box is closed, you don't go there, and it's not necessarily "below") */ ?>
122
+ <?php if( wpsc_product_has_children( $post->ID ) ) : ?>
123
+ <?php $price = wpsc_product_variation_price_available( $post->ID ); ?>
124
+ <p><?php printf( __( 'This Product has variations, to edit the price please use the %1s Variation Controls%2s below.' , 'wpsc' ), '<a href="#variation_control">','</a>' ); ?></p>
 
125
  <p><?php printf( __( 'Price: %s and above.' ,'wpsc' ) , $price ); ?></p>
126
  <?php else: ?>
127
 
161
  $i = 0;
162
  foreach ($product_alt_currency as $iso => $alt_price ) {
163
  $i++; ?>
164
+ <div class='wpsc_additional_currency'>
165
+ <label for='newCurrency[]'><?php _e( 'Currency type', 'wpsc' ); ?>:</label><br />
166
  <select name='newCurrency[]' class='newCurrency' style='width:42%'> <?php
167
  foreach ( $currency_data as $currency ) {
168
  if ( $iso == $currency['isocode'] )
175
  } ?>
176
  </select>
177
  <?php _e( 'Price', 'wpsc' ); ?>: <input type='text' class='text' size='8' name='newCurrPrice[]' value='<?php echo $alt_price; ?>' style=' display:inline' />
178
+ <a href='' class='wpsc_delete_currency_layer' rel='<?php echo $iso; ?>'><img src='<?php echo WPSC_CORE_IMAGES_URL; ?>/cross.png' /></a></div>
179
  <?php }
180
+
181
  endif;
182
 
183
  echo "<br style='clear:both' />
220
  </table>
221
  </div>
222
  <?php endif; ?>
 
 
223
  <?php
224
  }
225
+ function wpsc_stock_control_forms() {
226
+ global $post, $wpdb, $variations_processor, $wpsc_product_defaults;
227
+
228
+ $product_data = get_post_custom( $post->ID );
229
+ $product_data['meta'] = maybe_unserialize( $product_data );
230
+
231
+ foreach( $product_data['meta'] as $meta_key => $meta_value )
232
+ $product_data['meta'][$meta_key] = $meta_value[0];
233
+
234
+ $product_meta = maybe_unserialize( $product_data["_wpsc_product_metadata"][0] );
235
 
236
  if ( !isset( $product_meta['unpublish_when_none_left'] ) )
237
  $product_meta['unpublish_when_none_left'] = ''; ?>
238
 
239
+ <label for="wpsc_sku"><abbr title="<?php _e( 'Stock Keeping Unit', 'wpsc' ); ?>">SKU:</abbr></label>
 
 
 
 
240
  <?php
241
  if ( !isset( $product_data['meta']['_wpsc_sku'] ) )
242
  $product_data['meta']['_wpsc_sku'] = $wpsc_product_defaults['meta']['sku']; ?><br />
248
  <br /><input class='limited_stock_checkbox' id='add_form_quantity_limited' type='checkbox' value='yes' <?php if(is_numeric( $product_data['meta']['_wpsc_stock'] )) echo 'checked="checked"'; else echo ''; ?> name='meta[_wpsc_limited_stock]' />
249
  <label for='add_form_quantity_limited' class='small'><?php _e( 'I have limited stock for this Product', 'wpsc' ); ?></label>
250
  <?php
251
+ if ( $post->ID > 0 ){
252
  if ( is_numeric( $product_data['meta']['_wpsc_stock'] ) ){?>
253
  <div class='edit_stock' style='display: block;'> <?php
254
  } else { ?>
255
  <div class='edit_stock' style='display: none;'><?php
256
  } ?>
257
+ <?php if( wpsc_product_has_children( $post->ID ) ) : ?>
258
+ <?php $stock = wpsc_variations_stock_remaining( $post->ID ); ?>
259
  <p><?php _e( 'This Product has variations, to edit the quantity please use the Variation Controls below.' , 'wpsc' ); ?></p>
260
  <p><?php printf(_n("%s variant item in stock.", "%s variant items in stock.", $stock), $stock); ?></p>
261
  <?php else: ?>
277
  </div><?php
278
  }
279
  ?>
 
 
280
  <?php
281
  }
282
+ function wpsc_product_taxes_forms(){
283
+ global $post, $wpdb, $wpsc_product_defaults;
284
+ $product_data = get_post_custom( $post->ID );
285
+
286
+ $product_data['meta'] = $product_meta = maybe_unserialize($product_data['_wpsc_product_metadata'][0]);
287
 
288
  if ( !isset( $product_data['meta']['_wpsc_custom_tax'] ) )
289
  $product_data['meta']['_wpsc_custom_tax'] = '';
290
  $custom_tax = $product_data['meta']['_wpsc_custom_tax'];
291
 
292
 
293
+ if ( !isset( $product_meta['custom_tax'] ) ){
294
+ $product_meta['custom_tax'] = 0.00;
295
+ }
296
+
297
  //Add New WPEC-Taxes Bands Here
298
  $wpec_taxes_controller = new wpec_taxes_controller();
299
 
304
  'label' => __( 'Custom Tax Band' )
305
  );
306
  $wpec_taxes_band = '';
307
+ if(isset($product_meta['wpec_taxes_band'])){
308
+ $wpec_taxes_band = $product_meta['wpec_taxes_band'];
309
+ }
310
+
311
+ $taxable_checkbox_settings = array(
312
+ 'type' => 'checkbox',
313
+ 'id' => 'wpec_taxes_taxable',
314
+ 'name' => 'meta[_wpsc_product_metadata][wpec_taxes_taxable]',
315
+ 'label' => __( 'This product is not taxable.' )
316
+ );
317
+
318
+ if(isset($product_meta['wpec_taxes_taxable']) && 'on' == $product_meta['wpec_taxes_taxable']){
319
+ $taxable_checkbox_settings['checked'] = 'checked';
320
+ }
321
 
322
+ //add taxable amount only for exclusive tax
323
+ if(!$wpec_taxes_controller->wpec_taxes_isincluded())
324
+ {
325
+ $taxable_amount_input_settings = array(
326
+ 'id' => 'wpec_taxes_taxable_amount',
327
+ 'name' => 'meta[_wpsc_product_metadata][wpec_taxes_taxable_amount]',
328
+ 'label' => __( 'Taxable Amount' )
329
+ );
330
+
331
+ if(isset($product_meta['wpec_taxes_taxable_amount'])){
332
+ $taxable_amount_input_settings['value'] = $product_meta['wpec_taxes_taxable_amount'];
333
+ }
334
+ }// if
335
+
336
+ ?>
337
+ <p><?php echo $wpec_taxes_controller->wpec_taxes_display_tax_bands( $band_select_settings, $wpec_taxes_band ); ?></p>
338
  <p>
339
+ <?php if(!$wpec_taxes_controller->wpec_taxes_isincluded()): ?>
340
+ <?php echo $wpec_taxes_controller->wpec_taxes_build_input( $taxable_amount_input_settings );?>
341
+ <?php endif;?>
342
  </p>
343
+ <p><?php echo $wpec_taxes_controller->wpec_taxes_build_input( $taxable_checkbox_settings ); ?></p>
 
344
  <?php
345
  }
346
+ function wpsc_product_variation_forms() {
347
+ global $post, $wpdb, $wp_query, $variations_processor, $wpsc_product_defaults;
348
 
349
+ $db_version = get_option( 'db_version' );
350
+
351
+ $product_data = get_post_custom( $post->ID );
352
+ $product_data['meta'] = maybe_unserialize( $product_data );
353
+
354
+ foreach( $product_data['meta'] as $meta_key => $meta_value )
355
+ $product_data['meta'][$meta_key] = $meta_value[0];
356
+
357
+ $product_meta = maybe_unserialize( $product_data["_wpsc_product_metadata"][0] );
358
 
359
  $siteurl = get_option( 'siteurl' );
360
  $output = '';
361
 
 
 
 
 
362
  // Get variation data from WP Terms
363
+ $product_term_data = wp_get_object_terms( $post->ID, 'wpsc-variation' );
364
  if ( !empty( $product_term_data ) ) {
365
  foreach ( $product_term_data as $product_term )
366
  $product_terms[] = $product_term->term_id;
367
  } else {
368
  $product_terms = array();
369
  }
370
+ ?>
371
+ <?php if( empty( $post->post_title ) ) : ?>
 
 
 
 
 
 
 
 
372
  <p><?php _e( 'You must first save this Product as a Draft before adding variations', 'wpsc' ); ?></p>
373
  <?php else : ?>
374
  <div id="product_variations">
421
  <?php endforeach; ?>
422
 
423
  </div>
424
+ <a class="preview button update_variations_action" href='#'><?php _e( 'Update Variations &rarr;', 'wpsc' ); ?></a>
 
425
 
426
  </div>
427
  <?php
428
+ $parent_product = $post->ID;
429
 
430
  $query = array(
431
  'post_type' => 'wpsc-product',
432
  'orderby' => 'menu_order post_title',
433
  'post_parent' => $parent_product,
434
+ 'post_status' => 'publish, inherit',
435
  'order' => "ASC"
436
  );
437
+
438
  $args = array(
439
  'post_type' => 'attachment',
440
  'numberposts' => 1,
447
  $image_data = (array)get_posts( $args );
448
  $parent_product_data['image'] = array_shift( $image_data );
449
 
450
+ $wp_query = new WP_Query( $query );
451
+ if ( !isset( $parent_product_data ) )
452
+ $parent_product_data = null;
453
  ?>
454
 
455
  <p><a name='variation_control'>&nbsp;</a><?php _e( 'Check or uncheck variation boxes and then click Update Variations to add or remove variations.' ) ?></p>
456
+
457
+ <table class="widefat page" id='wpsc_product_list' cellspacing="0">
458
  <thead>
459
  <tr>
460
+ <?php print_column_headers( 'wpsc-product_variants' ); ?>
461
  </tr>
462
  </thead>
463
 
464
  <tfoot>
465
  <tr>
466
+ <?php print_column_headers( 'wpsc-product_variants', false ); ?>
467
  </tr>
468
  </tfoot>
469
 
470
  <tbody>
471
+ <?php
 
 
 
 
 
472
  wpsc_admin_product_listing( $parent_product_data );
473
+ ?>
474
+ <?php
475
+ if ( count( $wp_query->posts ) < 1 ) :
476
+ ?>
477
  <tr>
478
  <td colspan="8">
479
+ <?php _e( 'You have no Variations added.', 'wpsc' ); ?>
480
  </td>
481
  </tr>
482
 
484
  </tbody>
485
 
486
  </table>
487
+
488
+ <?php
489
+ endif;
 
 
 
 
 
 
 
 
 
 
 
490
  }
491
+ function wpsc_product_shipping_forms() {
492
+ global $post, $wpdb, $variations_processor, $wpsc_product_defaults;
493
 
494
+ $product_data = get_post_custom( $post->ID );
495
+ $product_data['meta'] = maybe_unserialize( $product_data );
 
 
 
496
 
497
+ foreach( $product_data['meta'] as $meta_key => $meta_value )
498
+ $product_data['meta'][$meta_key] = $meta_value[0];
499
 
500
+ $product_meta = maybe_unserialize( $product_data["_wpsc_product_metadata"][0] );
 
501
 
502
+ $product_data['transformed'] = array();
503
+ if( !isset( $product_meta['weight'] ) )
504
+ $product_meta['weight'] = "";
505
 
506
+ $product_data['transformed']['weight'] = wpsc_convert_weight( $product_meta['weight'], "pound", $product_meta['weight_unit'] );
 
 
 
 
507
 
508
+ ?>
509
+ <table>
 
510
 
511
+ <!--USPS shipping changes-->
512
+ <tr>
513
+ <td>
514
+ <?php _e( 'Weight', 'wpsc' )?>
515
+ </td>
516
+ <td>
517
+ <input type='text' size='5' name='meta[_wpsc_product_metadata][weight]' value='<?php echo $product_data['transformed']['weight']; ?>' />
518
+ <select name='meta[_wpsc_product_metadata][weight_unit]'>
519
+ <option value='pound' <?php echo (($product_meta['display_weight_as'] == 'pound') ? 'selected="selected"' : ''); ?> >Pounds</option>
520
+ <option value='ounce' <?php echo ((preg_match( "/o(u)?nce/", $product_meta['display_weight_as'] )) ? 'selected="selected"' : ''); ?> >Ounces</option>
521
+ <option value='gram' <?php echo (($product_meta['display_weight_as'] == 'gram') ? 'selected="selected"' : ''); ?> >Grams</option>
522
+ <option value='kilogram' <?php echo (($product_meta['display_weight_as'] == 'kilogram' || $product_meta['display_weight_as'] == 'kilograms') ? 'selected="selected"' : ''); ?> >Kilograms</option>
523
+ </select>
524
+ </td>
525
+ </tr>
526
+ <!--dimension-->
527
+ <tr>
528
+ <td>
529
+ <?php _e( 'Height', 'wpsc' ); ?>
530
+ </td>
531
+ <td>
532
+ <input type='text' size='5' name='meta[_wpsc_product_metadata][dimensions][height]' value= '<?php echo $product_meta['dimensions']['height']; ?>'>
533
+ <select name='meta[_wpsc_product_metadata][dimensions][height_unit]'>
534
+ <option value='in' <?php echo (($product_meta['dimensions']['height_unit'] == 'in') ? 'selected' : ''); ?> >inches</option>
535
+ <option value='cm' <?php echo (($product_meta['dimensions']['height_unit'] == 'cm') ? 'selected' : ''); ?> >cm</option>
536
+ <option value='meter' <?php echo (($product_meta['dimensions']['height_unit'] == 'meter') ? 'selected' : ''); ?> >meter</option>
537
+ </select>
538
+ </td>
539
+ </tr>
540
+ <tr>
541
+ <td>
542
+ <?php _e( 'Width', 'wpsc' ); ?>
543
+ </td>
544
+ <td>
545
+ <input type='text' size='5' name='meta[_wpsc_product_metadata][dimensions][width]' value='<?php echo $product_meta['dimensions']['width']; ?> '>
546
+ <select name='meta[_wpsc_product_metadata][dimensions][width_unit]'>
547
+ <option value='in' <?php echo(($product_meta['dimensions']['width_unit'] == 'in') ? 'selected' : ''); ?> >inches</option>
548
+ <option value='cm' <?php echo (($product_meta['dimensions']['width_unit'] == 'cm') ? 'selected' : ''); ?> >cm</option>
549
+ <option value='meter' <?php echo (($product_meta['dimensions']['width_unit'] == 'meter') ? 'selected' : ''); ?> >meter</option>
550
+ </select>
551
+ </td>
552
+ </tr>
553
+ <tr>
554
+ <td>
555
+ <?php _e( 'Length', 'wpsc' ); ?>
556
+ </td>
557
+ <td>
558
+ <input type='text' size='5' name='meta[_wpsc_product_metadata][dimensions][length]' value='<?php echo $product_meta['dimensions']['length']; ?>'>
559
+ <select name='meta[_wpsc_product_metadata][dimensions][length_unit]'>
560
+ <option value='in' <?php echo(($product_meta['dimensions']['length_unit'] == 'in') ? 'selected' : ''); ?> >inches</option>
561
+ <option value='cm' <?php echo(($product_meta['dimensions']['length_unit'] == 'cm') ? 'selected' : ''); ?> >cm</option>
562
+ <option value='meter' <?php echo (($product_meta['dimensions']['length_unit'] == 'meter') ? 'selected' : ''); ?> >meter</option>
563
+ </select>
564
+ </td>
565
+ </tr>
566
 
567
+ <!--//dimension-->
568
+ <!--USPS shipping changes ends-->
569
+ <tr>
570
+ <td colspan='2'>
571
+ <strong><?php _e( 'Flat Rate Settings', 'wpsc' ); ?></strong>
572
+ </td>
573
+ </tr>
574
+ <tr>
575
+ <td>
576
+ <?php _e( 'Local Shipping Fee', 'wpsc' ); ?>
577
+ </td>
578
+ <td>
579
+ <input type='text' size='10' name='meta[_wpsc_product_metadata][shipping][local]' value='<?php echo number_format( $product_meta['shipping']['local'], 2, '.', '' ); ?>' />
580
+ </td>
581
+ </tr>
582
+
583
+ <tr>
584
+ <td>
585
+ <?php _e( 'International Shipping Fee', 'wpsc' ); ?>
586
+ </td>
587
+ <td>
588
+ <input type='text' size='10' name='meta[_wpsc_product_metadata][shipping][international]' value='<?php echo number_format( $product_meta['shipping']['international'], 2, '.', '' ); ?>' />
589
+ </td>
590
+ </tr>
591
+ <tr>
592
+ <td>
593
+ <br />
594
+ <input id='add_form_no_shipping' type='checkbox' name='meta[_wpsc_product_metadata][no_shipping]' value='1' <?php echo (($product_meta['no_shipping'] == 1) ? 'checked="checked"' : ''); ?> />&nbsp;<label for='add_form_no_shipping'><?php _e( 'Disregard Shipping for this Product', 'wpsc' ); ?></label>
595
+ </td>
596
+ </tr>
597
+ </table>
598
+ <?php
599
+ }
600
+ function wpsc_product_advanced_forms() {
601
+ global $post, $wpdb, $variations_processor, $wpsc_product_defaults;
602
+ $product_data = get_post_custom( $post->ID );
603
+
604
+ $product_data['meta'] = $product_meta = maybe_unserialize($product_data['_wpsc_product_metadata'][0]);
605
+
606
+ $custom_fields = $wpdb->get_results( "
607
+ SELECT
608
+ `meta_id`, `meta_key`, `meta_value`
609
+ FROM
610
+ `{$wpdb->postmeta}`
611
+ WHERE
612
+ `post_id` = {$post->ID}
613
+ AND
614
+ `meta_key` NOT LIKE '\_%'
615
+ ORDER BY
616
+ LOWER(meta_key)", ARRAY_A
617
+ );
618
+ ?>
619
+
620
+ <table>
621
+ <tr>
622
+ <td colspan='2' class='itemfirstcol'>
623
+ <strong><?php _e( 'Custom Meta', 'wpsc' ); ?>:</strong><br />
624
+ <a href='#' class='add_more_meta' onclick="return add_more_meta(this)"> + <?php _e( 'Add Custom Meta', 'wpsc' );?> </a><br /><br />
625
+
626
+ <?php
627
+ foreach ( (array)$custom_fields as $custom_field ) {
628
+ $i = $custom_field['meta_id'];
629
+
630
+ ?>
631
+ <div class='product_custom_meta' id='custom_meta_<?php echo $i; ?>'>
632
+ <?php _e( 'Name', 'wpsc' ); ?>
633
+ <input type='text' class='text' value='<?php echo $custom_field['meta_key']; ?>' name='custom_meta[<?php echo $i; ?>][name]' id='custom_meta_name_<?php echo $i; ?>'>
634
+ <?php _e( 'Value', 'wpsc' ); ?>
635
+ <textarea class='text' name='custom_meta[<?php echo $i; ?>][value]' id='custom_meta_value_<?php echo $i; ?>'><?php echo $custom_field['meta_value']; ?></textarea>
636
+ <a href='#' class='remove_meta' onclick='return remove_meta(this, <?php echo $i; ?>)'><?php _e( 'Delete' ); ?></a>
637
+ <br />
638
+ </div>
639
+ <?php
640
+ }
641
+ ?>
642
+ <div class='product_custom_meta'>
643
+ <?php _e( 'Name', 'wpsc' ); ?>: <br />
644
+ <input type='text' name='new_custom_meta[name][]' value='' class='text'/><br />
645
+ <?php _e( 'Description', 'wpsc' ); ?>: <br />
646
+ <textarea name='new_custom_meta[value][]' cols='40' rows='10' class='text' ></textarea>
647
+ <br />
648
+ </div>
649
+ </td>
650
+ </tr>
651
+ <tr>
652
+ <td class='itemfirstcol' colspan='2'><br /> <strong><?php _e( 'Merchant Notes', 'wpsc' ); ?>:</strong><br />
653
+
654
+ <textarea cols='40' rows='3' name='meta[_wpsc_product_metadata][merchant_notes]' id='merchant_notes'>
655
+ <?php if ( isset( $product_meta['merchant_notes'] ) )
656
+ echo stripslashes( trim( $product_meta['merchant_notes'] ) );
657
+ ?>
658
+ </textarea>
659
+ <small><?php _e( 'These notes are only available here.', 'wpsc' ); ?></small>
660
+ </td>
661
+ </tr>
662
+ <tr>
663
+ <td class='itemfirstcol' colspan='2'><br />
664
+ <strong><?php _e( 'Personalisation Options', 'wpsc' ); ?>:</strong><br />
665
+ <input type='hidden' name='meta[_wpsc_product_metadata][engraved]' value='0' />
666
+ <input type='checkbox' name='meta[_wpsc_product_metadata][engraved]' <?php echo (($product_meta['engraved'] == true) ? 'checked="checked"' : ''); ?> id='add_engrave_text' />
667
+ <label for='add_engrave_text'><?php _e( 'Users can personalize this Product by leaving a message on single product page', 'wpsc' ); ?></label>
668
+ <br />
669
+ </td>
670
+ </tr>
671
+ <tr>
672
+ <td class='itemfirstcol' colspan='2'>
673
+ <input type='hidden' name='meta[_wpsc_product_metadata][can_have_uploaded_image]' value='0' />
674
+ <input type='checkbox' name='meta[_wpsc_product_metadata][can_have_uploaded_image]' <?php echo ($product_meta['can_have_uploaded_image'] == true) ? 'checked="checked"' : ''; ?> id='can_have_uploaded_image' />
675
+ <label for='can_have_uploaded_image'> <?php _e( 'Users can upload images on single product page to purchase logs.', 'wpsc' ); ?> </label>
676
+ <br />
677
+ </td>
678
+ </tr>
679
+ <?php
680
+ if ( get_option( 'payment_gateway' ) == 'google' ) {
681
+ ?>
682
+ <tr>
683
+ <td class='itemfirstcol' colspan='2'>
684
+
685
+ <input type='checkbox' <?php echo $product_meta['google_prohibited']; ?> name='meta[_wpsc_product_metadata][google_prohibited]' id='add_google_prohibited' /> <label for='add_google_prohibited'>
686
+ <?php _e( 'Prohibited', 'wpsc' ); ?>
687
+ <a href='http://checkout.google.com/support/sell/bin/answer.py?answer=75724'>by Google?</a></label><br />
688
+ </td>
689
+ </tr>
690
+ <?php
691
+ }
692
+ ob_start();
693
+ do_action( 'wpsc_add_advanced_options', $post->ID );
694
+ ob_get_contents();
695
+ ob_end_clean();
696
+ ?>
697
+ <tr>
698
+ <td class='itemfirstcol' colspan='2'><br />
699
+ <strong><?php _e( 'Enable Comments', 'wpsc' ); ?>:</strong><br />
700
+ <select name='meta[_wpsc_product_metadata][enable_comments]'>
701
+ <option value='' <?php echo ((isset( $product_meta['enable_comments'] ) && $product_meta['enable_comments'] == '' ) ? 'selected' : ''); ?> >Use Default</option>
702
+ <option value='1' <?php echo ((isset( $product_meta['enable_comments'] ) && $product_meta['enable_comments'] == '1') ? 'selected' : ''); ?> >Yes</option>
703
+ <option value='0' <?php echo ((isset( $product_meta['enable_comments'] ) && $product_meta['enable_comments'] == '0') ? 'selected' : ''); ?> >No</option>
704
+ </select>
705
+ <br/><?php _e( 'Allow users to comment on this Product.', 'wpsc' ); ?>
706
+ </td>
707
+ </tr>
708
+ </table>
709
+ <?php
710
+ }
711
+ function wpsc_product_external_link_forms() {
712
+
713
+ global $post, $wpdb, $variations_processor, $wpsc_product_defaults;
714
+ $product_data = get_post_custom( $post->ID );
715
+
716
+ $product_data['meta'] = $product_meta = maybe_unserialize($product_data['_wpsc_product_metadata'][0]);
717
+
718
+ // Get External Link Values
719
+ $external_link_value = isset( $product_meta['external_link'] ) ? $product_meta['external_link'] : '';
720
+ $external_link_text_value = isset( $product_meta['external_link_text'] ) ? $product_meta['external_link_text'] : '';
721
+ $external_link_target_value = isset( $product_meta['external_link_target'] ) ? $product_meta['external_link_target'] : '';
722
+ $external_link_target_value_selected[$external_link_target_value] = ' selected="selected"';
723
+ if( !isset($external_link_target_value_selected['_self']) ) $external_link_target_value_selected['_self'] = '';
724
+ if( !isset($external_link_target_value_selected['_blank']) ) $external_link_target_value_selected['_blank'] = '';
725
+
726
+ ?>
727
+ <p><?php _e( 'If this product is for sale on another website enter the link here. For instance if your product is an MP3 file for sale on iTunes you could put the link here. This option overrides the buy now and add to cart links and takes you to the site linked here. You can also customise the Buy Now text and choose to open the link in a new window.', 'wpsc' ); ?>
728
+ <table class="form-table" style="width: 100%;" cellspacing="2" cellpadding="5">
729
+ <tbody>
730
+ <tr class="form-field">
731
+ <th valign="top" scope="row"><label for="external_link"><?php _e( 'External Link', 'wpsc' ); ?></label></th>
732
+ <td><input type="text" name="meta[_wpsc_product_metadata][external_link]" id="external_link" value="<?php echo $external_link_value; ?>" size="50" style="width: 95%"></td>
733
+ </tr>
734
+ <tr class="form-field">
735
+ <th valign="top" scope="row"><label for="external_link_text"><?php _e( 'External Link Text', 'wpsc' ); ?></label></th>
736
+ <td><input type="text" name="meta[_wpsc_product_metadata][external_link_text]" id="external_link_text" value="<?php echo $external_link_text_value; ?>" size="50" style="width: 95%"></td>
737
+ </tr>
738
+ <tr class="form-field">
739
+ <th valign="top" scope="row"><label for="external_link_target"><?php _e( 'External Link Target', 'wpsc' ); ?></label></th>
740
+ <td>
741
+ <select id="external_link_target" name="meta[_wpsc_product_metadata][external_link_target]">
742
+ <option value="">Default (set by theme)</option>
743
+ <option value="_self" <?php echo $external_link_target_value_selected['_self']; ?>>Open link in the same window</option>
744
+ <option value="_blank" <?php echo $external_link_target_value_selected['_blank']; ?>>Open link in a new window</option>
745
+ </select>
746
+ </td>
747
+ </tr>
748
+ </tbody>
749
+ </table>
750
+ <?php
751
+ }
752
+ function wpsc_product_image_forms() {
753
+
754
+ global $post;
755
+
756
+ edit_multiple_image_gallery( $post );
757
+
758
+ ?>
759
+
760
+ <p><strong <?php if ( isset( $display ) ) echo $display; ?>><a href="media-upload.php?parent_page=wpsc-edit-products&post_id=<?php echo $post->ID; ?>&type=image&tab=gallery&TB_iframe=1&width=640&height=566" class="thickbox" title="Manage Your Product Images"><?php _e( 'Manage Product Images', 'wpsc' ); ?></a></strong></p>
761
+ <?php
762
+ }
763
+ function wpsc_additional_desc() {
764
+ global $post;
765
+ ?>
766
+ <textarea name='additional_description' id='additional_description' cols='40' rows='5' ><?php echo stripslashes( $post->post_excerpt ); ?></textarea>
767
+ <?php
768
+
769
+ }
770
+ function wpsc_product_download_forms() {
771
+
772
+ global $post, $wpdb, $wpsc_product_defaults;
773
+ $product_data = get_post_custom( $post->ID );
774
+
775
+ $product_data['meta'] = $product_meta = maybe_unserialize($product_data['_wpsc_product_metadata'][0]);
776
+
777
+ $upload_max = wpsc_get_max_upload_size();
778
+ ?>
779
+ <?php echo wpsc_select_product_file( $post->ID ); ?>
780
+ <h4><?php _e( 'Upload New File', 'wpsc' ); ?>:</h4>
781
+ <input type='file' name='file' value='' /><br /><?php _e( 'Max Upload Size', 'wpsc' ); ?>:<span><?php echo $upload_max; ?></span><br /><br />
782
+ <h4><a href="admin.php?wpsc_admin_action=product_files_existing&product_id=<?php echo $post->ID; ?>" class="thickbox" title="<?php _e( 'Select all downloadable files for ' . $post->post_title, 'wpsc' ); ?>"><?php _e( 'Select from existing files', 'wpsc' ); ?></a></h4>
783
+ <?php
784
+ if ( function_exists( "make_mp3_preview" ) || function_exists( "wpsc_media_player" ) ) {
785
+ ?>
786
+ <br />
787
+ <h4>" . __( "Select an MP3 file to upload as a preview" ) . "</h4>";
788
+ <input type='file' name='preview_file' value='' /><br />";
789
+ <br />
790
+ <?php
791
+ }
792
+ $output = apply_filters('wpsc_downloads_metabox', $output);
793
+ }
794
+ function wpsc_product_label_forms() {
795
+ //This is new to me...not sure why this is even here
796
+ ?>
797
+ <div id='wpsc_product_label_forms' class='postbox <?php echo ((array_search( 'wpsc_product_label_forms', $product_data['closed_postboxes'] ) !== false) ? 'closed' : ''); ?>'><div class="handlediv" title="Click to toggle"><br></div>
798
+ <h3 class="<?php if ( function_exists( 'add_object_page' ) ) : ?>hndle<?php endif; ?>">
799
+ <?php if ( !function_exists( 'add_object_page' ) ) : ?>
800
+
801
+ <a class='togbox'>+</a>
802
+
803
+ <?php endif; ?>
804
+
805
+ <?php _e( 'Label Control', 'wpsc' ); ?>
806
+ </h3>
807
+ <div class='inside'>
808
+ <table>
809
+ <tr>
810
+ <td colspan='2'>
811
+ <?php _e( 'Add Label', 'wpsc' ); ?> :
812
+ <a id='add_label'><?php _e( 'Add Label', 'wpsc' ); ?></a>
813
+ </td>
814
+ </tr>
815
+ <tr>
816
+ <td colspan='2'>
817
+ <div id="labels">
818
+ <table>
819
+ <tr>
820
+ <td><?php _e( 'Label', 'wpsc' ) ?> :</td>
821
+ <td><input type="text" name="productmeta_values[labels][]"></td>
822
+ </tr>
823
+ <tr>
824
+ <td><?php _e( 'Label Description', 'wpsc' ) ?> :</td>
825
+ <td><textarea name="productmeta_values[labels_desc][]"></textarea></td>
826
+ </tr>
827
+ <tr>
828
+ <td><?php _e( 'Life Number', 'wpsc' ) ?> :</td>
829
+ <td><input type="text" name="productmeta_values[life_number][]"></td>
830
+ </tr>
831
+ <tr>
832
+ <td><?php _e( 'Item Number', 'wpsc' ) ?> :</td>
833
+ <td><input type="text" name="productmeta_values[item_number][]"></td>
834
+ </tr>
835
+ <tr>
836
+ <td><?php _e( 'Product Code', 'wpsc' ) ?> :</td>
837
+ <td><input type="text" name="productmeta_values[product_code][]"></td>
838
+ </tr>
839
+ <tr>
840
+ <td><?php _e( 'PDF', 'wpsc' ) ?> :</td>
841
+ <td><input type="file" name="pdf[]"></td>
842
+ </tr>
843
+ </table>
844
+ </div>
845
+ </td>
846
+ </tr>
847
+ </table>
848
+ </div>
849
+ </div>
850
+
851
+ <?php
852
+ }
853
+ /**
854
+ * Adding function to change text for media buttons
855
+ */
856
+ function change_context( $context ) {
857
+ global $current_screen;
858
+
859
+ if( $current_screen->id != 'wpsc-product' )
860
+ return $context;
861
+ return __( 'Upload Image%s' );
862
+ }
863
+ function change_link( $link ) {
864
+ global $post_ID, $current_screen;
865
+
866
+ if( $current_screen->id != 'wpsc-product' )
867
+ return $link;
868
+
869
+ $uploading_iframe_ID = $post_ID;
870
+ $media_upload_iframe_src = "media-upload.php?post_id=$uploading_iframe_ID";
871
+
872
+ return $media_upload_iframe_src . "&amp;type=image&parent_page=wpsc-edit-products";
873
+ }
874
+ function wpsc_form_multipart_encoding() {
875
+ echo ' enctype="multipart/form-data"';
876
+ }
877
+
878
+ add_action( 'post_edit_form_tag', 'wpsc_form_multipart_encoding' );
879
+ add_filter( 'media_buttons_context', 'change_context' );
880
+ add_filter( 'image_upload_iframe_src', "change_link" );
881
+ /*
882
+ * Modifications to Media Gallery
883
+ */
884
+
885
+ if ( (isset( $_REQUEST['parent_page'] ) && ( $_REQUEST['parent_page'] == 'wpsc-edit-products' ) ) ) {
886
+ add_filter( 'media_upload_tabs', 'wpsc_media_upload_tab_gallery', 12 );
887
+ add_filter( 'attachment_fields_to_save', 'wpsc_save_attachment_fields', 9, 2 );
888
+ add_filter( 'media_upload_form_url', 'wpsc_media_upload_url', 9, 1 );
889
+ add_action( 'admin_head', 'wpsc_gallery_css_mods' );
890
+ }
891
+ add_filter( 'gettext','wpsc_filter_delete_text',12 , 3 );
892
+ add_filter( 'attachment_fields_to_edit', 'wpsc_attachment_fields', 11, 2 );
893
+ add_filter( 'gettext','wpsc_filter_feature_image_text', 12, 3 );
894
+
895
+ if( isset( $_REQUEST["save"] ) && isset($_REQUEST["attachments"]) && is_array($_REQUEST["attachments"]) ) {
896
  wpsc_regenerate_thumbnails();
897
  }
898
 
914
  }
915
  return $translation;
916
  }
 
917
  function wpsc_attachment_fields($form_fields, $post) {
918
 
919
  $parent_post = get_post($post->post_parent);
997
  }
998
  return $form_fields;
999
 
1000
+ }
 
1001
  function wpsc_save_attachment_fields($post, $attachment) {
1002
 
1003
  if ( isset ( $attachment['wpsc_custom_thumb_w']) )
1011
 
1012
  return $post;
1013
  }
 
1014
  function wpsc_media_upload_url($form_action_url) {
1015
 
1016
  $form_action_url = esc_url(add_query_arg(array('parent_page'=>'wpsc-edit-products')));
1018
  return $form_action_url;
1019
 
1020
  }
 
1021
  function wpsc_gallery_css_mods() {
1022
 
1023
  print '<style type="text/css">
1066
 
1067
  </script>';
1068
  }
 
 
1069
  function wpsc_media_upload_tab_gallery($tabs) {
1070
 
1071
  unset($tabs['gallery']);
1073
 
1074
  return $tabs;
1075
  }
 
1076
  function wpsc_filter_delete_text($translation, $text, $domain){
1077
 
1078
  if( 'Delete' == $text && isset( $_REQUEST['post_id'] ) && isset( $_REQUEST["parent_page"] ) ){
1081
  }
1082
  return $translation;
1083
  }
1084
+ function edit_multiple_image_gallery( $post ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1085
  global $wpdb;
1086
+ //Make sure thumbnail isn't duplicated
1087
  $siteurl = get_option( 'siteurl' );
1088
+
1089
+ if ( $post->ID > 0 ) {
1090
+ if ( has_post_thumbnail( $post->ID ) )
1091
+ echo get_the_post_thumbnail( $post->ID, 'admin-product-thumbnails' );
1092
+
1093
  $args = array(
1094
  'post_type' => 'attachment',
1095
  'numberposts' => -1,
1096
  'post_status' => null,
1097
+ 'post_parent' => $post->ID,
1098
  'orderby' => 'menu_order',
1099
  'order' => 'ASC'
1100
  );
1101
 
1102
  $attached_images = (array)get_posts( $args );
1103
+
1104
+ if(count($attached_images) > 0){
1105
+ foreach($attached_images as $images){
1106
+ $attached_image = wp_get_attachment_image( $images->ID, 'admin-product-thumbnails' );
1107
+ echo $attached_image. '&nbsp;';
1108
+ }
1109
+ }
1110
+
1111
  }
1112
  }
1113
 
1114
  /**
1115
+ * wpsc_save_quickedit_box function
1116
+ * Saves input for the various meta in the quick edit boxes
1117
+ *
1118
+ * @todo UI
1119
+ * @todo Data validation / sanitization / security
1120
+ * @todo AJAX should probably return weight unit
1121
+ * @return $post_id (int) Post ID
1122
+ */
 
 
 
 
 
 
 
 
1123
 
1124
+ function wpsc_save_quickedit_box( $post_id ) {
 
 
 
 
 
1125
 
1126
+ if( !defined( 'DOING_AJAX' ) )
1127
+ return;
1128
 
1129
+ $is_parent = ( bool )wpsc_product_has_children( $post_id );
1130
+ $product_meta = get_post_meta( $post_id, '_wpsc_product_metadata', true );
1131
+ $weight_unit = $product_meta["weight_unit"];
1132
+ $weight = wpsc_convert_weight( $_POST["weight"], $weight_unit, "gram" );
1133
 
1134
+ if( isset( $product_meta["weight"] ) )
1135
+ unset($product_meta["weight"]);
 
 
 
1136
 
1137
+ $product_meta["weight"] = $weight;
 
 
 
 
 
 
 
 
 
1138
 
1139
+ if( !$is_parent ) {
1140
+ update_post_meta( $post_id, '_wpsc_product_metadata', $product_meta );
1141
+ update_post_meta( $post_id, '_wpsc_stock', $_POST['stock'] );
1142
+ update_post_meta( $post_id, '_wpsc_price', $_POST['price'] );
1143
+ update_post_meta( $post_id, '_wpsc_special_price', $_POST['sale_price'] );
1144
+ }
1145
+ update_post_meta( $post_id, '_wpsc_sku', $_POST['sku'] );
1146
 
1147
+ return $post_id;
1148
  }
1149
 
1150
  /**
1151
+ * wpsc_quick_edit_boxes function
1152
+ * Creates inputs for the various meta in the quick edit boxes.
1153
+ *
1154
+ * @todo UI
1155
+ * @internal Tried accessing post_id in here to do the is_parent/variation thing - no luck :(
1156
+ */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1157
 
1158
+ function wpsc_quick_edit_boxes( $col_name ) {
1159
+ ?>
1160
+
1161
+ <fieldset class="inline-edit-col-left wpsc-cols">
1162
+ <div class="inline-edit-col">
1163
+ <div class="inline-edit-group">
1164
+ <?php
1165
+ switch ( $col_name ) :
1166
+ case 'SKU' :
1167
+ ?>
1168
+ <label class="alignleft">
1169
+ <span class="checkbox-title wpsc-quick-edit"><?php _e('SKU:', 'wpsc'); ?> </span>
1170
+ <input type="text" name="sku" id="wpsc_ie_sku">
1171
+ </label>
1172
+ <?php
1173
+ break;
1174
+ case 'weight' :
1175
+ ?>
1176
+ <label class="alignleft">
1177
+ <span class="checkbox-title wpsc-quick-edit"><?php _e('Weight:', 'wpsc'); ?> </span>
1178
+ <input type="text" name="weight" id="wpsc_ie_weight">
1179
+ </label>
1180
+ <?php
1181
+ break;
1182
+ case 'stock' :
1183
+ ?>
1184
+ <label class="alignleft">
1185
+ <span class="checkbox-title wpsc-quick-edit"><?php _e('Stock:', 'wpsc'); ?> </span>
1186
+ <input type="text" name="stock" id="wpsc_ie_stock">
1187
+ </label>
1188
+ <?php
1189
+ break;
1190
+ case 'price' :
1191
+ ?>
1192
+ <label class="alignleft">
1193
+ <span class="checkbox-title wpsc-quick-edit"><?php _e('Price:', 'wpsc'); ?> </span>
1194
+ <input type="text" name="price" id="wpsc_ie_price">
1195
+ </label>
1196
+ <?php
1197
+ break;
1198
+ case 'sale_price' :
1199
+ ?>
1200
+ <label class="alignleft">
1201
+ <span class="checkbox-title wpsc-quick-edit"><?php _e('Sale Price:', 'wpsc'); ?> </span>
1202
+ <input type="text" name="sale_price" id="wpsc_ie_sale_price">
1203
+ </label>
1204
+ <?php
1205
+ break;
1206
+ endswitch;
1207
+ ?>
1208
+ </div>
1209
+ </div>
1210
+ </fieldset>
1211
  <?php
1212
  }
1213
 
1214
+ add_action( 'bulk_edit_custom_box', 'wpsc_quick_edit_boxes', 10 );
1215
+ add_action( 'quick_edit_custom_box', 'wpsc_quick_edit_boxes', 10 );
1216
+ add_action( 'save_post', 'wpsc_save_quickedit_box' );
1217
+
1218
  ?>
wpsc-admin/includes/product-functions.php CHANGED
@@ -8,46 +8,11 @@
8
 
9
  function wpsc_get_max_upload_size(){
10
  // Get PHP Max Upload Size
11
- if(ini_get('upload_max_filesize')) $upload_max = ini_get('upload_max_filesize');
12
- else $upload_max = __('N/A', 'wpsc');
13
  return $upload_max;
14
  }
15
 
16
- /**
17
- * wpsc_product_variation_price_available function
18
- * Checks for the lowest price of a products variations
19
- *
20
- * @return $price (string) number formatted price
21
- */
22
- function wpsc_product_variation_price_available($product_id){
23
- global $wpdb;
24
- $price = $wpdb->get_var('
25
- SELECT
26
- `pm`.`meta_value`
27
- FROM
28
- `' . $wpdb->postmeta . '` `pm`
29
- JOIN
30
- `' . $wpdb->posts . '` `p`
31
- ON
32
- `pm`.`post_id` = `p`.`id`
33
- WHERE
34
- `p`.`post_type`= "wpsc-product"
35
- AND
36
- `p`.`post_parent` = ' . $product_id . '
37
- AND
38
- `pm`.`meta_key` = "_wpsc_price"
39
- AND
40
- `p`.`ID` IN (
41
- SELECT `' . $wpdb->postmeta . '`.`post_id` FROM `' . $wpdb->postmeta . '` WHERE `meta_key` = "_wpsc_stock" AND `meta_value` != "0"
42
- )
43
- ORDER BY
44
- `meta_value` ASC
45
- LIMIT 1'
46
- );
47
-
48
- $price = wpsc_currency_display($price, array('display_as_html' => false));
49
- return $price;
50
- }
51
 
52
  /**
53
  * wpsc_product_has_children function
@@ -68,47 +33,195 @@ function wpsc_product_has_children($id){
68
  return true;
69
  }
70
 
71
-
72
  /**
73
  * wpsc_admin_submit_product function
74
- *
 
 
75
  * @return nothing
76
  */
77
- function wpsc_admin_submit_product() {
78
- check_admin_referer('edit-product', 'wpsc-edit-product');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
 
80
- $sendback = wp_get_referer();
81
- $post_data = wpsc_sanitise_product_forms();
82
- if(isset($post_data['title']) && $post_data['title'] != '') {
83
- $product_id = wpsc_insert_product($post_data, true);
84
- if($product_id > 0) {
85
- $sendback = add_query_arg('product', $product_id);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  }
87
-
88
- $sendback = add_query_arg('message', 1, $sendback);
89
- wp_redirect($sendback);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  } else {
91
- $_SESSION['product_error_messages'] = array();
92
- if($post_data['title'] == ''){
93
- $_SESSION['product_error_messages'][] = __('<strong>ERROR</strong>: Please enter a Product name.<br />');
94
- }
95
- if(!isset($post_data['category'])){
96
- $_SESSION['product_error_messages'][] = __('<strong>ERROR</strong>: Please enter a Product Category.<br />');
97
- }
98
-
99
- $_SESSION['wpsc_failed_product_post_data'] = $post_data;
100
- $sendback = add_query_arg('ErrMessage', 1);
101
- wp_redirect($sendback);
102
  }
103
- exit();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
  }
105
 
106
-
107
- /**
108
- * wpsc_sanitise_product_forms function
109
- *
110
- * @return array - Sanitised product details
111
- */
112
  function wpsc_sanitise_product_forms($post_data = null) {
113
  if ( empty($post_data) ) {
114
  $post_data = &$_POST;
@@ -205,8 +318,6 @@ function wpsc_sanitise_product_forms($post_data = null) {
205
  return $post_data;
206
  }
207
 
208
-
209
-
210
  /**
211
  * wpsc_insert_product function
212
  *
@@ -272,7 +383,6 @@ function wpsc_insert_product($post_data, $wpsc_error = false) {
272
  'post_type' => "wpsc-product",
273
  'post_name' => sanitize_title($post_data['name'])
274
  );
275
-
276
  if ($post_data['meta']['_wpsc_product_metadata']['enable_comments'] == 0) {
277
  $product_post_values["comment_status"] = "closed";
278
  }else {
@@ -322,17 +432,6 @@ function wpsc_insert_product($post_data, $wpsc_error = false) {
322
 
323
  // if we succeed, we can do further editing
324
 
325
- // update the categories
326
-
327
- if (!isset($post_data['category'])) $post_data['category'] = array();
328
- wp_set_product_categories($product_id, $post_data['category']);
329
-
330
-
331
- // and the tags
332
- if (!isset($post_data['product_tags'])) $post_data['product_tags'] = '';
333
- if (!isset($post_data['wpsc_existing_tags'])) $post_data['wpsc_existing_tags'] = '';
334
- wpsc_update_product_tags($product_id, $post_data['product_tags'], $post_data['wpsc_existing_tags']);
335
-
336
  // and the meta
337
  wpsc_update_product_meta($product_id, $post_data['meta']);
338
 
@@ -343,7 +442,7 @@ function wpsc_insert_product($post_data, $wpsc_error = false) {
343
  foreach((array)$post_data['newCurrency'] as $key =>$value){
344
  wpsc_update_alt_product_currency($product_id, $value, $post_data['newCurrPrice'][$key]);
345
  }
346
-
347
  if($post_data['files']['file']['tmp_name'] != '') {
348
  wpsc_item_process_file($product_id, $post_data['files']['file']);
349
  } else {
@@ -354,14 +453,11 @@ function wpsc_insert_product($post_data, $wpsc_error = false) {
354
  if(isset($post_data['files']['preview_file']['tmp_name']) && ($post_data['files']['preview_file']['tmp_name'] != '')) {
355
  wpsc_item_add_preview_file($product_id, $post_data['files']['preview_file']);
356
  }
357
-
358
-
359
  do_action('wpsc_edit_product', $product_id);
360
  wpsc_ping();
361
  return $product_id;
362
  }
363
 
364
-
365
  /**
366
  * term_id_price function
367
  * Retreives associated price, if any, with term_id
@@ -421,8 +517,6 @@ function term_id_price($term_id, $parent_price) {
421
  return $price;
422
  }
423
 
424
-
425
-
426
  /**
427
  * wpsc_edit_product_variations function.
428
  * this is the function to make child products using variations
@@ -435,17 +529,14 @@ function term_id_price($term_id, $parent_price) {
435
  function wpsc_edit_product_variations($product_id, $post_data) {
436
  global $wpdb, $user_ID;
437
  $variations = array();
 
438
  if (!isset($post_data['edit_var_val'])) $post_data['edit_var_val'] = '';
439
 
440
  $variations = (array)$post_data['edit_var_val'];
441
- // bail if the array is empty
442
- if(count($variations) < 1) {
443
- return false;
444
- }
445
-
446
-
447
  // Generate the arrays for variation sets, values and combinations
448
  $wpsc_combinator = new wpsc_variation_combinator($variations);
 
449
  // Retrieve the array containing the variation set IDs
450
  $variation_sets = $wpsc_combinator->return_variation_sets();
451
 
@@ -457,19 +548,18 @@ function wpsc_edit_product_variations($product_id, $post_data) {
457
 
458
  $product_terms = wp_get_object_terms($product_id, 'wpsc-variation');
459
 
460
-
461
  $variation_sets_and_values = array_merge($variation_sets, $variation_values);
462
- wp_set_object_terms($product_id, $variation_sets_and_values, 'wpsc-variation');
463
-
464
  $child_product_template = array(
465
- 'post_author' => $user_ID,
466
- 'post_content' => $post_data['description'],
467
- 'post_excerpt' => $post_data['additional_description'],
468
- 'post_title' => $post_data['name'],
469
- 'post_status' => 'inherit',
470
- 'post_type' => "wpsc-product",
471
- 'post_name' => sanitize_title($post_data['name']),
472
- 'post_parent' => $product_id
473
  );
474
 
475
  $child_product_meta = get_post_custom($product_id);
@@ -482,10 +572,11 @@ function wpsc_edit_product_variations($product_id, $post_data) {
482
  $product_values = $child_product_template;
483
 
484
  $combination_terms = get_terms('wpsc-variation', array(
485
- 'hide_empty' => 0,
486
- 'include' => implode(",", $combination),
487
- 'orderby' => 'parent',
488
  ));
 
489
  foreach($combination_terms as $term) {
490
  $term_ids[] = $term->term_id;
491
  $term_slugs[] = $term->slug;
@@ -496,14 +587,13 @@ function wpsc_edit_product_variations($product_id, $post_data) {
496
  $product_values['post_name'] = sanitize_title($product_values['post_title']);
497
 
498
  $selected_post = get_posts(array(
499
- 'name' => $product_values['post_name'],
500
- 'post_parent' => $product_id,
501
- 'post_type' => "wpsc-product",
502
- 'post_status' => 'all',
503
- 'suppress_filters' => true
504
  ));
505
  $selected_post = array_shift($selected_post);
506
-
507
  $child_product_id = wpsc_get_child_object_in_terms($product_id, $term_ids, 'wpsc-variation');
508
  $already_a_variation = true;
509
  if($child_product_id == false) {
@@ -519,6 +609,7 @@ function wpsc_edit_product_variations($product_id, $post_data) {
519
  $child_product_id = $selected_post->ID;
520
  }
521
  }
 
522
  if($child_product_id > 0) {
523
  wp_set_object_terms($child_product_id, $term_slugs, 'wpsc-variation');
524
  }
@@ -535,7 +626,7 @@ function wpsc_edit_product_variations($product_id, $post_data) {
535
 
536
  //Adding this to check for a price on variations. Applying the highest price, seems to make the most sense.
537
  if ( is_array ($term_ids) ) {
538
- $price = array();
539
  foreach ($term_ids as $term_id_price) {
540
  $price[] = term_id_price($term_id_price, $child_product_meta["_wpsc_price"][0]);
541
  }
@@ -550,133 +641,86 @@ function wpsc_edit_product_variations($product_id, $post_data) {
550
  }
551
 
552
 
553
- //For reasons unknown, this code did not previously deal with variation deletions. Basically, we'll just check if any existing term associations are missing from the posted variables, delete if they are.
 
554
  //Get posted terms (multi-dimensional array, first level = parent var, second level = child var)
555
  $posted_term = $variations;
556
  //Get currently associated terms
557
  $currently_associated_var = $product_terms;
 
 
 
 
558
 
559
- foreach ($currently_associated_var as $current) {
560
- $currently_associated_vars[] = $current->term_id;
 
 
 
 
561
  }
 
 
 
 
 
 
 
 
 
 
 
562
 
563
- foreach ($posted_term as $term=>$val) {
564
- $posted_terms[] = $term;
565
- if(is_array($val)) {
566
- foreach($val as $term2=>$val2) {
567
- $posted_terms[] = $term2;
568
- }
 
569
  }
 
570
  }
571
-
572
- //if currently associated > posted, get diff (current_associated - posted)
573
- if(count($currently_associated_vars) > count($posted_terms) && isset($_REQUEST["product"]) ) {
574
-
575
- $post_ids_to_delete = array();
576
- $term_ids_to_delete = array();
577
- $term_ids_to_delete = array_diff($currently_associated_vars, $posted_terms);
578
 
579
- // Whatever remains, find child products of current product with that term, in the variation taxonomy, and delete
580
- $post_ids_to_delete = wpsc_get_child_object_in_terms_var($_REQUEST["product_id"], $term_ids_to_delete, 'wpsc-variation');
581
- if(is_array($post_ids_to_delete)) {
582
- foreach($post_ids_to_delete as $object_ids) {
583
- foreach($object_ids as $object_id) {
584
- wp_delete_post($object_id);
 
 
585
  }
586
  }
587
  }
588
- }
589
-
590
  }
591
 
592
  function wpsc_update_alt_product_currency($product_id, $newCurrency, $newPrice){
593
  global $wpdb;
 
594
  $old_curr = get_product_meta($product_id, 'currency',true);
595
  $sql = "SELECT `isocode` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `id`=".$newCurrency;
596
  $isocode = $wpdb->get_var($sql);
597
 
598
  $newCurrency = 'currency';
599
  $old_curr[$isocode] = $newPrice;
600
- if(($newPrice != '') && ($newPrice > 0)){
601
  update_product_meta($product_id, $newCurrency, $old_curr);
602
  } else {
603
- if(!empty($old_curr[$isocode]) && is_array($old_curr))
604
  unset($old_curr[$isocode]);
605
-
606
  update_product_meta($product_id, $newCurrency, $old_curr);
607
 
608
  }
609
- }
610
- /**
611
- * wpsc_update_categories function
612
- *
613
- * @param integer product ID
614
- * @param array submitted categories
615
- */
616
- function wpsc_update_category_associations($product_id, $categories = array()) {
617
- global $wpdb;
618
-
619
- $associated_categories = $wpdb->get_col($wpdb->prepare("SELECT `category_id` FROM `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."` WHERE `product_id` IN('%s')", $product_id));
620
-
621
- $categories_to_add = array_diff((array)$categories, (array)$associated_categories);
622
- $categories_to_delete = array_diff((array)$associated_categories, (array)$categories);
623
- $insert_sections = array();
624
- foreach($categories_to_delete as $key => $category_to_delete) {
625
- $categories_to_delete[$key] = absint($category_to_delete);
626
- }
627
-
628
 
629
- foreach($categories_to_add as $category_id) {
630
- $insert_sections[] = $wpdb->prepare("( %d, %d)", $product_id, $category_id);
631
- }
632
- if(count($insert_sections)) {
633
- $wpdb->query("INSERT INTO `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."` (`product_id`, `category_id`) VALUES ".implode(", ",$insert_sections)."");
634
- }
635
-
636
- foreach($categories_to_add as $category_id) {
637
- $check_existing = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_PRODUCT_ORDER."` WHERE `category_id` IN('$category_id') AND `order` IN('0') LIMIT 1;",ARRAY_A);
638
- if($wpdb->get_var("SELECT `id` FROM `".WPSC_TABLE_PRODUCT_ORDER."` WHERE `category_id` IN('$category_id') AND `product_id` IN('$product_id') LIMIT 1")) {
639
- $wpdb->query("UPDATE `".WPSC_TABLE_PRODUCT_ORDER."` SET `order` = '0' WHERE `category_id` IN('$category_id') AND `product_id` IN('$product_id') LIMIT 1;");
640
- } else {
641
- $wpdb->query("INSERT INTO `".WPSC_TABLE_PRODUCT_ORDER."` (`category_id`, `product_id`, `order`) VALUES ('$category_id', '$product_id', 0)");
642
- }
643
- if($check_existing != null) {
644
- $wpdb->query("UPDATE `".WPSC_TABLE_PRODUCT_ORDER."` SET `order` = (`order` + 1) WHERE `category_id` IN('$category_id') AND `product_id` NOT IN('$product_id') AND `order` < '0'");
645
- }
646
- }
647
- if(count($categories_to_delete) > 0) {
648
- $wpdb->query("DELETE FROM`".WPSC_TABLE_ITEM_CATEGORY_ASSOC."` WHERE `product_id` = {$product_id} AND `category_id` IN(".implode(",",$categories_to_delete).") LIMIT ".count($categories_to_delete)."");
649
- }
650
- }
651
-
652
- /**
653
- * wpsc_update_product_tags function
654
- *
655
- * @param integer product ID
656
- * @param string comma separated tags
657
- */
658
- function wpsc_update_product_tags($product_id, $product_tags, $existing_tags) {
659
- if(isset($existing_tags)){
660
- $tags = explode(',',$existing_tags);
661
- if(is_array($tags)){
662
- foreach((array)$tags as $tag){
663
- $tt = wp_insert_term((string)$tag, 'product_tag');
664
- }
665
- }
666
- }
667
- wp_set_object_terms($product_id, $tags, 'product_tag');
668
- if(isset($product_tags) && $product_tags != 'Add new tag') {
669
-
670
- $tags = explode(',',$product_tags);
671
- if(is_array($tags)) {
672
- foreach((array)$tags as $tag){
673
- $tt = wp_insert_term((string)$tag, 'product_tag');
674
- }
675
- }
676
- wp_set_object_terms($product_id, $tags, 'product_tag');
677
- }
678
  }
679
-
680
  /**
681
  * wpsc_update_product_meta function
682
  *
@@ -695,57 +739,6 @@ function wpsc_update_product_meta($product_id, $product_meta) {
695
  }
696
  }
697
 
698
- /*
699
- /* Code to support Publish/No Publish (1bigidea)
700
- */
701
- /**
702
- * set status of publish conditions
703
- * @return
704
- * @param string $product_id
705
- * @param bool $status Publish State
706
- */
707
- function wpsc_set_publish_status($product_id, $state) {
708
- global $wpdb;
709
- switch($state) {
710
- case 'draft':
711
- case 0:
712
- $status = 'draft';
713
- break;
714
-
715
- default:
716
- $status = 'publish';
717
- break;
718
- }
719
- $result = $wpdb->query("UPDATE `".$wpdb->posts."` SET `post_status` = '{$status}' WHERE `ID` = '{$product_id}'");
720
- }
721
-
722
- /**
723
- * Toggle publish status and update product record
724
- * @return bool Publish status
725
- * @param string $product_id
726
- */
727
- function wpsc_toggle_publish_status($product_id) {
728
- global $wpdb;
729
-
730
- if(wpsc_publish_status($product_id) == 'publish') {
731
- $status = 'draft';
732
- } else {
733
- $status = 'publish';
734
- }
735
-
736
- wpsc_set_publish_status($product_id, $status);
737
- return $status;
738
- }
739
- /**
740
- * Returns publish status from product database
741
- * @return bool publish status
742
- * @param string $product_id
743
- */
744
- function wpsc_publish_status($product_id) {
745
- global $wpdb;
746
- $status = $wpdb->get_var("SELECT `post_status` FROM `".$wpdb->posts."` WHERE `ID` = '{$product_id}'");
747
- return $status;
748
- }
749
  /**
750
  * Called from javascript within product page to toggle publish status - AJAX
751
  * @return bool publish status
@@ -802,7 +795,6 @@ function wpsc_item_process_file($product_id, $submitted_file, $preview_file = nu
802
  }
803
 
804
  $file = wp_handle_upload($submitted_file, $overrides, $time);
805
-
806
  if ( isset($file['error']) )
807
  return new WP_Error( 'upload_error', $file['error'] );
808
 
@@ -834,11 +826,9 @@ function wpsc_item_process_file($product_id, $submitted_file, $preview_file = nu
834
  function wpsc_modify_upload_directory($input) {
835
  $previous_subdir = $input['subdir'];
836
  $download_subdir = str_replace($input['basedir'], '', WPSC_FILE_DIR);
837
-
838
- $input['path'] = str_replace($previous_subdir, $download_subdir, $input['path']);
839
- $input['url'] = str_replace($previous_subdir, $download_subdir, $input['url']);
840
- $input['subdir'] = str_replace($previous_subdir, $download_subdir, $input['subdir']);
841
-
842
  return $input;
843
  }
844
 
@@ -846,14 +836,13 @@ function wpsc_modify_preview_directory($input) {
846
  $previous_subdir = $input['subdir'];
847
  $download_subdir = str_replace($input['basedir'], '', WPSC_PREVIEW_DIR);
848
 
849
- $input['path'] = str_replace($previous_subdir, $download_subdir, $input['path']);
850
- $input['url'] = str_replace($previous_subdir, $download_subdir, $input['url']);
851
- $input['subdir'] = str_replace($previous_subdir, $download_subdir, $input['subdir']);
852
 
853
  return $input;
854
  }
855
-
856
-
857
  /**
858
  * wpsc_item_reassign_file function
859
  *
@@ -930,8 +919,6 @@ function wpsc_item_reassign_file($product_id, $selected_files) {
930
  return $fileid;
931
  }
932
 
933
-
934
-
935
  /**
936
  * wpsc_item_add_preview_file function
937
  *
@@ -985,7 +972,6 @@ function wpsc_item_add_preview_file($product_id, $preview_file) {
985
 
986
  }
987
 
988
-
989
  /**
990
  * wpsc_variation_combinator class.
991
  * Produces all combinations of variations selected for this product
@@ -1063,4 +1049,4 @@ function wpsc_variations_stock_remaining($product_id){
1063
  ');
1064
  }
1065
 
1066
- ?>
8
 
9
  function wpsc_get_max_upload_size(){
10
  // Get PHP Max Upload Size
11
+ if( ini_get( 'upload_max_filesize' ) ) $upload_max = ini_get( 'upload_max_filesize' );
12
+ else $upload_max = __( 'N/A', 'wpsc' );
13
  return $upload_max;
14
  }
15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
  /**
18
  * wpsc_product_has_children function
33
  return true;
34
  }
35
 
 
36
  /**
37
  * wpsc_admin_submit_product function
38
+ * @internal Was going to completely refactor sanitise forms and wpsc_insert_product, but they are also used by the import system
39
+ * which I'm not really familiar with...so I'm not touching them :) Erring on the side of redundancy and caution I'll just
40
+ * refactor this to do the job.
41
  * @return nothing
42
  */
43
+ function wpsc_admin_submit_product( $post_ID, $post ) {
44
+ global $current_screen, $wpdb;
45
+ if( $current_screen->id != 'wpsc-product' )
46
+ return;
47
+ //Type-casting ( not so much sanitization, which would be good to do )
48
+ $post_data = $_POST;
49
+ $product_id = $post_ID;
50
+ $post_data['additional_description'] = isset($post_data['additional_description']) ? $post_data['additional_description'] : '';
51
+ $post_meta['meta'] = (array)$_POST['meta'];
52
+ $post_data['meta']['_wpsc_price'] = (float)str_replace( ',','',$post_data['meta']['_wpsc_price'] );
53
+ $post_data['meta']['_wpsc_special_price'] = (float)str_replace( ',','',$post_data['meta']['_wpsc_special_price'] );
54
+ $post_data['meta']['_wpsc_sku'] = $post_data['meta']['_wpsc_sku'];
55
+ if (!isset($post_data['meta']['_wpsc_is_donation'])) $post_data['meta']['_wpsc_is_donation'] = '';
56
+ $post_data['meta']['_wpsc_is_donation'] = (int)(bool)$post_data['meta']['_wpsc_is_donation'];
57
+ $post_data['meta']['_wpsc_stock'] = (int)$post_data['meta']['_wpsc_stock'];
58
+ if (!isset($post_data['meta']['_wpsc_limited_stock'])) $post_data['meta']['_wpsc_limited_stock'] = '';
59
+ if((bool)$post_data['meta']['_wpsc_limited_stock'] != true) {
60
+ $post_data['meta']['_wpsc_stock'] = false;
61
+ }
62
+ unset($post_data['meta']['_wpsc_limited_stock']);
63
+ if(!isset($post_data['meta']['_wpsc_product_metadata']['unpublish_when_none_left'])) $post_data['meta']['_wpsc_product_metadata']['unpublish_when_none_left'] = '';
64
+ if(!isset($post_data['quantity_limited'])) $post_data['quantity_limited'] = '';
65
+ if(!isset($post_data['special'])) $post_data['special'] = '';
66
+ if(!isset($post_data['meta']['_wpsc_product_metadata']['no_shipping'])) $post_data['meta']['_wpsc_product_metadata']['no_shipping'] = '';
67
+
68
+ $post_data['meta']['_wpsc_product_metadata']['unpublish_when_none_left'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['unpublish_when_none_left'];
69
+ $post_data['meta']['_wpsc_product_metadata']['quantity_limited'] = (int)(bool)$post_data['quantity_limited'];
70
+ $post_data['meta']['_wpsc_product_metadata']['special'] = (int)(bool)$post_data['special'];
71
+ $post_data['meta']['_wpsc_product_metadata']['no_shipping'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['no_shipping'];
72
+
73
+ // Product Weight
74
+ if(!isset($post_data['meta']['_wpsc_product_metadata']['display_weight_as'])) $post_data['meta']['_wpsc_product_metadata']['display_weight_as'] = '';
75
+ if(!isset($post_data['meta']['_wpsc_product_metadata']['display_weight_as'])) $post_data['meta']['_wpsc_product_metadata']['display_weight_as'] = '';
76
+
77
+ $weight = wpsc_convert_weight($post_data['meta']['_wpsc_product_metadata']['weight'], $post_data['meta']['_wpsc_product_metadata']['weight_unit'], "pound");
78
+ $post_data['meta']['_wpsc_product_metadata']['weight'] = (float)$weight;
79
+ $post_data['meta']['_wpsc_product_metadata']['display_weight_as'] = $post_data['meta']['_wpsc_product_metadata']['weight_unit'];
80
+
81
+ // table rate price
82
+ $post_data['meta']['_wpsc_product_metadata']['table_rate_price'] = $post_data['table_rate_price'];
83
+ // if table_rate_price is unticked, wipe the table rate prices
84
+ if(!isset($post_data['table_rate_price']['state'])) $post_data['table_rate_price']['state'] = '';
85
+ if($post_data['table_rate_price']['state'] != 1) {$post_data['meta']['_wpsc_product_metadata']['table_rate_price']['quantity'] = null;
86
+ $post_data['meta']['_wpsc_product_metadata']['table_rate_price']['table_price'] = null;
87
+ $post_data['meta']['_wpsc_product_metadata']['table_rate_price']['quantity'] = null;
88
+ $post_data['meta']['_wpsc_product_metadata']['table_rate_price']['table_price'] = null;
89
+ }
90
+ foreach((array)$post_data['meta']['_wpsc_product_metadata']['table_rate_price']['table_price'] as $key => $value){
91
+ if(empty($value)){
92
+ unset($post_data['meta']['_wpsc_product_metadata']['table_rate_price']['table_price'][$key]);
93
+ unset($post_data['meta']['_wpsc_product_metadata']['table_rate_price']['quantity'][$key]);
94
+ }
95
+ }
96
+
97
+
98
+ $post_data['meta']['_wpsc_product_metadata']['shipping']['local'] = (float)$post_data['meta']['_wpsc_product_metadata']['shipping']['local'];
99
+ $post_data['meta']['_wpsc_product_metadata']['shipping']['international'] = (float)$post_data['meta']['_wpsc_product_metadata']['shipping']['international'];
100
+
101
+
102
+ // Advanced Options
103
+ $post_data['meta']['_wpsc_product_metadata']['engraved'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['engraved'];
104
+ $post_data['meta']['_wpsc_product_metadata']['can_have_uploaded_image'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['can_have_uploaded_image'];
105
+ if(!isset($post_data['meta']['_wpsc_product_metadata']['google_prohibited'])) $post_data['meta']['_wpsc_product_metadata']['google_prohibited'] = '';
106
+ $post_data['meta']['_wpsc_product_metadata']['google_prohibited'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['google_prohibited'];
107
+ $post_data['meta']['_wpsc_product_metadata']['external_link'] = (string)$post_data['meta']['_wpsc_product_metadata']['external_link'];
108
+ $post_data['meta']['_wpsc_product_metadata']['external_link_text'] = (string)$post_data['meta']['_wpsc_product_metadata']['external_link_text'];
109
+ $post_data['meta']['_wpsc_product_metadata']['external_link_target'] = (string)$post_data['meta']['_wpsc_product_metadata']['external_link_target'];
110
 
111
+ $post_data['meta']['_wpsc_product_metadata']['enable_comments'] = $post_data['meta']['_wpsc_product_metadata']['enable_comments'];
112
+ $post_data['meta']['_wpsc_product_metadata']['merchant_notes'] = $post_data['meta']['_wpsc_product_metadata']['merchant_notes'];
113
+
114
+ $post_data['files'] = $_FILES;
115
+
116
+ if(isset($post_data['post_title']) && $post_data['post_title'] != '') {
117
+
118
+ $product_columns = array(
119
+ 'name' => '',
120
+ 'description' => '',
121
+ 'additional_description' => '',
122
+ 'price' => null,
123
+ 'weight' => null,
124
+ 'weight_unit' => '',
125
+ 'pnp' => null,
126
+ 'international_pnp' => null,
127
+ 'file' => null,
128
+ 'image' => '0',
129
+ 'quantity_limited' => '',
130
+ 'quantity' => null,
131
+ 'special' => null,
132
+ 'special_price' => null,
133
+ 'display_frontpage' => null,
134
+ 'notax' => null,
135
+ 'publish' => null,
136
+ 'active' => null,
137
+ 'donation' => null,
138
+ 'no_shipping' => null,
139
+ 'thumbnail_image' => null,
140
+ 'thumbnail_state' => null
141
+ );
142
+
143
+ foreach($product_columns as $column => $default)
144
+ {
145
+ if (!isset($post_data[$column])) $post_data[$column] = '';
146
+
147
+ if($post_data[$column] !== null) {
148
+ $update_values[$column] = stripslashes($post_data[$column]);
149
+ } else if(($update != true) && ($default !== null)) {
150
+ $update_values[$column] = stripslashes($default);
151
  }
152
+ }
153
+ // if we succeed, we can do further editing (todo - if_wp_error)
154
+
155
+ // and the meta
156
+
157
+ wpsc_update_product_meta($product_id, $post_data['meta']);
158
+
159
+ // and the custom meta
160
+ wpsc_update_custom_meta($product_id, $post_data);
161
+
162
+ // sort out the variations
163
+ wpsc_edit_product_variations( $product_id, $post_data );
164
+
165
+ //and the alt currency
166
+ foreach((array)$post_data['newCurrency'] as $key =>$value){
167
+ wpsc_update_alt_product_currency($product_id, $value, $post_data['newCurrPrice'][$key]);
168
+ }
169
+
170
+ if($post_data['files']['file']['tmp_name'] != '') {
171
+ wpsc_item_process_file($product_id, $post_data['files']['file']);
172
  } else {
173
+ if (!isset($post_data['select_product_file'])) $post_data['select_product_file'] = null;
174
+ wpsc_item_reassign_file($product_id, $post_data['select_product_file']);
175
+ }
176
+
177
+ if(isset($post_data['files']['preview_file']['tmp_name']) && ($post_data['files']['preview_file']['tmp_name'] != '')) {
178
+ wpsc_item_add_preview_file($product_id, $post_data['files']['preview_file']);
 
 
 
 
 
179
  }
180
+ do_action('wpsc_edit_product', $product_id);
181
+ wpsc_ping();
182
+ }
183
+ return $product_id;
184
+ }
185
+ function wpsc_pre_update( $data , $postarr ) {
186
+ if( wp_is_post_autosave( $postarr["ID"] ) || wp_is_post_revision( $postarr["ID"] ) )
187
+ return;
188
+
189
+ if( isset( $postarr["additional_description"] ) && !empty( $postarr["additional_description"] ) )
190
+ $data["post_excerpt"] = $postarr["additional_description"];
191
+
192
+ if( isset( $postarr["parent_post"] ) && !empty( $postarr["parent_post"] ) )
193
+ $data["post_parent"] = $postarr["parent_post"];
194
+
195
+
196
+ if ( $postarr['meta']['_wpsc_product_metadata']['enable_comments'] == 0 || empty( $postarr['meta']['_wpsc_product_metadata']['enable_comments'] ) )
197
+ $data["comment_status"] = "closed";
198
+ else
199
+ $data["comment_status"] = "open";
200
+
201
+ //Can anyone explain to me why this is here?
202
+ if ( isset( $sku ) && ( $sku != '' ) )
203
+ $data['guid'] = $sku;
204
+
205
+ return $data;
206
+ }
207
+ add_filter( 'wp_insert_post_data','wpsc_pre_update', 99, 2 );
208
+ add_action( 'save_post', 'wpsc_admin_submit_product', 10, 2 );
209
+ add_action( 'admin_notices', 'wpsc_admin_submit_notices' );
210
+ function wpsc_admin_submit_notices() {
211
+ global $current_screen, $post;
212
+
213
+ if( $current_screen->id != 'wpsc-product' || !isset( $_SESSION['product_error_messages'] ) )
214
+ return;
215
+ foreach ( $_SESSION['product_error_messages'] as $error )
216
+ echo "<div id=\"message\" class=\"updated below-h2\"><p>".$error."</p></div>";
217
+ unset( $_SESSION['product_error_messages'] );
218
  }
219
 
220
+ /**
221
+ * wpsc_sanitise_product_forms function
222
+ *
223
+ * @return array - Sanitised product details
224
+ */
 
225
  function wpsc_sanitise_product_forms($post_data = null) {
226
  if ( empty($post_data) ) {
227
  $post_data = &$_POST;
318
  return $post_data;
319
  }
320
 
 
 
321
  /**
322
  * wpsc_insert_product function
323
  *
383
  'post_type' => "wpsc-product",
384
  'post_name' => sanitize_title($post_data['name'])
385
  );
 
386
  if ($post_data['meta']['_wpsc_product_metadata']['enable_comments'] == 0) {
387
  $product_post_values["comment_status"] = "closed";
388
  }else {
432
 
433
  // if we succeed, we can do further editing
434
 
 
 
 
 
 
 
 
 
 
 
 
435
  // and the meta
436
  wpsc_update_product_meta($product_id, $post_data['meta']);
437
 
442
  foreach((array)$post_data['newCurrency'] as $key =>$value){
443
  wpsc_update_alt_product_currency($product_id, $value, $post_data['newCurrPrice'][$key]);
444
  }
445
+
446
  if($post_data['files']['file']['tmp_name'] != '') {
447
  wpsc_item_process_file($product_id, $post_data['files']['file']);
448
  } else {
453
  if(isset($post_data['files']['preview_file']['tmp_name']) && ($post_data['files']['preview_file']['tmp_name'] != '')) {
454
  wpsc_item_add_preview_file($product_id, $post_data['files']['preview_file']);
455
  }
 
 
456
  do_action('wpsc_edit_product', $product_id);
457
  wpsc_ping();
458
  return $product_id;
459
  }
460
 
 
461
  /**
462
  * term_id_price function
463
  * Retreives associated price, if any, with term_id
517
  return $price;
518
  }
519
 
 
 
520
  /**
521
  * wpsc_edit_product_variations function.
522
  * this is the function to make child products using variations
529
  function wpsc_edit_product_variations($product_id, $post_data) {
530
  global $wpdb, $user_ID;
531
  $variations = array();
532
+ $product_children = array();
533
  if (!isset($post_data['edit_var_val'])) $post_data['edit_var_val'] = '';
534
 
535
  $variations = (array)$post_data['edit_var_val'];
536
+
 
 
 
 
 
537
  // Generate the arrays for variation sets, values and combinations
538
  $wpsc_combinator = new wpsc_variation_combinator($variations);
539
+
540
  // Retrieve the array containing the variation set IDs
541
  $variation_sets = $wpsc_combinator->return_variation_sets();
542
 
548
 
549
  $product_terms = wp_get_object_terms($product_id, 'wpsc-variation');
550
 
 
551
  $variation_sets_and_values = array_merge($variation_sets, $variation_values);
552
+ wp_set_object_terms($product_id, $variation_sets_and_values, 'wpsc-variation');
553
+
554
  $child_product_template = array(
555
+ 'post_author' => $user_ID,
556
+ 'post_content' => $post_data['description'],
557
+ 'post_excerpt' => $post_data['additional_description'],
558
+ 'post_title' => $post_data['name'],
559
+ 'post_status' => 'inherit',
560
+ 'post_type' => "wpsc-product",
561
+ 'post_name' => sanitize_title($post_data['name']),
562
+ 'post_parent' => $product_id
563
  );
564
 
565
  $child_product_meta = get_post_custom($product_id);
572
  $product_values = $child_product_template;
573
 
574
  $combination_terms = get_terms('wpsc-variation', array(
575
+ 'hide_empty' => 0,
576
+ 'include' => implode(",", $combination),
577
+ 'orderby' => 'parent',
578
  ));
579
+
580
  foreach($combination_terms as $term) {
581
  $term_ids[] = $term->term_id;
582
  $term_slugs[] = $term->slug;
587
  $product_values['post_name'] = sanitize_title($product_values['post_title']);
588
 
589
  $selected_post = get_posts(array(
590
+ 'name' => $product_values['post_name'],
591
+ 'post_parent' => $product_id,
592
+ 'post_type' => "wpsc-product",
593
+ 'post_status' => 'all',
594
+ 'suppress_filters' => true
595
  ));
596
  $selected_post = array_shift($selected_post);
 
597
  $child_product_id = wpsc_get_child_object_in_terms($product_id, $term_ids, 'wpsc-variation');
598
  $already_a_variation = true;
599
  if($child_product_id == false) {
609
  $child_product_id = $selected_post->ID;
610
  }
611
  }
612
+ $product_children[] = $child_product_id;
613
  if($child_product_id > 0) {
614
  wp_set_object_terms($child_product_id, $term_slugs, 'wpsc-variation');
615
  }
626
 
627
  //Adding this to check for a price on variations. Applying the highest price, seems to make the most sense.
628
  if ( is_array ($term_ids) ) {
629
+ $price = array();
630
  foreach ($term_ids as $term_id_price) {
631
  $price[] = term_id_price($term_id_price, $child_product_meta["_wpsc_price"][0]);
632
  }
641
  }
642
 
643
 
644
+ //For reasons unknown, this code did not previously deal with variation deletions.
645
+ //Basically, we'll just check if any existing term associations are missing from the posted variables, delete if they are.
646
  //Get posted terms (multi-dimensional array, first level = parent var, second level = child var)
647
  $posted_term = $variations;
648
  //Get currently associated terms
649
  $currently_associated_var = $product_terms;
650
+
651
+ foreach ($currently_associated_var as $current) {
652
+ $currently_associated_vars[] = $current->term_id;
653
+ }
654
 
655
+ foreach ($posted_term as $term=>$val) {
656
+ $posted_terms[] = $term;
657
+ if(is_array($val)) {
658
+ foreach($val as $term2=>$val2) {
659
+ $posted_terms[] = $term2;
660
+ }
661
  }
662
+ }
663
+ if(!empty($currently_associated_vars)){
664
+ $term_ids_to_delete = array();
665
+ $term_ids_to_delete = array_diff($currently_associated_vars, $posted_terms);
666
+ }
667
+ if(isset($_REQUEST["post_ID"]))
668
+ $post_id = $_REQUEST["post_ID"];
669
+ elseif(isset($_REQUEST["product_id"]))
670
+ $post_id = $_REQUEST["product_id"];
671
+ if(!empty($term_ids_to_delete) && (isset($_REQUEST["product_id"]) || isset($post_id))) {
672
+ $post_ids_to_delete = array();
673
 
674
+ // Whatever remains, find child products of current product with that term, in the variation taxonomy, and delete
675
+ $post_ids_to_delete = wpsc_get_child_object_in_terms_var($_REQUEST["product_id"], $term_ids_to_delete, 'wpsc-variation');
676
+
677
+ if(is_array($post_ids_to_delete) && !empty($post_ids_to_delete)) {
678
+ foreach($post_ids_to_delete as $object_ids) {
679
+ foreach($object_ids as $object_id) {
680
+ wp_delete_post($object_id);
681
  }
682
+ }
683
  }
684
+ }
685
+ $current_children = query_posts(array(
686
+ 'post_parent' => $post_id,
687
+ 'post_type' => "wpsc-product",
688
+ 'post_status' => 'all'
689
+ ));
 
690
 
691
+ foreach((array)$current_children as $child_prod){
692
+ $childs[] = $child_prod->ID;
693
+ }
694
+ if(!empty($childs)){
695
+ $old_ids_to_delete = array_diff($childs, $product_children);
696
+ if(is_array($old_ids_to_delete) && !empty($old_ids_to_delete)) {
697
+ foreach($old_ids_to_delete as $object_ids) {
698
+ wp_delete_post($object_ids);
699
  }
700
  }
701
  }
 
 
702
  }
703
 
704
  function wpsc_update_alt_product_currency($product_id, $newCurrency, $newPrice){
705
  global $wpdb;
706
+ // exit($newCurrency.' '.$newPrice);
707
  $old_curr = get_product_meta($product_id, 'currency',true);
708
  $sql = "SELECT `isocode` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `id`=".$newCurrency;
709
  $isocode = $wpdb->get_var($sql);
710
 
711
  $newCurrency = 'currency';
712
  $old_curr[$isocode] = $newPrice;
713
+ if(($newPrice != '') && ($newPrice > 0.00)){
714
  update_product_meta($product_id, $newCurrency, $old_curr);
715
  } else {
716
+ if((empty($old_curr[$isocode]) || 0.00 == $old_curr[$isocode]) && is_array($old_curr))
717
  unset($old_curr[$isocode]);
 
718
  update_product_meta($product_id, $newCurrency, $old_curr);
719
 
720
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
721
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
722
  }
723
+
724
  /**
725
  * wpsc_update_product_meta function
726
  *
739
  }
740
  }
741
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
742
  /**
743
  * Called from javascript within product page to toggle publish status - AJAX
744
  * @return bool publish status
795
  }
796
 
797
  $file = wp_handle_upload($submitted_file, $overrides, $time);
 
798
  if ( isset($file['error']) )
799
  return new WP_Error( 'upload_error', $file['error'] );
800
 
826
  function wpsc_modify_upload_directory($input) {
827
  $previous_subdir = $input['subdir'];
828
  $download_subdir = str_replace($input['basedir'], '', WPSC_FILE_DIR);
829
+ $input['path'] = substr_replace(str_replace($previous_subdir, $download_subdir, $input['path']),'',-1);
830
+ $input['url'] = substr_replace(str_replace($previous_subdir, $download_subdir, $input['url']),'',-1);
831
+ $input['subdir'] = substr_replace(str_replace($previous_subdir, $download_subdir, $input['subdir']),'',-1);
 
 
832
  return $input;
833
  }
834
 
836
  $previous_subdir = $input['subdir'];
837
  $download_subdir = str_replace($input['basedir'], '', WPSC_PREVIEW_DIR);
838
 
839
+ $input['path'] = substr_replace(str_replace($previous_subdir, $download_subdir, $input['path']),'',-1);
840
+ $input['url'] = substr_replace(str_replace($previous_subdir, $download_subdir, $input['url']),'',-1);
841
+ $input['subdir'] = substr_replace(str_replace($previous_subdir, $download_subdir, $input['subdir']),'',-1);
842
 
843
  return $input;
844
  }
845
+
 
846
  /**
847
  * wpsc_item_reassign_file function
848
  *
919
  return $fileid;
920
  }
921
 
 
 
922
  /**
923
  * wpsc_item_add_preview_file function
924
  *
972
 
973
  }
974
 
 
975
  /**
976
  * wpsc_variation_combinator class.
977
  * Produces all combinations of variations selected for this product
1049
  ');
1050
  }
1051
 
1052
+ ?>
wpsc-admin/includes/products.php CHANGED
@@ -1,534 +1,419 @@
1
- <?php
2
- /**
3
- * WP eCommerce product page functions
4
- *
5
- * These are the main WPSC Admin functions
6
- *
7
- * @package wp-e-commerce
8
- * @since 3.8
9
- */
10
-
11
-
12
- /**
13
- * wpsc_product_rows function, copies the functionality of the wordpress code for displaying posts and pages, but is for products
14
- *
15
- */
16
- function wpsc_admin_product_listing($parent_product = null) {
17
- global $wp_query, $wpsc_products, $mode;
18
-
19
- add_filter('the_title','esc_html');
20
-
21
- // Create array of post IDs.
22
- $product_ids = array();
23
-
24
- if ( empty($wpsc_products) ) {
25
- $wpsc_products = &$wp_query->posts;
26
- }
27
-
28
- foreach ( (array)$wpsc_products as $product ) {
29
- $product_ids[] = $product->ID;
30
- }
31
-
32
- foreach ( (array)$wpsc_products as $product ) {
33
- wpsc_product_row($product, $parent_product);
34
- }
35
- }
36
- /**
37
- * Adds the -trash status in the product row of manage products page
38
- * @access public
39
- *
40
- * @since 3.8
41
- * @param $post_status (array) of current posts statuses
42
- * @return $post_status (array)
43
- */
44
- function wpsc_trashed_post_status($post_status){
45
- $post = get_post(get_the_ID());
46
- if(empty($post)) return $post_status;
47
- if('wpsc-product' == $post->post_type && 'trash' == $post->post_status && !in_array('trash', $post_status))
48
- $post_status[] = 'Trash';
49
-
50
- return $post_status;
51
- }
52
- add_filter('display_post_states','wpsc_trashed_post_status');
53
-
54
- /**
55
- * Spits out the current products details in a table row for manage products page and variations on edit product page.
56
- * @access public
57
- *
58
- * @since 3.8
59
- * @param $product (Object), $parent_product (Int) Note: I believe parent_product is unused
60
- */
61
- function wpsc_product_row(&$product, $parent_product = null) {
62
- global $wp_query, $wpsc_products, $mode, $current_user;
63
- static $rowclass;
64
- $is_parent = false;
65
- $global_product = $product;
66
- setup_postdata($product);
67
-
68
- $rowclass = 'alternate' == $rowclass ? '' : 'alternate';
69
- $post_owner = ( $current_user->ID == $product->post_author ? 'self' : 'other' );
70
- $edit_link = get_edit_post_link( $product->ID );
71
- $is_parent = wpsc_product_has_children($product->ID);
72
- if( !empty($children) ) $is_parent = true;
73
- $title = get_the_title( $product->ID);
74
- if ( empty($title) ) {
75
- $title = __('(no title)');
76
- }
77
-
78
- ?>
79
-
80
- <tr id='post-<?php echo $product->ID; ?>' class='<?php echo trim( $rowclass . ' author-' . $post_owner . ' status-' . $product->post_status ); ?> iedit <?php if ( get_option ( 'wpsc_sort_by' ) == 'dragndrop') { echo 'product-edit'; } ?>' valign="top">
81
- <?php
82
- $posts_columns = get_column_headers('display-product-list');
83
- $posts_columns = apply_filters( 'manage_display-product-list_columns', $posts_columns );
84
- $hidden = get_hidden_columns('display-product-list');
85
-
86
- foreach ( $posts_columns as $column_name=>$column_display_name ) {
87
- $class = "class=\"$column_name column-$column_name\"";
88
-
89
- $style = '';
90
- if ( in_array($column_name, $hidden) )
91
- $style = ' style="display:none;"';
92
-
93
- $attributes = "$class$style";
94
-
95
- switch ($column_name) {
96
-
97
- case 'cb':
98
- ?>
99
- <th scope="row" class="check-column"><?php if ( current_user_can( 'edit_post', $product->ID ) ) { ?>
100
- <input type="checkbox" name="post[]" value="<?php the_ID(); ?>" />
101
- <?php do_action('wpsc_admin_product_checkbox', $product->ID); ?>
102
-
103
- <?php } ?></th>
104
- <?php
105
- break;
106
-
107
- case 'date':
108
- if ( '0000-00-00 00:00:00' == $product->post_date && 'date' == $column_name ) {
109
- $t_time = $h_time = __('Unpublished');
110
- $time_diff = 0;
111
- } else {
112
- $t_time = get_the_time(__('Y/m/d g:i:s A'));
113
- $m_time = $product->post_date;
114
- $time = get_post_time('G', true, $post);
115
-
116
- $time_diff = time() - $time;
117
-
118
- if ( $time_diff > 0 && $time_diff < 24*60*60 )
119
- $h_time = sprintf( __('%s ago'), human_time_diff( $time ) );
120
- else
121
- $h_time = mysql2date(__('Y/m/d'), $m_time);
122
- }
123
-
124
- echo '<td ' . $attributes . '>';
125
- if ( 'excerpt' == $mode )
126
- echo apply_filters('post_date_column_time', $t_time, $post, $column_name, $mode);
127
- else
128
- echo '<abbr title="' . $t_time . '">' . apply_filters('post_date_column_time', $h_time, $post, $column_name, $mode) . '</abbr>';
129
- echo '<br />';
130
- if ( 'publish' == $product->post_status ) {
131
- _e('Published');
132
- } elseif ( 'future' == $product->post_status ) {
133
- if ( $time_diff > 0 )
134
- echo '<strong class="attention">' . __('Missed schedule') . '</strong>';
135
- else
136
- _e('Scheduled');
137
- } else {
138
- _e('Last Modified');
139
- }
140
- echo '</td>';
141
- break;
142
-
143
-
144
-
145
- case 'title':
146
- $attributes = 'class="post-title column-title"' . $style;
147
- $_GET["product_parent"] = '';
148
- if( isset($_GET["product"]) && ($_GET["product_parent"] == '' )){
149
- $edit_link = add_query_arg(array('page' => 'wpsc-edit-products', 'action' => 'wpsc_add_edit' ,'product' => $product->ID, 'product_parent' => $_GET["product"]));
150
- } else {
151
- $edit_link = add_query_arg(array('page' => 'wpsc-edit-products', 'action' => 'wpsc_add_edit' ,'product' => $product->ID));
152
- $edit_link = remove_query_arg( 'product_parent' );
153
- }
154
- $edit_link = wp_nonce_url($edit_link, 'edit-product_'.$product->ID);
155
- ?>
156
- <td <?php echo $attributes ?>>
157
- <strong>
158
- <?php if ( current_user_can('edit_post', $product->ID) && $product->post_status != 'trash' ) { ?>
159
- <a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $title)); ?>"><?php echo $title ?></a>
160
- <?php } else {
161
- echo $title;
162
- };
163
-
164
- _post_states($product);
165
- $product_alert = apply_filters('wpsc_product_alert', array(false, ''), $product);
166
- if(!empty($product_alert['messages']))
167
- $product_alert['messages'] = implode("\n",(array)$product_alert['messages']);
168
-
169
- if($product_alert['state'] === true) {
170
- ?>
171
- <img alt='<?php echo $product_alert['messages'];?>' title='<?php echo $product_alert['messages'];?>' class='product-alert-image' src='<?php echo WPSC_CORE_IMAGES_URL;?>/product-alert.jpg' alt='' />
172
- <?php
173
- }
174
-
175
- // If a product alert has stuff to display, show it.
176
- // Can be used to add extra icons etc
177
- if ( !empty( $product_alert['display'] ) ) {
178
- echo $product_alert['display'];
179
- }
180
-
181
- ?>
182
- </strong>
183
- <?php
184
-
185
- $actions = array();
186
- if ( current_user_can('edit_post', $product->ID) && 'trash' != $product->post_status ) {
187
- $actions['edit'] = '<a class="edit-product" href="'.$edit_link.'" title="' . esc_attr(__('Edit this product', 'wpsc')) . '">'. __('Edit', 'wpsc') . '</a>';
188
- if(!$is_parent)
189
- $actions['quick_edit'] = "<a class='wpsc-quickedit' title='".esc_attr(__('Quick Edit', 'wpsc'))."' href='#'>".__('Quick Edit')."</a>";
190
- else
191
- $actions['quick_edit'] = __('Quick Edit');
192
- }
193
-
194
- if ( current_user_can('delete_post', $product->ID) ) {
195
- if ( 'trash' == $product->post_status ) {
196
- $actions['untrash'] = "<a title='" . esc_attr(__('Restore this product from the Trash', 'wpsc')) . "' href='" . wp_nonce_url("admin.php?page=wpsc-edit-products&amp;wpsc_admin_action=untrash&amp;product={$product->ID}", 'untrash-product_' . $product->ID) . "'>".__('Restore')."</a>";
197
- } else if ( EMPTY_TRASH_DAYS ) {
198
- $actions['trash'] = "<a class='submitdelete' title='".esc_attr(__('Move this product to the Trash', 'wpsc'))."' href='" .wp_nonce_url("admin.php?page=wpsc-edit-products&amp;wpsc_admin_action=trash&amp;product={$product->ID}", 'delete-product_'.$product->ID) . "'>".__('Trash')."</a>";
199
- }
200
-
201
- if ( 'trash' == $product->post_status || !EMPTY_TRASH_DAYS ) {
202
- $actions['delete'] = "<a class='submitdelete' title='".esc_attr(__('Delete this product permanently', 'wpsc'))."' href='" . wp_nonce_url("admin.php?page=wpsc-edit-products&amp;wpsc_admin_action=delete&amp;product={$product->ID}", 'delete-product_'.$product->ID)."'>".__('Delete Permanently')."</a>";
203
- }
204
- }
205
-
206
- if ( in_array($product->post_status, array('pending', 'draft')) ) {
207
- if ( current_user_can('edit_product', $product->ID) ) {
208
- $actions['view'] = '<a href="'.get_permalink($product->ID).'" title="'.esc_attr(sprintf(__('Preview &#8220;%s&#8221;'), $title)) . '" rel="permalink">'.__('Preview').'</a>';
209
- }
210
- } else if ( 'trash' != $product->post_status ) {
211
- $actions['view'] = '<a href="'.get_permalink($product->ID).'" title="'.esc_attr(sprintf(__('View &#8220;%s&#8221;'), $title)).'" rel="permalink">'.__('View').'</a>';
212
- }
213
- if(!isset($_GET["product"]) || $_GET["product"] == '' ) {
214
- $actions['duplicate'] = "<a class='submitdelete' title='".esc_attr(__('Duplicate', 'wpsc'))."' href='" . wp_nonce_url("admin.php?page=wpsc-edit-products&amp;wpsc_admin_action=duplicate_product&amp;product={$product->ID}", 'duplicate-product_'.$product->ID)."'>".__('Duplicate')."</a>";
215
- }
216
-
217
- $actions = apply_filters('post_row_actions', $actions, $product);
218
- $action_count = count($actions);
219
- $i = 0;
220
- echo '<div class="row-actions">';
221
-
222
- foreach ( $actions as $action => $link ) {
223
- ++$i;
224
- ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
225
- echo "<span class='$action'>$link$sep</span>";
226
- }
227
-
228
- echo '</div>';
229
- get_inline_data($product);
230
- ?>
231
- </td>
232
- <?php
233
- break;
234
-
235
-
236
-
237
- case 'image':
238
- ?>
239
- <td class="product-image ">
240
- <?php
241
- $attached_images = (array)get_posts(array(
242
- 'post_type' => 'attachment',
243
- 'numberposts' => 1,
244
- 'post_status' => null,
245
- 'post_parent' => $product->ID,
246
- 'orderby' => 'menu_order',
247
- 'order' => 'ASC'
248
- ));
249
-
250
-
251
-
252
- if(isset($product->ID) && has_post_thumbnail($product->ID)){
253
- echo get_the_post_thumbnail($product->ID, 'admin-product-thumbnails');
254
- }elseif(!empty($attached_images)){
255
- $attached_image = $attached_images[0];
256
-
257
- $src =wp_get_attachment_url($attached_image->ID);
258
- ?>
259
- <div style='width:38px;height:38px;overflow:hidden;'>
260
- <img title='Drag to a new position' src='<?php echo $src; ?>' alt='<?php echo $title; ?>' width='38' height='38' />
261
- </div>
262
- <?php
263
-
264
-
265
- }else{
266
- $image_url = WPSC_CORE_IMAGES_URL . "/no-image-uploaded.gif";
267
- ?>
268
- <img title='Drag to a new position' src='<?php echo $image_url; ?>' alt='<?php echo $title; ?>' width='38' height='38' />
269
- <?php
270
-
271
-
272
- }
273
-
274
- ?>
275
- </td>
276
- <?php
277
- break;
278
-
279
-
280
-
281
- case 'price':
282
- if(!$is_parent){
283
- $price = get_post_meta($product->ID, '_wpsc_price', true);
284
- ?>
285
- <td <?php echo $attributes ?>>
286
- <?php echo wpsc_currency_display( $price ); ?>
287
- <div class='price-editing-fields' id='price-editing-fields-<?php echo $product->ID; ?>'>
288
- <input type='text' class='the-product-price' name='product_price[<?php echo $product->ID; ?>][price]' value='<?php echo number_format($price,2,'.',''); ?>' />
289
- <input type='hidden' name='product_price[<?php echo $product->ID; ?>][id]' value='<?php echo $product->ID; ?>' />
290
- <input type='hidden' name='product_price[<?php echo $product->ID; ?>][nonce]' value='<?php echo wp_create_nonce('edit-product_price-'.$product->ID); ?>' />
291
-
292
-
293
- </div>
294
- </td>
295
-
296
- <?php
297
-
298
- }else{
299
- $price = wpsc_product_variation_price_available($product->ID);
300
- ?>
301
- <td >
302
- <?php echo $price.'+' ; ?>
303
-
304
- </td>
305
- <?php
306
- }
307
- break;
308
-
309
- // 5.8.2010 - Justin Sainton - Addition of weight and stock cases to column header switch.
310
-
311
- case 'weight' :
312
- if($is_parent){ ?>
313
- <td>
314
- <?php _e( 'N/A', 'wpsc'); ?>
315
- </td>
316
- <?php
317
- break;
318
- }
319
- $product_data['meta'] = array();
320
- $product_data['meta'] = get_post_meta($product->ID, '');
321
- foreach($product_data['meta'] as $meta_name => $meta_value) {
322
- $product_data['meta'][$meta_name] = maybe_unserialize(array_pop($meta_value));
323
- }
324
- $product_data['transformed'] = array();
325
- if(!isset($product_data['meta']['_wpsc_product_metadata']['weight'])) $product_data['meta']['_wpsc_product_metadata']['weight'] = "";
326
- if(!isset($product_data['meta']['_wpsc_product_metadata']['weight_unit'])) $product_data['meta']['_wpsc_product_metadata']['weight_unit'] = "";
327
-
328
- $product_data['transformed']['weight'] = wpsc_convert_weight($product_data['meta']['_wpsc_product_metadata']['weight'], "gram", $product_data['meta']['_wpsc_product_metadata']['weight_unit']);
329
- $weight = $product_data['transformed']['weight'];
330
- if($weight == ''){
331
- $weight = '0';
332
- }
333
-
334
- $unit = $product_data['meta']['_wpsc_product_metadata']['weight_unit'];
335
- switch($unit) {
336
- case "pound":
337
- $unit = " lbs.";
338
- break;
339
- case "ounce":
340
- $unit = " oz.";
341
- break;
342
- case "gram":
343
- $unit = " g";
344
- break;
345
- case "kilograms":
346
- case "kilogram":
347
- $unit = " kgs.";
348
- break;
349
- }
350
- ?>
351
- <td <?php echo $attributes ?>>
352
- <span class="weightdisplay"><?php echo $weight; ?></span>
353
- <div class='weight-editing-fields' id='weight-editing-fields-<?php echo $product->ID; ?>'>
354
- <input type='text' class='the-weight-fields' name='weight_field[<?php echo $product->ID; ?>][weight]' value='<?php echo $weight; ?>' />
355
- <input type='hidden' name='weight_field[<?php echo $product->ID; ?>][id]' value='<?php echo $product->ID; ?>' />
356
- <input type='hidden' name='weight_field[<?php echo $product->ID; ?>][nonce]' value='<?php echo wp_create_nonce('edit-weight-'.$product->ID); ?>' />
357
- </div><?php echo $unit; ?>
358
- </td>
359
- <?php
360
-
361
- break;
362
-
363
- case 'stock' :
364
- $stock = get_post_meta($product->ID, '_wpsc_stock', true);
365
- if($stock == ''){
366
- $stock = 'N/A';
367
- }
368
- if(!$is_parent){
369
- ?>
370
- <td <?php echo $attributes ?>>
371
- <span class="stockdisplay"><?php echo $stock; ?></span>
372
- <div class='stock-editing-fields' id='stock-editing-fields-<?php echo $product->ID; ?>'>
373
- <input type='text' class='the-stock-fields' name='stock_field[<?php echo $product->ID; ?>][stock]' value='<?php echo $stock; ?>' />
374
- <input type='hidden' name='stock_field[<?php echo $product->ID; ?>][id]' value='<?php echo $product->ID; ?>' />
375
- <input type='hidden' name='stock_field[<?php echo $product->ID; ?>][nonce]' value='<?php echo wp_create_nonce('edit-stock-'.$product->ID); ?>' />
376
-
377
-
378
- </div>
379
- </td>
380
- <?php
381
- }else{
382
- ?> <td>
383
- <?php echo '~'.wpsc_variations_stock_remaining($product->ID); ?>
384
- </td>
385
- <?php
386
- }
387
- break;
388
-
389
- case 'categories':
390
- ?>
391
- <td <?php echo $attributes ?>><?php
392
- $categories = get_the_product_category($product->ID);
393
- if ( !empty( $categories ) ) {
394
- $out = array();
395
- foreach ( $categories as $c )
396
- $out[] = "<a href='admin.php?page=wpsc-edit-products&amp;category={$c->slug}'> " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'category', 'display')) . "</a>";
397
- echo join( ', ', $out );
398
- } else {
399
- _e('Uncategorized');
400
- }
401
- ?></td>
402
- <?php
403
- break;
404
-
405
-
406
-
407
- case 'tags':
408
- ?>
409
- <td <?php echo $attributes ?>><?php
410
- $tags = get_the_tags($product->ID);
411
- if ( !empty( $tags ) ) {
412
- $out = array();
413
- foreach ( $tags as $c )
414
- $out[] = "<a href='edit.php?tag=$c->slug'> " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'post_tag', 'display')) . "</a>";
415
- echo join( ', ', $out );
416
- } else {
417
- _e('No Tags');
418
- }
419
- ?></td>
420
- <?php
421
- break;
422
- case 'SKU':
423
- $sku = get_post_meta($product->ID, '_wpsc_sku', true);
424
- if($sku == ''){
425
- $sku = 'N/A';
426
- }
427
- if($is_parent) {
428
- ?>
429
- <td> <?php echo $sku; ?></td>
430
- <?php
431
- break;
432
- }
433
-
434
- ?>
435
- <td <?php echo $attributes ?>>
436
- <span class="skudisplay"><?php echo $sku; ?></span>
437
- <div class='sku-editing-fields' id='sku-editing-fields-<?php echo $product->ID; ?>'>
438
- <input type='text' class='the-sku-fields' name='sku_field[<?php echo $product->ID; ?>][sku]' value='<?php echo $sku; ?>' />
439
- <input type='hidden' name='sku_field[<?php echo $product->ID; ?>][id]' value='<?php echo $product->ID; ?>' />
440
- <input type='hidden' name='sku_field[<?php echo $product->ID; ?>][nonce]' value='<?php echo wp_create_nonce('edit-sku-'.$product->ID); ?>' />
441
-
442
-
443
- </div>
444
- </td>
445
- <?php
446
- break;
447
- case 'sale_price':
448
- if( $is_parent ){ ?>
449
- <td>
450
- <?php _e('N/A' , 'wpsc'); ?>
451
- </td>
452
- <?php
453
- break;
454
- }
455
- $price = get_post_meta($product->ID, '_wpsc_special_price', true);
456
- ?>
457
- <td <?php echo $attributes ?>>
458
- <?php echo wpsc_currency_display( $price ); ?>
459
- <div class='sales-price-fields' id='sales-price-editing-fields-<?php echo $product->ID; ?>'>
460
- <input type='text' class='the-sale-price' name='sale_product_price[<?php echo $product->ID; ?>][price]' value='<?php echo number_format( (double)$price, 2, '.', ''); ?>' />
461
- <input type='hidden' name='sale_product_price[<?php echo $product->ID; ?>][id]' value='<?php echo $product->ID; ?>' />
462
- <input type='hidden' name='sale_product_price[<?php echo $product->ID; ?>][nonce]' value='<?php echo wp_create_nonce('sale-edit-product_price-'.$product->ID); ?>' />
463
- </div>
464
- </td>
465
- <?php
466
-
467
- break;
468
-
469
-
470
- case 'comments':
471
- ?>
472
- <td <?php echo $attributes ?>><div class="post-com-count-wrapper">
473
- <?php
474
- $pending_phrase = sprintf( __('%s pending'), number_format( $pending_comments ) );
475
- if ( $pending_comments )
476
- echo '<strong>';
477
- comments_number("<a href='edit-comments.php?p=$product->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link */ _x('0', 'comment count') . '</span></a>', "<a href='edit-comments.php?p=$product->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link */ _x('1', 'comment count') . '</span></a>', "<a href='edit-comments.php?p=$product->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link: % will be substituted by comment count */ _x('%', 'comment count') . '</span></a>');
478
- if ( $pending_comments )
479
- echo '</strong>';
480
- ?>
481
- </div></td>
482
- <?php
483
- break;
484
-
485
-
486
-
487
- case 'author':
488
- ?>
489
- <td <?php echo $attributes ?>><a href="edit.php?author=<?php the_author_meta('ID'); ?>"><?php the_author() ?></a></td>
490
- <?php
491
- break;
492
-
493
-
494
- case 'control_view':
495
- ?>
496
- <td><a href="<?php the_permalink(); ?>" rel="permalink" class="view"><?php _e('View'); ?></a></td>
497
- <?php
498
- break;
499
-
500
-
501
-
502
- case 'control_edit':
503
- ?>
504
- <td><?php if ( current_user_can('edit_post', $product->ID) ) { echo "<a href='$edit_link' class='edit'>" . __('Edit') . "</a>"; } ?></td>
505
- <?php
506
- break;
507
-
508
-
509
-
510
- case 'control_delete':
511
- ?>
512
- <td><?php if ( current_user_can('delete_post', $product->ID) ) { echo "<a href='" . wp_nonce_url("post.php?action=delete&amp;post=$id", 'delete-post_' . $product->ID) . "' class='delete'>" . __('Delete') . "</a>"; } ?></td>
513
- <?php
514
- break;
515
-
516
- case 'featured':
517
- ?>
518
- <td><?php do_action('manage_posts_featured_column', $product->ID); ?></td>
519
- <?php
520
- break;
521
- default:
522
- ?>
523
- <td <?php echo $attributes ?>><?php do_action('manage_posts_custom_column', $column_name, $product->ID); ?></td>
524
- <?php
525
- break;
526
- }
527
- }
528
- ?>
529
- </tr>
530
- <?php
531
- $product = $global_product;
532
- }
533
-
534
- ?>
1
+ <?php
2
+ /**
3
+ * WP eCommerce product page functions
4
+ *
5
+ * These are the main WPSC Admin functions
6
+ *
7
+ * @package wp-e-commerce
8
+ * @since 3.8
9
+ *
10
+ */
11
+
12
+ /**
13
+ * wpsc_product_rows function, copies the functionality of the wordpress code for displaying posts and pages, but is for products
14
+ *
15
+ */
16
+ function wpsc_admin_product_listing($parent_product = null) {
17
+ global $wp_query, $wpsc_products;
18
+
19
+ add_filter('the_title','esc_html');
20
+
21
+ if ( empty($wpsc_products) )
22
+ $wpsc_products = &$wp_query->posts;
23
+
24
+ foreach ( (array)$wpsc_products as $product ) {
25
+ wpsc_product_row($product, $parent_product);
26
+ }
27
+ }
28
+ /**
29
+ * Adds the -trash status in the product row of manage products page
30
+ * @access public
31
+ *
32
+ * @since 3.8
33
+ * @param $post_status (array) of current posts statuses
34
+ * @return $post_status (array)
35
+ */
36
+ function wpsc_trashed_post_status($post_status){
37
+ $post = get_post(get_the_ID());
38
+ if('wpsc-product' == $post->post_type && 'trash' == $post->post_status && !in_array('trash', $post_status))
39
+ $post_status[] = 'Trash';
40
+
41
+ return $post_status;
42
+ }
43
+ add_filter('display_post_states','wpsc_trashed_post_status');
44
+
45
+ /**
46
+ * Spits out the current products details in a table row for manage products page and variations on edit product page.
47
+ * @access public
48
+ *
49
+ * @since 3.8
50
+ * @param $product (Object), $parent_product (Int) Note: I believe parent_product is unused
51
+ */
52
+ function wpsc_product_row(&$product, $parent_product = null) {
53
+ global $mode, $current_user;
54
+
55
+ //is this good practice? <v.bakaitis@gmail.com>
56
+ static $rowclass;
57
+
58
+ $global_product = $product;
59
+ setup_postdata($product);
60
+
61
+ $rowclass = 'alternate' == $rowclass ? '' : 'alternate';
62
+ $post_owner = ( $current_user->ID == $product->post_author ? 'self' : 'other' );
63
+ $edit_link = get_edit_post_link( $product->ID );
64
+
65
+ $title = get_the_title( $product->ID );
66
+
67
+ if ( empty( $title ) )
68
+ $title = __('(no title)');
69
+
70
+ ?>
71
+
72
+ <tr id='post-<?php echo $product->ID; ?>' class='<?php echo trim( $rowclass . ' author-' . $post_owner . ' status-' . $product->post_status ); ?> iedit <?php if ( get_option ( 'wpsc_sort_by' ) == 'dragndrop') { echo 'product-edit'; } ?>' valign="top">
73
+ <?php
74
+ $posts_columns = get_column_headers( 'wpsc-product_variants' );
75
+
76
+ if(empty($posts_columns))
77
+ $posts_columns = array('image' => '', 'title' => __('Name', 'wpsc') , 'weight' => __('Weight', 'wpsc'), 'stock' => __('Stock', 'wpsc'), 'price' => __('Price', 'wpsc'), 'sale_price' => __('Sale Price', 'wpsc'), 'SKU' => __('SKU', 'wpsc'), 'hidden_alerts' => '');
78
+
79
+ foreach ( $posts_columns as $column_name=>$column_display_name ) {
80
+ $class = "class=\"$column_name column-$column_name\"";
81
+
82
+ $attributes = "$class$style";
83
+
84
+ switch ($column_name) {
85
+
86
+ case 'date': /* !date case */
87
+ if ( '0000-00-00 00:00:00' == $product->post_date && 'date' == $column_name ) {
88
+ $t_time = $h_time = __('Unpublished');
89
+ $time_diff = 0;
90
+ } else {
91
+ $t_time = get_the_time(__('Y/m/d g:i:s A'));
92
+ $m_time = $product->post_date;
93
+ $time = get_post_time('G', true, $post);
94
+
95
+ $time_diff = time() - $time;
96
+
97
+ if ( $time_diff > 0 && $time_diff < 24*60*60 )
98
+ $h_time = sprintf( __('%s ago'), human_time_diff( $time ) );
99
+ else
100
+ $h_time = mysql2date(__('Y/m/d'), $m_time);
101
+ }
102
+
103
+ echo '<td ' . $attributes . '>';
104
+ if ( 'excerpt' == $mode )
105
+ echo apply_filters('post_date_column_time', $t_time, $post, $column_name, $mode);
106
+ else
107
+ echo '<abbr title="' . $t_time . '">' . apply_filters('post_date_column_time', $h_time, $post, $column_name, $mode) . '</abbr>';
108
+ echo '<br />';
109
+ if ( 'publish' == $product->post_status ) {
110
+ _e('Published');
111
+ } elseif ( 'future' == $product->post_status ) {
112
+ if ( $time_diff > 0 )
113
+ echo '<strong class="attention">' . __('Missed schedule') . '</strong>';
114
+ else
115
+ _e('Scheduled');
116
+ } else {
117
+ _e('Last Modified');
118
+ }
119
+ echo '</td>';
120
+ break;
121
+
122
+ case 'title': /* !title case */
123
+ $attributes = 'class="post-title column-title"' . $style;
124
+
125
+ $edit_link = wp_nonce_url( $edit_link, 'edit-product_'.$product->ID );
126
+ ?>
127
+ <td <?php echo $attributes ?>>
128
+ <strong>
129
+ <?php if ( current_user_can('edit_post', $product->ID) && $product->post_status != 'trash' ) { ?>
130
+ <a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $title)); ?>"><?php echo $title ?></a>
131
+ <?php if($parent_product): ?>
132
+ <input type="hidden" class="wpsc_ie_id wpsc_ie_field" value="<?php echo $product->ID ?>">
133
+ <input type="text" class="wpsc_ie_title wpsc_ie_field" value="<?php echo $title ?>">
134
+ <div class="wpsc_inline_actions"><input type="button" class="button-primary wpsc_ie_save" value="Save"><img src="<?php bloginfo('url') ?>/wp-admin/images/wpspin_light.gif" class="loading_indicator"><br/><input type="button" class="button-secondary cancel wpsc_ie_cancel" value="Cancel"></div>
135
+ <?php endif; ?>
136
+ <?php } else {
137
+ echo $title;
138
+ };
139
+
140
+ _post_states($product);
141
+ $product_alert = apply_filters('wpsc_product_alert', array(false, ''), $product);
142
+ if(!empty($product_alert['messages']))
143
+ $product_alert['messages'] = implode("\n",(array)$product_alert['messages']);
144
+
145
+ if($product_alert['state'] === true) {
146
+ ?>
147
+ <img alt='<?php echo $product_alert['messages'];?>' title='<?php echo $product_alert['messages'];?>' class='product-alert-image' src='<?php echo WPSC_CORE_IMAGES_URL;?>/product-alert.jpg' alt='' />
148
+ <?php
149
+ }
150
+
151
+ // If a product alert has stuff to display, show it.
152
+ // Can be used to add extra icons etc
153
+ if ( !empty( $product_alert['display'] ) ) {
154
+ echo $product_alert['display'];
155
+ }
156
+
157
+ ?>
158
+ </strong>
159
+ <?php
160
+
161
+ $actions = array();
162
+ if ( current_user_can('edit_post', $product->ID) && 'trash' != $product->post_status ) {
163
+ $actions['edit'] = '<a class="edit-product" href="'.$edit_link.'" title="' . esc_attr(__('Edit this product', 'wpsc')) . '">'. __('Edit', 'wpsc') . '</a>';
164
+ $actions['quick_edit'] = "<a class='wpsc_editinline' title='".esc_attr(__('Quick Edit', 'wpsc'))."' href='#'>".__('Quick Edit')."</a>";
165
+ }
166
+
167
+ if ( in_array($product->post_status, array('pending', 'draft')) ) {
168
+ if ( current_user_can('edit_product', $product->ID) ) {
169
+ $actions['view'] = '<a href="'.get_permalink($product->ID).'" title="'.esc_attr(sprintf(__('Preview &#8220;%s&#8221;'), $title)) . '" rel="permalink">'.__('Preview').'</a>';
170
+ }
171
+ } else if ( 'trash' != $product->post_status ) {
172
+ $actions['view'] = '<a href="'.get_permalink($product->ID).'" title="'.esc_attr(sprintf(__('View &#8220;%s&#8221;'), $title)).'" rel="permalink">'.__('View').'</a>';
173
+ }
174
+
175
+ $actions = apply_filters('post_row_actions', $actions, $product);
176
+ $action_count = count($actions);
177
+ $i = 0;
178
+ echo '<div class="row-actions">';
179
+
180
+ foreach ( $actions as $action => $link ) {
181
+ ++$i;
182
+ ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
183
+ echo "<span class='$action'>$link$sep</span>";
184
+ }
185
+
186
+ echo '</div>';
187
+ get_inline_data($product);
188
+ ?>
189
+ </td>
190
+ <?php
191
+ break;
192
+
193
+
194
+
195
+ case 'image': /* !image case */
196
+ ?>
197
+ <td class="product-image ">
198
+ <?php
199
+ $attached_images = (array)get_posts(array(
200
+ 'post_type' => 'attachment',
201
+ 'numberposts' => 1,
202
+ 'post_status' => null,
203
+ 'post_parent' => $product->ID,
204
+ 'orderby' => 'menu_order',
205
+ 'order' => 'ASC'
206
+ ));
207
+
208
+
209
+
210
+ if(isset($product->ID) && has_post_thumbnail($product->ID)){
211
+ echo get_the_post_thumbnail($product->ID, 'admin-product-thumbnails');
212
+ }elseif(!empty($attached_images)){
213
+ $attached_image = $attached_images[0];
214
+
215
+ $src =wp_get_attachment_url($attached_image->ID);
216
+ ?>
217
+ <div style='width:38px;height:38px;overflow:hidden;'>
218
+ <img title='Drag to a new position' src='<?php echo $src; ?>' alt='<?php echo $title; ?>' width='38' height='38' />
219
+ </div>
220
+ <?php
221
+
222
+
223
+ }else{
224
+ $image_url = WPSC_CORE_IMAGES_URL . "/no-image-uploaded.gif";
225
+ ?>
226
+ <img title='Drag to a new position' src='<?php echo $image_url; ?>' alt='<?php echo $title; ?>' width='38' height='38' />
227
+ <?php
228
+
229
+
230
+ }
231
+
232
+ ?>
233
+ </td>
234
+ <?php
235
+ break;
236
+
237
+
238
+
239
+ case 'price': /* !price case */
240
+
241
+ $price = get_post_meta($product->ID, '_wpsc_price', true);
242
+ ?>
243
+ <td <?php echo $attributes ?>>
244
+ <?php echo wpsc_currency_display( $price ); ?>
245
+ <input type="text" class="wpsc_ie_field wpsc_ie_price" value="<?php echo $price; ?>">
246
+ </td>
247
+ <?php
248
+ break;
249
+
250
+ case 'weight' :
251
+
252
+ $product_data['meta'] = array();
253
+ $product_data['meta'] = get_post_meta($product->ID, '');
254
+ foreach($product_data['meta'] as $meta_name => $meta_value) {
255
+ $product_data['meta'][$meta_name] = maybe_unserialize(array_pop($meta_value));
256
+ }
257
+ $product_data['transformed'] = array();
258
+ if(!isset($product_data['meta']['_wpsc_product_metadata']['weight'])) $product_data['meta']['_wpsc_product_metadata']['weight'] = "";
259
+ if(!isset($product_data['meta']['_wpsc_product_metadata']['weight_unit'])) $product_data['meta']['_wpsc_product_metadata']['weight_unit'] = "";
260
+
261
+ $product_data['transformed']['weight'] = wpsc_convert_weight($product_data['meta']['_wpsc_product_metadata']['weight'], "pounds", $product_data['meta']['_wpsc_product_metadata']['weight_unit']);
262
+ $weight = $product_data['transformed']['weight'];
263
+ if($weight == ''){
264
+ $weight = '0';
265
+ }
266
+
267
+ $unit = $product_data['meta']['_wpsc_product_metadata']['weight_unit'];
268
+ switch($unit) {
269
+ case "pound":
270
+ $unit = " lbs.";
271
+ break;
272
+ case "ounce":
273
+ $unit = " oz.";
274
+ break;
275
+ case "gram":
276
+ $unit = " g";
277
+ break;
278
+ case "kilograms":
279
+ case "kilogram":
280
+ $unit = " kgs.";
281
+ break;
282
+ }
283
+ ?>
284
+ <td <?php echo $attributes ?>>
285
+ <span><?php echo $weight; ?></span>
286
+ <input type="text" class="wpsc_ie_field wpsc_ie_weight" value="<?php echo $weight; ?>">
287
+ </td>
288
+ <?php
289
+
290
+ break;
291
+
292
+ case 'stock' :
293
+ $stock = get_post_meta($product->ID, '_wpsc_stock', true);
294
+ ?>
295
+ <td <?php echo $attributes ?>>
296
+ <span><?php echo $stock ? $stock : __('N/A', 'wpsc') ; ?></span>
297
+ <input type="text" class="wpsc_ie_field wpsc_ie_stock" value="<?php echo $stock; ?>">
298
+ </td>
299
+ <?php
300
+ break;
301
+
302
+ case 'categories': /* !categories case */
303
+ ?>
304
+ <td <?php echo $attributes ?>><?php
305
+ $categories = get_the_product_category($product->ID);
306
+ if ( !empty( $categories ) ) {
307
+ $out = array();
308
+ foreach ( $categories as $c )
309
+ $out[] = "<a href='admin.php?page=wpsc-edit-products&amp;category={$c->slug}'> " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'category', 'display')) . "</a>";
310
+ echo join( ', ', $out );
311
+ } else {
312
+ _e('Uncategorized');
313
+ }
314
+ ?></td>
315
+ <?php
316
+ break;
317
+
318
+
319
+
320
+ case 'tags': /* !tags case */
321
+ ?>
322
+ <td <?php echo $attributes ?>><?php
323
+ $tags = get_the_tags($product->ID);
324
+ if ( !empty( $tags ) ) {
325
+ $out = array();
326
+ foreach ( $tags as $c )
327
+ $out[] = "<a href='edit.php?tag=$c->slug'> " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'post_tag', 'display')) . "</a>";
328
+ echo join( ', ', $out );
329
+ } else {
330
+ _e('No Tags');
331
+ }
332
+ ?></td>
333
+ <?php
334
+ break;
335
+ case 'SKU':
336
+ $sku = get_post_meta($product->ID, '_wpsc_sku', true);
337
+ ?>
338
+ <td <?php echo $attributes ?>>
339
+ <span><?php echo $sku ? $sku : __('N/A', 'wpsc'); ?></span>
340
+ <input type="text" class="wpsc_ie_field wpsc_ie_sku" value="<?php echo $sku; ?>">
341
+ </td>
342
+ <?php
343
+ break;
344
+ case 'sale_price':
345
+
346
+ $price = get_post_meta($product->ID, '_wpsc_special_price', true);
347
+ ?>
348
+ <td <?php echo $attributes ?>>
349
+ <span><?php echo wpsc_currency_display( $price ); ?></span>
350
+ <input type="text" class="wpsc_ie_field wpsc_ie_special_price" value="<?php echo $price; ?>">
351
+ </td>
352
+ <?php
353
+
354
+ break;
355
+
356
+
357
+ case 'comments': /* !comments case */
358
+ ?>
359
+ <td <?php echo $attributes ?>><div class="post-com-count-wrapper">
360
+ <?php
361
+ $pending_phrase = sprintf( __('%s pending'), number_format( $pending_comments ) );
362
+ if ( $pending_comments )
363
+ echo '<strong>';
364
+ comments_number("<a href='edit-comments.php?p=$product->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link */ _x('0', 'comment count') . '</span></a>', "<a href='edit-comments.php?p=$product->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link */ _x('1', 'comment count') . '</span></a>', "<a href='edit-comments.php?p=$product->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link: % will be substituted by comment count */ _x('%', 'comment count') . '</span></a>');
365
+ if ( $pending_comments )
366
+ echo '</strong>';
367
+ ?>
368
+ </div></td>
369
+ <?php
370
+ break;
371
+
372
+
373
+
374
+ case 'author': /* !author case */
375
+ ?>
376
+ <td <?php echo $attributes ?>><a href="edit.php?author=<?php the_author_meta('ID'); ?>"><?php the_author() ?></a></td>
377
+ <?php
378
+ break;
379
+
380
+
381
+ case 'control_view': /* !control view case */
382
+ ?>
383
+ <td><a href="<?php the_permalink(); ?>" rel="permalink" class="view"><?php _e('View'); ?></a></td>
384
+ <?php
385
+ break;
386
+
387
+
388
+
389
+ case 'control_edit': /* !control edit case */
390
+ ?>
391
+ <td><?php if ( current_user_can('edit_post', $product->ID) ) { echo "<a href='$edit_link' class='edit'>" . __('Edit') . "</a>"; } ?></td>
392
+ <?php
393
+ break;
394
+
395
+
396
+
397
+ case 'control_delete': /* !control delete case */
398
+ ?>
399
+ <td><?php if ( current_user_can('delete_post', $product->ID) ) { echo "<a href='" . wp_nonce_url("post.php?action=delete&amp;post=$id", 'delete-post_' . $product->ID) . "' class='delete'>" . __('Delete') . "</a>"; } ?></td>
400
+ <?php
401
+ break;
402
+
403
+ case 'featured': /* !control featured case */
404
+ ?>
405
+ <td><?php do_action('manage_posts_featured_column', $product->ID); ?></td>
406
+ <?php
407
+ break;
408
+ default: /* !default case */
409
+ ?>
410
+ <td <?php echo $attributes ?>><?php do_action('manage_posts_custom_column', $column_name, $product->ID); ?></td>
411
+ <?php
412
+ break;
413
+ }
414
+ }
415
+ ?>
416
+ </tr>
417
+ <?php
418
+ $product = $global_product;
419
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-admin/includes/purchlogs_upgrade.php CHANGED
@@ -4,7 +4,7 @@
4
  $numQueries = 0;
5
  $purchlog = "SELECT DISTINCT id FROM `".WPSC_TABLE_PURCHASE_LOGS."` LIMIT 1";
6
  $id = $wpdb->get_var($purchlog);
7
- $usersql = "SELECT DISTINCT `".WPSC_TABLE_SUBMITED_FORM_DATA."`.value, `".WPSC_TABLE_CHECKOUT_FORMS."`.* FROM `".WPSC_TABLE_CHECKOUT_FORMS."` LEFT JOIN `".WPSC_TABLE_SUBMITED_FORM_DATA."` ON `".WPSC_TABLE_CHECKOUT_FORMS."`.id = `".WPSC_TABLE_SUBMITED_FORM_DATA."`.`form_id` WHERE `".WPSC_TABLE_SUBMITED_FORM_DATA."`.log_id=".$id." ORDER BY `".WPSC_TABLE_CHECKOUT_FORMS."`.`order`" ;
8
  $formfields = $wpdb->get_results($usersql);
9
 
10
 
4
  $numQueries = 0;
5
  $purchlog = "SELECT DISTINCT id FROM `".WPSC_TABLE_PURCHASE_LOGS."` LIMIT 1";
6
  $id = $wpdb->get_var($purchlog);
7
+ $usersql = "SELECT DISTINCT `".WPSC_TABLE_SUBMITED_FORM_DATA."`.value, `".WPSC_TABLE_CHECKOUT_FORMS."`.* FROM `".WPSC_TABLE_CHECKOUT_FORMS."` LEFT JOIN `".WPSC_TABLE_SUBMITED_FORM_DATA."` ON `".WPSC_TABLE_CHECKOUT_FORMS."`.id = `".WPSC_TABLE_SUBMITED_FORM_DATA."`.`form_id` WHERE `".WPSC_TABLE_SUBMITED_FORM_DATA."`.log_id=".$id." ORDER BY `".WPSC_TABLE_CHECKOUT_FORMS."`.`checkout_order`" ;
8
  $formfields = $wpdb->get_results($usersql);
9
 
10
 
wpsc-admin/includes/save-data.functions.php CHANGED
@@ -1,311 +1,696 @@
1
  <?php
2
 
3
  /**
4
- * WP eCommerce form and other data saving functions
5
  *
6
- * This is used for functions that save things like variation sets and product groups that would be too large to have in the ajax.php file.
 
 
 
 
 
 
 
 
7
  *
8
  * @package wp-e-commerce
9
  * @since 3.7
10
  */
11
-
12
-
 
 
 
 
 
 
 
 
 
 
 
 
13
  /**
14
- * Saves the variation set data
15
  * @param nothing
16
  * @return nothing
17
  */
18
- function wpsc_save_variation_set() {
19
- global $wpdb, $wp_rewrite;
20
-
21
-
22
 
23
- /* delete variation_value */
24
- if($_GET['delete_value'] == 'true') {
25
- if(is_numeric($_GET['value_id'])) {
26
- $value_id = absint($_GET['value_id']);
27
- check_admin_referer("delete-variation-$value_id");
28
-
29
- $return_value = wp_delete_term($value_id, 'wpsc-variation');
30
- if($_POST['ajax'] == 'true') {
31
- echo (string)$value_id;
32
- exit();
33
- }
34
- }
35
- }
36
-
37
- if(($_POST['submit_action'] == "add") || ($_POST['submit_action'] == "edit")) {
38
- check_admin_referer('edit-variation', 'wpsc-edit-variation');
39
-
40
- /* add variation */
41
- if($_POST['submit_action'] == "add") {
42
- $name = $_POST['name'];
43
- $term = get_term_by('name', $name, 'wpsc-variation', ARRAY_A);
44
- if(empty($term)) {
45
- $term = wp_insert_term( $name, 'wpsc-variation',array('parent' => 0));
46
- }
47
-
48
- if(!empty($term)) {
49
- $variation_id = $term['term_id'];
50
- $variation_values = $_POST['new_variation_values'];
51
- $variation_value_sql_items = array();
52
- foreach($variation_values as $variation_value) {
53
- $term = get_term_by('name', $variation_value, 'wpsc-variation', ARRAY_A);
54
- if(empty($term)) {
55
- $term = wp_insert_term( $variation_value, 'wpsc-variation',array('parent' => $variation_id));
56
- }
57
- }
58
- }
59
- }
60
-
61
- /* edit variation */
62
- if(($_POST['submit_action'] == "edit") && is_numeric($_POST['variation_id'])) {
63
- $variation_id = absint($_POST['variation_id']);
64
-
65
- $variation_set_name = $_POST['name'];
66
- $term = get_term_by('name', $name, 'wpsc-variation', ARRAY_A);
67
- if(empty($term)) {
68
- $term = wp_insert_term( $name, 'wpsc-variation',array('parent' => 0));
69
- } else {
70
- wp_update_term($variation_id, 'wpsc-variation', array(
71
- 'name' => $variation_set_name
72
- ));
73
- }
74
-
75
- foreach($_POST['variation_values'] as $variation_value_id => $variation_value_name) {
76
- if(is_numeric($variation_value_id)) {
77
- $variation_value_id = absint($variation_value_id);
78
- wp_update_term($variation_value_id, 'wpsc-variation', array(
79
- 'name' => $variation_value_name
80
- ));
81
- }
82
-
83
- if($variation_value_state != $variation_value) {
84
- }
85
- }
86
-
87
- if($_POST['new_variation_values'] != null) {
88
- foreach($_POST['new_variation_values'] as $variation_value) {
89
- $term = get_term_by('name', $variation_value, 'wpsc-variation', ARRAY_A);
90
- if(empty($term)) {
91
- $term = wp_insert_term( $variation_value, 'wpsc-variation',array('parent' => $variation_id));
92
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  }
94
  }
 
 
95
  }
96
- }
97
- $sendback = remove_query_arg(array(
98
- 'wpsc_admin_action',
99
- 'delete_value',
100
- '_wpnonce',
101
- 'value_id'
102
- ));
103
-
104
- if($_GET['page'] == null) {
105
- $sendback = add_query_arg('page', 'wpsc-edit-variations', $sendback);
106
- }
107
- $sendback = add_query_arg('message', 1, $sendback);
108
- wp_redirect($sendback);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
  }
110
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111
 
112
  /**
113
  * wpsc_save_category_set, Saves the category set data
114
  * @param nothing
115
  * @return nothing
116
  */
117
- function wpsc_save_category_set() {
118
  global $wpdb;
119
-
120
- if(($_POST['submit_action'] == "add") || ($_POST['submit_action'] == "edit")) {
121
- check_admin_referer('edit-category', 'wpsc-edit-category');
122
  /* Image Processing Code*/
123
- if(($_FILES['image'] != null) && preg_match("/\.(gif|jp(e)*g|png){1}$/i",$_FILES['image']['name'])) {
124
- if(function_exists("getimagesize")) {
125
- if(((int)$_POST['width'] > 10 && (int)$_POST['width'] < 512) && ((int)$_POST['height'] > 10 && (int)$_POST['height'] < 512) ) {
126
- $width = (int)$_POST['width'];
127
- $height = (int)$_POST['height'];
128
- image_processing($_FILES['image']['tmp_name'], (WPSC_CATEGORY_DIR.$_FILES['image']['name']), $width, $height);
129
  } else {
130
- image_processing($_FILES['image']['tmp_name'], (WPSC_CATEGORY_DIR.$_FILES['image']['name']));
131
  }
132
- $image = $wpdb->escape($_FILES['image']['name']);
133
  } else {
134
- $new_image_path = (WPSC_CATEGORY_DIR.basename($_FILES['image']['name']));
135
- move_uploaded_file($_FILES['image']['tmp_name'], $new_image_path);
136
- $stat = stat( dirname( $new_image_path ));
137
  $perms = $stat['mode'] & 0000666;
138
  @ chmod( $new_image_path, $perms );
139
- $image = $wpdb->escape($_FILES['image']['name']);
140
  }
141
  } else {
142
  $image = '';
143
  }
144
-
145
- /* Set the parent category ID variable*/
146
- if(is_numeric($_POST['category_parent']) && absint($_POST['category_parent']) > 0) {
147
- $parent_category = (int)$_POST['category_parent'];
148
- } else {
149
- $parent_category = 0;
150
- }
151
-
152
 
153
- /* add category code */
154
- if($_POST['submit_action'] == "add") {
155
- $name = $_POST['name'];
156
- $term = get_term_by('name', $name, 'wpsc_product_category', ARRAY_A);
157
-
158
- $term = wp_insert_term( $name, 'wpsc_product_category',array('parent' => $parent_category));
159
-
160
- if (is_wp_error($term)) {
161
- $sendback = add_query_arg('message',$term->get_error_code());
162
- wp_redirect($sendback);
163
- return;
164
- }
165
-
166
- $category_id= $term['term_id'];
167
-
168
- $category = get_term_by('id', $category_id, 'wpsc_product_category');
169
- $url_name=$category->slug;
170
-
171
- if($category_id > 0) {
172
- wpsc_update_categorymeta($category_id, 'nice-name', $url_name);
173
- wpsc_update_categorymeta($category_id, 'description', $wpdb->escape(stripslashes($_POST['description'])));
174
- if($image != '') {
175
- wpsc_update_categorymeta($category_id, 'image', $image);
176
- }
177
- wpsc_update_categorymeta($category_id, 'fee', '0');
178
- wpsc_update_categorymeta($category_id, 'active', '1');
179
- wpsc_update_categorymeta($category_id, 'order', '0');
180
- wpsc_update_categorymeta($category_id, 'display_type',$wpdb->escape(stripslashes($_POST['display_type'])));
181
- wpsc_update_categorymeta($category_id, 'image_height', $wpdb->escape(stripslashes($_POST['image_height'])));
182
- wpsc_update_categorymeta($category_id, 'image_width', $wpdb->escape(stripslashes($_POST['image_width'])));
183
- if($_POST['use_additonal_form_set'] != '') {
184
- wpsc_update_categorymeta($category_id, 'use_additonal_form_set', $_POST['use_additonal_form_set']);
185
- } else {
186
- wpsc_delete_categorymeta($category_id, 'use_additonal_form_set');
187
- }
188
-
189
- if((bool)(int)$_POST['uses_billing_address'] == true) {
190
- wpsc_update_categorymeta($category_id, 'uses_billing_address', 1);
191
- $uses_additional_forms = true;
192
- } else {
193
- wpsc_update_categorymeta($category_id, 'uses_billing_address', 0);
194
- $uses_additional_forms = false;
195
- }
196
- }
197
 
198
- if(isset($_POST['countrylist2']) && ($_POST['countrylist2'] != null ) && ($category_id > 0)){
199
- $AllSelected = false;
200
- $countryList = $wpdb->get_col("SELECT `id` FROM `".WPSC_TABLE_CURRENCY_LIST."`");
201
-
202
- if($AllSelected != true){
203
- $unselectedCountries = array_diff($countryList, $_POST['countrylist2']);
204
- //find the countries that are selected
205
- $selectedCountries = array_intersect($countryList, $_POST['countrylist2']);
206
- wpsc_update_meta( $category_id, 'target_market',$selectedCountries, 'wpsc_category');
207
- }
208
- }elseif(!isset($_POST['countrylist2'])){
209
- wpsc_update_meta( $category_id, 'target_market','', 'wpsc_category');
210
- $AllSelected = true;
211
-
 
 
 
 
 
 
 
212
  }
 
213
 
214
- }
 
 
215
 
216
-
217
- /* edit category code */
218
- if(($_POST['submit_action'] == "edit") && is_numeric($_POST['category_id'])) {
219
- $category_id = absint($_POST['category_id']);
220
-
221
- $name = $_POST['name'];
222
-
223
- $category = get_term_by('id', $category_id, 'wpsc_product_category');
224
- if($category->name != $name || $category->parent != $parent_category) {
225
- wp_update_term($category_id, 'wpsc_product_category', array(
226
- 'name' => $name , 'parent' => $parent_category
227
- ));
228
- $category = get_term($category_id, 'wpsc_product_category');
229
- }
230
-
231
-
232
- $url_name=$category->slug;
233
- wpsc_update_categorymeta($category_id, 'nice-name', $url_name);
234
- wpsc_update_categorymeta($category_id, 'description', $wpdb->escape(stripslashes($_POST['description'])));
235
-
236
-
237
- if(isset($_POST['deleteimage']) && $_POST['deleteimage'] == 1) {
238
- wpsc_delete_categorymeta($category_id, 'image');
239
- } else if($image != '') {
240
- wpsc_update_categorymeta($category_id, 'image', $image);
241
- }
242
-
243
- if(is_numeric($_POST['height']) && is_numeric($_POST['width']) && ($image == null)) {
244
- $imagedata = wpsc_get_categorymeta($category_id, 'image');
245
- if($imagedata != null) {
246
- $height = $_POST['height'];
247
- $width = $_POST['width'];
248
- $imagepath = WPSC_CATEGORY_DIR . $imagedata;
249
- $image_output = WPSC_CATEGORY_DIR . $imagedata;
250
- image_processing($imagepath, $image_output, $width, $height);
251
- }
252
- }
253
-
254
-
255
- wpsc_update_categorymeta($category_id, 'fee', '0');
256
- wpsc_update_categorymeta($category_id, 'active', '1');
257
- wpsc_update_categorymeta($category_id, 'order', '0');
258
-
259
- wpsc_update_categorymeta($category_id, 'display_type',$wpdb->escape(stripslashes($_POST['display_type'])));
260
- wpsc_update_categorymeta($category_id, 'image_height', $wpdb->escape(stripslashes($_POST['image_height'])));
261
- wpsc_update_categorymeta($category_id, 'image_width', $wpdb->escape(stripslashes($_POST['image_width'])));
262
-
263
-
264
- if($_POST['use_additonal_form_set'] != '') {
265
- wpsc_update_categorymeta($category_id, 'use_additonal_form_set', $_POST['use_additonal_form_set']);
266
- } else {
267
- wpsc_delete_categorymeta($category_id, 'use_additonal_form_set');
268
  }
269
-
270
- if((bool)(int)$_POST['uses_billing_address'] == true) {
271
- wpsc_update_categorymeta($category_id, 'uses_billing_address', 1);
272
- $uses_additional_forms = true;
273
- } else {
274
- wpsc_update_categorymeta($category_id, 'uses_billing_address', 0);
275
- $uses_additional_forms = false;
276
- }
277
 
278
- if(($_POST['countrylist2'] != null ) && ($category_id > 0)){
279
- $AllSelected = false;
280
- $countryList = $wpdb->get_col("SELECT `id` FROM `".WPSC_TABLE_CURRENCY_LIST."`");
281
-
282
- if($AllSelected != true){
283
- $unselectedCountries = array_diff($countryList, $_POST['countrylist2']);
284
- //find the countries that are selected
285
- $selectedCountries = array_intersect($countryList, $_POST['countrylist2']);
286
- wpsc_update_meta( $category_id, 'target_market',$selectedCountries, 'wpsc_category');
287
- }
288
- }elseif(!isset($_POST['countrylist2'])){
289
- wpsc_update_meta( $category_id, 'target_market','', 'wpsc_category');
290
- $AllSelected = true;
291
-
292
- }
293
- }
294
- }
295
-
296
- $sendback = remove_query_arg(array(
297
- 'wpsc_admin_action',
298
- 'delete_category',
299
- '_wpnonce',
300
- 'category_id'
301
- ));
302
-
303
- if($_GET['page'] == null) {
304
- $sendback = add_query_arg('page', 'wpsc-edit-variations', $sendback);
305
  }
306
-
307
- $sendback = add_query_arg('message', 1, $sendback);
308
- wp_redirect($sendback);
309
  }
310
 
311
 
1
  <?php
2
 
3
  /**
4
+ * This file used for adding fields to the products category taxonomy page and saving those values correctly :)
5
  *
6
+ * @package wp-e-commerce
7
+ * @since 3.8
8
+ * @todo UI needs a lot of loving - lots of padding issues, if we have these boxes, they should be sortable, closable, hidable, etc.
9
+ */
10
+
11
+ /**
12
+ * WP eCommerce edit and add product category page functions
13
+ *
14
+ * These are the main WPSC Admin functions
15
  *
16
  * @package wp-e-commerce
17
  * @since 3.7
18
  */
19
+
20
+ function wpsc_ajax_set_category_order(){
21
+ global $wpdb;
22
+ $sort_order = $_POST['sort_order'];
23
+ $parent_id = $_POST['parent_id'];
24
+
25
+ $result = true;
26
+ foreach( $sort_order as $key=>$value ){
27
+ if( !wpsc_update_meta( $value, 'sort_order', $key, 'wpsc_category' ) )
28
+ $result = false;
29
+ }
30
+
31
+ }
32
+
33
  /**
34
+ * Remove the AJAX response on the categories page. Necessary for allowing for image upload.
35
  * @param nothing
36
  * @return nothing
37
  */
 
 
 
 
38
 
39
+ function wpsc_cat_kill_ajax() {
40
+ global $current_screen;
41
+
42
+ if( $current_screen->id == 'edit-wpsc_product_category' ) {
43
+ wp_deregister_script( 'wp-ajax-response' );
44
+ wp_deregister_script( 'admin-tags' );
45
+ wp_deregister_script( 'inline-edit-post' );
46
+ }
47
+ }
48
+
49
+ add_action( 'admin_head', 'wpsc_cat_kill_ajax' );
50
+ add_filter( 'manage_edit-wpsc_product_category_columns', 'wpsc_custom_category_columns' );
51
+ add_filter( 'manage_wpsc_product_category_custom_column', 'wpsc_custom_category_column_data', 10, 3);
52
+ add_action( 'wpsc_product_category_add_form_fields', 'wpsc_admin_category_forms_add' ); // After left-col
53
+ add_action( 'wpsc_product_category_edit_form_fields', 'wpsc_admin_category_forms_edit' ); // After left-col
54
+ add_action( 'created_wpsc_product_category', 'wpsc_save_category_set', 10 , 2 ); //After created
55
+ add_action( 'edited_wpsc_product_category', 'wpsc_save_category_set', 10 , 2 ); //After saved
56
+
57
+ /**
58
+ * wpsc_custom_category_columns
59
+ * Adds images column to category column.
60
+ * @internal Don't feel handle column is necessary, but you would add it here if you wanted to
61
+ * @param (array) columns | Array of columns assigned to this taxonomy
62
+ * @return (array) columns | Modified array of columns
63
+ */
64
+
65
+ function wpsc_custom_category_columns( $columns ) {
66
+ // Doing it this funny way to ensure that image stays in far left, even if other items are added via plugin.
67
+ unset( $columns["cb"] );
68
+
69
+ $custom_array = array(
70
+ 'cb' => '<input type="checkbox">',
71
+ 'image' => __( 'Image' )
72
+ );
73
+
74
+ $columns = array_merge( $custom_array, $columns );
75
+
76
+ return $columns;
77
+ }
78
+ /**
79
+ * wpsc_custom_category_column_data
80
+ * Adds images to the custom category column
81
+ * @param (array) column_name | column name
82
+ * @return nada
83
+ */
84
+
85
+ function wpsc_custom_category_column_data( $string, $column_name, $term_id ) {
86
+ global $wpdb;
87
+
88
+ $image = wpsc_get_categorymeta( $term_id, 'image' );
89
+ $name = get_term_by( 'id', $term_id, 'wpsc_product_category' );
90
+ $name = $name->name;
91
+
92
+ if( !empty( $image ) )
93
+ $image = "<img src=\"".WPSC_CATEGORY_URL.stripslashes( $image )."\" title='".$name."' alt='".$name."' width='30' height='30' />";
94
+ else
95
+ $image = "<img src='".WPSC_CORE_IMAGES_URL."/no-image-uploaded.gif' title='".$name."' alt='".$name."' width='30' height='30' />";
96
+
97
+
98
+ return $image;
99
+
100
+ }
101
+ /**
102
+ * Create the actual drag and drop list used for the admin category view
103
+ *
104
+ * @param array $categories
105
+ * @param int $level
106
+ * @return string $output
107
+ */
108
+ function wpsc_admin_list_category_array($categories, $level = 0){
109
+
110
+ $output = '';
111
+ foreach($categories as $cat){
112
+
113
+ $output .= "<li id='".$cat['id']."'>";
114
+ $output .= "<div id='category-".$cat['id']."-container'>";
115
+
116
+ $output .= "<div class='category_admin_list_img' id='category-".$cat['id']."-imgs'>";
117
+ $output .= "<span title='click and drag to move' class='handle'>↕</span>";
118
+ if($level > 0){
119
+ $output .= "<img class='category_indenter' src='".WPSC_CORE_IMAGES_URL."/indenter.gif' alt='' title='' />";
120
+ }
121
+ $output .= "<a class='row-title' href='".add_query_arg('category_id', $cat['id'])."'>";
122
+ if(isset($cat['image'])){
123
+ $output .= "<img src=\"".WPSC_CATEGORY_URL.stripslashes($cat['image'])."\" title='".$cat['name']."' alt='".$cat['name']."' width='30' height='30' />";
124
+ }else{
125
+ $output .= "<img src='".WPSC_CORE_IMAGES_URL."/no-image-uploaded.gif' title='".$cat['name']."' alt='".$cat['name']."' width='30' height='30' />";
126
+ }
127
+ $output .= stripslashes($cat['name'])."</a>";
128
+
129
+ $output .= "<div class='row-actions'><span class='edit'><a class='edit-product' style='cursor:pointer;' title='Edit This Category' href='".add_query_arg('category_id', $cat['id'])."'>". __('Edit', 'wpsc')."</a>";
130
+ $output .= "</span> | <span class='edit'>";
131
+ $nonced_url = wp_nonce_url("admin.php?wpsc_admin_action=wpsc-delete-category&amp;deleteid={$cat['id']}", 'delete-category');
132
+ $output .= "<a class='delete_button' style='text-decoration:none;' href='".$nonced_url."' onclick=\"return conf();\" >". __('Delete', 'wpsc')."</a>";
133
+ $output .= "</span></div>";
134
+ $output .= "</div>";
135
+ if(is_array($cat['children'])){
136
+ $newhandle = "category-".$cat['id']."-children";
137
+ $output .= <<<EOT
138
+ <script type="text/javascript">
139
+ jQuery(document).ready(function(){
140
+ jQuery('#{$newhandle}').sortable({
141
+ axis: 'y',
142
+ containment: 'parent',
143
+ handle: '.handle',
144
+ tolerance: 'pointer',
145
+ update: function(event, ui){
146
+ categorySort(jQuery('#{$newhandle}').sortable('toArray'), 0);
147
+ }
148
+ });
149
+ });
150
+ </script>
151
+ EOT;
152
+ $output .= "<ul id='{$newhandle}' class='ui-sortable'>";
153
+ $output .= wpsc_admin_list_category_array($cat['children'], ($level + 1));
154
+ $output .= "</ul>";
155
+ }
156
+ $output .= "</div></li>";
157
+
158
+ }
159
+ return $output;
160
+ }
161
+
162
+ /**
163
+ * wpsc_admin_get_category_array
164
+ * Recursively step through the categories and return it in a clean multi demensional array
165
+ * for use in other list functions
166
+ * @param int $parent_id
167
+ */
168
+ function wpsc_admin_get_category_array($parent_id = null){
169
+ global $wpdb;
170
+ $orderedList = array();
171
+ if(!isset($parent_id)) $parent_id = 0;
172
+ $category_list = get_terms('wpsc_product_category','hide_empty=0&parent='.$parent_id);
173
+ if(!is_array($category_list)){
174
+ return false;
175
+ }
176
+ foreach($category_list as $category){
177
+ $category_order = wpsc_get_categorymeta($category->term_id, 'order');
178
+ $category_image = wpsc_get_categorymeta($category->term_id, 'image');
179
+ if(!isset($category_order) || $category_order == 0) $category_order = (count($orderedList) +1);
180
+ print "<!-- setting category Order number to ".$category_order."-->";
181
+ $orderedList[$category_order]['id'] = $category->term_id;
182
+ $orderedList[$category_order]['name'] = $category->name;
183
+ $orderedList[$category_order]['image'] = $category_image;
184
+ $orderedList[$category_order]['parent_id'] = $parent_id;
185
+ $orderedList[$category_order]['children'] = wpsc_admin_get_category_array($category->term_id);
186
+ }
187
+
188
+ ksort($orderedList);
189
+ return($orderedList);
190
+ }
191
+
192
+ /**
193
+ * wpsc_admin_category_group_list, prints the left hand side of the add categories page
194
+ * nothing returned
195
+ */
196
+ function wpsc_admin_category_forms_add() {
197
+ global $wpdb;
198
+ $category_value_count = 0;
199
+ ?>
200
+
201
+ <h3><?php _e('Advanced Settings', 'wpsc'); ?></h3>
202
+
203
+ <div id="poststuff" class="postbox">
204
+ <h3 class="hndle"><?php _e('Presentation Settings'); ?></h3>
205
+
206
+ <div class="inside">
207
+ <input type='file' name='image' value='' /><br /><br />
208
+
209
+ <tr>
210
+ <td>
211
+ <?php _e('Catalog View', 'wpsc'); ?>
212
+ </td>
213
+ <td>
214
+ <?php
215
+ if (!isset($category['display_type'])) $category['display_type'] = '';
216
+
217
+ if ($category['display_type'] == 'grid') {
218
+ $display_type1="selected='selected'";
219
+ } else if ($category['display_type'] == 'default') {
220
+ $display_type2="selected='selected'";
221
+ }
222
+
223
+ switch($category['display_type']) {
224
+ case "default":
225
+ $category_view1 = "selected ='selected'";
226
+ break;
227
+
228
+ case "grid":
229
+ if(function_exists('product_display_grid')) {
230
+ $category_view3 = "selected ='selected'";
231
+ break;
232
+ }
233
+
234
+ case "list":
235
+ if(function_exists('product_display_list')) {
236
+ $category_view2 = "selected ='selected'";
237
+ break;
238
+ }
239
+
240
+ default:
241
+ $category_view0 = "selected ='selected'";
242
+ break;
243
+ }?>
244
+
245
+
246
+ <select name='display_type'>
247
+ <option value=''<?php echo $category_view0; ?> ><?php _e('Please select', 'wpsc'); ?></option>
248
+ <option value='default' <?php if (isset($category_view1)) echo $category_view1; ?> ><?php _e('Default View', 'wpsc'); ?></option>
249
+
250
+ <?php if(function_exists('product_display_list')) {?>
251
+ <option value='list' <?php echo $category_view2; ?>><?php _e('List View', 'wpsc'); ?></option>
252
+ <?php } else { ?>
253
+ <option value='list' disabled='disabled' <?php if (isset($category_view2)) echo $category_view2; ?>><?php _e('List View', 'wpsc'); ?></option>
254
+ <?php } ?>
255
+ <?php if(function_exists('product_display_grid')) { ?>
256
+ <option value='grid' <?php if (isset($category_view3)) echo $category_view3; ?>><?php _e('Grid View', 'wpsc'); ?></option>
257
+ <?php } else { ?>
258
+ <option value='grid' disabled='disabled' <?php if (isset($category_view3)) echo $category_view3; ?>><?php _e('Grid View', 'wpsc'); ?></option>
259
+ <?php } ?>
260
+ </select><br /><br />
261
+ </td>
262
+ </tr>
263
+ <tr>
264
+ <td>
265
+ <span class='small'><?php _e('To over-ride the presentation settings for this group you can enter in your prefered settings here', 'wpsc'); ?></span><br /><br />
266
+ </td>
267
+ </tr>
268
+
269
+ <?php if(function_exists("getimagesize")) { ?>
270
+ <tr>
271
+ <td>
272
+ <?php _e('Thumbnail&nbsp;Size', 'wpsc'); ?>
273
+ </td>
274
+ <td>
275
+ <?php _e('Width', 'wpsc'); ?> <input type='text' value='<?php if (isset($category['image_width'])) echo $category['image_width']; ?>' name='image_width' size='6'/>
276
+ <?php _e('Height', 'wpsc'); ?> <input type='text' value='<?php if (isset($category['image_height'])) echo $category['image_height']; ?>' name='image_height' size='6'/><br/>
277
+ </td>
278
+ </tr>
279
+ <?php
280
+ }
281
+ ?>
282
+ </div>
283
+ </div>
284
+
285
+ <!-- START OF TARGET MARKET SELECTION -->
286
+ <div id="poststuff" class="postbox">
287
+ <h3 class="hndle"><?php _e('Target Market Restrictions'); ?></h3>
288
+ <div class="inside"><?php
289
+ $category_id = '';
290
+ if (isset($_GET["tag_ID"])) $category_id = $_GET["tag_ID"];
291
+ $countrylist = $wpdb->get_results("SELECT id,country,visible FROM `".WPSC_TABLE_CURRENCY_LIST."` ORDER BY country ASC ",ARRAY_A);
292
+ $selectedCountries = wpsc_get_meta($category_id,'target_market','wpsc_category');
293
+ $output = '';
294
+ $output .= " <tr>\n\r";
295
+ $output .= " <td>\n\r";
296
+ $output .= __('Target Markets', 'wpsc').":\n\r";
297
+ $output .= " </td>\n\r";
298
+ $output .= " <td>\n\r";
299
+
300
+ if(@extension_loaded('suhosin')) {
301
+ $output .= "<em>".__("The Target Markets feature has been disabled because you have the Suhosin PHP extension installed on this server. If you need to use the Target Markets feature then disable the suhosin extension, if you can not do this, you will need to contact your hosting provider.
302
+ ",'wpsc')."</em>";
303
+
304
+ } else {
305
+ $output .= "<span>Select: <a href='' class='wpsc_select_all'>All</a>&nbsp; <a href='' class='wpsc_select_none'>None</a></span><br />";
306
+ $output .= " <div id='resizeable' class='ui-widget-content multiple-select'>\n\r";
307
+ foreach($countrylist as $country){
308
+ if(in_array($country['id'], (array)$selectedCountries)){
309
+ $output .= " <input type='checkbox' name='countrylist2[]' value='".$country['id']."' checked='".$country['visible']."' />".$country['country']."<br />\n\r";
310
+ } else {
311
+ $output .= " <input type='checkbox' name='countrylist2[]' value='".$country['id']."' />".$country['country']."<br />\n\r";
312
  }
313
  }
314
+ $output .= " </div><br /><br />";
315
+ $output .= " <span class='wpscsmall description'>Select the markets you are selling this category to.<span>\n\r";
316
  }
317
+ $output .= " </td>\n\r";
318
+ $output .= " </tr>\n\r";
319
+
320
+ echo $output;
321
+ ?>
322
+ </div>
323
+ </div>
324
+
325
+ <!-- Checkout settings -->
326
+ <div id="poststuff" class="postbox">
327
+ <h3 class="hndle"><?php _e('Checkout Settings', 'wpsc'); ?></h3>
328
+ <div class="inside">
329
+ <table class='category_forms'>
330
+ <?php
331
+ if (!isset($category['term_id'])) $category['term_id'] = '';
332
+ $used_additonal_form_set = wpsc_get_categorymeta($category['term_id'], 'use_additonal_form_set'); ?>
333
+ <tr>
334
+ <td>
335
+ <?php _e("This category requires additional checkout form fields",'wpsc'); ?>
336
+ </td>
337
+ <td>
338
+ <select name='use_additonal_form_set'>
339
+ <option value=''><?php _e("None",'wpsc'); ?></option>
340
+ <?php
341
+ $checkout_sets = get_option('wpsc_checkout_form_sets');
342
+ unset($checkout_sets[0]);
343
+
344
+ foreach((array)$checkout_sets as $key => $value) {
345
+ $selected_state = "";
346
+ if($used_additonal_form_set == $key)
347
+ $selected_state = "selected='selected'";
348
+ ?>
349
+ <option <?php echo $selected_state; ?> value='<?php echo $key; ?>'><?php echo stripslashes($value); ?></option>
350
+ <?php
351
+ }
352
+ ?>
353
+ </select>
354
+ </td>
355
+ </tr>
356
+ <?php $uses_billing_address = (bool)wpsc_get_categorymeta($category['term_id'], 'uses_billing_address'); ?>
357
+ <tr>
358
+ <td>
359
+ <?php _e("Products in this category use the billing address to calculate shipping",'wpsc'); ?>
360
+ </td>
361
+ <td>
362
+ <input type='radio' value='1' name='uses_billing_address' <?php echo (($uses_billing_address == true) ? "checked='checked'" : ""); ?> /><?php _e("Yes",'wpsc'); ?>
363
+ <input type='radio' value='0' name='uses_billing_address' <?php echo (($uses_billing_address != true) ? "checked='checked'" : ""); ?> /><?php _e("No",'wpsc'); ?>
364
+ </td>
365
+ </tr>
366
+ </table>
367
+ </div>
368
+ </div>
369
+
370
+ <table class="category_forms">
371
+ <tr>
372
+
373
+ </tr>
374
+ </table>
375
+ <?php
376
  }
377
 
378
+ function wpsc_admin_category_forms_edit() {
379
+ global $wpdb;
380
+
381
+ $category_value_count = 0;
382
+ $category_name = '';
383
+ $category = array();
384
+
385
+ $category_id = absint( $_REQUEST["tag_ID"] );
386
+ $category = get_term($category_id, 'wpsc_product_category', ARRAY_A);
387
+ $category['nice-name'] = wpsc_get_categorymeta($category['term_id'], 'nice-name');
388
+ $category['description'] = wpsc_get_categorymeta($category['term_id'], 'description');
389
+ $category['image'] = wpsc_get_categorymeta($category['term_id'], 'image');
390
+ $category['fee'] = wpsc_get_categorymeta($category['term_id'], 'fee');
391
+ $category['active'] = wpsc_get_categorymeta($category['term_id'], 'active');
392
+ $category['order'] = wpsc_get_categorymeta($category['term_id'], 'order');
393
+ $category['display_type'] = wpsc_get_categorymeta($category['term_id'], 'display_type');
394
+ $category['image_height'] = wpsc_get_categorymeta($category['term_id'], 'image_height');
395
+ $category['image_width'] = wpsc_get_categorymeta($category['term_id'], 'image_width');
396
+
397
+
398
+ ?>
399
+
400
+ <tr>
401
+ <td colspan="2">
402
+ <h3><?php _e( 'Advanced Settings', 'wpsc' ); ?></h3>
403
+ </td>
404
+ </tr>
405
+
406
+ <tr class="form-field">
407
+ <th scope="row" valign="top">
408
+ <label for="display_type"><?php _e( 'Catalog View', 'wpsc' ); ?></label>
409
+ </th>
410
+ <td>
411
+ <?php
412
+ //Could probably be *heavily* refactored later just to use do_action here and in GoldCart. Baby steps.
413
+ if (!isset($category['display_type'])) $category['display_type'] = '';
414
+
415
+ if ($category['display_type'] == 'grid') {
416
+ $display_type1="selected='selected'";
417
+ } else if ($category['display_type'] == 'default') {
418
+ $display_type2="selected='selected'";
419
+ }
420
+
421
+ switch($category['display_type']) {
422
+ case "default":
423
+ $category_view1 = "selected ='selected'";
424
+ break;
425
+
426
+ case "grid":
427
+ if(function_exists('product_display_grid')) {
428
+ $category_view3 = "selected ='selected'";
429
+ break;
430
+ }
431
+
432
+ case "list":
433
+ if(function_exists('product_display_list')) {
434
+ $category_view2 = "selected ='selected'";
435
+ break;
436
+ }
437
+
438
+ default:
439
+ $category_view0 = "selected ='selected'";
440
+ break;
441
+ }
442
+ ?>
443
+ <select name='display_type'>
444
+ <option value=''<?php echo $category_view0; ?> ><?php _e('Please select', 'wpsc'); ?></option>
445
+ <option value='default' <?php if (isset($category_view1)) echo $category_view1; ?> ><?php _e( 'Default View', 'wpsc' ); ?></option>
446
+
447
+ <?php if(function_exists('product_display_list')) {?>
448
+ <option value='list' <?php echo $category_view2; ?>><?php _e('List View', 'wpsc'); ?></option>
449
+ <?php } else { ?>
450
+ <option value='list' disabled='disabled' <?php if (isset($category_view2)) echo $category_view2; ?>><?php _e( 'List View', 'wpsc' ); ?></option>
451
+ <?php } ?>
452
+ <?php if(function_exists('product_display_grid')) { ?>
453
+ <option value='grid' <?php if (isset($category_view3)) echo $category_view3; ?>><?php _e( 'Grid View', 'wpsc' ); ?></option>
454
+ <?php } else { ?>
455
+ <option value='grid' disabled='disabled' <?php if (isset($category_view3)) echo $category_view3; ?>><?php _e( 'Grid View', 'wpsc' ); ?></option>
456
+ <?php } ?>
457
+ </select><br />
458
+ <span class="description"><?php _e( 'To over-ride the presentation settings for this group you can enter in your prefered settings here', 'wpsc' ); ?></span>
459
+ </td>
460
+ </tr>
461
+ <tr class="form-field">
462
+ <th scope="row" valign="top">
463
+ <label for="image"><?php _e( 'Category Image', 'wpsc' ); ?></label>
464
+ </th>
465
+ <td>
466
+ <input type='file' name='image' value='' /><br />
467
+ <label><input type='checkbox' name='deleteimage' class="wpsc_cat_box" value='1' /><?php _e( 'Delete Image', 'wpsc' ); ?></label><br/>
468
+ <span class="description"><?php _e( 'You can set an image for the category here. If one exists, check the box to delete.', 'wpsc' ); ?></span>
469
+ </td>
470
+ </tr>
471
+ <?php if( function_exists( "getimagesize" ) ) : ?>
472
+ <tr class="form-field">
473
+ <th scope="row" valign="top">
474
+ <label for="image"><?php _e( 'Thumbnail Size', 'wpsc' ); ?></label>
475
+ </th>
476
+ <td>
477
+ <?php _e( 'Width', 'wpsc' ); ?> <input type='text' class="wpsc_cat_image_size" value='<?php if (isset($category['image_width'])) echo $category['image_width']; ?>' name='image_width' size='6' />
478
+ <?php _e( 'Height', 'wpsc' ); ?> <input type='text' class="wpsc_cat_image_size" value='<?php if (isset($category['image_height'])) echo $category['image_height']; ?>' name='image_height' size='6' /><br/>
479
+ </td>
480
+ </tr>
481
+ <?php endif; // 'getimagesize' condition ?>
482
+ <tr>
483
+ <td colspan="2"><h3><?php _e( 'Shortcodes and Template Tags', 'wpsc' ); ?></h3></td>
484
+ </tr>
485
+
486
+ <tr class="form-field">
487
+ <th scope="row" valign="top">
488
+ <label for="image"><?php _e( 'Display Category Shortcode', 'wpsc' ); ?>:</label>
489
+ </th>
490
+ <td>
491
+ <span>[wpsc_products category_url_name='<?php echo $category["slug"]; ?>']</span><br />
492
+ <span class="description"><?php _e( 'Shortcodes are used to display a particular category or group within any WordPress page or post.', 'wpsc' ); ?></span>
493
+ </td>
494
+ </tr>
495
+ <tr class="form-field">
496
+ <th scope="row" valign="top">
497
+ <label for="image"><?php _e( 'Display Category Template Tag', 'wpsc' ); ?>:</label>
498
+ </th>
499
+ <td>
500
+ <span>&lt;?php echo wpsc_display_products_page( array( 'category_url_name'=>'<?php echo $category["slug"]; ?>' ) ); ?&gt;</span><br />
501
+ <span class="description"><?php _e( 'Template tags are used to display a particular category or group within your theme / template.', 'wpsc' ); ?></span>
502
+ </td>
503
+ </tr>
504
+
505
+ <!-- START OF TARGET MARKET SELECTION -->
506
+
507
+ <tr>
508
+ <td colspan="2">
509
+ <h3><?php _e( 'Target Market Restrictions', 'wpsc' ); ?></h3>
510
+ </td>
511
+ </tr>
512
+ <?php
513
+ $countrylist = $wpdb->get_results( "SELECT id,country,visible FROM `".WPSC_TABLE_CURRENCY_LIST."` ORDER BY country ASC ",ARRAY_A );
514
+ $selectedCountries = wpsc_get_meta( $category_id,'target_market','wpsc_category' );
515
+ ?>
516
+ <tr class="form-field">
517
+ <th scope="row" valign="top">
518
+ <label for="image"><?php _e( 'Target Markets', 'wpsc' ); ?>:</label>
519
+ </th>
520
+ <td>
521
+ <?php
522
+ if ( @extension_loaded( 'suhosin' ) ) :
523
+ ?>
524
+ <em><?php _e( 'The Target Markets feature has been disabled because you have the Suhosin PHP extension installed on this server. If you need to use the Target Markets feature, then disable the suhosin extension. If you can not do this, you will need to contact your hosting provider.','wpsc'); ?></em>
525
+
526
+ <?php
527
+ else :
528
+ ?>
529
+ <span><?php _e( 'Select', 'wpsc' ); ?>: <a href='' class='wpsc_select_all'><?php _e( 'All', 'wpsc' ); ?></a>&nbsp; <a href='' class='wpsc_select_none'><?php _e( 'None', 'wpsc' ); ?></a></span><br />
530
+ <div id='resizeable' class='ui-widget-content multiple-select'>
531
+ <?php
532
+ foreach( $countrylist as $country ) {
533
+ if( in_array( $country['id'], (array)$selectedCountries ) )
534
+ echo " <input type='checkbox' class='wpsc_cat_box' name='countrylist2[]' value='".$country['id']."' checked='".$country['visible']."' />".$country['country']."<br />";
535
+ else
536
+ echo " <input type='checkbox' class='wpsc_cat_box' name='countrylist2[]' value='".$country['id']."' />".$country['country']."<br />";
537
+ }
538
+ ?>
539
+ </div>
540
+ <?php
541
+ endif;
542
+ ?><br />
543
+ <span class="description"><?php _e( 'Select the markets you are selling this category to.', 'wpsc' ); ?></span>
544
+ </td>
545
+ </tr>
546
+ <!-- Checkout settings -->
547
+
548
+ <tr>
549
+ <td colspan="2">
550
+ <h3><?php _e( 'Checkout Settings', 'wpsc' ); ?></h3>
551
+ </td>
552
+ </tr>
553
+ <?php
554
+ if ( !isset( $category['term_id'] ) )
555
+ $category['term_id'] = '';
556
+ $used_additonal_form_set = wpsc_get_categorymeta( $category['term_id'], 'use_additonal_form_set' );
557
+ $checkout_sets = get_option('wpsc_checkout_form_sets');
558
+ unset($checkout_sets[0]);
559
+ $uses_billing_address = (bool)wpsc_get_categorymeta( $category['term_id'], 'uses_billing_address' );
560
+ ?>
561
+ <tr class="form-field">
562
+ <th scope="row" valign="top">
563
+ <label for="image"><?php _e( 'Category requires additional checkout form fields', 'wpsc' ); ?></label>
564
+ </th>
565
+ <td>
566
+ <select name='use_additonal_form_set'>
567
+ <option value=''><?php _e( 'None', 'wpsc' ); ?></option>
568
+ <?php
569
+ foreach( (array) $checkout_sets as $key => $value ) {
570
+ $selected_state = "";
571
+ if( $used_additonal_form_set == $key )
572
+ $selected_state = "selected='selected'";
573
+ ?>
574
+ <option <?php echo $selected_state; ?> value='<?php echo $key; ?>'><?php echo stripslashes( $value ); ?></option>
575
+ <?php
576
+ }
577
+ ?>
578
+ </select><br />
579
+ </td>
580
+ </tr>
581
+
582
+ <tr class="form-field">
583
+ <th scope="row" valign="top">
584
+ <label for="image"><?php _e( 'Products in this category use the billing address to calculate shipping', 'wpsc' ); ?></label>
585
+ </th>
586
+ <td>
587
+ <input type='radio' class="wpsc_cat_box" value='1' name='uses_billing_address' <?php echo ( ( $uses_billing_address == true ) ? "checked='checked'" : "" ); ?> /><?php _e( 'Yes','wpsc' ); ?>
588
+ <input type='radio' class="wpsc_cat_box" value='0' name='uses_billing_address' <?php echo (($uses_billing_address != true) ? "checked='checked'" : ""); ?> /><?php _e( 'No','wpsc' ); ?>
589
+ <br />
590
+ </td>
591
+ </tr>
592
+
593
+ <?php
594
+ }
595
 
596
  /**
597
  * wpsc_save_category_set, Saves the category set data
598
  * @param nothing
599
  * @return nothing
600
  */
601
+ function wpsc_save_category_set($category_id, $tt_id) {
602
  global $wpdb;
603
+ if( !empty( $_POST ) ) {
 
 
604
  /* Image Processing Code*/
605
+ if( !empty( $_FILES['image'] ) && preg_match( "/\.(gif|jp(e)*g|png){1}$/i", $_FILES['image']['name'] ) ) {
606
+ if( function_exists( "getimagesize" ) ) {
607
+ if( ( (int) $_POST['width'] > 10 && (int) $_POST['width'] < 512 ) && ((int)$_POST['height'] > 10 && (int)$_POST['height'] < 512) ) {
608
+ $width = (int) $_POST['width'];
609
+ $height = (int) $_POST['height'];
610
+ image_processing( $_FILES['image']['tmp_name'], ( WPSC_CATEGORY_DIR.$_FILES['image']['name'] ), $width, $height );
611
  } else {
612
+ image_processing( $_FILES['image']['tmp_name'], ( WPSC_CATEGORY_DIR.$_FILES['image']['name'] ) );
613
  }
614
+ $image = $wpdb->escape( $_FILES['image']['name'] );
615
  } else {
616
+ $new_image_path = ( WPSC_CATEGORY_DIR.basename($_FILES['image']['name'] ) );
617
+ move_uploaded_file( $_FILES['image']['tmp_name'], $new_image_path );
618
+ $stat = stat( dirname( $new_image_path ) );
619
  $perms = $stat['mode'] & 0000666;
620
  @ chmod( $new_image_path, $perms );
621
+ $image = $wpdb->escape( $_FILES['image']['name'] );
622
  }
623
  } else {
624
  $image = '';
625
  }
626
+ //Good to here
 
 
 
 
 
 
 
627
 
628
+ $name = $_POST['name'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
629
 
630
+ if( isset( $_POST['tag_ID'] ) ) {
631
+ //Editing
632
+ $category_id= $_POST['tag_ID'];
633
+ $category = get_term_by( 'id', $category_id, 'wpsc_product_category' );
634
+ $url_name=$category->slug;
635
+
636
+ }
637
+ if(isset($_POST['deleteimage']) && $_POST['deleteimage'] == 1) {
638
+ wpsc_delete_categorymeta($category_id, 'image');
639
+ } else if($image != '') {
640
+ wpsc_update_categorymeta($category_id, 'image', $image);
641
+ }
642
+
643
+ if(is_numeric($_POST['height']) && is_numeric($_POST['width']) && ($image == null)) {
644
+ $imagedata = wpsc_get_categorymeta($category_id, 'image');
645
+ if($imagedata != null) {
646
+ $height = $_POST['height'];
647
+ $width = $_POST['width'];
648
+ $imagepath = WPSC_CATEGORY_DIR . $imagedata;
649
+ $image_output = WPSC_CATEGORY_DIR . $imagedata;
650
+ image_processing($imagepath, $image_output, $width, $height);
651
  }
652
+ }
653
 
654
+ wpsc_update_categorymeta($category_id, 'fee', '0');
655
+ wpsc_update_categorymeta($category_id, 'active', '1');
656
+ wpsc_update_categorymeta($category_id, 'order', '0');
657
 
658
+ wpsc_update_categorymeta($category_id, 'display_type',$wpdb->escape(stripslashes($_POST['display_type'])));
659
+ wpsc_update_categorymeta($category_id, 'image_height', $wpdb->escape(stripslashes($_POST['image_height'])));
660
+ wpsc_update_categorymeta($category_id, 'image_width', $wpdb->escape(stripslashes($_POST['image_width'])));
661
+
662
+
663
+ if($_POST['use_additonal_form_set'] != '') {
664
+ wpsc_update_categorymeta($category_id, 'use_additonal_form_set', $_POST['use_additonal_form_set']);
665
+ } else {
666
+ wpsc_delete_categorymeta($category_id, 'use_additonal_form_set');
667
+ }
668
+
669
+ if((bool)(int)$_POST['uses_billing_address'] == true) {
670
+ wpsc_update_categorymeta($category_id, 'uses_billing_address', 1);
671
+ $uses_additional_forms = true;
672
+ } else {
673
+ wpsc_update_categorymeta($category_id, 'uses_billing_address', 0);
674
+ $uses_additional_forms = false;
675
+ }
676
+
677
+ if(($_POST['countrylist2'] != null ) && ($category_id > 0)){
678
+ $AllSelected = false;
679
+ $countryList = $wpdb->get_col("SELECT `id` FROM `".WPSC_TABLE_CURRENCY_LIST."`");
680
+
681
+ if($AllSelected != true){
682
+ $unselectedCountries = array_diff($countryList, $_POST['countrylist2']);
683
+ //find the countries that are selected
684
+ $selectedCountries = array_intersect($countryList, $_POST['countrylist2']);
685
+ wpsc_update_categorymeta( $category_id, 'target_market', $selectedCountries);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
686
  }
 
 
 
 
 
 
 
 
687
 
688
+ }elseif(!isset($_POST['countrylist2'])){
689
+ wpsc_update_categorymeta( $category_id, 'target_market','');
690
+ $AllSelected = true;
691
+ }
692
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
693
  }
 
 
 
694
  }
695
 
696
 
wpsc-admin/includes/settings-pages/admin.php CHANGED
@@ -2,7 +2,7 @@
2
  function wpsc_options_admin(){
3
  global $wpdb;
4
  ?>
5
- <form name='cart_options' id='cart_options' method='post' action=''>
6
  <div id="options_admin">
7
  <h3><?php _e('Admin Settings', 'wpsc'); ?></h3>
8
  <?php
@@ -110,12 +110,12 @@ global $wpdb;
110
  <h3 class="form_group"><?php _e('Custom Messages', 'wpsc');?>:</h3>
111
  <table class='wpsc_options form-table'>
112
  <tr>
113
- <th colspan="2"><?php _e('Tags can be used', 'wpsc');?>: %shop_name%,<!-- %order_status%,--> %product_list%, %total_price%, %total_shipping%, %find_us%</th>
114
  </tr>
115
  <tr>
116
  <td class='wpsc_td_note' colspan='2'>
117
  <span class="wpscsmall description">
118
- Note: The purchase receipt is the message e-mailed to users after purchasing products from your shop.
119
  </span>
120
  </td>
121
  </tr>
@@ -126,7 +126,7 @@ global $wpdb;
126
  <tr>
127
  <td class='wpsc_td_note' colspan='2'>
128
  <span class="wpscsmall description">
129
- Note: The Admin Report is the email sent to the e-mail address set above as soon as someone successfully buys a product.
130
  </span>
131
  </td>
132
  </tr>
@@ -141,7 +141,7 @@ global $wpdb;
141
  <tr>
142
  <td class='wpsc_td_note' colspan='2'>
143
  <span class="wpscsmall description">
144
- Note: The Tracking Subject, is the subject for The Tracking Message email. The Tracking Message is the message e-mailed to users when you click 'Email buyer' on the sales log. This option is only available for purchases with the status of 'Job Dispatched'. Tags you can use in the email message section are %trackid% and %shop_name%
145
  </span>
146
  </td>
147
  </tr>
2
  function wpsc_options_admin(){
3
  global $wpdb;
4
  ?>
5
+ <form name='cart_options' id='cart_options' method='post' action='' class='wpsc_form_track'>
6
  <div id="options_admin">
7
  <h3><?php _e('Admin Settings', 'wpsc'); ?></h3>
8
  <?php
110
  <h3 class="form_group"><?php _e('Custom Messages', 'wpsc');?>:</h3>
111
  <table class='wpsc_options form-table'>
112
  <tr>
113
+ <th colspan="2"><?php _e('Tags can be used', 'wpsc');?>: %purchase_id%, %shop_name%,<!-- %order_status%,--> %product_list%, %total_price%, %total_shipping%, %find_us%, %total_tax%</th>
114
  </tr>
115
  <tr>
116
  <td class='wpsc_td_note' colspan='2'>
117
  <span class="wpscsmall description">
118
+ <?php _e('Note: The purchase receipt is the message e-mailed to users after purchasing products from your shop.' , 'wpsc'); ?>
119
  </span>
120
  </td>
121
  </tr>
126
  <tr>
127
  <td class='wpsc_td_note' colspan='2'>
128
  <span class="wpscsmall description">
129
+ <?php _e('Note: The Admin Report is the email sent to the e-mail address set above as soon as someone successfully buys a product.' , 'wpsc'); ?>
130
  </span>
131
  </td>
132
  </tr>
141
  <tr>
142
  <td class='wpsc_td_note' colspan='2'>
143
  <span class="wpscsmall description">
144
+ <?php _e('Note: The Tracking Subject, is the subject for The Tracking Message email. The Tracking Message is the message e-mailed to users when you click \'Email buyer\' on the sales log. This option is only available for purchases with the status of \'Job Dispatched\'. Tags you can use in the email message section are %trackid% and %shop_name%' , 'wpsc'); ?>
145
  </span>
146
  </td>
147
  </tr>
wpsc-admin/includes/settings-pages/checkout.php CHANGED
@@ -1,48 +1,30 @@
1
  <?php
2
  function wpsc_options_checkout(){
3
- global $wpdb;
4
- $form_types = Array("Text" => "text",
5
- "Email Address" => "email",
6
- "Street Address" => "address",
7
- "City" => "city",
8
- "Country" => "country",
9
- "Delivery Address" => "delivery_address",
10
- "Delivery City" => "delivery_city",
11
- "Delivery Country" => "delivery_country",
12
- "Text Area" => "textarea",
13
- "Heading" => "heading",
14
- "Select" => "select",
15
- "Radio Button" => "radio",
16
- "Checkbox" => "checkbox"
17
- );
18
 
19
- $unique_names = Array('billingfirstname','billinglastname','billingaddress','billingcity','billingstate','billingcountry','billingemail','billingphone','billingpostcode','delivertoafriend','shippingfirstname','shippinglastname','shippingaddress','shippingcity','shippingstate','shippingcountry','shippingpostcode');
 
 
 
 
 
 
 
 
 
20
 
21
- update_option('wpsc_checkout_form_fields', $form_types);
22
- if(get_option('wpsc_checkout_form_fields') == ''){
23
- update_option('wpsc_checkout_form_fields', $form_types);
24
- }
25
- do_action('wpsc_checkout_form_fields_page');
26
- $columns = array(
27
- 'drag' => 'Drag',
28
- 'name' => 'Name',
29
- 'type' => 'Type',
30
- 'unique_names' => 'Unique Names',
31
- 'mandatory' => 'Mandatory',
32
- 'trash' => 'Trash',
33
- );
34
- register_column_headers('display-checkout-list', $columns);
35
- $form_types = get_option('wpsc_checkout_form_fields');
36
-
37
- ?>
38
 
39
- <form name='cart_options' id='cart_options' method='post' action=''>
40
  <div class="wrap">
41
  <?php
42
  /* wpsc_setting_page_update_notification displays the wordpress styled notifications */
43
  wpsc_settings_page_update_notification(); ?>
44
 
45
- <form method='post' action='' id='chekcout_options_tbl'>
46
  <div class='metabox-holder' style='width:95%;'>
47
  <div class='postbox'>
48
  <input type='hidden' name='checkout_submits' value='true' />
@@ -154,12 +136,12 @@ $form_types = get_option('wpsc_checkout_form_fields');
154
 
155
  <?php
156
  if(!isset($_GET['checkout-set']) || ($_GET['checkout-set'] == 0)) {
157
- $form_sql = "SELECT * FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `active` = '1' AND `checkout_set` IN ('0', '') ORDER BY `order`;";
158
  } else {
159
  $filter = $wpdb->escape($_GET['checkout-set']);
160
- $form_sql = "SELECT * FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `active` = '1' AND `checkout_set` IN ('".$filter."') ORDER BY `order`;";
161
  }
162
- $email_form_field = $wpdb->get_row("SELECT `id` FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `type` IN ('email') AND `active` = '1' ORDER BY `order` ASC LIMIT 1",ARRAY_A);
163
 
164
 
165
  $form_data = $wpdb->get_results($form_sql,ARRAY_A);
1
  <?php
2
  function wpsc_options_checkout(){
3
+ global $wpdb;
4
+ $form_types = get_option('wpsc_checkout_form_fields');
5
+ $unique_names = get_option('wpsc_checkout_unique_names');
 
 
 
 
 
 
 
 
 
 
 
 
6
 
7
+ do_action('wpsc_checkout_form_fields_page');
8
+ $columns = array(
9
+ 'drag' => 'Drag',
10
+ 'name' => 'Name',
11
+ 'type' => 'Type',
12
+ 'unique_names' => 'Unique Names',
13
+ 'mandatory' => 'Mandatory',
14
+ 'trash' => 'Trash',
15
+ );
16
+ register_column_headers('display-checkout-list', $columns);
17
 
18
+
19
+ ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
+ <form name='cart_options' id='cart_options' method='post' action='' class='wpsc_form_track'>
22
  <div class="wrap">
23
  <?php
24
  /* wpsc_setting_page_update_notification displays the wordpress styled notifications */
25
  wpsc_settings_page_update_notification(); ?>
26
 
27
+ <form method='post' action='' id='chekcout_options_tbl' class='wpsc_form_track'>
28
  <div class='metabox-holder' style='width:95%;'>
29
  <div class='postbox'>
30
  <input type='hidden' name='checkout_submits' value='true' />
136
 
137
  <?php
138
  if(!isset($_GET['checkout-set']) || ($_GET['checkout-set'] == 0)) {
139
+ $form_sql = "SELECT * FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `active` = '1' AND `checkout_set` IN ('0', '') ORDER BY `checkout_order`;";
140
  } else {
141
  $filter = $wpdb->escape($_GET['checkout-set']);
142
+ $form_sql = "SELECT * FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `active` = '1' AND `checkout_set` IN ('".$filter."') ORDER BY `checkout_order`;";
143
  }
144
+ $email_form_field = $wpdb->get_row("SELECT `id` FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `type` IN ('email') AND `active` = '1' ORDER BY `checkout_order` ASC LIMIT 1",ARRAY_A);
145
 
146
 
147
  $form_data = $wpdb->get_results($form_sql,ARRAY_A);
wpsc-admin/includes/settings-pages/gateway.php CHANGED
@@ -48,7 +48,7 @@ function wpsc_options_gateway() {
48
 
49
  <div class="wrap">
50
  <div class='metabox-holder'>
51
- <form name='gatewayopt' method='post' id='gateway_opt' action='' >
52
  <input type='hidden' name='gateway_submits' value='true' />
53
  <input type='hidden' name='wpsc_gateway_settings' value='gateway_settings' />
54
  <?php
@@ -125,6 +125,7 @@ function wpsc_options_gateway() {
125
  <td class='gateway_settings' rowspan='2'>
126
  <div class='postbox'>
127
  <?php
 
128
  if ( !isset( $_SESSION['previous_payment_name'] ) )
129
  $_SESSION['previous_payment_name'] = "";
130
  if ( !isset( $selected_gateway_data ) )
@@ -133,15 +134,14 @@ function wpsc_options_gateway() {
133
  ?>
134
  <h3 class='hndle'><?php echo $payment_data['name']; ?></h3>
135
  <div class='inside'>
136
- <table class='form-table'>
137
- <?php echo $payment_data['form_fields']; ?>
138
  </table>
139
  <?php
140
- if ( $payment_data['has_submit_button'] == 0 ) {
141
  $update_button_css = 'style= "display: none;"';
142
- } else {
143
  $update_button_css = '';
144
- }
145
  ?>
146
  <div class='submit' <?php echo $update_button_css; ?>>
147
  <?php wp_nonce_field( 'update-options', 'wpsc-update-options' ); ?>
48
 
49
  <div class="wrap">
50
  <div class='metabox-holder'>
51
+ <form name='gatewayopt' method='post' id='gateway_opt' action='' class='wpsc_form_track'>
52
  <input type='hidden' name='gateway_submits' value='true' />
53
  <input type='hidden' name='wpsc_gateway_settings' value='gateway_settings' />
54
  <?php
125
  <td class='gateway_settings' rowspan='2'>
126
  <div class='postbox'>
127
  <?php
128
+
129
  if ( !isset( $_SESSION['previous_payment_name'] ) )
130
  $_SESSION['previous_payment_name'] = "";
131
  if ( !isset( $selected_gateway_data ) )
134
  ?>
135
  <h3 class='hndle'><?php echo $payment_data['name']; ?></h3>
136
  <div class='inside'>
137
+ <table class='form-table'>
138
+ <?php echo $payment_data['form_fields']; ?>
139
  </table>
140
  <?php
141
+ if ( $payment_data['has_submit_button'] == 0 )
142
  $update_button_css = 'style= "display: none;"';
143
+ else
144
  $update_button_css = '';
 
145
  ?>
146
  <div class='submit' <?php echo $update_button_css; ?>>
147
  <?php wp_nonce_field( 'update-options', 'wpsc-update-options' ); ?>
wpsc-admin/includes/settings-pages/general.php CHANGED
@@ -3,7 +3,7 @@
3
  function wpsc_options_general() {
4
  global $wpdb;
5
  ?>
6
- <form method='post' action='' id='cart_options' name='cart_options'>
7
  <div id="options_general">
8
  <h3><?php _e( 'General Settings', 'wpsc' ); ?></h3>
9
  <?php
3
  function wpsc_options_general() {
4
  global $wpdb;
5
  ?>
6
+ <form method='post' action='' id='cart_options' name='cart_options' class='wpsc_form_track'>
7
  <div id="options_general">
8
  <h3><?php _e( 'General Settings', 'wpsc' ); ?></h3>
9
  <?php
wpsc-admin/includes/settings-pages/import.php CHANGED
@@ -7,7 +7,7 @@
7
  function wpsc_options_import() {
8
  global $wpdb;
9
  ?>
10
- <form name='cart_options' enctype='multipart/form-data' id='cart_options' method='post' action='<?php echo 'admin.php?page=wpsc-settings&tab=import'; ?>'>
11
  <div class="wrap">
12
  <?php _e( '<p>You can import your products from a comma delimited text file.</p><p>An example of a csv import file would look like this: </p><p>Description, Additional Description, Product Name, Price, SKU, weight, weight unit, stock quantity, is limited quantity</p>', 'wpsc' ); ?>
13
 
7
  function wpsc_options_import() {
8
  global $wpdb;
9
  ?>
10
+ <form name='cart_options' enctype='multipart/form-data' id='cart_options' method='post' action='<?php echo 'admin.php?page=wpsc-settings&tab=import'; ?>' class='wpsc_form_track'>
11
  <div class="wrap">
12
  <?php _e( '<p>You can import your products from a comma delimited text file.</p><p>An example of a csv import file would look like this: </p><p>Description, Additional Description, Product Name, Price, SKU, weight, weight unit, stock quantity, is limited quantity</p>', 'wpsc' ); ?>
13
 
wpsc-admin/includes/settings-pages/marketing.php CHANGED
@@ -53,7 +53,7 @@ function wpsc_marketing_meta_box() {
53
  $display_find_us1 = "checked ='checked'"; ?>
54
 
55
 
56
- <form method='post' action='' id='cart_options' name='cart_options'>
57
  <input type='hidden' name='change-settings' value='true' />
58
  <p>
59
  <span class='input_label'><?php _e( 'Display Cross Sales', 'wpsc' ); ?></span>
53
  $display_find_us1 = "checked ='checked'"; ?>
54
 
55
 
56
+ <form method='post' action='' id='cart_options' name='cart_options' class='wpsc_form_track'>
57
  <input type='hidden' name='change-settings' value='true' />
58
  <p>
59
  <span class='input_label'><?php _e( 'Display Cross Sales', 'wpsc' ); ?></span>
wpsc-admin/includes/settings-pages/presentation.php CHANGED
@@ -45,9 +45,20 @@ function wpsc_theme_presentation_page_metabox(){
45
  ?>
46
  <div id="poststuff" class="metabox-holder">
47
  <div id="themes_and_appearance" class='postbox'>
48
- <h3 class="hndle"><span><?php _e( "Theme Settings", 'wpsc' ); ?></span></h3>
49
  <div class="inside">
50
  <?php
 
 
 
 
 
 
 
 
 
 
 
51
  if ( isset( $_SESSION['wpsc_themes_copied'] ) && ($_SESSION['wpsc_themes_copied'] == true) ) {
52
  ?>
53
  <div class="updated fade below-h2" id="message" style="background-color: rgb(255, 251, 204);">
@@ -67,19 +78,19 @@ function wpsc_theme_presentation_page_metabox(){
67
  }
68
  ?>
69
  <p>
70
- <?php if(false !== $themes_location){
71
  //Some themes have been moved to the themes folder
72
  _e('Some Theme files have been moved to your WordPress Theme Folder.','wpsc');
73
- ?>
74
-
75
- <?php }else{
76
- //No themes have been moved to the theme folder
77
- _e('No Theme files have been moved to your WordPress Theme Folder.','wpsc');
78
- }?>
79
-
80
  </p>
81
  <p>
82
- <?php _e('These are the template files, used for WP e-Commerce. If you anticipate changing the look of your site, select the files you would like to edit from the list bellow, and we will move them to your active WordPress Theme.','wpsc'); ?>
 
 
83
  </p>
84
  <ul>
85
  <?php
@@ -95,18 +106,27 @@ function wpsc_theme_presentation_page_metabox(){
95
  </ul>
96
  <p>
97
  <?php if(false !== $themes_location){
98
- _e('To change the look of certain aspects of your shop, you can edit the moved files found here:','wpsc');
99
  ?>
100
  </p>
101
- <p class="howto"><?php echo get_stylesheet_directory(); ?></p>
102
  <?php } ?>
103
  <p><?php
104
  wp_nonce_field('wpsc_copy_themes');
105
  ?>
106
- <input type='submit' value='Move Template Files' class="button" name='wpsc_move_themes' />
107
- <?php printf( __( '<a href="%s" class="button preview">Backup Your Theme</a>', 'wpsc' ), wp_nonce_url( 'admin.php?wpsc_admin_action=backup_themes', 'backup_themes' ) ); ?>
108
- <?php printf( __( '<a href="%s" class="button preview">Flush Theme Cache</a>', 'wpsc' ), wp_nonce_url( 'admin.php?wpsc_flush_theme_transients=true', 'wpsc_flush_theme_transients' ) ); ?>
 
 
 
 
 
109
  </p>
 
 
 
 
110
  <br style="clear:both" />
111
  <br style="clear:both" />
112
  </div>
@@ -143,6 +163,7 @@ function options_categorylist() {
143
  $selected = '';
144
 
145
  $categorylist .= "<option value='list' " . $selected . " >" . __( 'Show list of product categories', 'wpsc' ) . "</option>";
 
146
 
147
  if ( get_option( 'wpsc_default_category' ) == 'all+list' )
148
  $selected = "selected='selected'";
@@ -150,6 +171,7 @@ function options_categorylist() {
150
  $selected = '';
151
 
152
  $categorylist .= "<option value='all+list' " . $selected . " >" . __( 'Show all products + list', 'wpsc' ) . "</option>";
 
153
  $categorylist .= "<optgroup label='Product Categories'>";
154
  foreach ( $group_data as $group ) {
155
  $selected = "";
@@ -188,7 +210,7 @@ function wpsc_options_presentation() {
188
 
189
  ?>
190
 
191
- <form name='cart_options' id='cart_options' method='post' action=''>
192
  <div id="options_presentation">
193
 
194
  <?php wpsc_settings_page_update_notification(); ?>
@@ -511,9 +533,24 @@ function wpsc_options_presentation() {
511
  </td>
512
  </tr>
513
  <?php
514
- // }
 
 
 
 
 
 
 
515
  ?>
516
-
 
 
 
 
 
 
 
 
517
  <tr>
518
  <th scope="row"><?php _e( 'Select what product category you want to display on the products page', 'wpsc' ); ?>:</th>
519
  <td>
@@ -708,6 +745,28 @@ function wpsc_options_presentation() {
708
  <input type='radio' value='0' name='wpsc_options[wpsc_replace_page_title]' id='wpsc_replace_page_title2' <?php echo $wpsc_replace_page_title2; ?> /> <label for='wpsc_replace_page_title2'><?php _e( 'No', 'wpsc' ); ?></label>
709
  </td>
710
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
711
  </table>
712
 
713
  <h3 class="form_group"><?php _e( 'Shopping Cart Settings', 'wpsc' ); ?></h3>
@@ -922,14 +981,15 @@ function wpsc_options_presentation() {
922
 
923
 
924
  <h3 class="form_group"><a name='thumb_settings'><?php _e( 'Thumbnail Settings', 'wpsc' ); ?></a></h3>
925
- <p><em>Note: Anytime you update any of the thumbnail settings, WPeC will automatically resize all of your thumbnails for you. Depending on how many images you have, this could take awhile.</em></p>
926
  <table class='wpsc_options form-table'>
927
  <?php if ( function_exists( "getimagesize" ) ) { ?>
928
  <tr>
929
  <th scope="row"><?php _e( 'Default Product Thumbnail Size', 'wpsc' ); ?>:</th>
930
  <td>
931
- <?php _e( 'Height', 'wpsc' ); ?>:<input type='text' size='6' name='wpsc_options[product_image_height]' class='wpsc_prod_thumb_option' value='<?php echo get_option( 'product_image_height' ); ?>' />
932
  <?php _e( 'Width', 'wpsc' ); ?>:<input type='text' size='6' name='wpsc_options[product_image_width]' class='wpsc_prod_thumb_option' value='<?php echo get_option( 'product_image_width' ); ?>' />
 
 
933
  </td>
934
  </tr>
935
  <tr>
@@ -937,7 +997,8 @@ function wpsc_options_presentation() {
937
  <?php _e( 'Default Product Group Thumbnail Size', 'wpsc' ); ?>:
938
  </th>
939
  <td>
940
- <?php _e( 'Height', 'wpsc' ); ?>:<input type='text' size='6' name='wpsc_options[category_image_height]' value='<?php echo get_option( 'category_image_height' ); ?>' /> <?php _e( 'Width', 'wpsc' ); ?>:<input type='text' size='6' name='wpsc_options[category_image_width]' value='<?php echo get_option( 'category_image_width' ); ?>' />
 
941
  </td>
942
  </tr>
943
  <tr>
@@ -945,7 +1006,8 @@ function wpsc_options_presentation() {
945
  <?php _e( 'Single Product Image Size', 'wpsc' ); ?>:
946
  </th>
947
  <td>
948
- <?php _e( 'Height', 'wpsc' ); ?>:<input type='text' size='6' name='wpsc_options[single_view_image_height]' value='<?php echo get_option( 'single_view_image_height' ); ?>' /> <?php _e( 'Width', 'wpsc' ); ?>:<input type='text' size='6' name='wpsc_options[single_view_image_width]' value='<?php echo get_option( 'single_view_image_width' ); ?>' />
 
949
  </td>
950
  </tr>
951
  <tr>
45
  ?>
46
  <div id="poststuff" class="metabox-holder">
47
  <div id="themes_and_appearance" class='postbox'>
48
+ <h3 class="hndle"><span><?php _e( "Advanced Theme Settings", 'wpsc' ); ?></span></h3>
49
  <div class="inside">
50
  <?php
51
+
52
+ if( isset( $_SESSION['wpsc_theme_empty'] ) && ($_SESSION['wpsc_theme_empty'] == true) ) {
53
+ ?>
54
+
55
+ <div class="updated fade below-h2" id="message" style="background-color: rgb(255, 251, 204);">
56
+ <p><?php _e('You did not specify any template files to be moved.','wpsc'); ?></p>
57
+ </div>
58
+ <?php
59
+ $_SESSION['wpsc_theme_empty'] = false;
60
+ $themes_copied = false;
61
+ }
62
  if ( isset( $_SESSION['wpsc_themes_copied'] ) && ($_SESSION['wpsc_themes_copied'] == true) ) {
63
  ?>
64
  <div class="updated fade below-h2" id="message" style="background-color: rgb(255, 251, 204);">
78
  }
79
  ?>
80
  <p>
81
+ <?php if(false !== $themes_location)
82
  //Some themes have been moved to the themes folder
83
  _e('Some Theme files have been moved to your WordPress Theme Folder.','wpsc');
84
+ else
85
+ _e('No Theme files have been moved to your WordPress Theme Folder.','wpsc');
86
+
87
+ ?>
88
+
 
 
89
  </p>
90
  <p>
91
+ <?php _e('WP e-Commerce provides you the ability to move your theme files to a safe place for theming control.
92
+
93
+ If you want to change the look of your site, select the files you want to edit from the list and click the move button. This will copy the template files to your active WordPress theme. ','wpsc'); ?>
94
  </p>
95
  <ul>
96
  <?php
106
  </ul>
107
  <p>
108
  <?php if(false !== $themes_location){
109
+ _e('To change the look of certain aspects of your shop, you can edit the moved files that are found here:','wpsc');
110
  ?>
111
  </p>
112
+ <p class="howto"> <?php echo get_stylesheet_directory(); ?></p>
113
  <?php } ?>
114
  <p><?php
115
  wp_nonce_field('wpsc_copy_themes');
116
  ?>
117
+ <input type='submit' value='Move Template Files &rarr;' class="button" name='wpsc_move_themes' />
118
+ </p>
119
+ <p><?php _e('You can create a copy of your WordPress Theme by clicking the backup button bellow. Once copied you can find them here:' ,'wpsc'); ?></p>
120
+ <p class="howto"> /wp-content/uploads/wpsc/theme_backup/ </p>
121
+ <p>
122
+ <?php
123
+ printf( __( '<a href="%s" class="button">Backup Your WordPress Theme</a>', 'wpsc' ), wp_nonce_url( 'admin.php?wpsc_admin_action=backup_themes', 'backup_themes' ) ); ?>
124
+ <br style="clear:both" />
125
  </p>
126
+
127
+ <br style="clear:both" />
128
+ <p><?php _e('If you have moved your files in some other way i.e FTP, you may need to click the Flush Theme Cache. This will refresh the locations WordPress looks for your templates.' ,'wpsc'); ?></p>
129
+ <p><?php printf( __( '<a href="%s" class="button">Flush Theme Cache</a>', 'wpsc' ), wp_nonce_url( 'admin.php?wpsc_flush_theme_transients=true', 'wpsc_flush_theme_transients' ) ); ?></p>
130
  <br style="clear:both" />
131
  <br style="clear:both" />
132
  </div>
163
  $selected = '';
164
 
165
  $categorylist .= "<option value='list' " . $selected . " >" . __( 'Show list of product categories', 'wpsc' ) . "</option>";
166
+ /*
167
 
168
  if ( get_option( 'wpsc_default_category' ) == 'all+list' )
169
  $selected = "selected='selected'";
171
  $selected = '';
172
 
173
  $categorylist .= "<option value='all+list' " . $selected . " >" . __( 'Show all products + list', 'wpsc' ) . "</option>";
174
+ */
175
  $categorylist .= "<optgroup label='Product Categories'>";
176
  foreach ( $group_data as $group ) {
177
  $selected = "";
210
 
211
  ?>
212
 
213
+ <form name='cart_options' id='cart_options' method='post' action='' class='wpsc_form_track'>
214
  <div id="options_presentation">
215
 
216
  <?php wpsc_settings_page_update_notification(); ?>
533
  </td>
534
  </tr>
535
  <?php
536
+ if(get_option('wpsc_display_categories')){
537
+ $selected1 = 'checked="checked"';
538
+ $selected2 = '';
539
+ }else{
540
+ $selected1 = '';
541
+ $selected2 = 'checked="checked"';
542
+ }
543
+
544
  ?>
545
+ <tr>
546
+ <th scope="row"><?php _e('Show list of categories','wpsc'); ?></th>
547
+ <td>
548
+ <input type='radio' value='1' name='wpsc_options[wpsc_display_categories]' id='display_categories2' <?php echo $selected1; ?> /> <label for='display_addtocart'><?php _e( 'Yes', 'wpsc' ); ?></label>
549
+ <input type='radio' value='0' name='wpsc_options[wpsc_display_categories]' id='display_categories1' <?php echo $selected2; ?> />
550
+ <label for='display_addtocart'><?php _e( 'No', 'wpsc' ); ?></label><br />
551
+ </td>
552
+ </tr>
553
+
554
  <tr>
555
  <th scope="row"><?php _e( 'Select what product category you want to display on the products page', 'wpsc' ); ?>:</th>
556
  <td>
745
  <input type='radio' value='0' name='wpsc_options[wpsc_replace_page_title]' id='wpsc_replace_page_title2' <?php echo $wpsc_replace_page_title2; ?> /> <label for='wpsc_replace_page_title2'><?php _e( 'No', 'wpsc' ); ?></label>
746
  </td>
747
  </tr>
748
+ <tr>
749
+ <th scope="row"><?php _e( 'Display Featured Product above Product Pages', 'wpsc' ); ?>:</th>
750
+ <td>
751
+ <?php
752
+ $wpsc_hide_featured_products = get_option( 'wpsc_hide_featured_products' );
753
+ $wpsc_hide_featured_products1 = "";
754
+ $wpsc_hide_featured_products2 = "";
755
+ switch ( $wpsc_hide_featured_products ) {
756
+ case 0:
757
+ $wpsc_hide_featured_products2 = "checked ='checked'";
758
+ break;
759
+
760
+ case 1:
761
+ default:
762
+ $wpsc_hide_featured_products1 = "checked ='checked'";
763
+ break;
764
+ }
765
+ ?>
766
+ <input type='radio' value='1' name='wpsc_options[wpsc_hide_featured_products]' id='wpsc_hide_featured_products1' <?php echo $wpsc_hide_featured_products1; ?> /> <label for='wpsc_hide_featured_products1'><?php _e( 'Yes', 'wpsc' ); ?></label> &nbsp;
767
+ <input type='radio' value='0' name='wpsc_options[wpsc_hide_featured_products]' id='wpsc_hide_featured_products2' <?php echo $wpsc_hide_featured_products2; ?> /> <label for='wpsc_hide_featured_products2'><?php _e( 'No', 'wpsc' ); ?></label>
768
+ </td>
769
+ </tr>
770
  </table>
771
 
772
  <h3 class="form_group"><?php _e( 'Shopping Cart Settings', 'wpsc' ); ?></h3>
981
 
982
 
983
  <h3 class="form_group"><a name='thumb_settings'><?php _e( 'Thumbnail Settings', 'wpsc' ); ?></a></h3>
984
+ <p><em><?php _e('Note: Anytime you update any of the thumbnail settings, WPeC will automatically resize all of your thumbnails for you. Depending on how many images you have, this could take awhile.','wpsc'); ?></em></p>
985
  <table class='wpsc_options form-table'>
986
  <?php if ( function_exists( "getimagesize" ) ) { ?>
987
  <tr>
988
  <th scope="row"><?php _e( 'Default Product Thumbnail Size', 'wpsc' ); ?>:</th>
989
  <td>
 
990
  <?php _e( 'Width', 'wpsc' ); ?>:<input type='text' size='6' name='wpsc_options[product_image_width]' class='wpsc_prod_thumb_option' value='<?php echo get_option( 'product_image_width' ); ?>' />
991
+ <?php _e( 'Height', 'wpsc' ); ?>:<input type='text' size='6' name='wpsc_options[product_image_height]' class='wpsc_prod_thumb_option' value='<?php echo get_option( 'product_image_height' ); ?>' />
992
+
993
  </td>
994
  </tr>
995
  <tr>
997
  <?php _e( 'Default Product Group Thumbnail Size', 'wpsc' ); ?>:
998
  </th>
999
  <td>
1000
+ <?php _e( 'Width', 'wpsc' ); ?>:<input type='text' size='6' name='wpsc_options[category_image_width]' value='<?php echo get_option( 'category_image_width' ); ?>' />
1001
+ <?php _e( 'Height', 'wpsc' ); ?>:<input type='text' size='6' name='wpsc_options[category_image_height]' value='<?php echo get_option( 'category_image_height' ); ?>' />
1002
  </td>
1003
  </tr>
1004
  <tr>
1006
  <?php _e( 'Single Product Image Size', 'wpsc' ); ?>:
1007
  </th>
1008
  <td>
1009
+ <?php _e( 'Width', 'wpsc' ); ?>:<input type='text' size='6' name='wpsc_options[single_view_image_width]' value='<?php echo get_option( 'single_view_image_width' ); ?>' />
1010
+ <?php _e( 'Height', 'wpsc' ); ?>:<input type='text' size='6' name='wpsc_options[single_view_image_height]' value='<?php echo get_option( 'single_view_image_height' ); ?>' />
1011
  </td>
1012
  </tr>
1013
  <tr>
wpsc-admin/includes/settings-pages/shipping.php CHANGED
@@ -2,8 +2,9 @@
2
 
3
  function wpsc_options_shipping() {
4
  global $wpdb, $wpsc_shipping_modules, $external_shipping_modules, $internal_shipping_modules;
5
- // sort into external and internal arrays.
6
  foreach ( $GLOBALS['wpsc_shipping_modules'] as $key => $module ) {
 
7
  if ( isset( $module->is_external ) && ($module->is_external == true) ) {
8
  $external_shipping_modules[$key] = $module;
9
  } else {
@@ -16,10 +17,10 @@ function wpsc_options_shipping() {
16
  } else {
17
  $currency_sign = $currency_data['code'];
18
  }
19
- //get shipping options that are selected
20
  $selected_shippings = get_option( 'custom_shipping_options' );
21
  ?>
22
- <form name='cart_options' id='cart_options' method='post' action=''>
23
 
24
  <script type='text/javascript'>
25
  function selectgateway() {
@@ -28,7 +29,7 @@ function wpsc_options_shipping() {
28
  </script>
29
  <div class="wrap">
30
  <div class="metabox-holder">
31
- <form name='shippingopt' method='post' id='shipping_options' action=''>
32
  <input type='hidden' name='shipping_submits' value='true' />
33
  <?php wp_nonce_field( 'update-options', 'wpsc-update-options' ); ?>
34
  <input type='hidden' name='wpsc_admin_action' value='submit_options' />
@@ -155,7 +156,15 @@ function wpsc_options_shipping() {
155
  </td>
156
 
157
  </tr>
 
 
 
 
 
 
 
158
  <?php do_action('wpsc_shipping_settings_page'); ?>
 
159
  </table>
160
  </div>
161
  </div>
@@ -204,7 +213,7 @@ function wpsc_options_shipping() {
204
  // print the internal shipping methods
205
  foreach ( $external_shipping_modules as $shipping ) {
206
  $disabled = '';
207
- if ( ($shipping->requires_curl == true) && !function_exists( 'curl_init' ) ) {
208
  $disabled = "disabled='disabled'";
209
  }
210
  $shipping->checked = '';
@@ -244,9 +253,10 @@ function wpsc_options_shipping() {
244
  <?php echo $shipping_data['form_fields']; ?>
245
  </table>
246
  <?php
247
- if ( $shipping_data['has_submit_button'] == 0 ) {
248
  $update_button_css = 'style= "display: none;"';
249
- }
 
250
  ?>
251
  <div class='submit' <?php echo $update_button_css; ?>>
252
  <input type='submit' value='<?php _e( 'Update &raquo;', 'wpsc' ); ?>' name='updateoption' />
2
 
3
  function wpsc_options_shipping() {
4
  global $wpdb, $wpsc_shipping_modules, $external_shipping_modules, $internal_shipping_modules;
5
+ // sort into external and internal arrays.
6
  foreach ( $GLOBALS['wpsc_shipping_modules'] as $key => $module ) {
7
+ if(empty($module))continue;
8
  if ( isset( $module->is_external ) && ($module->is_external == true) ) {
9
  $external_shipping_modules[$key] = $module;
10
  } else {
17
  } else {
18
  $currency_sign = $currency_data['code'];
19
  }
20
+ //get shipping options that are selected
21
  $selected_shippings = get_option( 'custom_shipping_options' );
22
  ?>
23
+ <form name='cart_options' id='cart_options' method='post' action='' class='wpsc_form_track'>
24
 
25
  <script type='text/javascript'>
26
  function selectgateway() {
29
  </script>
30
  <div class="wrap">
31
  <div class="metabox-holder">
32
+ <form name='shippingopt' method='post' id='shipping_options' action='' class='wpsc_form_track'>
33
  <input type='hidden' name='shipping_submits' value='true' />
34
  <?php wp_nonce_field( 'update-options', 'wpsc-update-options' ); ?>
35
  <input type='hidden' name='wpsc_admin_action' value='submit_options' />
156
  </td>
157
 
158
  </tr>
159
+ <tr>
160
+ <td>
161
+ <div class='submit' <?php echo $update_button_css; ?>>
162
+ <input type='submit' value='<?php _e( 'Update &raquo;', 'wpsc' ); ?>' name='updateoption' />
163
+ </div>
164
+ </td>
165
+ </tr>
166
  <?php do_action('wpsc_shipping_settings_page'); ?>
167
+
168
  </table>
169
  </div>
170
  </div>
213
  // print the internal shipping methods
214
  foreach ( $external_shipping_modules as $shipping ) {
215
  $disabled = '';
216
+ if ( isset($shipping->requires_curl) && ($shipping->requires_curl == true) && !function_exists( 'curl_init' ) ) {
217
  $disabled = "disabled='disabled'";
218
  }
219
  $shipping->checked = '';
253
  <?php echo $shipping_data['form_fields']; ?>
254
  </table>
255
  <?php
256
+ if ( $shipping_data['has_submit_button'] == 0 )
257
  $update_button_css = 'style= "display: none;"';
258
+ else
259
+ $update_button_css = '';
260
  ?>
261
  <div class='submit' <?php echo $update_button_css; ?>>
262
  <input type='submit' value='<?php _e( 'Update &raquo;', 'wpsc' ); ?>' name='updateoption' />
wpsc-admin/includes/settings-pages/taxes.php CHANGED
@@ -1,183 +1,188 @@
1
- <?php
2
-
3
- function wpec_options_taxes() {
4
- $wpec_taxes_controller = new wpec_taxes_controller;
5
- $wpec_taxes_options = $wpec_taxes_controller->wpec_taxes->wpec_taxes_get_options();
6
-
7
- //include standard shopping cart notifications
8
- wpsc_settings_page_update_notification();
9
- ?>
10
- <form name='wpec_taxes_options' id='wpec_taxes_options' method='post' action=''>
11
- <div class="wrap">
12
- <h3><?php _e( 'Tax Settings' ); ?></h3>
13
- <p>
14
- <label for='wpec_taxes_enabled'>
15
- <input <?php if ( $wpec_taxes_options['wpec_taxes_enabled'] ) {
16
- echo 'checked="checked"';
17
- } ?> type="checkbox" id='wpec_taxes_enabled' name='wpsc_options[wpec_taxes_enabled]' />
18
- <?php _e( 'Turn tax on' ); ?>
19
- </label>
20
- </p>
21
- <p>
22
- <label for='wpec_taxes_inprice1'>
23
- <input <?php if ( $wpec_taxes_options['wpec_taxes_inprice'] == 'exclusive' ) {
24
- echo 'checked="checked"';
25
- } ?> type="radio" value='exclusive' id='wpec_taxes_inprice1' name='wpsc_options[wpec_taxes_inprice]' />
26
- <?php _e( 'Product prices are tax exclusive - add tax to the price during checkout' ); ?>
27
- </label>
28
- </p>
29
- <p>
30
- <label for='wpec_taxes_inprice2'>
31
- <input <?php if ( $wpec_taxes_options['wpec_taxes_inprice'] == 'inclusive' ) {
32
- echo 'checked="checked"';
33
- } ?> type="radio" value='inclusive' id='wpec_taxes_inprice2' name='wpsc_options[wpec_taxes_inprice]' />
34
- <?php _e( "Product prices are tax inclusive - during checkout the total price doesn't increase but tax is shown as a line item" ); ?>
35
- </label>
36
- </p>
37
- <h4><?php _e( 'Product Specific Tax' ); ?></h4>
38
- <p>
39
- <label for='wpec_taxes_product_1'>
40
- <input <?php if ( $wpec_taxes_options['wpec_taxes_product'] == 'add' ) {
41
- echo 'checked="checked"';
42
- } ?> type="radio" value='add' id='wpec_taxes_product_1' name='wpsc_options[wpec_taxes_product]' />
43
- <?php _e( 'Add per product tax to tax percentage if product has a specific tax rate' ); ?>
44
- </label>
45
- </p>
46
- <p>
47
- <label for='wpec_taxes_product_2'>
48
- <input <?php if ( $wpec_taxes_options['wpec_taxes_product'] == 'replace' ) {
49
- echo 'checked="checked"';
50
- } ?> type="radio" value='replace' id='wpec_taxes_product_2' name='wpsc_options[wpec_taxes_product]' />
51
- <?php _e( 'Replace tax percentage with product specific tax rate' ); ?>
52
- </label>
53
- </p>
54
-
55
- <h4><?php _e( 'Tax Logic' ); ?></h4>
56
- <p>
57
- <label for='wpec_taxes_logic_1'>
58
- <input <?php if ( $wpec_taxes_options['wpec_taxes_logic'] == 'billing_shipping' ) {
59
- echo 'checked="checked"';
60
- } ?> type="radio" value='billing_shipping' id='wpec_taxes_logic_1' name='wpsc_options[wpec_taxes_logic]' />
61
- <?php _e( 'Apply tax when Billing and Shipping Country is the same as Tax Rate' ); ?>
62
- </label>
63
- <div id='billing_shipping_preference_container' style='margin-left: 20px;'>
64
- <p>
65
- <label for='wpec_billing_preference'>
66
- <input <?php if ( $wpec_taxes_options['wpec_taxes_logic'] == 'billing_shipping' && $wpec_taxes_options['wpec_billing_shipping_preference'] == 'billing_address' ) {
67
- echo 'checked="checked"';
68
- } ?> type="radio" value='billing_address' id='wpec_billing_preference' name='wpsc_options[wpec_billing_shipping_preference]' />
69
- <?php _e( 'Apply tax to Billing Address' ); ?>
70
- </label>
71
- </p>
72
- <p>
73
- <label for='wpec_shipping_preference'>
74
- <input <?php if ( $wpec_taxes_options['wpec_taxes_logic'] == 'billing_shipping' && $wpec_taxes_options['wpec_billing_shipping_preference'] == 'shipping_address' ) {
75
- echo 'checked="checked"';
76
- } ?> type="radio" value='shipping_address' id='wpec_shipping_preference' name='wpsc_options[wpec_billing_shipping_preference]' />
77
- <?php _e( 'Apply tax to Shipping Address' ); ?>
78
- </label>
79
- </p>
80
- </div>
81
- </p>
82
- <p>
83
- <label for='wpec_taxes_logic_2'>
84
- <input <?php if ( $wpec_taxes_options['wpec_taxes_logic'] == 'billing' ) {
85
- echo 'checked="checked"';
86
- } ?> type="radio" value='billing' id='wpec_taxes_logic_2' name='wpsc_options[wpec_taxes_logic]' />
87
- <?php _e( 'Apply tax when Billing Country is the same as Tax Rate' ); ?>
88
- </label>
89
- </p>
90
- <p>
91
- <label for='wpec_taxes_logic_3'>
92
- <input <?php if ( $wpec_taxes_options['wpec_taxes_logic'] == 'shipping' ) {
93
- echo 'checked="checked"';
94
- } ?> type="radio" value='shipping' id='wpec_taxes_logic_3' name='wpsc_options[wpec_taxes_logic]' />
95
- <?php _e( 'Apply tax when Shipping Country is the same as Tax Rate' ); ?>
96
- </label>
97
- </p>
98
- <div id='metabox-holder' class="metabox-holder">
99
- <div id='wpec-taxes-rates-container' class='postbox'>
100
- <h3 class='hndle' style='cursor: default'><?php _e( 'Tax Rates' ); ?></h3>
101
- <div id='wpec-taxes-rates' class='inside'>
102
- <!--Start Taxes Output-->
103
- <?php
104
- /**
105
- * Add New Tax Rate - should add another paragraph with the
106
- another key specified for the input array
107
- * Delete - Should remove the given paragraph from the page
108
- and either ajax delete it from the DB or mark it for
109
- deletion and process it after the changes are made.
110
- * Selecting a Country - should automatically populate the
111
- regions select box. Selecting a different country should
112
- remove the region select box. If the user selects a
113
- different country with regions it shouldn't matter because
114
- the code should automatically add the region select in.
115
- * - Allow users to define tax for entire country even if regions exist.
116
- * Shipping Tax - needs to be per region or per tax rate.
117
- Remove the setting from the main Tax Settings area.
118
- * Constraints -
119
- 1. Should not allow a user to add more than one
120
- tax rate for the same area.
121
- 2. If a country tax rate is specified and then a region tax
122
- rate, the region tax rate takes precedence.
123
- * */
124
- //if tax is included warn about shipping
125
- if ( $wpec_taxes_controller->wpec_taxes_isincluded() ) {
126
- echo '<p>' . __( 'Note: Tax is not applied to shipping when product prices are tax inclusive.' ) . '</p>';
127
- }// if
128
- //get current tax rates
129
- $tax_rates = $wpec_taxes_controller->wpec_taxes->wpec_taxes_get_rates();
130
- $tax_rate_count = 0;
131
- if ( !empty( $tax_rates ) ) {
132
- foreach ( $tax_rates as $tax_rate ) {
133
- echo $wpec_taxes_controller->wpec_taxes_build_form( $tax_rate_count, $tax_rate );
134
- $tax_rate_count++;
135
- }// foreach
136
- }// if
137
- ?>
138
- <!--End Taxes Output-->
139
- <p>
140
- <a id="add_taxes_rate" href="#"><?php _e( 'Add New Tax Rate' ); ?></a>
141
- </p>
142
- </div>
143
- </div>
144
- <div id='wpec-taxes-bands-container' class='postbox'>
145
- <h3 class='hndle' style='cursor: default'><?php _e( 'Tax Bands' ); ?></h3>
146
- <div id='wpec-taxes-bands' class='inside'>
147
-
148
- <?php
149
- echo '<p>' . __( 'Note: Tax Bands are special tax rules you can create and apply on a per-product basis.' ) . '</p>';
150
-
151
- //echo message regarding inclusive tax
152
- if ( !$wpec_taxes_controller->wpec_taxes_isincluded() ) {
153
- echo '<p>' . __( 'Note: Tax Bands do not take affect when product prices are tax exclusive.' ) . '</p>';
154
- }// if
155
-
156
- $tax_bands = $wpec_taxes_controller->wpec_taxes->wpec_taxes_get_bands();
157
- $tax_band_count = 0;
158
- if ( !empty( $tax_bands ) ) {
159
- foreach ( $tax_bands as $tax_band ) {
160
- echo $wpec_taxes_controller->wpec_taxes_build_form( $tax_band_count, $tax_band, 'bands' );
161
- $tax_band_count++;
162
- }// foreach
163
- }// if
164
- ?>
165
- <p>
166
- <a id="add_taxes_band" href="#"><?php _e( 'Add New Tax Band' ); ?></a>
167
- </p>
168
- </div>
169
- </div><!--wpec-taxes-bands-container-->
170
- </div><!--metabox-holder-->
171
- <?php do_action('wpsc_taxes_settings_page'); ?>
172
- <div class="submit">
173
- <input type='hidden' name='wpec_admin_action' value='submit_taxes_options' />
174
- <?php wp_nonce_field( 'update-options', 'wpsc-update-options' ); ?>
175
- <input type="submit" class='button-primary' value="Save Changes" name="submit_taxes" />
176
- </div>
177
- </div>
178
- </form>
179
- <?php
180
- }
181
-
182
- // wpec_options_taxes
183
- ?>
 
 
 
 
 
1
+ <?php
2
+
3
+ function wpec_options_taxes() {
4
+ $wpec_taxes_controller = new wpec_taxes_controller;
5
+ $wpec_taxes_options = $wpec_taxes_controller->wpec_taxes->wpec_taxes_get_options();
6
+
7
+ //include standard shopping cart notifications
8
+ wpsc_settings_page_update_notification();
9
+ ?>
10
+ <form name='wpec_taxes_options' id='wpec_taxes_options' method='post' action='' class='wpsc_form_track'>
11
+ <div class="wrap">
12
+ <h3><?php _e( 'Tax Settings' ); ?></h3>
13
+ <p>
14
+ <label for='wpec_taxes_enabled'>
15
+ <input <?php if ( $wpec_taxes_options['wpec_taxes_enabled'] ) {
16
+ echo 'checked="checked"';
17
+ } ?> type="checkbox" id='wpec_taxes_enabled' name='wpsc_options[wpec_taxes_enabled]' />
18
+ <?php _e( 'Turn tax on' ); ?>
19
+ </label>
20
+ </p>
21
+ <p>
22
+ <label for='wpec_taxes_inprice1'>
23
+ <input <?php if ( $wpec_taxes_options['wpec_taxes_inprice'] == 'exclusive' ) {
24
+ echo 'checked="checked"';
25
+ } ?> type="radio" value='exclusive' id='wpec_taxes_inprice1' name='wpsc_options[wpec_taxes_inprice]' />
26
+ <?php _e( 'Product prices are tax exclusive - add tax to the price during checkout' ); ?>
27
+ </label>
28
+ </p>
29
+ <p>
30
+ <label for='wpec_taxes_inprice2'>
31
+ <input <?php if ( $wpec_taxes_options['wpec_taxes_inprice'] == 'inclusive' ) {
32
+ echo 'checked="checked"';
33
+ } ?> type="radio" value='inclusive' id='wpec_taxes_inprice2' name='wpsc_options[wpec_taxes_inprice]' />
34
+ <?php _e( "Product prices are tax inclusive - during checkout the total price doesn't increase but tax is shown as a line item" ); ?>
35
+ </label>
36
+ </p>
37
+ <h4><?php _e( 'Product Specific Tax' ); ?></h4>
38
+ <p>
39
+ <label for='wpec_taxes_product_1'>
40
+ <input <?php if ( $wpec_taxes_options['wpec_taxes_product'] == 'add' ) {
41
+ echo 'checked="checked"';
42
+ } ?> type="radio" value='add' id='wpec_taxes_product_1' name='wpsc_options[wpec_taxes_product]' />
43
+ <?php _e( 'Add per product tax to tax percentage if product has a specific tax rate' ); ?>
44
+ </label>
45
+ </p>
46
+ <p>
47
+ <label for='wpec_taxes_product_2'>
48
+ <input <?php if ( $wpec_taxes_options['wpec_taxes_product'] == 'replace' ) {
49
+ echo 'checked="checked"';
50
+ } ?> type="radio" value='replace' id='wpec_taxes_product_2' name='wpsc_options[wpec_taxes_product]' />
51
+ <?php _e( 'Replace tax percentage with product specific tax rate' ); ?>
52
+ </label>
53
+ </p>
54
+
55
+ <h4><?php _e( 'Tax Logic' ); ?></h4>
56
+ <p>
57
+ <label for='wpec_taxes_logic_1'>
58
+ <input <?php if ( $wpec_taxes_options['wpec_taxes_logic'] == 'billing_shipping' ) {
59
+ echo 'checked="checked"';
60
+ } ?> type="radio" value='billing_shipping' id='wpec_taxes_logic_1' name='wpsc_options[wpec_taxes_logic]' />
61
+ <?php _e( 'Apply tax when Billing and Shipping Country is the same as Tax Rate' ); ?>
62
+ </label>
63
+ <div id='billing_shipping_preference_container' style='margin-left: 20px;'>
64
+ <p>
65
+ <label for='wpec_billing_preference'>
66
+ <input <?php if ( $wpec_taxes_options['wpec_taxes_logic'] == 'billing_shipping' && $wpec_taxes_options['wpec_billing_shipping_preference'] == 'billing_address' ) {
67
+ echo 'checked="checked"';
68
+ } ?> type="radio" value='billing_address' id='wpec_billing_preference' name='wpsc_options[wpec_billing_shipping_preference]' />
69
+ <?php _e( 'Apply tax to Billing Address' ); ?>
70
+ </label>
71
+ </p>
72
+ <p>
73
+ <label for='wpec_shipping_preference'>
74
+ <input <?php if ( $wpec_taxes_options['wpec_taxes_logic'] == 'billing_shipping' && $wpec_taxes_options['wpec_billing_shipping_preference'] == 'shipping_address' ) {
75
+ echo 'checked="checked"';
76
+ } ?> type="radio" value='shipping_address' id='wpec_shipping_preference' name='wpsc_options[wpec_billing_shipping_preference]' />
77
+ <?php _e( 'Apply tax to Shipping Address' ); ?>
78
+ </label>
79
+ </p>
80
+ </div>
81
+ </p>
82
+ <p>
83
+ <label for='wpec_taxes_logic_2'>
84
+ <input <?php if ( $wpec_taxes_options['wpec_taxes_logic'] == 'billing' ) {
85
+ echo 'checked="checked"';
86
+ } ?> type="radio" value='billing' id='wpec_taxes_logic_2' name='wpsc_options[wpec_taxes_logic]' />
87
+ <?php _e( 'Apply tax when Billing Country is the same as Tax Rate' ); ?>
88
+ </label>
89
+ </p>
90
+ <p>
91
+ <label for='wpec_taxes_logic_3'>
92
+ <input <?php if ( $wpec_taxes_options['wpec_taxes_logic'] == 'shipping' ) {
93
+ echo 'checked="checked"';
94
+ } ?> type="radio" value='shipping' id='wpec_taxes_logic_3' name='wpsc_options[wpec_taxes_logic]' />
95
+ <?php _e( 'Apply tax when Shipping Country is the same as Tax Rate' ); ?>
96
+ </label>
97
+ </p>
98
+ <div id='metabox-holder' class="metabox-holder">
99
+ <div id='wpec-taxes-rates-container' class='postbox'>
100
+ <h3 class='hndle' style='cursor: default'><?php _e( 'Tax Rates' ); ?></h3>
101
+ <div id='wpec-taxes-rates' class='inside'>
102
+ <!--Start Taxes Output-->
103
+ <?php
104
+ /**
105
+ * Add New Tax Rate - should add another paragraph with the
106
+ another key specified for the input array
107
+ * Delete - Should remove the given paragraph from the page
108
+ and either ajax delete it from the DB or mark it for
109
+ deletion and process it after the changes are made.
110
+ * Selecting a Country - should automatically populate the
111
+ regions select box. Selecting a different country should
112
+ remove the region select box. If the user selects a
113
+ different country with regions it shouldn't matter because
114
+ the code should automatically add the region select in.
115
+ * - Allow users to define tax for entire country even if regions exist.
116
+ * Shipping Tax - needs to be per region or per tax rate.
117
+ Remove the setting from the main Tax Settings area.
118
+ * Constraints -
119
+ 1. Should not allow a user to add more than one
120
+ tax rate for the same area.
121
+ 2. If a country tax rate is specified and then a region tax
122
+ rate, the region tax rate takes precedence.
123
+ * */
124
+
125
+ /**
126
+ * Removed Shipping Restriction on Included tax - 01-20-2011
127
+ //if tax is included warn about shipping
128
+ if ( $wpec_taxes_controller->wpec_taxes_isincluded() ) {
129
+ echo '<p>' . __( 'Note: Tax is not applied to shipping when product prices are tax inclusive.' ) . '</p>';
130
+ }// if
131
+ **/
132
+
133
+ //get current tax rates
134
+ $tax_rates = $wpec_taxes_controller->wpec_taxes->wpec_taxes_get_rates();
135
+ $tax_rate_count = 0;
136
+ if ( !empty( $tax_rates ) ) {
137
+ foreach ( $tax_rates as $tax_rate ) {
138
+ echo $wpec_taxes_controller->wpec_taxes_build_form( $tax_rate_count, $tax_rate );
139
+ $tax_rate_count++;
140
+ }// foreach
141
+ }// if
142
+ ?>
143
+ <!--End Taxes Output-->
144
+ <p>
145
+ <a id="add_taxes_rate" href="#"><?php _e( 'Add New Tax Rate' ); ?></a>
146
+ </p>
147
+ </div>
148
+ </div>
149
+ <div id='wpec-taxes-bands-container' class='postbox'>
150
+ <h3 class='hndle' style='cursor: default'><?php _e( 'Tax Bands' ); ?></h3>
151
+ <div id='wpec-taxes-bands' class='inside'>
152
+
153
+ <?php
154
+ echo '<p>' . __( 'Note: Tax Bands are special tax rules you can create and apply on a per-product basis. <br /> Please visit the product page to apply your Tax Band.' ) . '</p>';
155
+
156
+ //echo message regarding inclusive tax
157
+ if ( !$wpec_taxes_controller->wpec_taxes_isincluded() ) {
158
+ echo '<p>' . __( 'Note: Tax Bands do not take affect when product prices are tax exclusive.' ) . '</p>';
159
+ }// if
160
+
161
+ $tax_bands = $wpec_taxes_controller->wpec_taxes->wpec_taxes_get_bands();
162
+ $tax_band_count = 0;
163
+ if ( !empty( $tax_bands ) ) {
164
+ foreach ( $tax_bands as $tax_band ) {
165
+ echo $wpec_taxes_controller->wpec_taxes_build_form( $tax_band_count, $tax_band, 'bands' );
166
+ $tax_band_count++;
167
+ }// foreach
168
+ }// if
169
+ ?>
170
+ <p>
171
+ <a id="add_taxes_band" href="#"><?php _e( 'Add New Tax Band' ); ?></a>
172
+ </p>
173
+ </div>
174
+ </div><!--wpec-taxes-bands-container-->
175
+ </div><!--metabox-holder-->
176
+ <?php do_action('wpsc_taxes_settings_page'); ?>
177
+ <div class="submit">
178
+ <input type='hidden' name='wpec_admin_action' value='submit_taxes_options' />
179
+ <?php wp_nonce_field( 'update-options', 'wpsc-update-options' ); ?>
180
+ <input type="submit" class='button-primary' value="Save Changes" name="submit_taxes" />
181
+ </div>
182
+ </div>
183
+ </form>
184
+ <?php
185
+ }
186
+
187
+ // wpec_options_taxes
188
+ ?>
wpsc-admin/includes/tax_and_shipping.php CHANGED
@@ -20,7 +20,7 @@ $base_region = get_option('base_region');
20
  echo "Thanks, your changes have been made<br />";
21
  }
22
  ?>
23
- <form action='' method='post' name='regional_tax'>
24
  <?php
25
  $country_data = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `isocode` IN('".$country_isocode."') LIMIT 1",ARRAY_A);
26
  if(($country_data['has_regions'] == 1))
20
  echo "Thanks, your changes have been made<br />";
21
  }
22
  ?>
23
+ <form action='' method='post' name='regional_tax' class='wpsc_form_track'>
24
  <?php
25
  $country_data = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `isocode` IN('".$country_isocode."') LIMIT 1",ARRAY_A);
26
  if(($country_data['has_regions'] == 1))
wpsc-admin/includes/updating-functions.php CHANGED
@@ -1,591 +1,591 @@
1
- <?php
2
- /**
3
- * WP eCommerce database updating functions
4
- *
5
- * @package wp-e-commerce
6
- * @since 3.8
7
- */
8
-
9
- /**
10
- * wpsc_convert_category_groups function.
11
- *
12
- * @access public
13
- * @return void
14
- */
15
- function wpsc_convert_category_groups() {
16
- global $wpdb, $wp_rewrite, $user_ID;
17
-
18
- //if they're updating from 3.6, and they've got categories with no group, let's fix that problem, eh?
19
- $categorisation_groups = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_CATEGORISATION_GROUPS."` WHERE `active` IN ('1')");
20
- if(count($categorisation_groups) == 0) {
21
- $sql = "insert into `".WPSC_TABLE_CATEGORISATION_GROUPS."` set `id` = 1000, `name` = 'Default Group', `description` = 'This is your default category group', `active` = 1, `default` = 1;";
22
- $wpdb->query($sql);
23
- $sql = "update `".WPSC_TABLE_PRODUCT_CATEGORIES."` set group_id = 1000";
24
- $wpdb->query($sql);
25
- $categorisation_groups = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_CATEGORISATION_GROUPS."` WHERE `active` IN ('1')");
26
- }
27
-
28
- foreach((array)$categorisation_groups as $cat_group) {
29
- $category_id = wpsc_get_meta($cat_group->id, 'category_group_id', 'wpsc_category_group');
30
-
31
- if(!is_numeric($category_id) || ( $category_id < 1)) {
32
- $new_category = wp_insert_term( $cat_group->name, 'wpsc_product_category', array('description' => $cat_group->description));
33
- if(!is_wp_error($new_category))
34
- $category_id = $new_category['term_id'];
35
-
36
- }
37
- if(is_numeric($category_id)) {
38
-
39
- wpsc_update_meta($cat_group->id, 'category_group_id', $category_id, 'wpsc_category_group');
40
- wpsc_update_categorymeta($category_id, 'category_group_id', $cat_group->id);
41
-
42
- wpsc_update_categorymeta($category_id, 'image', '');
43
- wpsc_update_categorymeta($category_id, 'uses_billing_address', 0);
44
- }
45
-
46
- if(!is_wp_error($new_category))
47
- wpsc_convert_categories($category_id, $cat_group->id);
48
- }
49
- delete_option("wpsc_product_category_children");
50
- _get_term_hierarchy('wpsc_product_category');
51
- }
52
-
53
- /**
54
- * wpsc_convert_categories function.
55
- *
56
- * @access public
57
- * @param int $parent_category. (default: 0)
58
- * @return void
59
- */
60
- function wpsc_convert_categories($new_parent_category, $group_id, $old_parent_category = 0) {
61
- global $wpdb, $wp_rewrite, $user_ID;
62
-
63
- if($old_parent_category > 0) {
64
- $categorisation = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_PRODUCT_CATEGORIES."` WHERE `active` IN ('1') AND `group_id` IN ('{$group_id}') AND `category_parent` IN ('{$old_parent_category}')");
65
- } else {
66
- $categorisation = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_PRODUCT_CATEGORIES."` WHERE `active` IN ('1') AND `group_id` IN ('{$group_id}') AND `category_parent` IN (0)");
67
- }
68
-
69
- if($categorisation > 0) {
70
-
71
- foreach((array)$categorisation as $category) {
72
- $category_id = wpsc_get_meta($category->id, 'category_id', 'wpsc_old_category');
73
-
74
- if(!is_numeric($category_id) || ( $category_id < 1)) {
75
- $new_category = wp_insert_term( $category->name, 'wpsc_product_category', array('description' => $category->description, 'parent' => $new_parent_category));
76
- if(!is_wp_error($new_category))
77
- $category_id = $new_category['term_id'];
78
- }
79
-
80
- if(is_numeric($category_id)) {
81
-
82
- wpsc_update_meta($category->id, 'category_id', $category_id, 'wpsc_old_category');
83
- wpsc_update_categorymeta($category_id, 'category_id', $category->id);
84
-
85
- wpsc_update_categorymeta($category_id, 'image', $category->image);
86
- wpsc_update_categorymeta($category_id, 'display_type', $category->display_type);
87
-
88
- wpsc_update_categorymeta($category_id, 'image_height', $category->image_height);
89
- wpsc_update_categorymeta($category_id, 'image_width', $category->image_width);
90
-
91
- $use_additonal_form_set = wpsc_get_categorymeta($category->id, 'use_additonal_form_set');
92
- if($use_additonal_form_set != '') {
93
- wpsc_update_categorymeta($category_id, 'use_additonal_form_set', $use_additonal_form_set);
94
- } else {
95
- wpsc_delete_categorymeta($category_id, 'use_additonal_form_set');
96
- }
97
-
98
-
99
- wpsc_update_categorymeta($category_id, 'uses_billing_address', (bool)(int)wpsc_get_categorymeta($category->id, 'uses_billing_address'));
100
-
101
-
102
- }
103
- if($category_id > 0) {
104
- wpsc_convert_categories($category_id, $group_id, $category->id);
105
- }
106
-
107
- }
108
- }
109
- }
110
-
111
- function wpsc_convert_variation_sets() {
112
- global $wpdb, $wp_rewrite, $user_ID;
113
- $variation_sets = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_PRODUCT_VARIATIONS."`");
114
-
115
- foreach((array)$variation_sets as $variation_set) {
116
- $variation_set_id = wpsc_get_meta($variation_set->id, 'variation_set_id', 'wpsc_variation_set');
117
-
118
- if(!is_numeric($variation_set_id) || ( $variation_set_id < 1)) {
119
- $new_variation_set = wp_insert_term( $variation_set->name, 'wpsc-variation',array('parent' => 0));
120
-
121
- if(!is_wp_error($new_variation_set))
122
- $variation_set_id = $new_variation_set['term_id'];
123
- }
124
-
125
- if(is_numeric($variation_set_id)) {
126
- wpsc_update_meta($variation_set->id, 'variation_set_id', $variation_set_id, 'wpsc_variation_set');
127
-
128
-
129
- $variations = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_VARIATION_VALUES."` WHERE `variation_id` IN ({$variation_set->id})");
130
- foreach((array)$variations as $variation) {
131
- $variation_id = wpsc_get_meta($variation->id, 'variation_id', 'wpsc_variation');
132
-
133
- if(!is_numeric($variation_id) || ( $variation_id < 1)) {
134
- $new_variation = wp_insert_term( $variation->name, 'wpsc-variation',array('parent' => $variation_set_id));
135
-
136
- if(!is_wp_error($new_variation))
137
- $variation_id = $new_variation['term_id'];
138
- }
139
- if(is_numeric($variation_id)) {
140
- wpsc_update_meta($variation->id, 'variation_id', $variation_id, 'wpsc_variation');
141
-
142
- }
143
- }
144
- }
145
- }
146
-
147
- }
148
-
149
- /**
150
- * wpsc_convert_products_to_posts function.
151
- *
152
- * @access public
153
- * @return void
154
- */
155
- function wpsc_convert_products_to_posts() {
156
- global $wpdb, $wp_rewrite, $user_ID;
157
- // Select all products
158
-
159
- $product_data = $wpdb->get_results("SELECT `".WPSC_TABLE_PRODUCT_LIST."`. * , `".WPSC_TABLE_PRODUCT_ORDER."`.order FROM `".WPSC_TABLE_PRODUCT_LIST."` LEFT JOIN `".WPSC_TABLE_PRODUCT_ORDER."` ON `".WPSC_TABLE_PRODUCT_LIST."`.id = `".WPSC_TABLE_PRODUCT_ORDER."`.product_id WHERE `".WPSC_TABLE_PRODUCT_LIST."`.`active` IN ( '1' )
160
- GROUP BY ".WPSC_TABLE_PRODUCT_LIST.".id", ARRAY_A);
161
- foreach((array)$product_data as $product) {
162
- $post_id = (int)$wpdb->get_var($wpdb->prepare( "SELECT `post_id` FROM `{$wpdb->postmeta}` WHERE meta_key = %s AND `meta_value` = %d LIMIT 1", '_wpsc_original_id', $product['id'] ));
163
-
164
- $sku = get_product_meta($product['id'], 'sku', true);
165
-
166
- if($post_id == 0) {
167
- $post_status = "publish";
168
- if($product['publish'] != 1) {
169
- $post_status = "draft";
170
- }
171
-
172
- //check the product added time with the current time to make sure its not out - this aviods the future post status
173
- $product_added_time = strtotime($product['date_added']);
174
- $current_time = time();
175
-
176
- $post_date = $product['date_added'];
177
- if ((int)$current_time < (int)$product_added_time)
178
- $post_date = date("Y-m-d H:i:s");
179
-
180
- $product_post_values = array(
181
- 'post_author' => $user_ID,
182
- 'post_date' => $post_date,
183
- 'post_content' => $product['description'],
184
- 'post_excerpt' => $product['additional_description'],
185
- 'post_title' => $product['name'],
186
- 'post_status' => $post_status,
187
- 'post_type' => "wpsc-product",
188
- 'post_name' => sanitize_title($product['name']),
189
- 'menu_order' => $product['order']
190
- );
191
- $post_id = wp_insert_post($product_post_values);
192
- }
193
-
194
- $product_meta = $wpdb->get_results("
195
- SELECT IF( ( `custom` != 1 ),
196
- CONCAT( '_wpsc_', `meta_key` ) ,
197
- `meta_key`
198
- ) AS `meta_key`,
199
- `meta_value`
200
- FROM `".WPSC_TABLE_PRODUCTMETA."`
201
- WHERE `product_id` = " . $product['id'] . "
202
- AND `meta_value` != ''", ARRAY_A);
203
-
204
- $post_data = array();
205
-
206
- foreach($product_meta as $k => $pm) :
207
- if($pm['meta_value'] == 'om')
208
- $pm['meta_value'] = 1;
209
- $pm['meta_value'] = maybe_unserialize($pm['meta_value']);
210
- if(strpos($pm['meta_key'], '_wpsc_') === 0)
211
- $post_data['_wpsc_product_metadata'][$pm['meta_key']] = $pm['meta_value'];
212
- else
213
- update_post_meta($post_id, $pm['meta_key'], $pm['meta_value']);
214
- endforeach;
215
-
216
-
217
- $post_data['_wpsc_original_id'] = (int)$product['id'];
218
- $post_data['_wpsc_price'] = (float)$product['price'];
219
- $post_data['_wpsc_special_price'] = (float)$product['special_price'];
220
- $post_data['_wpsc_stock'] = (float)$product['quantity'];
221
- $post_data['_wpsc_is_donation'] = $product['donation'];
222
- $post_data['_wpsc_sku'] = $sku;
223
- if((bool)$product['quantity_limited'] != true) {
224
- $post_data['_wpsc_stock'] = false;
225
- }
226
- unset($post_data['_wpsc_limited_stock']);
227
-
228
- $post_data['_wpsc_product_metadata']['is_stock_limited'] = (int)(bool)$product['quantity_limited'];
229
-
230
- // Product Weight
231
- $post_data['_wpsc_product_metadata']['weight'] = wpsc_convert_weight($product['weight'], $product['weight_unit'], "gram");
232
- $post_data['_wpsc_product_metadata']['weight_unit'] = $product['weight_unit'];
233
- $post_data['_wpsc_product_metadata']['display_weight_as'] = $product['weight_unit'];
234
-
235
- $post_data['_wpsc_product_metadata']['has_no_shipping'] = (int)(bool)$product['no_shipping'];
236
- $post_data['_wpsc_product_metadata']['shipping'] = array('local' => $product['pnp'], 'international' => $product['international_pnp']);
237
-
238
-
239
- $post_data['_wpsc_product_metadata']['quantity_limited'] = (int)(bool)$product['quantity_limited'];
240
- $post_data['_wpsc_product_metadata']['special'] = (int)(bool)$product['special'];
241
- if(isset($post_data['meta'])) {
242
- $post_data['_wpsc_product_metadata']['unpublish_when_none_left'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['unpublish_when_none_left'];
243
- }
244
- $post_data['_wpsc_product_metadata']['no_shipping'] = (int)(bool)$product['no_shipping'];
245
-
246
- foreach($post_data as $meta_key => $meta_value) {
247
- // prefix all meta keys with _wpsc_
248
- update_post_meta($post_id, $meta_key, $meta_value);
249
- }
250
-
251
- // get the wordpress upload directory data
252
- $wp_upload_dir_data = wp_upload_dir();
253
- $wp_upload_basedir = $wp_upload_dir_data['basedir'];
254
-
255
- $category_ids = array();
256
- $category_data = $wpdb->get_col("SELECT `category_id` FROM `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."` WHERE `product_id` IN ('{$product['id']}')");
257
- foreach($category_data as $old_category_id) {
258
- $category_ids[] = wpsc_get_meta($old_category_id, 'category_id', 'wpsc_old_category');
259
-
260
- }
261
- wp_set_product_categories($post_id, $category_ids);
262
-
263
- $product_data = get_post($post_id);
264
- $image_data = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_PRODUCT_IMAGES."` WHERE `product_id` IN ('{$product['id']}') ORDER BY `image_order` ASC", ARRAY_A);
265
- foreach((array)$image_data as $image_row) {
266
- // Get the image path info
267
- $image_pathinfo = pathinfo($image_row['image']);
268
-
269
- // use the path info to clip off the file extension
270
- $image_name = basename($image_pathinfo['basename'], ".{$image_pathinfo['extension']}");
271
-
272
- // construct the full image path
273
- $full_image_path = WPSC_IMAGE_DIR.$image_row['image'];
274
- $attached_file_path = str_replace($wp_upload_basedir."/", '', $full_image_path);
275
- $upload_dir = wp_upload_dir();
276
- $new_path = $upload_dir['path'].'/'.$image_name.'.'.$image_pathinfo['extension'];
277
- if(is_file($full_image_path)){
278
- copy($full_image_path, $new_path);
279
- }else{
280
- continue;
281
- }
282
- // construct the full image url
283
- $subdir = $upload_dir['subdir'].'/'.$image_name.'.'.$image_pathinfo['extension'];
284
- $subdir = substr($subdir , 1);
285
- $attachment_id = (int)$wpdb->get_var("SELECT `ID` FROM `{$wpdb->posts}` WHERE `post_title` IN('$image_name') AND `post_parent` IN('$post_id') LIMIT 1");
286
-
287
- // get the image MIME type
288
- $mime_type_data = wpsc_get_mimetype($full_image_path, true);
289
- if((int)$attachment_id == 0 ) {
290
- // construct the image data array
291
- $image_post_values = array(
292
- 'post_author' => $user_ID,
293
- 'post_parent' => $post_id,
294
- 'post_date' => $product_data->post_date,
295
- 'post_content' => $image_name,
296
- 'post_title' => $image_name,
297
- 'post_status' => "inherit",
298
- 'post_type' => "attachment",
299
- 'post_name' => sanitize_title($image_name),
300
- 'post_mime_type' => $mime_type_data['mime_type'],
301
- 'menu_order' => absint($image_row['image_order']),
302
- 'guid' => $new_path
303
- );
304
- $attachment_id = wp_insert_post($image_post_values);
305
- }
306
- $image_size_data = @getimagesize($full_image_path);
307
- $image_metadata = array(
308
- 'width' => $image_size_data[0],
309
- 'height' => $image_size_data[1],
310
- 'file' => $subdir
311
- );
312
-
313
-
314
- update_post_meta( $attachment_id, '_wp_attached_file', $subdir );
315
- update_post_meta( $attachment_id, '_wp_attachment_metadata', $image_metadata);
316
-
317
- }
318
-
319
- }
320
-
321
- //Just throwing the payment gateway update in here because it doesn't really warrant it's own function :)
322
-
323
- $custom_gateways = get_option('custom_gateway_options');
324
- array_walk($custom_gateways, "wpec_update_gateway");
325
- update_option('custom_gateway_options', $custom_gateways);
326
- }
327
-
328
- function wpec_update_gateway(&$value,$key) {
329
- if ( $value == "testmode" )
330
- $value = "wpsc_merchant_testmode";
331
- if ( $value == "paypal_certified" )
332
- $value = "wpsc_merchant_paypal_express";
333
- if ( $value == "paypal_multiple" )
334
- $value = "wpsc_merchant_paypal_standard";
335
- if ( $value == "paypal_pro" )
336
- $value = "wpsc_merchant_paypal_pro";
337
-
338
- }
339
- function wpsc_convert_variation_combinations() {
340
- global $wpdb, $user_ID, $current_version_number;
341
-
342
- // get the posts
343
- // I use a direct SQL query here because the get_posts function sometimes does not function for a reason that is not clear.
344
- $posts = $wpdb->get_results("SELECT * FROM `{$wpdb->posts}` WHERE `post_type` IN('wpsc-product')");
345
-
346
-
347
- $posts = get_posts( array(
348
- 'post_type' => 'wpsc-product',
349
- 'post_status' => 'all',
350
- 'numberposts' => -1
351
- ) );
352
-
353
- foreach((array)$posts as $post) {
354
-
355
- $base_product_terms = array();
356
- //create a post template
357
- $child_product_template = array(
358
- 'post_author' => $user_ID,
359
- 'post_content' => $post->post_content,
360
- 'post_excerpt' => $post->post_excerpt,
361
- 'post_title' => $post->post_title,
362
- 'post_status' => 'inherit',
363
- 'post_type' => "wpsc-product",
364
- 'post_name' => sanitize_title($post->post_title),
365
- 'post_parent' => $post->ID
366
- );
367
-
368
- // select the original product ID
369
- $original_id = get_post_meta($post->ID, '_wpsc_original_id', true);
370
- $parent_stock = get_post_meta($post->ID, '_wpsc_stock', true);
371
-
372
- // select the variation set associations
373
- $variation_set_associations = $wpdb->get_col("SELECT `variation_id` FROM ".WPSC_TABLE_VARIATION_ASSOC." WHERE `associated_id` = '{$original_id}'");
374
-
375
- // select the variation associations if the count of variation sets is greater than zero
376
- if(($original_id > 0) && (count($variation_set_associations) > 0)) {
377
- $variation_associations = $wpdb->get_col("SELECT `value_id` FROM ".WPSC_TABLE_VARIATION_VALUES_ASSOC." WHERE `product_id` = '{$original_id}' AND `variation_id` IN(".implode(", ", $variation_set_associations).") AND `visible` IN ('1')");
378
- } else {
379
- // otherwise, we have no active variations, skip to the next product
380
- continue;
381
- }
382
-
383
- foreach($variation_set_associations as $variation_set_id) {
384
- $base_product_terms[] = wpsc_get_meta($variation_set_id, 'variation_set_id', 'wpsc_variation_set');
385
- }
386
-
387
- foreach($variation_associations as $variation_association_id) {
388
- $base_product_terms[] = wpsc_get_meta($variation_association_id, 'variation_id', 'wpsc_variation');
389
- }
390
-
391
- // Now that we have the term IDs, we need to retrieve the slugs, as wp_set_object_terms will not use IDs in the way we want
392
- // If we pass IDs into wp_set_object_terms, it creates terms using the ID as the name.
393
- $parent_product_terms = get_terms('wpsc-variation', array(
394
- 'hide_empty' => 0,
395
- 'include' => implode(",", $base_product_terms),
396
- 'orderby' => 'parent'
397
- ));
398
- $base_product_term_slugs = array();
399
- foreach($parent_product_terms as $parent_product_term) {
400
- $base_product_term_slugs[] = $parent_product_term->slug;
401
-
402
- }
403
-
404
- wp_set_object_terms($post->ID, $base_product_term_slugs, 'wpsc-variation');
405
-
406
- // select all variation "products"
407
- $variation_items = $wpdb->get_results("SELECT * FROM ".WPSC_TABLE_VARIATION_PROPERTIES." WHERE `product_id` = '{$original_id}'");
408
-
409
- foreach((array)$variation_items as $variation_item) {
410
- // initialize the requisite arrays to empty
411
- $variation_ids = array();
412
- $term_data = array();
413
- // make a temporary copy of the product teplate
414
- $product_values = $child_product_template;
415
-
416
- // select all values this "product" is associated with, then loop through them, getting the term id of the variation using the value ID
417
- $variation_associations = $wpdb->get_results("SELECT * FROM ".WPSC_TABLE_VARIATION_COMBINATIONS." WHERE `priceandstock_id` = '{$variation_item->id}'");
418
- foreach((array)$variation_associations as $association) {
419
- $variation_id = (int)wpsc_get_meta($association->value_id, 'variation_id', 'wpsc_variation');
420
- // discard any values that are null, as they break the selecting of the terms
421
- if($variation_id > 0) {
422
- $variation_ids[] = $variation_id;
423
- }
424
- }
425
-
426
- // if we have more than zero remaining terms, get the term data, then loop through it to convert it to a more useful set of arrays.
427
- if(count($variation_ids) > 0) {
428
- $combination_terms = get_terms('wpsc-variation', array(
429
- 'hide_empty' => 0,
430
- 'include' => implode(",", $variation_ids),
431
- 'orderby' => 'parent',
432
- ));
433
- foreach($combination_terms as $term) {
434
- $term_data['ids'][] = $term->term_id;
435
- $term_data['slugs'][] = $term->slug;
436
- $term_data['names'][] = $term->name;
437
- }
438
-
439
- $product_values['post_title'] .= " (".implode(", ", $term_data['names']).")";
440
- $product_values['post_name'] = sanitize_title($product_values['post_title']);
441
-
442
- $selected_post = get_posts(array(
443
- 'name' => $product_values['post_name'],
444
- 'post_parent' => $post->ID,
445
- 'post_type' => "wpsc-product",
446
- 'post_status' => 'all',
447
- 'suppress_filters' => true
448
- ));
449
-
450
- $selected_post = array_shift($selected_post);
451
-
452
- $child_product_id = wpsc_get_child_object_in_terms($post->ID, $term_data['ids'], 'wpsc-variation');
453
- $post_data = array();
454
- $post_data['_wpsc_price'] = (float)$variation_item->price;
455
- $post_data['_wpsc_stock'] = (float)$variation_item->stock;
456
- if( !is_numeric( $parent_stock ) )
457
- $post_data['_wpsc_stock'] = false;
458
-
459
- $post_data['_wpsc_original_variation_id'] = (float)$variation_item->id;
460
-
461
- // Product Weight
462
- $post_data['_wpsc_product_metadata']['weight'] = wpsc_convert_weight($variation_item->weight, $variation_item->weight_unit, "gram");
463
- $post_data['_wpsc_product_metadata']['display_weight_as'] = $variation_item->weight_unit;
464
- $post_data['_wpsc_product_metadata']['weight_unit'] = $variation_item->weight_unit;
465
-
466
- //file
467
-
468
- if($child_product_id == false) {
469
- if($selected_post != null) {
470
- $child_product_id = $selected_post->ID;
471
- } else {
472
- $child_product_id = wp_update_post($product_values);
473
- }
474
- } else {
475
- // sometimes there have been problems saving the variations, this gets the correct product ID
476
- if(($selected_post != null) && ($selected_post->ID != $child_product_id)) {
477
- $child_product_id = $selected_post->ID;
478
- }
479
- }
480
- if($child_product_id > 0) {
481
-
482
- foreach($post_data as $meta_key => $meta_value) {
483
- // prefix all meta keys with _wpsc_
484
- update_post_meta($child_product_id, $meta_key, $meta_value);
485
- }
486
-
487
-
488
- wp_set_object_terms($child_product_id, $term_data['slugs'], 'wpsc-variation');
489
- }
490
-
491
- unset($term_data);
492
- }
493
-
494
- }
495
- }
496
- delete_option("wpsc-variation_children");
497
- _get_term_hierarchy('wpsc-variation');
498
- delete_option("wpsc_product_category_children");
499
- _get_term_hierarchy('wpsc_product_category');
500
- }
501
-
502
- function wpsc_update_files() {
503
- global $wpdb, $user_ID;
504
- $product_files = $wpdb->get_results("SELECT * FROM ".WPSC_TABLE_PRODUCT_FILES."");
505
-
506
- foreach($product_files as $product_file) {
507
- $variation_post_ids = array();
508
- if(!empty($product_file->product_id)){
509
- $product_post_id = (int)$wpdb->get_var($wpdb->prepare( "SELECT `post_id` FROM `{$wpdb->postmeta}` WHERE meta_key = %s AND `meta_value` = %d LIMIT 1", '_wpsc_original_id', $product_file->product_id ));
510
- }else{
511
- $product_post_id = (int)$wpdb->get_var("SELECT `id` FROM ".WPSC_TABLE_PRODUCT_LIST." WHERE file=".$product_file->id);
512
- $product_post_id = (int)$wpdb->get_var($wpdb->prepare( "SELECT `post_id` FROM `{$wpdb->postmeta}` WHERE meta_key = %s AND `meta_value` = %d LIMIT 1", '_wpsc_original_id', $product_post_id ));
513
- }
514
- $variation_items = $wpdb->get_col("SELECT `id` FROM ".WPSC_TABLE_VARIATION_PROPERTIES." WHERE `file` = '{$product_file->id}'");
515
-
516
- if(count($variation_items) > 0) {
517
- $variation_post_ids = $wpdb->get_col("SELECT `post_id` FROM `{$wpdb->postmeta}` WHERE meta_key = '_wpsc_original_variation_id' AND `meta_value` IN(".implode(", ", $variation_items).")");
518
- }
519
-
520
- $attachment_template = array(
521
- 'post_mime_type' => $product_file->mimetype,
522
- 'post_title' => $product_file->filename,
523
- 'post_name' => $product_file->idhash,
524
- 'post_content' => '',
525
- 'post_parent' => $product_post_id,
526
- 'post_type' => "wpsc-product-file",
527
- 'post_status' => 'inherit'
528
- );
529
-
530
- $file_id = wpsc_get_meta($product_file->id, '_new_file_id', 'wpsc_files');
531
-
532
- if($file_id == null) {
533
- $file_data = $attachment_template;
534
- $file_data['post_parent'] = $product_post_id;
535
- $new_file_id = wp_insert_post($file_data);
536
- wpsc_update_meta($product_file->id, '_new_file_id', $new_file_id, 'wpsc_files');
537
- }
538
- if(count($variation_post_ids) > 0) {
539
- foreach($variation_post_ids as $variation_post_id) {
540
- $old_file_id = get_product_meta($variation_post_id, 'old_file_id', true);
541
- if($old_file_id == null) {
542
- $file_data = $attachment_template;
543
- $file_data['post_parent'] = $variation_post_id;
544
- $new_file_id = wp_insert_post($file_data);
545
- update_product_meta($variation_post_id, 'old_file_id', $product_file->id, 'wpsc_files');
546
- }
547
- }
548
- }
549
-
550
- if(!empty($product_file->preview)){
551
- $preview_template = array(
552
- 'post_mime_type' => $product_file->preview_mimetype,
553
- 'post_title' => $product_file->preview,
554
- 'post_name' => $product_file->filename,
555
- 'post_content' => '',
556
- 'post_parent' => $new_file_id,
557
- 'post_type' => "wpsc-product-preview",
558
- 'post_status' => 'inherit'
559
- );
560
- wp_insert_post($preview_template);
561
-
562
-
563
- }
564
- }
565
-
566
- $download_ids = $wpdb->get_col("SELECT `id` FROM ".WPSC_TABLE_DOWNLOAD_STATUS."");
567
- foreach($download_ids as $download_id) {
568
- if(wpsc_get_meta($download_id, '_is_legacy', 'wpsc_downloads') !== 'false') {
569
- wpsc_update_meta($download_id, '_is_legacy', 'true', 'wpsc_downloads');
570
- }
571
- }
572
- }
573
-
574
- function wpsc_update_database() {
575
- global $wpdb;
576
-
577
- $result = $wpdb->get_results("SHOW COLUMNS FROM ". WPSC_TABLE_PURCHASE_LOGS."", ARRAY_A);
578
- if (!$result) {
579
- echo 'Could not run query: ' . mysql_error();
580
- exit;
581
- }
582
- foreach($result as $row_key=>$value) {
583
- $has_taxes = ($value["Field"] == "wpec_taxes_total" || $value["Field"] == "wpec_taxes_rate") ? true: false;
584
- }
585
- if (!$has_taxes) {
586
- $add_fields = $wpdb->query($wpdb->prepare("ALTER TABLE ".WPSC_TABLE_PURCHASE_LOGS." ADD wpec_taxes_total decimal(11,2)"));
587
- $add_fields = $wpdb->query($wpdb->prepare("ALTER TABLE ".WPSC_TABLE_PURCHASE_LOGS." ADD wpec_taxes_rate decimal(11,2)"));
588
- }
589
- }
590
-
591
  ?>
1
+ <?php
2
+ /**
3
+ * WP eCommerce database updating functions
4
+ *
5
+ * @package wp-e-commerce
6
+ * @since 3.8
7
+ */
8
+
9
+ /**
10
+ * wpsc_convert_category_groups function.
11
+ *
12
+ * @access public
13
+ * @return void
14
+ */
15
+ function wpsc_convert_category_groups() {
16
+ global $wpdb, $wp_rewrite, $user_ID;
17
+
18
+ //if they're updating from 3.6, and they've got categories with no group, let's fix that problem, eh?
19
+ $categorisation_groups = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_CATEGORISATION_GROUPS."` WHERE `active` IN ('1')");
20
+ if(count($categorisation_groups) == 0) {
21
+ $sql = "insert into `".WPSC_TABLE_CATEGORISATION_GROUPS."` set `id` = 1000, `name` = 'Default Group', `description` = 'This is your default category group', `active` = 1, `default` = 1;";
22
+ $wpdb->query($sql);
23
+ $sql = "update `".WPSC_TABLE_PRODUCT_CATEGORIES."` set group_id = 1000";
24
+ $wpdb->query($sql);
25
+ $categorisation_groups = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_CATEGORISATION_GROUPS."` WHERE `active` IN ('1')");
26
+ }
27
+
28
+ foreach((array)$categorisation_groups as $cat_group) {
29
+ $category_id = wpsc_get_meta($cat_group->id, 'category_group_id', 'wpsc_category_group');
30
+
31
+ if(!is_numeric($category_id) || ( $category_id < 1)) {
32
+ $new_category = wp_insert_term( $cat_group->name, 'wpsc_product_category', array('description' => $cat_group->description));
33
+ if(!is_wp_error($new_category))
34
+ $category_id = $new_category['term_id'];
35
+
36
+ }
37
+ if(is_numeric($category_id)) {
38
+
39
+ wpsc_update_meta($cat_group->id, 'category_group_id', $category_id, 'wpsc_category_group');
40
+ wpsc_update_categorymeta($category_id, 'category_group_id', $cat_group->id);
41
+
42
+ wpsc_update_categorymeta($category_id, 'image', '');
43
+ wpsc_update_categorymeta($category_id, 'uses_billing_address', 0);
44
+ }
45
+
46
+ if(!is_wp_error($new_category))
47
+ wpsc_convert_categories($category_id, $cat_group->id);
48
+ }
49
+ delete_option("wpsc_product_category_children");
50
+ _get_term_hierarchy('wpsc_product_category');
51
+ }
52
+
53
+ /**
54
+ * wpsc_convert_categories function.
55
+ *
56
+ * @access public
57
+ * @param int $parent_category. (default: 0)
58
+ * @return void
59
+ */
60
+ function wpsc_convert_categories($new_parent_category, $group_id, $old_parent_category = 0) {
61
+ global $wpdb, $wp_rewrite, $user_ID;
62
+
63
+ if($old_parent_category > 0) {
64
+ $categorisation = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_PRODUCT_CATEGORIES."` WHERE `active` IN ('1') AND `group_id` IN ('{$group_id}') AND `category_parent` IN ('{$old_parent_category}')");
65
+ } else {
66
+ $categorisation = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_PRODUCT_CATEGORIES."` WHERE `active` IN ('1') AND `group_id` IN ('{$group_id}') AND `category_parent` IN (0)");
67
+ }
68
+
69
+ if($categorisation > 0) {
70
+
71
+ foreach((array)$categorisation as $category) {
72
+ $category_id = wpsc_get_meta($category->id, 'category_id', 'wpsc_old_category');
73
+
74
+ if(!is_numeric($category_id) || ( $category_id < 1)) {
75
+ $new_category = wp_insert_term( $category->name, 'wpsc_product_category', array('description' => $category->description, 'parent' => $new_parent_category));
76
+ if(!is_wp_error($new_category))
77
+ $category_id = $new_category['term_id'];
78
+ }
79
+
80
+ if(is_numeric($category_id)) {
81
+
82
+ wpsc_update_meta($category->id, 'category_id', $category_id, 'wpsc_old_category');
83
+ wpsc_update_categorymeta($category_id, 'category_id', $category->id);
84
+
85
+ wpsc_update_categorymeta($category_id, 'image', $category->image);
86
+ wpsc_update_categorymeta($category_id, 'display_type', $category->display_type);
87
+
88
+ wpsc_update_categorymeta($category_id, 'image_height', $category->image_height);
89
+ wpsc_update_categorymeta($category_id, 'image_width', $category->image_width);
90
+
91
+ $use_additonal_form_set = wpsc_get_categorymeta($category->id, 'use_additonal_form_set');
92
+ if($use_additonal_form_set != '') {
93
+ wpsc_update_categorymeta($category_id, 'use_additonal_form_set', $use_additonal_form_set);
94
+ } else {
95
+ wpsc_delete_categorymeta($category_id, 'use_additonal_form_set');
96
+ }
97
+
98
+
99
+ wpsc_update_categorymeta($category_id, 'uses_billing_address', (bool)(int)wpsc_get_categorymeta($category->id, 'uses_billing_address'));
100
+
101
+
102
+ }
103
+ if($category_id > 0) {
104
+ wpsc_convert_categories($category_id, $group_id, $category->id);
105
+ }
106
+
107
+ }
108
+ }
109
+ }
110
+
111
+ function wpsc_convert_variation_sets() {
112
+ global $wpdb, $wp_rewrite, $user_ID;
113
+ $variation_sets = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_PRODUCT_VARIATIONS."`");
114
+
115
+ foreach((array)$variation_sets as $variation_set) {
116
+ $variation_set_id = wpsc_get_meta($variation_set->id, 'variation_set_id', 'wpsc_variation_set');
117
+
118
+ if(!is_numeric($variation_set_id) || ( $variation_set_id < 1)) {
119
+ $new_variation_set = wp_insert_term( $variation_set->name, 'wpsc-variation',array('parent' => 0));
120
+
121
+ if(!is_wp_error($new_variation_set))
122
+ $variation_set_id = $new_variation_set['term_id'];
123
+ }
124
+
125
+ if(is_numeric($variation_set_id)) {
126
+ wpsc_update_meta($variation_set->id, 'variation_set_id', $variation_set_id, 'wpsc_variation_set');
127
+
128
+
129
+ $variations = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_VARIATION_VALUES."` WHERE `variation_id` IN ({$variation_set->id})");
130
+ foreach((array)$variations as $variation) {
131
+ $variation_id = wpsc_get_meta($variation->id, 'variation_id', 'wpsc_variation');
132
+
133
+ if(!is_numeric($variation_id) || ( $variation_id < 1)) {
134
+ $new_variation = wp_insert_term( $variation->name, 'wpsc-variation',array('parent' => $variation_set_id));
135
+
136
+ if(!is_wp_error($new_variation))
137
+ $variation_id = $new_variation['term_id'];
138
+ }
139
+ if(is_numeric($variation_id)) {
140
+ wpsc_update_meta($variation->id, 'variation_id', $variation_id, 'wpsc_variation');
141
+
142
+ }
143
+ }
144
+ }
145
+ }
146
+
147
+ }
148
+
149
+ /**
150
+ * wpsc_convert_products_to_posts function.
151
+ *
152
+ * @access public
153
+ * @return void
154
+ */
155
+ function wpsc_convert_products_to_posts() {
156
+ global $wpdb, $wp_rewrite, $user_ID;
157
+ // Select all products
158
+
159
+ $product_data = $wpdb->get_results("SELECT `".WPSC_TABLE_PRODUCT_LIST."`. * , `".WPSC_TABLE_PRODUCT_ORDER."`.order FROM `".WPSC_TABLE_PRODUCT_LIST."` LEFT JOIN `".WPSC_TABLE_PRODUCT_ORDER."` ON `".WPSC_TABLE_PRODUCT_LIST."`.id = `".WPSC_TABLE_PRODUCT_ORDER."`.product_id WHERE `".WPSC_TABLE_PRODUCT_LIST."`.`active` IN ( '1' )
160
+ GROUP BY ".WPSC_TABLE_PRODUCT_LIST.".id", ARRAY_A);
161
+ foreach((array)$product_data as $product) {
162
+ $post_id = (int)$wpdb->get_var($wpdb->prepare( "SELECT `post_id` FROM `{$wpdb->postmeta}` WHERE meta_key = %s AND `meta_value` = %d LIMIT 1", '_wpsc_original_id', $product['id'] ));
163
+
164
+ $sku = get_product_meta($product['id'], 'sku', true);
165
+
166
+ if($post_id == 0) {
167
+ $post_status = "publish";
168
+ if($product['publish'] != 1) {
169
+ $post_status = "draft";
170
+ }
171
+
172
+ //check the product added time with the current time to make sure its not out - this aviods the future post status
173
+ $product_added_time = strtotime($product['date_added']);
174
+ $current_time = time();
175
+
176
+ $post_date = $product['date_added'];
177
+ if ((int)$current_time < (int)$product_added_time)
178
+ $post_date = date("Y-m-d H:i:s");
179
+
180
+ $product_post_values = array(
181
+ 'post_author' => $user_ID,
182
+ 'post_date' => $post_date,
183
+ 'post_content' => $product['description'],
184
+ 'post_excerpt' => $product['additional_description'],
185
+ 'post_title' => $product['name'],
186
+ 'post_status' => $post_status,
187
+ 'post_type' => "wpsc-product",
188
+ 'post_name' => sanitize_title($product['name']),
189
+ 'menu_order' => $product['order']
190
+ );
191
+ $post_id = wp_insert_post($product_post_values);
192
+ }
193
+
194
+ $product_meta = $wpdb->get_results("
195
+ SELECT IF( ( `custom` != 1 ),
196
+ CONCAT( '_wpsc_', `meta_key` ) ,
197
+ `meta_key`
198
+ ) AS `meta_key`,
199
+ `meta_value`
200
+ FROM `".WPSC_TABLE_PRODUCTMETA."`
201
+ WHERE `product_id` = " . $product['id'] . "
202
+ AND `meta_value` != ''", ARRAY_A);
203
+
204
+ $post_data = array();
205
+
206
+ foreach($product_meta as $k => $pm) :
207
+ if($pm['meta_value'] == 'om')
208
+ $pm['meta_value'] = 1;
209
+ $pm['meta_value'] = maybe_unserialize($pm['meta_value']);
210
+ if(strpos($pm['meta_key'], '_wpsc_') === 0)
211
+ $post_data['_wpsc_product_metadata'][$pm['meta_key']] = $pm['meta_value'];
212
+ else
213
+ update_post_meta($post_id, $pm['meta_key'], $pm['meta_value']);
214
+ endforeach;
215
+
216
+
217
+ $post_data['_wpsc_original_id'] = (int)$product['id'];
218
+ $post_data['_wpsc_price'] = (float)$product['price'];
219
+ $post_data['_wpsc_special_price'] = (float)$product['special_price'];
220
+ $post_data['_wpsc_stock'] = (float)$product['quantity'];
221
+ $post_data['_wpsc_is_donation'] = $product['donation'];
222
+ $post_data['_wpsc_sku'] = $sku;
223
+ if((bool)$product['quantity_limited'] != true) {
224
+ $post_data['_wpsc_stock'] = false;
225
+ }
226
+ unset($post_data['_wpsc_limited_stock']);
227
+
228
+ $post_data['_wpsc_product_metadata']['is_stock_limited'] = (int)(bool)$product['quantity_limited'];
229
+
230
+ // Product Weight
231
+ $post_data['_wpsc_product_metadata']['weight'] = wpsc_convert_weight($product['weight'], $product['weight_unit'], "gram");
232
+ $post_data['_wpsc_product_metadata']['weight_unit'] = $product['weight_unit'];
233
+ $post_data['_wpsc_product_metadata']['display_weight_as'] = $product['weight_unit'];
234
+
235
+ $post_data['_wpsc_product_metadata']['has_no_shipping'] = (int)(bool)$product['no_shipping'];
236
+ $post_data['_wpsc_product_metadata']['shipping'] = array('local' => $product['pnp'], 'international' => $product['international_pnp']);
237
+
238
+
239
+ $post_data['_wpsc_product_metadata']['quantity_limited'] = (int)(bool)$product['quantity_limited'];
240
+ $post_data['_wpsc_product_metadata']['special'] = (int)(bool)$product['special'];
241
+ if(isset($post_data['meta'])) {
242
+ $post_data['_wpsc_product_metadata']['unpublish_when_none_left'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['unpublish_when_none_left'];
243
+ }
244
+ $post_data['_wpsc_product_metadata']['no_shipping'] = (int)(bool)$product['no_shipping'];
245
+
246
+ foreach($post_data as $meta_key => $meta_value) {
247
+ // prefix all meta keys with _wpsc_
248
+ update_post_meta($post_id, $meta_key, $meta_value);
249
+ }
250
+
251
+ // get the wordpress upload directory data
252
+ $wp_upload_dir_data = wp_upload_dir();
253
+ $wp_upload_basedir = $wp_upload_dir_data['basedir'];
254
+
255
+ $category_ids = array();
256
+ $category_data = $wpdb->get_col("SELECT `category_id` FROM `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."` WHERE `product_id` IN ('{$product['id']}')");
257
+ foreach($category_data as $old_category_id) {
258
+ $category_ids[] = wpsc_get_meta($old_category_id, 'category_id', 'wpsc_old_category');
259
+
260
+ }
261
+ wp_set_product_categories($post_id, $category_ids);
262
+
263
+ $product_data = get_post($post_id);
264
+ $image_data = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_PRODUCT_IMAGES."` WHERE `product_id` IN ('{$product['id']}') ORDER BY `image_order` ASC", ARRAY_A);
265
+ foreach((array)$image_data as $image_row) {
266
+ // Get the image path info
267
+ $image_pathinfo = pathinfo($image_row['image']);
268
+
269
+ // use the path info to clip off the file extension
270
+ $image_name = basename($image_pathinfo['basename'], ".{$image_pathinfo['extension']}");
271
+
272
+ // construct the full image path
273
+ $full_image_path = WPSC_IMAGE_DIR.$image_row['image'];
274
+ $attached_file_path = str_replace($wp_upload_basedir."/", '', $full_image_path);
275
+ $upload_dir = wp_upload_dir();
276
+ $new_path = $upload_dir['path'].'/'.$image_name.'.'.$image_pathinfo['extension'];
277
+ if(is_file($full_image_path)){
278
+ copy($full_image_path, $new_path);
279
+ }else{
280
+ continue;
281
+ }
282
+ // construct the full image url
283
+ $subdir = $upload_dir['subdir'].'/'.$image_name.'.'.$image_pathinfo['extension'];
284
+ $subdir = substr($subdir , 1);
285
+ $attachment_id = (int)$wpdb->get_var("SELECT `ID` FROM `{$wpdb->posts}` WHERE `post_title` IN('$image_name') AND `post_parent` IN('$post_id') LIMIT 1");
286
+
287
+ // get the image MIME type
288
+ $mime_type_data = wpsc_get_mimetype($full_image_path, true);
289
+ if((int)$attachment_id == 0 ) {
290
+ // construct the image data array
291
+ $image_post_values = array(
292
+ 'post_author' => $user_ID,
293
+ 'post_parent' => $post_id,
294
+ 'post_date' => $product_data->post_date,
295
+ 'post_content' => $image_name,
296
+ 'post_title' => $image_name,
297
+ 'post_status' => "inherit",
298
+ 'post_type' => "attachment",
299
+ 'post_name' => sanitize_title($image_name),
300
+ 'post_mime_type' => $mime_type_data['mime_type'],
301
+ 'menu_order' => absint($image_row['image_order']),
302
+ 'guid' => $new_path
303
+ );
304
+ $attachment_id = wp_insert_post($image_post_values);
305
+ }
306
+ $image_size_data = @getimagesize($full_image_path);
307
+ $image_metadata = array(
308
+ 'width' => $image_size_data[0],
309
+ 'height' => $image_size_data[1],
310
+ 'file' => $subdir
311
+ );
312
+
313
+
314
+ update_post_meta( $attachment_id, '_wp_attached_file', $subdir );
315
+ update_post_meta( $attachment_id, '_wp_attachment_metadata', $image_metadata);
316
+
317
+ }
318
+
319
+ }
320
+
321
+ //Just throwing the payment gateway update in here because it doesn't really warrant it's own function :)
322
+
323
+ $custom_gateways = get_option('custom_gateway_options');
324
+ array_walk($custom_gateways, "wpec_update_gateway");
325
+ update_option('custom_gateway_options', $custom_gateways);
326
+ }
327
+
328
+ function wpec_update_gateway(&$value,$key) {
329
+ if ( $value == "testmode" )
330
+ $value = "wpsc_merchant_testmode";
331
+ if ( $value == "paypal_certified" )
332
+ $value = "wpsc_merchant_paypal_express";
333
+ if ( $value == "paypal_multiple" )
334
+ $value = "wpsc_merchant_paypal_standard";
335
+ if ( $value == "paypal_pro" )
336
+ $value = "wpsc_merchant_paypal_pro";
337
+
338
+ }
339
+ function wpsc_convert_variation_combinations() {
340
+ global $wpdb, $user_ID, $current_version_number;
341
+
342
+ // get the posts
343
+ // I use a direct SQL query here because the get_posts function sometimes does not function for a reason that is not clear.
344
+ $posts = $wpdb->get_results("SELECT * FROM `{$wpdb->posts}` WHERE `post_type` IN('wpsc-product')");
345
+
346
+
347
+ $posts = get_posts( array(
348
+ 'post_type' => 'wpsc-product',
349
+ 'post_status' => 'all',
350
+ 'numberposts' => -1
351
+ ) );
352
+
353
+ foreach((array)$posts as $post) {
354
+
355
+ $base_product_terms = array();
356
+ //create a post template
357
+ $child_product_template = array(
358
+ 'post_author' => $user_ID,
359
+ 'post_content' => $post->post_content,
360
+ 'post_excerpt' => $post->post_excerpt,
361
+ 'post_title' => $post->post_title,
362
+ 'post_status' => 'inherit',
363
+ 'post_type' => "wpsc-product",
364
+ 'post_name' => sanitize_title($post->post_title),
365
+ 'post_parent' => $post->ID
366
+ );
367
+
368
+ // select the original product ID
369
+ $original_id = get_post_meta($post->ID, '_wpsc_original_id', true);
370
+ $parent_stock = get_post_meta($post->ID, '_wpsc_stock', true);
371
+
372
+ // select the variation set associations
373
+ $variation_set_associations = $wpdb->get_col("SELECT `variation_id` FROM ".WPSC_TABLE_VARIATION_ASSOC." WHERE `associated_id` = '{$original_id}'");
374
+
375
+ // select the variation associations if the count of variation sets is greater than zero
376
+ if(($original_id > 0) && (count($variation_set_associations) > 0)) {
377
+ $variation_associations = $wpdb->get_col("SELECT `value_id` FROM ".WPSC_TABLE_VARIATION_VALUES_ASSOC." WHERE `product_id` = '{$original_id}' AND `variation_id` IN(".implode(", ", $variation_set_associations).") AND `visible` IN ('1')");
378
+ } else {
379
+ // otherwise, we have no active variations, skip to the next product
380
+ continue;
381
+ }
382
+
383
+ foreach($variation_set_associations as $variation_set_id) {
384
+ $base_product_terms[] = wpsc_get_meta($variation_set_id, 'variation_set_id', 'wpsc_variation_set');
385
+ }
386
+
387
+ foreach($variation_associations as $variation_association_id) {
388
+ $base_product_terms[] = wpsc_get_meta($variation_association_id, 'variation_id', 'wpsc_variation');
389
+ }
390
+
391
+ // Now that we have the term IDs, we need to retrieve the slugs, as wp_set_object_terms will not use IDs in the way we want
392
+ // If we pass IDs into wp_set_object_terms, it creates terms using the ID as the name.
393
+ $parent_product_terms = get_terms('wpsc-variation', array(
394
+ 'hide_empty' => 0,
395
+ 'include' => implode(",", $base_product_terms),
396
+ 'orderby' => 'parent'
397
+ ));
398
+ $base_product_term_slugs = array();
399
+ foreach($parent_product_terms as $parent_product_term) {
400
+ $base_product_term_slugs[] = $parent_product_term->slug;
401
+
402
+ }
403
+
404
+ wp_set_object_terms($post->ID, $base_product_term_slugs, 'wpsc-variation');
405
+
406
+ // select all variation "products"
407
+ $variation_items = $wpdb->get_results("SELECT * FROM ".WPSC_TABLE_VARIATION_PROPERTIES." WHERE `product_id` = '{$original_id}'");
408
+
409
+ foreach((array)$variation_items as $variation_item) {
410
+ // initialize the requisite arrays to empty
411
+ $variation_ids = array();
412
+ $term_data = array();
413
+ // make a temporary copy of the product teplate
414
+ $product_values = $child_product_template;
415
+
416
+ // select all values this "product" is associated with, then loop through them, getting the term id of the variation using the value ID
417
+ $variation_associations = $wpdb->get_results("SELECT * FROM ".WPSC_TABLE_VARIATION_COMBINATIONS." WHERE `priceandstock_id` = '{$variation_item->id}'");
418
+ foreach((array)$variation_associations as $association) {
419
+ $variation_id = (int)wpsc_get_meta($association->value_id, 'variation_id', 'wpsc_variation');
420
+ // discard any values that are null, as they break the selecting of the terms
421
+ if($variation_id > 0) {
422
+ $variation_ids[] = $variation_id;
423
+ }
424
+ }
425
+
426
+ // if we have more than zero remaining terms, get the term data, then loop through it to convert it to a more useful set of arrays.
427
+ if(count($variation_ids) > 0) {
428
+ $combination_terms = get_terms('wpsc-variation', array(
429
+ 'hide_empty' => 0,
430
+ 'include' => implode(",", $variation_ids),
431
+ 'orderby' => 'parent',
432
+ ));
433
+ foreach($combination_terms as $term) {
434
+ $term_data['ids'][] = $term->term_id;
435
+ $term_data['slugs'][] = $term->slug;
436
+ $term_data['names'][] = $term->name;
437
+ }
438
+
439
+ $product_values['post_title'] .= " (".implode(", ", $term_data['names']).")";
440
+ $product_values['post_name'] = sanitize_title($product_values['post_title']);
441
+
442
+ $selected_post = get_posts(array(
443
+ 'name' => $product_values['post_name'],
444
+ 'post_parent' => $post->ID,
445
+ 'post_type' => "wpsc-product",
446
+ 'post_status' => 'all',
447
+ 'suppress_filters' => true
448
+ ));
449
+
450
+ $selected_post = array_shift($selected_post);
451
+
452
+ $child_product_id = wpsc_get_child_object_in_terms($post->ID, $term_data['ids'], 'wpsc-variation');
453
+ $post_data = array();
454
+ $post_data['_wpsc_price'] = (float)$variation_item->price;
455
+ $post_data['_wpsc_stock'] = (float)$variation_item->stock;
456
+ if( !is_numeric( $parent_stock ) )
457
+ $post_data['_wpsc_stock'] = false;
458
+
459
+ $post_data['_wpsc_original_variation_id'] = (float)$variation_item->id;
460
+
461
+ // Product Weight
462
+ $post_data['_wpsc_product_metadata']['weight'] = wpsc_convert_weight($variation_item->weight, $variation_item->weight_unit, "gram");
463
+ $post_data['_wpsc_product_metadata']['display_weight_as'] = $variation_item->weight_unit;
464
+ $post_data['_wpsc_product_metadata']['weight_unit'] = $variation_item->weight_unit;
465
+
466
+ //file
467
+
468
+ if($child_product_id == false) {
469
+ if($selected_post != null) {
470
+ $child_product_id = $selected_post->ID;
471
+ } else {
472
+ $child_product_id = wp_update_post($product_values);
473
+ }
474
+ } else {
475
+ // sometimes there have been problems saving the variations, this gets the correct product ID
476
+ if(($selected_post != null) && ($selected_post->ID != $child_product_id)) {
477
+ $child_product_id = $selected_post->ID;
478
+ }
479
+ }
480
+ if($child_product_id > 0) {
481
+
482
+ foreach($post_data as $meta_key => $meta_value) {
483
+ // prefix all meta keys with _wpsc_
484
+ update_post_meta($child_product_id, $meta_key, $meta_value);
485
+ }
486
+
487
+
488
+ wp_set_object_terms($child_product_id, $term_data['slugs'], 'wpsc-variation');
489
+ }
490
+
491
+ unset($term_data);
492
+ }
493
+
494
+ }
495
+ }
496
+ delete_option("wpsc-variation_children");
497
+ _get_term_hierarchy('wpsc-variation');
498
+ delete_option("wpsc_product_category_children");
499
+ _get_term_hierarchy('wpsc_product_category');
500
+ }
501
+
502
+ function wpsc_update_files() {
503
+ global $wpdb, $user_ID;
504
+ $product_files = $wpdb->get_results("SELECT * FROM ".WPSC_TABLE_PRODUCT_FILES."");
505
+
506
+ foreach($product_files as $product_file) {
507
+ $variation_post_ids = array();
508
+ if(!empty($product_file->product_id)){
509
+ $product_post_id = (int)$wpdb->get_var($wpdb->prepare( "SELECT `post_id` FROM `{$wpdb->postmeta}` WHERE meta_key = %s AND `meta_value` = %d LIMIT 1", '_wpsc_original_id', $product_file->product_id ));
510
+ }else{
511
+ $product_post_id = (int)$wpdb->get_var("SELECT `id` FROM ".WPSC_TABLE_PRODUCT_LIST." WHERE file=".$product_file->id);
512
+ $product_post_id = (int)$wpdb->get_var($wpdb->prepare( "SELECT `post_id` FROM `{$wpdb->postmeta}` WHERE meta_key = %s AND `meta_value` = %d LIMIT 1", '_wpsc_original_id', $product_post_id ));
513
+ }
514
+ $variation_items = $wpdb->get_col("SELECT `id` FROM ".WPSC_TABLE_VARIATION_PROPERTIES." WHERE `file` = '{$product_file->id}'");
515
+
516
+ if(count($variation_items) > 0) {
517
+ $variation_post_ids = $wpdb->get_col("SELECT `post_id` FROM `{$wpdb->postmeta}` WHERE meta_key = '_wpsc_original_variation_id' AND `meta_value` IN(".implode(", ", $variation_items).")");
518
+ }
519
+
520
+ $attachment_template = array(
521
+ 'post_mime_type' => $product_file->mimetype,
522
+ 'post_title' => $product_file->filename,
523
+ 'post_name' => $product_file->idhash,
524
+ 'post_content' => '',
525
+ 'post_parent' => $product_post_id,
526
+ 'post_type' => "wpsc-product-file",
527
+ 'post_status' => 'inherit'
528
+ );
529
+
530
+ $file_id = wpsc_get_meta($product_file->id, '_new_file_id', 'wpsc_files');
531
+
532
+ if($file_id == null) {
533
+ $file_data = $attachment_template;
534
+ $file_data['post_parent'] = $product_post_id;
535
+ $new_file_id = wp_insert_post($file_data);
536
+ wpsc_update_meta($product_file->id, '_new_file_id', $new_file_id, 'wpsc_files');
537
+ }
538
+ if(count($variation_post_ids) > 0) {
539
+ foreach($variation_post_ids as $variation_post_id) {
540
+ $old_file_id = get_product_meta($variation_post_id, 'old_file_id', true);
541
+ if($old_file_id == null) {
542
+ $file_data = $attachment_template;
543
+ $file_data['post_parent'] = $variation_post_id;
544
+ $new_file_id = wp_insert_post($file_data);
545
+ update_product_meta($variation_post_id, 'old_file_id', $product_file->id, 'wpsc_files');
546
+ }
547
+ }
548
+ }
549
+
550
+ if(!empty($product_file->preview)){
551
+ $preview_template = array(
552
+ 'post_mime_type' => $product_file->preview_mimetype,
553
+ 'post_title' => $product_file->preview,
554
+ 'post_name' => $product_file->filename,
555
+ 'post_content' => '',
556
+ 'post_parent' => $new_file_id,
557
+ 'post_type' => "wpsc-product-preview",
558
+ 'post_status' => 'inherit'
559
+ );
560
+ wp_insert_post($preview_template);
561
+
562
+
563
+ }
564
+ }
565
+
566
+ $download_ids = $wpdb->get_col("SELECT `id` FROM ".WPSC_TABLE_DOWNLOAD_STATUS."");
567
+ foreach($download_ids as $download_id) {
568
+ if(wpsc_get_meta($download_id, '_is_legacy', 'wpsc_downloads') !== 'false') {
569
+ wpsc_update_meta($download_id, '_is_legacy', 'true', 'wpsc_downloads');
570
+ }
571
+ }
572
+ }
573
+
574
+ function wpsc_update_database() {
575
+ global $wpdb;
576
+
577
+ $result = $wpdb->get_results("SHOW COLUMNS FROM ". WPSC_TABLE_PURCHASE_LOGS."", ARRAY_A);
578
+ if (!$result) {
579
+ echo 'Could not run query: ' . mysql_error();
580
+ exit;
581
+ }
582
+ foreach($result as $row_key=>$value) {
583
+ $has_taxes = ($value["Field"] == "wpec_taxes_total" || $value["Field"] == "wpec_taxes_rate") ? true: false;
584
+ }
585
+ if (!$has_taxes) {
586
+ $add_fields = $wpdb->query($wpdb->prepare("ALTER TABLE ".WPSC_TABLE_PURCHASE_LOGS." ADD wpec_taxes_total decimal(11,2)"));
587
+ $add_fields = $wpdb->query($wpdb->prepare("ALTER TABLE ".WPSC_TABLE_PURCHASE_LOGS." ADD wpec_taxes_rate decimal(11,2)"));
588
+ }
589
+ }
590
+
591
  ?>
wpsc-admin/js/admin.js CHANGED
@@ -1,1359 +1,1067 @@
1
- // This is the wp-e-commerce front end javascript "library"
2
- var postboxes = function postboxes() {};
3
- jQuery(document).ready( function () {
4
-
5
- jQuery('a.update_variations_action').click(function(){
6
- jQuery("<img class='loading' src='images/loading.gif' height='15' width='15' />").insertAfter(this);
7
- edit_var_val = jQuery('div.variation_checkboxes input:checked').serialize();
8
- description = jQuery('iframe#content_ifr').text();
9
- additional_description = jQuery('textarea#additional_description').text();
10
- name = jQuery('input#title').val();
11
- product_id = jQuery('input#product_id').val();
12
- ;
13
- post_values = edit_var_val+'&description='+description+'&additional_description='+additional_description+'&name='+name+'&product_id='+product_id;
14
-
15
- jQuery.post('index.php?wpsc_admin_action=wpsc_update_variations',post_values, function(returned_data){
16
- var url = location.href;
17
- jQuery('table#wpsc_product_list').fadeOut(500).load(url +' table#wpsc_product_list').fadeIn(500);
18
- jQuery('img.loading').hide();
19
- });
20
- return false;
21
-
22
- });
23
- //JS - 5.12.2010 - Instead of modding functions, using JQuery to remove pricedisplay class from span.
24
- jQuery('td.sale_price span.pricedisplay').removeClass('pricedisplay').addClass('salespricedisplay');
25
-
26
- /* Coupon edit functionality */
27
- jQuery('.modify_coupon').hide();
28
- jQuery('.wpsc_edit_coupon').click(function(){
29
- id = jQuery(this).attr('rel');
30
- id = 'coupon_box_'+id;
31
- if(jQuery('#'+id).hasClass('displaynone')){
32
- jQuery('#'+id).show();
33
- jQuery('#'+id).removeClass('displaynone');
34
- }else{
35
- jQuery('#'+id).addClass('displaynone');
36
- jQuery('#'+id).hide();
37
- }
38
-
39
- });
40
- jQuery("form[name='add_coupon'] input[name='submit_coupon']").click(function() {
41
- var title = jQuery("form[name='add_coupon'] input[name='add_coupon_code']").val();
42
- if ( title == '') {
43
- alert('Please enter a coupon code.');
44
- return false;
45
- }
46
- });
47
- //Animateedit products columns
48
- jQuery('.wpsc-separator').livequery(function(){
49
- jQuery(this).click(function(){
50
- if(jQuery('#wpsc-col-left').css('width') == '20px'){
51
- left_col_width = '50%';
52
- right_col_width = '48%';
53
-
54
- }else{
55
- left_col_width = '20px';
56
- right_col_width = '95%';
57
- }
58
- if(left_col_width == '50%'){
59
- jQuery('.tablenav').show();
60
- jQuery('#posts-filter').show();
61
- }else{
62
- jQuery('.tablenav').hide();
63
- jQuery('#posts-filter').hide();
64
-
65
- }
66
- //jQuery(this).css('background-position','0');
67
- jQuery('#wpsc-col-left').animate(
68
- {
69
- width : left_col_width
70
- },
71
- 50,
72
- function(){
73
- //On complete
74
-
75
- }
76
- );
77
- jQuery('#wpsc-col-right').animate(
78
- {
79
- width : right_col_width
80
- },
81
- 50,
82
- function(){
83
- //On complete
84
-
85
- }
86
- );
87
- });
88
-
89
- });
90
-
91
- jQuery('.wpsc_prod_thumb_option').livequery(function(){
92
- jQuery(this).focus(function(){
93
- jQuery('.wpsc_mass_resize').css('visibility', 'visible');
94
- });
95
- });
96
-
97
- jQuery('.wpsc_prod_thumb_option').livequery(function(){
98
- jQuery(this).blur(function(){
99
- jQuery('.wpsc_mass_resize').css('visibility', 'hidden');
100
- });
101
- });
102
-
103
-
104
- //Delete checkout options on settings>checkout page
105
- jQuery('.wpsc_delete_option').livequery(function(){
106
- jQuery(this).click(function(event){
107
- jQuery(this).parent().parent('tr').remove();
108
- event.preventDefault();
109
- });
110
-
111
- });
112
- //Changing the checkout fields page
113
- jQuery('#wpsc_checkout_sets').livequery(function(){
114
- jQuery(this).change(function(){
115
-
116
- });
117
-
118
- });
119
- //checkboxes on checkout page
120
- /*
121
- jQuery('.wpsc_checkout_selectboxes').livequery(function(){
122
- jQuery(this).change(function(){
123
- if(jQuery(this).val() == 'checkbox' || jQuery(this).val() == 'radio' ||
124
- jQuery(this).val() == 'select'){
125
- id = jQuery(this).attr('name');
126
- id = id.replace('form_type', '');
127
- output = "<tr class='wpsc_grey'><td></td><td colspan='5'>Please save your changes to add options to this "+jQuery(this).val()+" form field.</td></tr>\r\n";
128
- jQuery(this).parent().parent('tr').after(output);
129
- }
130
-
131
- });
132
- });
133
- */
134
- jQuery('.wpsc_add_new_checkout_option').livequery(function(){
135
- jQuery(this).click(function(event){
136
- form_id = jQuery(this).attr('title');
137
- id = form_id.replace('form_options', '');
138
- output = "<tr class='wpsc_grey'><td></td><td><input type='text' value='' name='wpsc_checkout_option_label"+id+"[]' /></td><td colspan='4'><input type='text' value='' name='wpsc_checkout_option_value"+id+"[]' />&nbsp;<a class='wpsc_delete_option' href='' ><img src='" + WPSC_CORE_IMAGES_URL + "/trash.gif' alt='"+TXT_WPSC_DELETE+"' title='"+TXT_WPSC_DELETE+"' /></a></td></tr>";
139
- jQuery(this).parent().parent('tr').after(output);
140
- event.preventDefault();
141
- });
142
-
143
- });
144
-
145
-
146
- jQuery('.wpsc_edit_checkout_options').livequery(function(){
147
- jQuery(this).click(function(event){
148
- if(!jQuery(this).hasClass('triggered')){
149
- jQuery(this).addClass('triggered');
150
- id = jQuery(this).attr('rel');
151
- id = id.replace('form_options[', '');
152
- id = id.replace(']', '');
153
- post_values = "form_id="+id;
154
- jQuery.post('index.php?wpsc_admin_action=check_form_options',post_values, function(returned_data){
155
- if(returned_data != ''){
156
- jQuery('#checkout_'+id).after(returned_data);
157
- }else{
158
- output = "<tr class='wpsc_grey'><td></td><td colspan='5'>Please Save your changes before trying to Order your Checkout Forms again.</td></tr>\r\n<tr class='wpsc_grey'><td></td><th>Label</th><th >Value</th><td colspan='3'><a href='' class='wpsc_add_new_checkout_option' title='form_options["+id+"]'>+ New Layer</a></td></tr>";
159
- output += "<tr class='wpsc_grey'><td></td><td><input type='text' value='' name='wpsc_checkout_option_label["+id+"][]' /></td><td colspan='4'><input type='text' value='' name='wpsc_checkout_option_value["+id+"][]' /><a class='wpsc_delete_option' href='' ><img src='" + WPSC_CORE_IMAGES_URL + "trash.gif' alt='Delete' title='delete' /></a></td></tr>";
160
- jQuery('#checkout_'+id).after(output);
161
-
162
- }
163
-
164
- });
165
- jQuery('table#wpsc_checkout_list').sortable('disable');
166
- }
167
- event.preventDefault();
168
- });
169
-
170
-
171
- });
172
-
173
- //grid view checkbox ajax to deselect show images only when other checkboxes are selected
174
- jQuery('#show_images_only').livequery(function(){
175
- jQuery(this).click(function(){
176
- imagesonly = jQuery(this).is(':checked');
177
- if(imagesonly){
178
- jQuery('#display_variations').attr('checked', false);
179
- jQuery('#display_description').attr('checked', false);
180
- jQuery('#display_addtocart').attr('checked', false);
181
- jQuery('#display_moredetails').attr('checked', false);
182
-
183
- }
184
- });
185
- });
186
- jQuery('#display_variations, #display_description, #display_addtocart, #display_moredetails').livequery(function(){
187
- jQuery(this).click(function(){
188
- imagesonly = jQuery(this).is(':checked');
189
-
190
- if(imagesonly){
191
- jQuery('#show_images_only').attr('checked', false);
192
-
193
- }
194
- });
195
- });
196
- //new currency JS in admin product page
197
- jQuery('div.new_layer').livequery(function(){
198
- jQuery(this).hide();
199
-
200
- });
201
- var firstclick = true
202
- jQuery('a.wpsc_add_new_currency').livequery(function(){
203
- jQuery(this).click(function(event){
204
- if(firstclick == true){
205
- jQuery('div.new_layer').show();
206
- html = jQuery('div.new_layer').html();
207
- firstclick = false;
208
- }else{
209
- jQuery('div.new_layer').after('<div>'+html+'</div>');
210
- }
211
- event.preventDefault();
212
- });
213
- });
214
- //delete currency layer in admin product page
215
- jQuery('a.wpsc_delete_currency_layer').livequery(function(){
216
- jQuery(this).click(function(event){
217
- var currencySymbol = jQuery(this).attr('rel');
218
- jQuery(this).prev('input').val('');
219
- jQuery(this).prev('select').val('');
220
- jQuery(this).parent().parent('tr').hide();
221
-
222
- post_values = "currSymbol="+currencySymbol;
223
- jQuery.post('index.php?wpsc_admin_action=delete_currency_layer',post_values, function(returned_data){});
224
- //alert(currencySymbol);
225
-
226
- event.preventDefault();
227
- });
228
- });
229
-
230
- jQuery('form input.prdfil').livequery(function(){
231
- jQuery(this).click(function(event){
232
- var products = jQuery(this).parent("form.product_upload").find('input').serialize();
233
- var product_id = jQuery(this).parent("form.product_upload").find('input#hidden_id').val();
234
- post_values = products + '&product_id=' + product_id;
235
- jQuery.post('admin.php?wpsc_admin_action=product_files_upload',post_values, function(returned_data){
236
- jQuery("#TB_closeWindowButton").click(TB_remove);
237
-
238
- });
239
- // alert(products);
240
-
241
- event.preventDefault();
242
- });
243
- });
244
-
245
-
246
- //delete currency layer in admin product page
247
- jQuery('a.wpsc_mass_resize').livequery(function(){
248
- jQuery(this).click(function(event){
249
- this_href = jQuery(this).attr('href');
250
- parent_element = jQuery(this).parent();
251
- extra_parameters = jQuery("input[type=text]", parent_element).serialize();
252
- window.location = this_href+"&"+extra_parameters;
253
- return false;
254
- });
255
- });
256
-
257
- //select all target markets in general settings page
258
- jQuery('a.wpsc_select_all').livequery(function(){
259
- jQuery(this).click(function(event){
260
- jQuery('div#resizeable input:checkbox').attr('checked', true);
261
- event.preventDefault();
262
-
263
- });
264
-
265
- });
266
- //select all target markets in general settings page
267
- jQuery('a.wpsc_select_none').livequery(function(){
268
- jQuery(this).click(function(event){
269
- jQuery('div#resizeable input:checkbox').attr('checked', false);
270
- event.preventDefault();
271
-
272
- });
273
-
274
- });
275
- // this makes the product list table sortable
276
- jQuery('table#wpsc_product_list').sortable({
277
- update: function(event, ui) {
278
- category_id = jQuery('input#products_page_category_id').val();
279
- product_order = jQuery('table#wpsc_product_list').sortable( 'serialize' );
280
- post_values = "category_id="+category_id+"&"+product_order;
281
- jQuery.post( 'index.php?wpsc_admin_action=save_product_order', post_values, function(returned_data) { });
282
- },
283
- items: 'tr.product-edit',
284
- axis: 'y',
285
- containment: 'table#wpsc_product_list',
286
- placeholder: 'product-placeholder'
287
- });
288
-
289
- jQuery('table#wpsc_checkout_list').livequery(function(event){
290
- //this makes the checkout form fields sortable
291
- jQuery(this).sortable({
292
-
293
- items: 'tr.checkout_form_field',
294
- axis: 'y',
295
- containment: 'table#wpsc_checkout_list',
296
- placeholder: 'checkout-placeholder',
297
- handle: '.drag',
298
-
299
- });
300
- jQuery(this).bind('sortupdate', function(event, ui) {
301
-
302
- //post_values = jQuery(this).sortable();
303
- //post_values = "category_id="+category_id+"&"+checkout_order;
304
- post_values = jQuery( 'table#wpsc_checkout_list').sortable( 'serialize');
305
- jQuery.post( 'index.php?wpsc_admin_action=save_checkout_order', post_values, function(returned_data) { });
306
- });
307
-
308
- });
309
-
310
-
311
- // this helps show the links in the product list table, it is partially done using CSS, but that breaks in IE6
312
- jQuery("tr.product-edit").hover(
313
- function() {
314
- jQuery(".wpsc-row-actions", this).css("visibility", "visible");
315
- },
316
- function() {
317
- jQuery(".wpsc-row-actions", this).css("visibility", "hidden");
318
- }
319
- );
320
- // Used on admin/display-items.page.php - toggles the publish status of a product (dims background for unpublished) - 1bigidea
321
- // click logic from http://xplus3.net/2008/10/16/jquery-and-ajax-in-wordpress-plugins-administration-pages/
322
- /*
323
- jQuery(document).ready(function(){
324
- jQuery("span.publish_toggle a").click(function() {
325
- var that = this;
326
- var theRow = jQuery(this).parents('tr:first');
327
- jQuery.post(jQuery(this).attr("href"), {
328
- 'cookie': encodeURIComponent(document.cookie)
329
- }
330
- , function(newstatus){
331
- if (newstatus == 'true') {
332
- jQuery(that).text('Hide');
333
- jQuery(theRow).removeClass('wpsc_not_published').addClass('wpsc_published')
334
- } else {
335
- jQuery(that).text('Show');
336
- jQuery(theRow).removeClass('wpsc_published').addClass('wpsc_not_published');
337
- }
338
- }
339
- );
340
- return false; // The click never happened - defeat the a tag
341
- });
342
- });*/
343
-
344
- //jQuery('.selector :selected').val();
345
-
346
- jQuery('tr.wpsc_trackingid_row').hide();
347
- //jQuery('tr.wpsc_hastracking').show();
348
-
349
- jQuery('.wpsc_show_trackingid').click(function(event){
350
- purchlog_id = jQuery(this).attr('title');
351
- if(jQuery('tr.log'+purchlog_id).hasClass('wpsc_hastracking')){
352
- jQuery('tr.log'+purchlog_id).removeClass('wpsc_hastracking');
353
- jQuery('tr.log'+purchlog_id).hide();
354
- }else{
355
- jQuery('tr.log'+purchlog_id).addClass('wpsc_hastracking');
356
- jQuery('tr.log'+purchlog_id).show();
357
- }
358
- event.preventDefault();
359
- });
360
- // this changes the purchase log item status
361
- jQuery('.selector').change(function(){
362
- purchlog_id = jQuery(this).attr('title');
363
- purchlog_status = jQuery(this).val();
364
- post_values = "purchlog_id="+purchlog_id+"&purchlog_status="+purchlog_status;
365
- jQuery.post( 'index.php?ajax=true&wpsc_admin_action=purchlog_edit_status', post_values, function(returned_data) { });
366
-
367
- if(purchlog_status == 4){
368
- jQuery('tr.log'+purchlog_id).show();
369
-
370
- }
371
- });
372
-
373
- jQuery('.sendTrackingEmail').click(function(event){
374
- purchlog_id = jQuery(this).attr('title');
375
- post_values = "purchlog_id="+purchlog_id;
376
- jQuery.post( 'index.php?wpsc_admin_action=purchlog_email_trackid', post_values, function(returned_data) { });
377
- event.preventDefault();
378
- });
379
-
380
- // jQuery("#submit_category_select").click(function() {
381
- // new_url = jQuery("#category_select option:selected").val();
382
- // //console.log(new_url);
383
- // window.location = new_url;
384
- // return false;
385
- // });
386
-
387
-
388
- // this loads the edit-products page using javascript
389
- /* jQuery('.edit-product, .row-title').click(function(){
390
- jQuery(this).next('.loadingImg').removeAttr('style');
391
- product_id = jQuery(this).attr('href').match(/(?:;|&)product=(\d{1,})/);
392
- wpnonce = jQuery(this).attr('href').match(/_wpnonce=(\w{1,})/);
393
- post_values = "product="+product_id[1]+"&_wpnonce="+wpnonce[1];
394
- jQuery.post( 'index.php?wpsc_admin_action=load_product', post_values, function(returned_data) {
395
- if(typeof(tinyMCE) != "undefined") {
396
- tinyMCE.execCommand("mceRemoveControl",false,"content");
397
- }
398
- jQuery('form#modify-products #content').remove();
399
-
400
- jQuery('form#modify-products').html(returned_data);
401
- jQuery('.loadingImg').attr('style', 'display:none;');
402
- if ( getUserSetting( 'editor' ) != 'html' ) {
403
- jQuery("#quicktags").css('display', "none");
404
- if(typeof(tinyMCE) != "undefined") {
405
- tinyMCE.execCommand("mceAddControl", false, "content");
406
- }
407
- }
408
- });
409
-
410
- //
411
-
412
- });*/
413
-
414
- jQuery("a.thickbox").livequery(function(){
415
- tb_init(this);
416
- });
417
-
418
-
419
- // Code for using AJAX to change thr product price starts here
420
- ajax_submit_price = function(event) {
421
- target_element_id= event.data;
422
- form_data = jQuery("#"+target_element_id+" input").serialize();
423
- //console.log(form_data);
424
- jQuery.ajax({
425
- type: "POST",
426
- url: "admin.php?wpsc_admin_action=modify_price",
427
- data: form_data,
428
- success: function(returned_data) {
429
- eval(returned_data);
430
- if(success == 1) {
431
- parent_container = jQuery("#"+target_element_id+"").parent('.column-price');
432
- jQuery(".pricedisplay", parent_container).html(new_price);
433
- }
434
- jQuery('span.pricedisplay').css('display', 'inline-block');
435
- jQuery('div.price-editing-fields').css('display', 'none');
436
- jQuery('form#posts-filter').unbind('submit.disable');
437
- }
438
- });
439
- jQuery('form#posts-filter').unbind('submit.disable');
440
- return false;
441
- };
442
-
443
- jQuery("table#wpsc_product_list tr").livequery(function(){
444
- var open = true;
445
- jQuery("a.wpsc-quickedit", this).click( function(event) {
446
-
447
- if (open == true) {
448
- jQuery(this).parents("tr.iedit").find("span.skudisplay,span.salespricedisplay, span.pricedisplay,span.stockdisplay").click();
449
- jQuery(this).parents("tr.iedit").find("span.weightdisplay").click();
450
- open = false;
451
- } else {
452
- jQuery(this).parents("tr.iedit").find("div.price-editing-fields, div.sales-price-fields, div.weight-editing-fields, div.sku-editing-fields, div.stock-editing-fields").css("display", "none");
453
- jQuery(this).parents("tr.iedit").find("span.weightdisplay, span.skudisplay,span.salespricedisplay, span.pricedisplay,span.stockdisplay").css("display", "inline-block");
454
- open = true;
455
- }
456
-
457
- return false;
458
- });
459
- });
460
-
461
- jQuery("table#wpsc_product_list .column-price").livequery(function(){
462
- jQuery("span.pricedisplay", this).click( function(event) {
463
- jQuery('span.pricedisplay').css('display', 'inline-block');
464
- jQuery('div.price-editing-fields').css('display', 'none');
465
- jQuery(this).css('display', 'none');
466
- jQuery('div.price-editing-fields', jQuery(this).parent('.column-price')).css('display', 'inline-block');
467
-
468
- target_element_id = jQuery('div.price-editing-fields', jQuery(this).parent('.column-price')).attr('id');
469
- jQuery('form#posts-filter').bind('submit.disable',target_element_id, ajax_submit_price);
470
-
471
- jQuery('div.price-editing-fields .the-product-price', jQuery(this).parent('.column-price')).focus();
472
- });
473
-
474
- jQuery('.the-product-price',this).keyup(function(event){
475
- target_element_id = jQuery(jQuery(this).parent('.price-editing-fields')).attr('id');
476
- if(event.keyCode == 13) {
477
- jQuery('form#posts-filter').bind('submit.disable', target_element_id, ajax_submit_price);
478
- }
479
- });
480
-
481
- target_element_id = jQuery('.price-editing-fields',this).attr('id');
482
-
483
- jQuery('.the-product-price',this).bind('blur', target_element_id, ajax_submit_price);
484
- });
485
-
486
-
487
-
488
- // Code for using AJAX to change thr product price ends here
489
-
490
- // Code for using AJAX to change the sales price starts here
491
- ajax_submit_sales_price = function(event) {
492
- target_element_id= event.data;
493
- form_data = jQuery("#"+target_element_id+" input").serialize();
494
- // console.log(form_data);
495
- jQuery.ajax({
496
- type: "POST",
497
- url: "admin.php?wpsc_admin_action=modify_sales_price",
498
- data: form_data,
499
- success: function(returned_data) {
500
- eval(returned_data);
501
- if(success == 1) {
502
- parent_container = jQuery("#"+target_element_id+"").parent('.column-sale_price');
503
- jQuery(".salespricedisplay", parent_container).html(new_price);
504
- }
505
- jQuery('span.salespricedisplay').css('display', 'inline-block');
506
- jQuery('div.sales-price-fields').css('display', 'none');
507
- jQuery('form#posts-filter').unbind('submit.disable');
508
- }
509
- });
510
- jQuery('form#posts-filter').unbind('submit.disable');
511
- return false;
512
- };
513
-
514
- jQuery("table#wpsc_product_list .column-sale_price").livequery(function(){
515
- jQuery('span.salespricedisplay',this).click(function(){
516
- jQuery('span.salespricedisplay').css('display', 'inline-block');
517
- jQuery('div.sales-price-fields').css('display', 'none');
518
- jQuery(this).css('display', 'none');
519
- jQuery('div.sales-price-fields', jQuery(this).parent('.column-sale_price')).css('display', 'inline-block');
520
- target_element_id = jQuery('div.sales-price-fields', jQuery(this).parent('.column-sale_price')).attr('id');
521
- jQuery('form#posts-filter').bind('submit.disable',target_element_id, ajax_submit_sales_price);
522
- jQuery('div.sales-price-fields .the-sale-price', jQuery(this).parent('.column-sale_price')).focus();
523
- });
524
- jQuery('.the-sale-price',this).keyup(function(event){
525
- target_element_id = jQuery(jQuery(this).parent('.sales-price-fields')).attr('id');
526
- if(event.keyCode == 13) {
527
- jQuery('form#posts-filter').bind('submit.disable', target_element_id, ajax_submit_sales_price);
528
- }
529
- });
530
-
531
- target_element_id = jQuery('.sales-price-fields',this).attr('id');
532
-
533
- jQuery('.the-sale-price',this).bind('blur', target_element_id, ajax_submit_sales_price);
534
-
535
- });
536
-
537
- // Code for using AJAX to change the sales price ends here
538
-
539
- // Code for using AJAX to change the SKU starts here
540
- ajax_submit_sku = function(event) {
541
- target_element_id= event.data;
542
- form_data = jQuery("#"+target_element_id+" input").serialize();
543
- // console.log(form_data);
544
- jQuery.ajax({
545
- type: "POST",
546
- url: "admin.php?wpsc_admin_action=modify_sku",
547
- data: form_data,
548
- success: function(returned_data) {
549
- eval(returned_data);
550
- if(success == 1) {
551
- parent_container = jQuery("#"+target_element_id+"").parent('.column-SKU');
552
- jQuery(".skudisplay", parent_container).html(new_price);
553
- }
554
- jQuery('span.skudisplay').css('display', 'inline-block');
555
- jQuery('div.sku-editing-fields').css('display', 'none');
556
- jQuery('form#posts-filter').unbind('submit.disable');
557
- }
558
- });
559
- jQuery('form#posts-filter').unbind('submit.disable');
560
- return false;
561
- };
562
-
563
- jQuery("table#wpsc_product_list .column-SKU").livequery(function(){
564
- jQuery('span.skudisplay',this).click(function(){
565
- jQuery('span.skudisplay').css('display', 'inline-block');
566
- jQuery('div.sku-editing-fields').css('display', 'none');
567
- jQuery(this).css('display', 'none');
568
- jQuery('div.sku-editing-fields', jQuery(this).parent('.column-SKU')).css('display', 'inline-block');
569
- target_element_id = jQuery('div.sku-editing-fields', jQuery(this).parent('.column-SKU')).attr('id');
570
- jQuery('form#posts-filter').bind('submit.disable',target_element_id, ajax_submit_sku);
571
- jQuery('div.sku-editing-fields .the-sku-fields', jQuery(this).parent('.column-SKU')).focus();
572
- });
573
- jQuery('.the-sku-fields',this).keyup(function(event){
574
- target_element_id = jQuery(jQuery(this).parent('.sku-editing-fields')).attr('id');
575
- if(event.keyCode == 13) {
576
- jQuery('form#posts-filter').bind('submit.disable', target_element_id, ajax_submit_sku);
577
- }
578
- });
579
-
580
- target_element_id = jQuery('.sku-editing-fields',this).attr('id');
581
- jQuery('.the-sku-fields',this).bind('blur', target_element_id, ajax_submit_sku);
582
-
583
- });
584
-
585
- // Code for using AJAX to change the SKU ends here
586
-
587
-
588
-
589
-
590
-
591
-
592
- // Code for using AJAX to change the Weight starts here
593
- ajax_submit_weight= function(event) {
594
- target_element_id= event.data;
595
- form_data = jQuery("#"+target_element_id+" input").serialize();
596
- // console.log(form_data);
597
- jQuery.ajax({
598
- type: "POST",
599
- url: "admin.php?wpsc_admin_action=modify_weight",
600
- data: form_data,
601
- success: function(returned_data) {
602
- eval(returned_data);
603
- if(success == 1) {
604
- parent_container = jQuery("#"+target_element_id+"").parent('.column-weight');
605
- jQuery(".weightdisplay", parent_container).html(new_price);
606
- }
607
- jQuery('span.weightdisplay').css('display', 'inline-block');
608
- jQuery('div.weight-editing-fields').css('display', 'none');
609
- jQuery('form#posts-filter').unbind('submit.disable');
610
- }
611
- });
612
- jQuery('form#posts-filter').unbind('submit.disable');
613
- return false;
614
- };
615
-
616
- jQuery("table#wpsc_product_list .column-weight").livequery(function(){
617
- jQuery('span.weightdisplay',this).click(function(){
618
- jQuery('span.weightdisplay').css('display', 'inline-block');
619
- jQuery('div.weight-editing-fields').css('display', 'none');
620
- jQuery(this).css('display', 'none');
621
- jQuery('div.weight-editing-fields', jQuery(this).parent('.column-weight')).css('display', 'inline-block');
622
- target_element_id = jQuery('div.weight-editing-fields', jQuery(this).parent('.column-weight')).attr('id');
623
- jQuery('form#posts-filter').bind('submit.disable',target_element_id, ajax_submit_weight);
624
- jQuery('div.weight-editing-fields .the-weight-fields', jQuery(this).parent('.column-weight')).focus();
625
- });
626
- jQuery('.the-weight-fields',this).keyup(function(event){
627
- target_element_id = jQuery(jQuery(this).parent('.weight-editing-fields')).attr('id');
628
- if(event.keyCode == 13) {
629
- jQuery('form#posts-filter').bind('submit.disable', target_element_id, ajax_submit_weight);
630
- }
631
- });
632
-
633
- target_element_id = jQuery('.weight-editing-fields',this).attr('id');
634
- jQuery('.the-weight-fields',this).bind('blur', target_element_id, ajax_submit_weight);
635
-
636
- });
637
-
638
- // Code for using AJAX to change the Weight ends here
639
-
640
-
641
-
642
-
643
-
644
-
645
- // Code for using AJAX to change the Stock Levels starts here
646
- ajax_submit_stock = function(event) {
647
- target_element_id= event.data;
648
- form_data = jQuery("#"+target_element_id+" input").serialize();
649
- // console.log(form_data);
650
- jQuery.ajax({
651
- type: "POST",
652
- url: "admin.php?wpsc_admin_action=modify_stock",
653
- data: form_data,
654
- success: function(returned_data) {
655
- eval(returned_data);
656
- if(success == 1) {
657
- parent_container = jQuery("#"+target_element_id+"").parent('.column-stock');
658
- jQuery(".stockdisplay", parent_container).html(new_price);
659
- }
660
- jQuery('span.stockdisplay').css('display', 'inline-block');
661
- jQuery('div.stock-editing-fields').css('display', 'none');
662
- jQuery('form#posts-filter').unbind('submit.disable');
663
- }
664
- });
665
- jQuery('form#posts-filter').unbind('submit.disable');
666
- return false;
667
- };
668
-
669
- jQuery("table#wpsc_product_list .column-stock").livequery(function(){
670
- jQuery('span.stockdisplay',this).click(function(){
671
- jQuery('span.stockdisplay').css('display', 'inline-block');
672
- jQuery('div.stock-editing-fields').css('display', 'none');
673
- jQuery(this).css('display', 'none');
674
- jQuery('div.stock-editing-fields', jQuery(this).parent('.column-stock')).css('display', 'inline-block');
675
- target_element_id = jQuery('div.stock-editing-fields', jQuery(this).parent('.column-stock')).attr('id');
676
- jQuery('form#posts-filter').bind('submit.disable',target_element_id, ajax_submit_stock);
677
- jQuery('div.stock-editing-fields .the-stock-fields', jQuery(this).parent('.column-stock')).focus();
678
- });
679
- jQuery('.the-stock-fields',this).keyup(function(event){
680
- target_element_id = jQuery(jQuery(this).parent('.stock-editing-fields')).attr('id');
681
- if(event.keyCode == 13) {
682
- jQuery('form#posts-filter').bind('submit.disable', target_element_id, ajax_submit_stock);
683
- }
684
- });
685
-
686
- target_element_id = jQuery('.stock-editing-fields',this).attr('id');
687
- jQuery('.the-stock-fields',this).bind('blur', target_element_id, ajax_submit_stock);
688
-
689
- });
690
-
691
- // Code for using AJAX to change the Stock Levels ends here
692
-
693
-
694
-
695
-
696
- jQuery("div.admin_product_name a.shorttag_toggle").livequery(function(){
697
- jQuery(this).toggle(
698
- function () {
699
- jQuery("div.admin_product_shorttags", jQuery(this).parents("table.product_editform")).css('display', 'block');
700
- return false;
701
- },
702
- function () {
703
- //jQuery("div#admin_product_name a.shorttag_toggle").toggleClass('toggled');
704
- jQuery("div.admin_product_shorttags", jQuery(this).parents("table.product_editform")).css('display', 'none');
705
- return false;
706
- }
707
- );
708
- });
709
-
710
- jQuery('a.add_variation_item_form').livequery(function(){
711
- jQuery(this).click(function() {
712
- form_field_container = jQuery(this).siblings('#variation_values');
713
- form_field = jQuery("div.variation_value", form_field_container).eq(0).clone();
714
-
715
- jQuery('input.text',form_field).attr('name','new_variation_values[]');
716
- jQuery('input.text',form_field).val('');
717
- jQuery('input.variation_values_id',form_field).remove();
718
-
719
- jQuery(form_field_container).append(form_field);
720
- return false;
721
- });
722
- });
723
-
724
-
725
- jQuery('div.variation_value a.delete_variation_value').livequery(function(){
726
- jQuery(this).click( function() {
727
- element_count = jQuery("#variation_values div").size();
728
-
729
- if(element_count > 1) {
730
-
731
- parent_element = jQuery(this).parent("div.variation_value");
732
- variation_value_id = jQuery("input.variation_values_id", parent_element).val();
733
-
734
- delete_url = jQuery(this).attr('href');
735
- post_values = "remove_variation_value=true&variation_value_id="+variation_value_id;
736
- jQuery.post( delete_url, "ajax=true", function(returned_data) {
737
- jQuery("#variation_row_"+returned_data).fadeOut('fast', function() {
738
- jQuery(this).remove();
739
- });
740
- });
741
- }
742
- return false;
743
- });
744
- });
745
-
746
- jQuery('a.add_new_form_set').livequery(function(){
747
- jQuery(this).click( function() {
748
- jQuery(".add_new_form_set_forms").toggle();
749
- });
750
- });
751
-
752
-
753
- jQuery("#add-product-image").click(function(){
754
- swfu.selectFiles();
755
- });
756
-
757
- jQuery('.hide-postbox-tog').livequery(function(){
758
- jQuery(this).click( function() {
759
- var box = jQuery(this).val();
760
- if ( jQuery(this).attr('checked') ) {
761
- jQuery('#' + box).show();
762
- if ( jQuery.isFunction( postboxes.pbshow ) ) {
763
- postboxes.pbshow( box );
764
- }
765
- } else {
766
- jQuery('#' + box).hide();
767
- if ( jQuery.isFunction( postboxes.pbhide ) ) {
768
- postboxes.pbhide( box );
769
- }
770
- }
771
- // postboxes.save_state('products_page_wpsc-edit-products');
772
- });
773
- });
774
- //postbox hiding
775
-
776
- jQuery('div.metabox-prefs label input').livequery(function(){
777
- jQuery(this).click(function() {
778
- var hidden_val = jQuery(this).val();
779
- if ( jQuery(this).is(':checked') ) {
780
- var hidden = 1;
781
- }
782
- else {
783
- var hidden = 0;
784
- }
785
- jQuery.post('index.php?admin=true&ajax=true', {
786
- action: 'postbox-hide',
787
- hidden: hidden,
788
- hidden_val: hidden_val
789
- });
790
- });
791
- });
792
-
793
-
794
- // postbox sorting
795
- jQuery('div#side-sortables, div#advanced-sortables').livequery(function(){
796
- jQuery(this).sortable({
797
- placeholder: 'sortable-placeholder',
798
- connectWith: [ '.meta-box-sortables-wpec' ],
799
- items: '> .postbox',
800
- handle: '.hndle',
801
- distance: 2,
802
- tolerance: 'pointer',
803
- sort: function(e,ui) {
804
- if ( jQuery(document).width() - e.clientX < 300 ) {
805
- if ( ! jQuery('#post-body').hasClass('has-sidebar') ) {
806
- var pos = jQuery('#side-sortables').offset();
807
-
808
- jQuery('#side-sortables').append(ui.item)
809
- jQuery(ui.placeholder).css({
810
- 'top':pos.top,
811
- 'left':pos.left
812
- }).width(jQuery(ui.item).width())
813
- postboxes.expandSidebar(1);
814
- }
815
- }
816
- },
817
- stop: function() {
818
- var postVars = {
819
- action: 'product-page-order',
820
- ajax: 'true'
821
- }
822
- postVars["order[advanced]"] = jQuery('div#advanced-sortables').sortable( 'toArray' ).join(',');
823
- postVars["order[side]"] = jQuery('div#side-sortables').sortable( 'toArray' ).join(',');
824
- jQuery.post( 'index.php?admin=true&ajax=true', postVars, function() {
825
- postboxes.expandSidebar();
826
- } );
827
- }
828
- });
829
- });
830
-
831
- jQuery('a.closeimagesettings').livequery(function(){
832
- jQuery(this).click( function() {
833
- jQuery('.image_settings_box').hide();
834
- });
835
- });
836
-
837
-
838
- jQuery("#gallery_list").livequery(function(){
839
- jQuery(this).sortable({
840
- revert: false,
841
- placeholder: "ui-selected",
842
- start: function(e,ui) {
843
- jQuery('#image_settings_box').hide();
844
- jQuery('a.editButton').hide();
845
- jQuery('img.deleteButton').hide();
846
- jQuery('ul#gallery_list').children('li').removeClass('first');
847
- },
848
- stop:function (e,ui) {
849
- jQuery('ul#gallery_list').children('li:first').addClass('first');
850
- },
851
- update: function (e,ui){
852
- input_set = jQuery.makeArray(jQuery("#gallery_list li:not(.ui-sortable-helper) input.image-id"));
853
- //console.log(input_set);
854
- set = new Array();
855
- for( var i in input_set) {
856
- set[i] = jQuery(input_set[i]).val();
857
- }
858
- //console.log(set);
859
- /*
860
- img_id = jQuery('#gallery_image_'+set[0]).parent('li').attr('id');
861
-
862
- jQuery('#gallery_image_'+set[0]).children('img.deleteButton').remove();
863
- jQuery('#gallery_image_'+set[0]).append("<a class='editButton'>Edit <img src='" + WPSC_CORE_IMAGES_URL + "/pencil.png' alt ='' /></a>");
864
- // jQuery('#gallery_image_'+set[0]).parent('li').attr('id', "product_image_"+img_id);
865
- //for(i=1;i<set.length;i++) {
866
- // jQuery('#gallery_image_'+set[i]).children('a.editButton').remove();
867
- // jQuery('#gallery_image_'+set[i]).append("<img alt='-' class='deleteButton' src='" + WPSC_CORE_IMAGES_URL + "/cross.png'/>");
868
- //}
869
-
870
- for(i=1;i<set.length;i++) {
871
- jQuery('#gallery_image_'+set[i]).children('a.editButton').remove();
872
- jQuery('#gallery_image_'+set[i]).append("<img alt='-' class='deleteButton' src='" + WPSC_CORE_IMAGES_URL + "/cross.png'/>");
873
-
874
- element_id = jQuery('#gallery_image_'+set[i]).parent('li').attr('id');
875
- if(element_id == 0) {
876
- // jQuery('#gallery_image_'+set[i]).parent('li').attr('id', "product_image_"+img_id);
877
- }
878
- }
879
- */
880
- order = set.join(',');
881
- product_id = jQuery('#product_id').val();
882
-
883
- postVars = "product_id="+product_id+"&order="+order;
884
- jQuery.post( 'index.php?wpsc_admin_action=rearrange_images', postVars, function(returned_data) {
885
- eval(returned_data);
886
- jQuery('#gallery_image_'+image_id).children('a.editButton').remove();
887
- jQuery('#gallery_image_'+image_id).children('div.image_settings_box').remove();
888
- jQuery('#gallery_image_'+image_id).append(image_menu);
889
- });
890
-
891
- },
892
- 'opacity':0.5
893
- });
894
- });
895
-
896
-
897
-
898
-
899
- // show or hide the stock input forms
900
- jQuery("input.limited_stock_checkbox").livequery(function(){
901
- jQuery(this).click( function () {
902
- parent_form = jQuery(this).parents('form');
903
- if(jQuery(this).attr('checked') == true) {
904
- jQuery("div.edit_stock",parent_form).show();
905
- jQuery("th.stock, td.stock", parent_form).show();
906
- } else {
907
- jQuery("div.edit_stock", parent_form).hide();
908
- jQuery("th.stock, td.stock", parent_form).hide();
909
- }
910
- });
911
- });
912
-
913
-
914
- jQuery("#table_rate_price").livequery(function(){
915
- if (!this.checked) {
916
- jQuery("#table_rate").hide();
917
- }
918
- jQuery(this).click( function() {
919
- if (this.checked) {
920
- jQuery("#table_rate").show();
921
- } else {
922
- jQuery("#table_rate").hide();
923
- }
924
- });
925
- });
926
-
927
- jQuery("#custom_tax_checkbox").livequery(function(){
928
- jQuery(this).click( function() {
929
- if (this.checked) {
930
- jQuery("#custom_tax").show();
931
- } else {
932
- jQuery("#custom_tax input").val('');
933
- jQuery("#custom_tax").hide();
934
- }
935
- });
936
- });
937
-
938
- jQuery(".add_level").livequery(function(){
939
- jQuery(this).click(function() {
940
- added = jQuery(this).parent().children('table').append('<tr><td><input type="text" size="10" value="" name="table_rate_price[quantity][]"/> and above</td><td><input type="text" size="10" value="" name="table_rate_price[table_price][]"/></td></tr>');
941
- });
942
- });
943
-
944
-
945
- jQuery(".remove_line").livequery(function(){
946
- jQuery(this).click(function() {
947
- jQuery(this).parent().parent('tr').remove();
948
- });
949
- });
950
- /* shipping options start */
951
- // gets shipping form for admin page
952
- // show or hide the stock input forms
953
-
954
- jQuery(".wpsc-payment-actions a").livequery(function(){
955
- jQuery(this).click( function () {
956
- var module = jQuery(this).attr('rel');
957
- //console.log(module);
958
- jQuery.ajax({
959
- method: "post",
960
- url: "index.php",
961
- data: "wpsc_admin_action=get_payment_form&paymentname="+module,
962
- success: function(returned_data){
963
- // console.log(returned_data);
964
- eval(returned_data);
965
- //jQuery(".gateway_settings").children(".form-table").html(html)
966
- jQuery('.gateway_settings h3.hndle').html(payment_name_html);
967
- jQuery("td.gateway_settings table.form-table").html('<tr><td><input type="hidden" name="paymentname" value="'+module+'" /></td></tr>'+payment_form_html);
968
- if(has_submit_button != '') {
969
- jQuery('.gateway_settings div.submit').css('display', 'block');
970
- } else {
971
- jQuery('.gateway_settings div.submit').css('display', 'none');
972
- }
973
- }
974
- });
975
- return false;
976
-
977
- });
978
- });
979
-
980
- jQuery('#addweightlayer').livequery(function(){
981
- jQuery(this).click(function(){
982
- jQuery(this).parent().append("<div class='wpsc_newlayer'><tr class='rate_row'><td><i style='color:grey'>"+TXT_WPSC_IF_WEIGHT_IS+"</i><input type='text' name='weight_layer[]' size='10'> <i style='color:grey'>"+TXT_WPSC_AND_ABOVE+"</i></td><td><input type='text' name='weight_shipping[]' size='10'>&nbsp;&nbsp;<a href='' class='delete_button nosubmit' >"+TXT_WPSC_DELETE+"</a></td></tr></div>");
983
- });
984
-
985
- });
986
-
987
- jQuery('#addlayer').livequery(function(){
988
- jQuery(this).click(function(){
989
- jQuery(this).parent().append("<div class='wpsc_newlayer'><tr class='rate_row'><td><i style='color:grey'>"+TXT_WPSC_IF_PRICE_IS+"</i><input type='text' name='layer[]' size='10'> <i style='color:grey'>"+TXT_WPSC_AND_ABOVE+"</i></td><td><input type='text' name='shipping[]' size='10'>&nbsp;&nbsp;<a href='' class='delete_button nosubmit' >"+TXT_WPSC_DELETE+"</a></td></tr></div>");
990
- //bind_shipping_rate_deletion();
991
- return false;
992
- });
993
-
994
- });
995
-
996
- jQuery('table#gateway_options a.delete_button').livequery(function(){
997
- jQuery(this).click(function () {
998
- this_row = jQuery(this).parent().parent('tr .rate_row');
999
- // alert(this_row);
1000
- //jQuery(this_row).hide();
1001
- if(jQuery(this).hasClass('nosubmit')) {
1002
- // if the row was added using JS, just scrap it
1003
- this_row = jQuery(this).parent('div .wpsc_newlayer');
1004
- jQuery(this_row).remove();
1005
- } else {
1006
- // otherwise, empty it and submit it
1007
- jQuery('input', this_row).val('');
1008
- jQuery(this).parents('form').submit();
1009
- }
1010
- return false;
1011
- });
1012
- });
1013
-
1014
- // hover for gallery view
1015
- jQuery("div.previewimage").livequery(function(){
1016
- jQuery(this).hover(
1017
- function () {
1018
- jQuery(this).children('img.deleteButton').show();
1019
- if(jQuery('div.image_settings_box').css('display')!='block')
1020
- jQuery(this).children('a.editButton').show();
1021
- },
1022
- function () {
1023
- jQuery(this).children('img.deleteButton').hide();
1024
- jQuery(this).children('a.editButton').hide();
1025
- }
1026
- );
1027
- });
1028
-
1029
-
1030
- // display image editing menu
1031
- jQuery("a.editButton").livequery(function(){
1032
- jQuery(this).click( function(){
1033
- jQuery(this).hide();
1034
- jQuery('div.image_settings_box').show('fast');
1035
- });
1036
- });
1037
- // hide image editing menu
1038
- jQuery("a.closeimagesettings").livequery(function(){
1039
- jQuery(this).click(function (e) {
1040
- jQuery("div#image_settings_box").hide();
1041
- });
1042
- });
1043
-
1044
- // delete upload
1045
- jQuery(".file_delete_button").livequery(function(){
1046
- jQuery(this).click(function() {
1047
- url = jQuery(this).attr('href');
1048
- post_values = "ajax=true";
1049
- jQuery.post( url, post_values, function(returned_data) {
1050
- eval(returned_data);
1051
- });
1052
- return false;
1053
- });
1054
- });
1055
-
1056
- // Options page ajax tab display
1057
- jQuery('#sidemenu li').click(function(){
1058
- page_title = jQuery(this).attr('id');
1059
-
1060
- wpnonce = jQuery('a',this).attr('href').match(/_wpnonce=(\w{1,})/);
1061
- post_values = "wpsc_admin_action=settings_page_ajax&page_title="+page_title+"&_wpnonce="+wpnonce[1];
1062
- jQuery.post('admin.php?', post_values, function(html){
1063
- //console.log(html);
1064
- jQuery('a.current').removeClass('current');
1065
- jQuery('#'+page_title+' a' ).addClass('current');
1066
- jQuery('#wpsc_options_page').html('');
1067
- jQuery('#wpsc_options_page').html(html);
1068
-
1069
- });
1070
- return false;
1071
-
1072
- });
1073
-
1074
- jQuery('.wpsc_featured_product_toggle').livequery(function(){
1075
- jQuery(this).click(function(event){
1076
- target_url = jQuery(this).attr('href');
1077
- post_values = "ajax=true";
1078
- jQuery.post(target_url, post_values, function(returned_data){
1079
- eval(returned_data);
1080
- });
1081
- return false;
1082
- });
1083
- });
1084
-
1085
- });
1086
-
1087
-
1088
-
1089
- // function for adding more custom meta
1090
- function add_more_meta(e) {
1091
- current_meta_forms = jQuery(e).parent().children("div.product_custom_meta:last"); // grab the form container
1092
- new_meta_forms = current_meta_forms.clone(true); // clone the form container
1093
- jQuery("label input", new_meta_forms).val(''); // reset all contained forms to empty
1094
- current_meta_forms.after(new_meta_forms); // append it after the container of the clicked element
1095
- return false;
1096
- }
1097
-
1098
- // function for removing custom meta
1099
- function remove_meta(e, meta_id) {
1100
- current_meta_form = jQuery(e).parent("div.product_custom_meta"); // grab the form container
1101
- //meta_name = jQuery("input#custom_meta_name_"+meta_id, current_meta_form).val();
1102
- //meta_value = jQuery("input#custom_meta_value_"+meta_id, current_meta_form).val();
1103
- returned_value = jQuery.ajax({
1104
- type: "POST",
1105
- url: "admin.php?ajax=true",
1106
- data: "admin=true&remove_meta=true&meta_id="+meta_id+"",
1107
- success: function(results) {
1108
- if(results > 0) {
1109
- jQuery("div#custom_meta_"+meta_id).remove();
1110
- }
1111
- }
1112
- });
1113
- return false;
1114
- }
1115
-
1116
-
1117
- // function for switching the state of the image upload forms
1118
- function wpsc_upload_switcher(target_state) {
1119
- switch(target_state) {
1120
- case 'flash':
1121
- jQuery("div.browser-image-uploader").css("display","none");
1122
- jQuery("div.flash-image-uploader").css("display","block");
1123
- jQuery.post( 'index.php?admin=true', "admin=true&ajax=true&save_image_upload_state=true&image_upload_state=1", function(returned_data) { });
1124
- break;
1125
-
1126
- case 'browser':
1127
- jQuery("div.flash-image-uploader").css("display","none");
1128
- jQuery("div.browser-image-uploader").css("display","block");
1129
- jQuery.post( 'index.php?admin=true', "admin=true&ajax=true&save_image_upload_state=true&image_upload_state=0", function(returned_data) { });
1130
- break;
1131
- }
1132
- }
1133
-
1134
- // function for switching the state of the extra resize forms
1135
- function image_resize_extra_forms(option) {
1136
- container = jQuery(option).parent();
1137
- jQuery("div.image_resize_extra_forms").css('display', 'none');
1138
- jQuery("div.image_resize_extra_forms",container).css('display', 'block');
1139
- }
1140
-
1141
-
1142
- var prevElement = null;
1143
- var prevOption = null;
1144
-
1145
- function hideOptionElement(id, option) {
1146
- if (prevOption == option) {
1147
- return;
1148
- }
1149
- if (prevElement != null) {
1150
- prevElement.style.display = "none";
1151
- }
1152
-
1153
- if (id == null) {
1154
- prevElement = null;
1155
- } else {
1156
- prevElement = document.getElementById(id);
1157
- jQuery('#'+id).css( 'display','block');
1158
- }
1159
- prevOption = option;
1160
- }
1161
-
1162
-
1163
- function wpsc_save_postboxes_state(page, container) {
1164
- var closed = jQuery(container+' .postbox').filter('.closed').map(function() {
1165
- return this.id;
1166
- }).get().join(',');
1167
- jQuery.post('index.php?admin=true&ajax=true', {
1168
- action: 'closed-postboxes',
1169
- closed: closed,
1170
- closedpostboxesnonce: jQuery('#closedpostboxesnonce').val(),
1171
- page: page
1172
- });
1173
- }
1174
-
1175
-
1176
- function hideelement(id) {
1177
- state = document.getElementById(id).style.display;
1178
- //alert(document.getElementById(id).style.display);
1179
- if(state != 'block') {
1180
- document.getElementById(id).style.display = 'block';
1181
- } else {
1182
- document.getElementById(id).style.display = 'none';
1183
- }
1184
- }
1185
-
1186
- /*
1187
- * Modified copy of the wordpress edToolbar function that does the same job, it uses document.write, we cannot.
1188
- */
1189
- function wpsc_edToolbar() {
1190
- //document.write('<div id="ed_toolbar">');
1191
- output = '';
1192
- for (i = 0; i < edButtons.length; i++) {
1193
- output += wpsc_edShowButton(edButtons[i], i);
1194
- }
1195
- output += '<input type="button" id="ed_spell" class="ed_button" onclick="edSpell(edCanvas);" title="' + quicktagsL10n.dictionaryLookup + '" value="' + quicktagsL10n.lookup + '" />';
1196
- output += '<input type="button" id="ed_close" class="ed_button" onclick="edCloseAllTags();" title="' + quicktagsL10n.closeAllOpenTags + '" value="' + quicktagsL10n.closeTags + '" />';
1197
- // edShowLinks(); // disabled by default
1198
- //document.write('</div>');
1199
- jQuery('div#ed_toolbar').html(output);
1200
- }
1201
-
1202
-
1203
- /*
1204
- * Modified copy of the wordpress edShowButton function that does the same job, it uses document.write, we cannot.
1205
- */
1206
-
1207
- function wpsc_edShowButton(button, i) {
1208
- if (button.id == 'ed_img') {
1209
- output = '<input type="button" id="' + button.id + '" accesskey="' + button.access + '" class="ed_button" onclick="edInsertImage(edCanvas);" value="' + button.display + '" />';
1210
- }
1211
- else if (button.id == 'ed_link') {
1212
- output = '<input type="button" id="' + button.id + '" accesskey="' + button.access + '" class="ed_button" onclick="edInsertLink(edCanvas, ' + i + ');" value="' + button.display + '" />';
1213
- }
1214
- else {
1215
- output = '<input type="button" id="' + button.id + '" accesskey="' + button.access + '" class="ed_button" onclick="edInsertTag(edCanvas, ' + i + ');" value="' + button.display + '" />';
1216
- }
1217
- return output;
1218
- }
1219
-
1220
-
1221
-
1222
- function fillcategoryform(catid) {
1223
- post_values = 'ajax=true&admin=true&catid='+catid;
1224
- jQuery.post( 'index.php', post_values, function(returned_data) {
1225
- jQuery('#formcontent').html( returned_data );
1226
- jQuery('form.edititem').css('display', 'block');
1227
- jQuery('#additem').css('display', 'none');
1228
- jQuery('#blank_item').css('display', 'none');
1229
- jQuery('#productform').css('display', 'block');
1230
- jQuery("#loadingindicator_span").css('visibility','hidden');
1231
- });
1232
- }
1233
-
1234
- function submit_status_form(id) {
1235
- document.getElementById(id).submit();
1236
- }
1237
- function showaddform() {
1238
- jQuery('#blank_item').css('display', 'none');
1239
- jQuery('#productform').css('display', 'none');
1240
- jQuery('#additem').css('display', 'block');
1241
- return false;
1242
- }
1243
- //used to add new form fields in the checkout setting page
1244
- function add_form_field() {
1245
- time = new Date();
1246
- new_element_number = time.getTime();
1247
- new_element_id = "form_id_"+new_element_number;
1248
-
1249
- new_element_contents = "";
1250
- //new_element_contents += "<tr class='checkout_form_field' >\n\r";
1251
- new_element_contents += "<td class='drag'></td>";
1252
- new_element_contents += "<td class='namecol'><input type='text' name='new_form_name["+new_element_number+"]' value='' /></td>\n\r";
1253
- new_element_contents += "<td class='typecol'><select class='wpsc_checkout_selectboxes' name='new_form_type["+new_element_number+"]'>"+HTML_FORM_FIELD_TYPES+"</select></td>\n\r";
1254
- new_element_contents += "<td class='typecol'><select name='new_form_unique_name["+new_element_number+"]'>"+HTML_FORM_FIELD_UNIQUE_NAMES+"</select></td>\n\r";
1255
- new_element_contents += "<td class='mandatorycol' style='text-align: center;'><input type='checkbox' name='new_form_mandatory["+new_element_number+"]' value='1' /></td>\n\r";
1256
- new_element_contents += "<td><a class='image_link' href='#' onclick='return remove_new_form_field(\""+new_element_id+"\");'><img src='" + WPSC_CORE_IMAGES_URL + "/trash.gif' alt='"+TXT_WPSC_DELETE+"' title='"+TXT_WPSC_DELETE+"' /></a></td>\n\r";
1257
- // new_element_contents += "</tr>";
1258
-
1259
- new_element = document.createElement('tr');
1260
- new_element.id = new_element_id;
1261
- document.getElementById("wpsc_checkout_list_body").appendChild(new_element);
1262
- document.getElementById(new_element_id).innerHTML = new_element_contents;
1263
- jQuery('#'+new_element_id).addClass('checkout_form_field');
1264
- return false;
1265
- }
1266
-
1267
-
1268
-
1269
- function remove_new_form_field(id) {
1270
- element_count = document.getElementById("wpsc_checkout_list_body").childNodes.length;
1271
- if(element_count > 1) {
1272
- target_element = document.getElementById(id);
1273
- document.getElementById("wpsc_checkout_list_body").removeChild(target_element);
1274
- }
1275
- return false;
1276
- }
1277
-
1278
-
1279
- function submit_change_country() {
1280
- document.cart_options.submit();
1281
- //document.cart_options.submit();
1282
- }
1283
-
1284
- function getcurrency(id) {
1285
- //ajax.post("index.php",gercurrency,"wpsc_admin_action=change_currency&currencyid="+id);
1286
- }
1287
- //delete checkout fields from checkout settings page
1288
- function remove_form_field(id,form_id) {
1289
- var delete_variation_value=function(results) { }
1290
- element_count = document.getElementById("wpsc_checkout_list_body").childNodes.length;
1291
- if(element_count > 1) {
1292
- ajax.post("index.php",delete_variation_value,"admin=true&ajax=true&remove_form_field=true&form_id="+form_id);
1293
- target_element = document.getElementById(id);
1294
- document.getElementById("wpsc_checkout_list_body").removeChild(target_element);
1295
- }
1296
- return false;
1297
- }
1298
-
1299
- function showadd_categorisation_form() {
1300
- if(jQuery('div_categorisation').css('display') != 'block') {
1301
- jQuery('div#add_categorisation').css('display', 'block');
1302
- jQuery('div#edit_categorisation').css('display', 'none');
1303
- } else {
1304
- jQuery('div#add_categorisation').css('display', 'none');
1305
- }
1306
- return false;
1307
- }
1308
-
1309
-
1310
- function showedit_categorisation_form() {
1311
- if(jQuery('div#edit_categorisation').css('display') != 'block') {
1312
- jQuery('div#edit_categorisation').css('display', 'block');
1313
- jQuery('div#add_categorisation').css('display', 'none');
1314
- } else {
1315
- jQuery('div#edit_categorisation').css('display', 'none');
1316
- }
1317
- return false;
1318
- }
1319
-
1320
- function hideelement1(id, item_value) {
1321
- //alert(value);
1322
- if(item_value == 5) {
1323
- jQuery(document.getElementById(id)).css('display', 'block');
1324
- } else {
1325
- jQuery(document.getElementById(id)).css('display', 'none');
1326
- }
1327
- }
1328
-
1329
- function toggle_display_options(state) {
1330
- switch(state) {
1331
- case 'list':
1332
- document.getElementById('grid_view_options').style.display = 'none';
1333
- document.getElementById('list_view_options').style.display = 'block';
1334
- break;
1335
-
1336
- case 'grid':
1337
- document.getElementById('list_view_options').style.display = 'none';
1338
- document.getElementById('grid_view_options').style.display = 'block';
1339
- break;
1340
-
1341
- default:
1342
- document.getElementById('list_view_options').style.display = 'none';
1343
- document.getElementById('grid_view_options').style.display = 'none';
1344
- break;
1345
- }
1346
- }
1347
-
1348
- function show_status_box(id,image_id) {
1349
- state = document.getElementById(id).style.display;
1350
- if(state != 'block') {
1351
- document.getElementById(id).style.display = 'block';
1352
- document.getElementById(image_id).src = WPSC_CORE_IMAGES_URL + '/icon_window_collapse.gif';
1353
- } else {
1354
- document.getElementById(id).style.display = 'none';
1355
- document.getElementById(image_id).src = WPSC_CORE_IMAGES_URL + '/icon_window_expand.gif';
1356
- }
1357
- return false;
1358
- }
1359
-
1
+ // This is the wp-e-commerce front end javascript "library"
2
+
3
+ jQuery(document).ready(function(){
4
+
5
+ jQuery('table.widefat tbody tr').each(function(){
6
+ id = jQuery(this).attr("id");
7
+ jQuery('#' + id + ' td.hidden_alerts img').appendTo('#' + id + ' td.column-title strong');
8
+ });
9
+ jQuery('label[for=wpsc-variationdiv-hide]').css('display', 'none');
10
+
11
+ jQuery('a.update_variations_action').click(function(){
12
+ jQuery("<img class='loading' src='images/loading.gif' height='15' width='15' />").insertAfter(this);
13
+ edit_var_val = jQuery('div.variation_checkboxes input:checked').serialize();
14
+ description = jQuery('#content_ifr').contents().find('body').html();
15
+ additional_description = jQuery('textarea#additional_description').text();
16
+ name = jQuery('input#title').val();
17
+ product_id = jQuery('input#product_id').val();
18
+ post_values = edit_var_val+'&description='+description+'&additional_description='+additional_description+'&name='+name+'&product_id='+product_id;
19
+ jQuery('div#wpsc_product_variation_forms table.widefat tbody').fadeTo(200, 0, function(){
20
+ jQuery.post('index.php?wpsc_admin_action=wpsc_update_variations',post_values, function(returned_data){
21
+ jQuery('div#wpsc_product_variation_forms table.widefat tbody').html(returned_data).fadeTo(200, 1);
22
+ jQuery('img.loading').hide();
23
+ });
24
+ });
25
+ return false;
26
+
27
+ });
28
+ /* Coupon edit functionality */
29
+ jQuery('.modify_coupon').hide();
30
+ jQuery('.wpsc_edit_coupon').click(function(){
31
+ id = jQuery(this).attr('rel');
32
+ id = 'coupon_box_'+id;
33
+ if(jQuery('#'+id).hasClass('displaynone')){
34
+ jQuery('#'+id).show();
35
+ jQuery('#'+id).removeClass('displaynone');
36
+ }else{
37
+ jQuery('#'+id).addClass('displaynone');
38
+ jQuery('#'+id).hide();
39
+ }
40
+
41
+ });
42
+ jQuery("form[name='add_coupon'] input[name='submit_coupon']").click(function() {
43
+ var title = jQuery("form[name='add_coupon'] input[name='add_coupon_code']").val();
44
+ if ( title == '') {
45
+ alert('Please enter a coupon code.');
46
+ return false;
47
+ }
48
+ });
49
+ //Animateedit products columns
50
+ jQuery('.wpsc-separator').livequery(function(){
51
+ jQuery(this).click(function(){
52
+ if(jQuery('#wpsc-col-left').css('width') == '20px'){
53
+ left_col_width = '50%';
54
+ right_col_width = '48%';
55
+
56
+ }else{
57
+ left_col_width = '20px';
58
+ right_col_width = '95%';
59
+ }
60
+ if(left_col_width == '50%'){
61
+ jQuery('.tablenav').show();
62
+ jQuery('#posts-filter').show();
63
+ }else{
64
+ jQuery('.tablenav').hide();
65
+ jQuery('#posts-filter').hide();
66
+
67
+ }
68
+ //jQuery(this).css('background-position','0');
69
+ jQuery('#wpsc-col-left').animate(
70
+ {
71
+ width : left_col_width
72
+ },
73
+ 50,
74
+ function(){
75
+ //On complete
76
+
77
+ }
78
+ );
79
+ jQuery('#wpsc-col-right').animate(
80
+ {
81
+ width : right_col_width
82
+ },
83
+ 50,
84
+ function(){
85
+ //On complete
86
+
87
+ }
88
+ );
89
+ });
90
+
91
+ });
92
+
93
+ jQuery('.wpsc_prod_thumb_option').livequery(function(){
94
+ jQuery(this).focus(function(){
95
+ jQuery('.wpsc_mass_resize').css('visibility', 'visible');
96
+ });
97
+ });
98
+
99
+ jQuery('.wpsc_prod_thumb_option').livequery(function(){
100
+ jQuery(this).blur(function(){
101
+ jQuery('.wpsc_mass_resize').css('visibility', 'hidden');
102
+ });
103
+ });
104
+
105
+
106
+ //Delete checkout options on settings>checkout page
107
+ jQuery('.wpsc_delete_option').livequery(function(){
108
+ jQuery(this).click(function(event){
109
+ jQuery(this).parent().parent('tr').remove();
110
+ event.preventDefault();
111
+ });
112
+
113
+ });
114
+ //Changing the checkout fields page
115
+ jQuery('#wpsc_checkout_sets').livequery(function(){
116
+ jQuery(this).change(function(){
117
+
118
+ });
119
+
120
+ });
121
+ //checkboxes on checkout page
122
+ /*
123
+ jQuery('.wpsc_checkout_selectboxes').livequery(function(){
124
+ jQuery(this).change(function(){
125
+ if(jQuery(this).val() == 'checkbox' || jQuery(this).val() == 'radio' ||
126
+ jQuery(this).val() == 'select'){
127
+ id = jQuery(this).attr('name');
128
+ id = id.replace('form_type', '');
129
+ output = "<tr class='wpsc_grey'><td></td><td colspan='5'>Please save your changes to add options to this "+jQuery(this).val()+" form field.</td></tr>\r\n";
130
+ jQuery(this).parent().parent('tr').after(output);
131
+ }
132
+
133
+ });
134
+ });
135
+ */
136
+ jQuery('.wpsc_add_new_checkout_option').livequery(function(){
137
+ jQuery(this).click(function(event){
138
+ form_id = jQuery(this).attr('title');
139
+ id = form_id.replace('form_options', '');
140
+ output = "<tr class='wpsc_grey'><td></td><td><input type='text' value='' name='wpsc_checkout_option_label"+id+"[]' /></td><td colspan='4'><input type='text' value='' name='wpsc_checkout_option_value"+id+"[]' />&nbsp;<a class='wpsc_delete_option' href='' ><img src='" + WPSC_CORE_IMAGES_URL + "/trash.gif' alt='"+TXT_WPSC_DELETE+"' title='"+TXT_WPSC_DELETE+"' /></a></td></tr>";
141
+ jQuery(this).parent().parent('tr').after(output);
142
+ event.preventDefault();
143
+ });
144
+
145
+ });
146
+
147
+
148
+ jQuery('.wpsc_edit_checkout_options').livequery(function(){
149
+ jQuery(this).click(function(event){
150
+ if(!jQuery(this).hasClass('triggered')){
151
+ jQuery(this).addClass('triggered');
152
+ id = jQuery(this).attr('rel');
153
+ id = id.replace('form_options[', '');
154
+ id = id.replace(']', '');
155
+ post_values = "form_id="+id;
156
+ jQuery.post('index.php?wpsc_admin_action=check_form_options',post_values, function(returned_data){
157
+ if(returned_data != ''){
158
+ jQuery('#checkout_'+id).after(returned_data);
159
+ }else{
160
+ output = "<tr class='wpsc_grey'><td></td><td colspan='5'>Please Save your changes before trying to Order your Checkout Forms again.</td></tr>\r\n<tr class='wpsc_grey'><td></td><th>Label</th><th >Value</th><td colspan='3'><a href='' class='wpsc_add_new_checkout_option' title='form_options["+id+"]'>+ New Layer</a></td></tr>";
161
+ output += "<tr class='wpsc_grey'><td></td><td><input type='text' value='' name='wpsc_checkout_option_label["+id+"][]' /></td><td colspan='4'><input type='text' value='' name='wpsc_checkout_option_value["+id+"][]' /><a class='wpsc_delete_option' href='' ><img src='" + WPSC_CORE_IMAGES_URL + "trash.gif' alt='Delete' title='delete' /></a></td></tr>";
162
+ jQuery('#checkout_'+id).after(output);
163
+
164
+ }
165
+
166
+ });
167
+ jQuery('table#wpsc_checkout_list').sortable('disable');
168
+ }
169
+ event.preventDefault();
170
+ });
171
+
172
+
173
+ });
174
+
175
+ //grid view checkbox ajax to deselect show images only when other checkboxes are selected
176
+ jQuery('#show_images_only').livequery(function(){
177
+ jQuery(this).click(function(){
178
+ imagesonly = jQuery(this).is(':checked');
179
+ if(imagesonly){
180
+ jQuery('#display_variations').attr('checked', false);
181
+ jQuery('#display_description').attr('checked', false);
182
+ jQuery('#display_addtocart').attr('checked', false);
183
+ jQuery('#display_moredetails').attr('checked', false);
184
+
185
+ }
186
+ });
187
+ });
188
+ jQuery('#display_variations, #display_description, #display_addtocart, #display_moredetails').livequery(function(){
189
+ jQuery(this).click(function(){
190
+ imagesonly = jQuery(this).is(':checked');
191
+
192
+ if(imagesonly){
193
+ jQuery('#show_images_only').attr('checked', false);
194
+
195
+ }
196
+ });
197
+ });
198
+ //new currency JS in admin product page
199
+ jQuery('div.new_layer').livequery(function(){
200
+ jQuery(this).hide();
201
+
202
+ });
203
+ var firstclick = true
204
+ jQuery('a.wpsc_add_new_currency').livequery(function(){
205
+ jQuery(this).click(function(event){
206
+ if(firstclick == true){
207
+ jQuery('div.new_layer').show();
208
+ html = jQuery('div.new_layer').html();
209
+ firstclick = false;
210
+ }else{
211
+ jQuery('div.new_layer').after('<div>'+html+'</div>');
212
+ }
213
+ event.preventDefault();
214
+ });
215
+ });
216
+ //delete currency layer in admin product page
217
+ jQuery('a.wpsc_delete_currency_layer').livequery(function(){
218
+ jQuery(this).click(function(event){
219
+ var currencySymbol = jQuery(this).attr('rel');
220
+ jQuery(this).prev('input').val('');
221
+ jQuery(this).prev('select').val('');
222
+ jQuery(this).parent('.wpsc_additional_currency').hide();
223
+
224
+ post_values = "currSymbol="+currencySymbol;
225
+ jQuery.post('index.php?wpsc_admin_action=delete_currency_layer',post_values, function(returned_data){});
226
+ //alert(currencySymbol);
227
+
228
+ event.preventDefault();
229
+ });
230
+ });
231
+
232
+ jQuery('form input.prdfil').livequery(function(){
233
+ jQuery(this).click(function(event){
234
+ var products = jQuery(this).parent("form.product_upload").find('input').serialize();
235
+ var product_id = jQuery(this).parent("form.product_upload").find('input#hidden_id').val();
236
+ post_values = products + '&product_id=' + product_id;
237
+ jQuery.post('admin.php?wpsc_admin_action=product_files_upload',post_values, function(returned_data){
238
+ jQuery("#TB_closeWindowButton").click(TB_remove);
239
+
240
+ });
241
+ // alert(products);
242
+
243
+ event.preventDefault();
244
+ });
245
+ });
246
+
247
+
248
+ //delete currency layer in admin product page
249
+ jQuery('a.wpsc_mass_resize').livequery(function(){
250
+ jQuery(this).click(function(event){
251
+ this_href = jQuery(this).attr('href');
252
+ parent_element = jQuery(this).parent();
253
+ extra_parameters = jQuery("input[type=text]", parent_element).serialize();
254
+ window.location = this_href+"&"+extra_parameters;
255
+ return false;
256
+ });
257
+ });
258
+
259
+ //select all target markets in general settings page
260
+ jQuery('a.wpsc_select_all').livequery(function(){
261
+ jQuery(this).click(function(event){
262
+ jQuery('div#resizeable input:checkbox').attr('checked', true);
263
+ event.preventDefault();
264
+
265
+ });
266
+
267
+ });
268
+ //select all target markets in general settings page
269
+ jQuery('a.wpsc_select_none').livequery(function(){
270
+ jQuery(this).click(function(event){
271
+ jQuery('div#resizeable input:checkbox').attr('checked', false);
272
+ event.preventDefault();
273
+
274
+ });
275
+
276
+ });
277
+ if( pagenow == 'edit-wpsc_product_category' ) {
278
+ jQuery('table.tags').sortable({
279
+ axis: 'y',
280
+ items : 'tr',
281
+ containment: 'table.tags tbody',
282
+ placeholder: 'product-placeholder',
283
+ cursor: 'move',
284
+ tolerance: 'pointer',
285
+ update: function(event, ui){
286
+ categorySort(jQuery('table.tags').sortable('toArray'), 0);
287
+ }
288
+ });
289
+
290
+ function categorySort(order, parent){
291
+ var data = {
292
+ action: 'category_sort_order',
293
+ sort_order: order,
294
+ parent_id: parent
295
+ };
296
+
297
+ var id = '#debugData_';
298
+
299
+ jQuery.post(ajaxurl, data, function(response) {
300
+ jQuery(id).append(response);
301
+ });
302
+ return false;
303
+ }
304
+
305
+ jQuery('form#addtag, form#edittag').attr('enctype', 'multipart/form-data');
306
+
307
+ }
308
+ //Added for inline editing capabilities
309
+ jQuery('#wpsc_product_list a.wpsc_editinline').live('click', function() {
310
+ jQuery(this).parents('tr:first').find('a.row-title, td > span').hide();
311
+ jQuery('.wpsc_ie_field').each(function(){
312
+ jQuery(this).width( (jQuery(this).parents('td:first').innerWidth() - 14) + 'px' );
313
+ });
314
+ jQuery(this).parents('tr:first').find('td input.wpsc_ie_field, td .wpsc_inline_actions').show();
315
+ return false;
316
+ });
317
+
318
+ jQuery('#wpsc_product_list .wpsc_ie_cancel').live('click', function(){
319
+ jQuery(this).parents('tr:first').find('a.row-title, td > span').show();
320
+ jQuery(this).parents('tr:first').find('td input.wpsc_ie_field, td .wpsc_inline_actions').hide();
321
+ jQuery(this).parents('tr:first').find('.loading_indicator').css('visibility', 'hidden');
322
+ });
323
+ jQuery('#wpsc_product_list .wpsc_ie_save').live('click', function(){
324
+ jQuery(this).parents('tr:first').find('.loading_indicator').css('visibility', 'visible');
325
+ var id =jQuery(this).parents('tr:first').find('.wpsc_ie_id').val();
326
+ var title = jQuery(this).parents('tr:first').find('.wpsc_ie_title').val();
327
+ var weight = jQuery(this).parents('tr:first').find('.wpsc_ie_weight').val();
328
+ var stock = jQuery(this).parents('tr:first').find('.wpsc_ie_stock').val();
329
+ var price = jQuery(this).parents('tr:first').find('.wpsc_ie_price').val();
330
+ var special_price = jQuery(this).parents('tr:first').find('.wpsc_ie_special_price').val();
331
+ var sku = jQuery(this).parents('tr:first').find('.wpsc_ie_sku').val();
332
+ //post stuff
333
+ var data = {
334
+ action: 'wpsc_ie_save',
335
+ id: id,
336
+ title: title,
337
+ weight: weight,
338
+ stock: stock,
339
+ price: price,
340
+ special_price: special_price,
341
+ sku: sku
342
+ };
343
+
344
+ jQuery.post(ajaxurl, data, function(response) {
345
+ response = eval(response);
346
+ if(response.error){
347
+ alert(response.error);
348
+ jQuery('#post-' + response.id + ' a.row-title, #post-' + response.id + ' td > span').show();
349
+ jQuery('#post-' + response.id + ' td input.wpsc_ie_field, #post-' + response.id + ' td .wpsc_inline_actions').hide();
350
+ jQuery('#post-' + response.id + ' .loading_indicator').css('visibility', 'hidden');
351
+ }
352
+ else{
353
+ jQuery('#post-' + response.id + ' .post-title a.row-title').text(response.title);
354
+ jQuery('#post-' + response.id + ' .column-weight span').text(response.weight);
355
+ jQuery('#post-' + response.id + ' .column-stock span').text(response.stock);
356
+ jQuery('#post-' + response.id + ' .column-SKU span').text(response.sku);
357
+
358
+ jQuery('#post-' + response.id + ' .column-price .pricedisplay').html(jQuery(response.price).text());
359
+ jQuery('#post-' + response.id + ' .column-sale_price .pricedisplay').html(jQuery(response.special_price).text());
360
+
361
+ jQuery('#post-' + response.id + ' a.row-title, #post-' + response.id + ' td > span').show();
362
+ jQuery('#post-' + response.id + ' td input.wpsc_ie_field, #post-' + response.id + ' td .wpsc_inline_actions').hide();
363
+ jQuery('#post-' + response.id + ' .loading_indicator').css('visibility', 'hidden');
364
+ }
365
+ });
366
+ });
367
+
368
+ //As far as I can tell, WP provides no good way of unsetting elements in the bulk edit area...tricky jQuery action will do for now....not ideal whatsoever, nor eternally stable.
369
+ if( pagenow == 'edit-wpsc-product' ) {
370
+ //jQuery('fieldset.inline-edit-col-left .inline-edit-date').css('display','none');
371
+ //jQuery('fieldset.inline-edit-col-center span.title:eq(1), ul.cat-checklist:eq(1)').css('display','none');
372
+ jQuery("label:contains('Date')").css('display', 'none');
373
+ jQuery(".inline-edit-group:contains('Password')").css('display', 'none');
374
+ jQuery('fieldset.inline-edit-col-left.wpsc-cols').css({'float': 'right', 'clear' : 'right'});
375
+ jQuery("label:contains('Parent')").css('display', 'none');
376
+ jQuery("label:contains('Status')").css('display', 'none');
377
+ jQuery("span:contains('Variations')").css('display', 'none');
378
+ jQuery("ul.wpsc-variation-checklist").css('display', 'none');
379
+ jQuery("div.inline-edit-date").css('display', 'none');
380
+ }
381
+ if( wpsc_adminL10n.dragndrop_set == "true" && typenow == "wpsc-product" && adminpage == "edit-php" ) {
382
+ // this makes the product list table sortable
383
+ jQuery('table.widefat:not(.tags)').sortable({
384
+ update: function(event, ui) {
385
+ category_id = jQuery('select#wpsc_product_category option:selected').val();
386
+ product_order = jQuery('table.widefat').sortable( 'serialize' );
387
+ post_values = "category_id="+category_id+"&"+product_order;
388
+ jQuery.post( 'index.php?wpsc_admin_action=save_product_order', post_values, function(returned_data) { });
389
+ },
390
+ items: 'tr',
391
+ axis: 'y',
392
+ containment: 'table.widefat tbody',
393
+ placeholder: 'product-placeholder',
394
+ cursor: 'move',
395
+ cancel: 'tr.inline-edit-wpsc-product'
396
+ });
397
+ }
398
+
399
+ jQuery('table#wpsc_checkout_list').livequery(function(event){
400
+ //this makes the checkout form fields sortable
401
+ jQuery(this).sortable({
402
+
403
+ items: 'tr.checkout_form_field',
404
+ axis: 'y',
405
+ containment: 'table#wpsc_checkout_list',
406
+ placeholder: 'checkout-placeholder',
407
+ handle: '.drag',
408
+
409
+ });
410
+ jQuery(this).bind('sortupdate', function(event, ui) {
411
+
412
+ //post_values = jQuery(this).sortable();
413
+ //post_values = "category_id="+category_id+"&"+checkout_order;
414
+ post_values = jQuery( 'table#wpsc_checkout_list').sortable( 'serialize');
415
+ jQuery.post( 'index.php?wpsc_admin_action=save_checkout_order', post_values, function(returned_data) { });
416
+ });
417
+
418
+ });
419
+
420
+ // this helps show the links in the product list table, it is partially done using CSS, but that breaks in IE6
421
+ jQuery("tr.product-edit").hover(
422
+ function() {
423
+ jQuery(".wpsc-row-actions", this).css("visibility", "visible");
424
+ },
425
+ function() {
426
+ jQuery(".wpsc-row-actions", this).css("visibility", "hidden");
427
+ }
428
+ );
429
+
430
+
431
+ jQuery('tr.wpsc_trackingid_row').hide();
432
+
433
+ jQuery('.wpsc_show_trackingid').click(function(event){
434
+ purchlog_id = jQuery(this).attr('title');
435
+ if(jQuery('tr.log'+purchlog_id).hasClass('wpsc_hastracking')){
436
+ jQuery('tr.log'+purchlog_id).removeClass('wpsc_hastracking');
437
+ jQuery('tr.log'+purchlog_id).hide();
438
+ }else{
439
+ jQuery('tr.log'+purchlog_id).addClass('wpsc_hastracking');
440
+ jQuery('tr.log'+purchlog_id).show();
441
+ }
442
+ event.preventDefault();
443
+ });
444
+ // this changes the purchase log item status
445
+ jQuery('.selector').change(function(){
446
+ purchlog_id = jQuery(this).attr('title');
447
+ purchlog_status = jQuery(this).val();
448
+ post_values = "purchlog_id="+purchlog_id+"&purchlog_status="+purchlog_status;
449
+ jQuery.post( 'index.php?ajax=true&wpsc_admin_action=purchlog_edit_status', post_values, function(returned_data) { });
450
+
451
+ if(purchlog_status == 4){
452
+ jQuery('tr.log'+purchlog_id).show();
453
+
454
+ }
455
+ });
456
+
457
+ jQuery('.sendTrackingEmail').click(function(event){
458
+ purchlog_id = jQuery(this).attr('title');
459
+ post_values = "purchlog_id="+purchlog_id;
460
+ jQuery.post( 'index.php?wpsc_admin_action=purchlog_email_trackid', post_values, function(returned_data) { });
461
+ event.preventDefault();
462
+ });
463
+
464
+ jQuery("a.thickbox").livequery(function(){
465
+ tb_init(this);
466
+ });
467
+
468
+ jQuery("div.admin_product_name a.shorttag_toggle").livequery(function(){
469
+ jQuery(this).toggle(
470
+ function () {
471
+ jQuery("div.admin_product_shorttags", jQuery(this).parents("table.product_editform")).css('display', 'block');
472
+ return false;
473
+ },
474
+ function () {
475
+ //jQuery("div#admin_product_name a.shorttag_toggle").toggleClass('toggled');
476
+ jQuery("div.admin_product_shorttags", jQuery(this).parents("table.product_editform")).css('display', 'none');
477
+ return false;
478
+ }
479
+ );
480
+ });
481
+
482
+ jQuery('a.add_variation_item_form').livequery(function(){
483
+ jQuery(this).click(function() {
484
+ form_field_container = jQuery(this).siblings('#variation_values');
485
+ form_field = jQuery("div.variation_value", form_field_container).eq(0).clone();
486
+
487
+ jQuery('input.text',form_field).attr('name','new_variation_values[]');
488
+ jQuery('input.text',form_field).val('');
489
+ jQuery('input.variation_values_id',form_field).remove();
490
+
491
+ jQuery(form_field_container).append(form_field);
492
+ return false;
493
+ });
494
+ });
495
+
496
+
497
+ jQuery('div.variation_value a.delete_variation_value').livequery(function(){
498
+ jQuery(this).click( function() {
499
+ element_count = jQuery("#variation_values div").size();
500
+
501
+ if(element_count > 1) {
502
+
503
+ parent_element = jQuery(this).parent("div.variation_value");
504
+ variation_value_id = jQuery("input.variation_values_id", parent_element).val();
505
+
506
+ delete_url = jQuery(this).attr('href');
507
+ post_values = "remove_variation_value=true&variation_value_id="+variation_value_id;
508
+ jQuery.post( delete_url, "ajax=true", function(returned_data) {
509
+ jQuery("#variation_row_"+returned_data).fadeOut('fast', function() {
510
+ jQuery(this).remove();
511
+ });
512
+ });
513
+ }
514
+ return false;
515
+ });
516
+ });
517
+
518
+ jQuery('a.add_new_form_set').livequery(function(){
519
+ jQuery(this).click( function() {
520
+ jQuery(".add_new_form_set_forms").toggle();
521
+ });
522
+ });
523
+
524
+
525
+ jQuery("#add-product-image").click(function(){
526
+ swfu.selectFiles();
527
+ });
528
+
529
+
530
+ jQuery('a.closeimagesettings').livequery(function(){
531
+ jQuery(this).click( function() {
532
+ jQuery('.image_settings_box').hide();
533
+ });
534
+ });
535
+
536
+
537
+ jQuery("#gallery_list").livequery(function(){
538
+ jQuery(this).sortable({
539
+ revert: false,
540
+ placeholder: "ui-selected",
541
+ start: function(e,ui) {
542
+ jQuery('#image_settings_box').hide();
543
+ jQuery('a.editButton').hide();
544
+ jQuery('img.deleteButton').hide();
545
+ jQuery('ul#gallery_list').children('li').removeClass('first');
546
+ },
547
+ stop:function (e,ui) {
548
+ jQuery('ul#gallery_list').children('li:first').addClass('first');
549
+ },
550
+ update: function (e,ui){
551
+ input_set = jQuery.makeArray(jQuery("#gallery_list li:not(.ui-sortable-helper) input.image-id"));
552
+ //console.log(input_set);
553
+ set = new Array();
554
+ for( var i in input_set) {
555
+ set[i] = jQuery(input_set[i]).val();
556
+ }
557
+ //console.log(set);
558
+ /*
559
+ img_id = jQuery('#gallery_image_'+set[0]).parent('li').attr('id');
560
+
561
+ jQuery('#gallery_image_'+set[0]).children('img.deleteButton').remove();
562
+ jQuery('#gallery_image_'+set[0]).append("<a class='editButton'>Edit <img src='" + WPSC_CORE_IMAGES_URL + "/pencil.png' alt ='' /></a>");
563
+ // jQuery('#gallery_image_'+set[0]).parent('li').attr('id', "product_image_"+img_id);
564
+ //for(i=1;i<set.length;i++) {
565
+ // jQuery('#gallery_image_'+set[i]).children('a.editButton').remove();
566
+ // jQuery('#gallery_image_'+set[i]).append("<img alt='-' class='deleteButton' src='" + WPSC_CORE_IMAGES_URL + "/cross.png'/>");
567
+ //}
568
+
569
+ for(i=1;i<set.length;i++) {
570
+ jQuery('#gallery_image_'+set[i]).children('a.editButton').remove();
571
+ jQuery('#gallery_image_'+set[i]).append("<img alt='-' class='deleteButton' src='" + WPSC_CORE_IMAGES_URL + "/cross.png'/>");
572
+
573
+ element_id = jQuery('#gallery_image_'+set[i]).parent('li').attr('id');
574
+ if(element_id == 0) {
575
+ // jQuery('#gallery_image_'+set[i]).parent('li').attr('id', "product_image_"+img_id);
576
+ }
577
+ }
578
+ */
579
+ order = set.join(',');
580
+ product_id = jQuery('#product_id').val();
581
+
582
+ postVars = "product_id="+product_id+"&order="+order;
583
+ jQuery.post( 'index.php?wpsc_admin_action=rearrange_images', postVars, function(returned_data) {
584
+ eval(returned_data);
585
+ jQuery('#gallery_image_'+image_id).children('a.editButton').remove();
586
+ jQuery('#gallery_image_'+image_id).children('div.image_settings_box').remove();
587
+ jQuery('#gallery_image_'+image_id).append(image_menu);
588
+ });
589
+
590
+ },
591
+ 'opacity':0.5
592
+ });
593
+ });
594
+
595
+
596
+
597
+
598
+ // show or hide the stock input forms
599
+ jQuery("input.limited_stock_checkbox").livequery(function(){
600
+ jQuery(this).click( function () {
601
+ parent_form = jQuery(this).parents('form');
602
+ if(jQuery(this).attr('checked') == true) {
603
+ jQuery("div.edit_stock",parent_form).show();
604
+ jQuery("th.stock, td.stock", parent_form).show();
605
+ } else {
606
+ jQuery("div.edit_stock", parent_form).hide();
607
+ jQuery("th.stock, td.stock", parent_form).hide();
608
+ }
609
+ });
610
+ });
611
+
612
+
613
+ jQuery("#table_rate_price").livequery(function(){
614
+ if (!this.checked) {
615
+ jQuery("#table_rate").hide();
616
+ }
617
+ jQuery(this).click( function() {
618
+ if (this.checked) {
619
+ jQuery("#table_rate").show();
620
+ } else {
621
+ jQuery("#table_rate").hide();
622
+ }
623
+ });
624
+ });
625
+
626
+ jQuery("#custom_tax_checkbox").livequery(function(){
627
+ jQuery(this).click( function() {
628
+ if (this.checked) {
629
+ jQuery("#custom_tax").show();
630
+ } else {
631
+ jQuery("#custom_tax input").val('');
632
+ jQuery("#custom_tax").hide();
633
+ }
634
+ });
635
+ });
636
+
637
+ jQuery(".add_level").livequery(function(){
638
+ jQuery(this).click(function() {
639
+ added = jQuery(this).parent().children('table').append('<tr><td><input type="text" size="10" value="" name="table_rate_price[quantity][]"/> and above</td><td><input type="text" size="10" value="" name="table_rate_price[table_price][]"/></td></tr>');
640
+ });
641
+ });
642
+
643
+
644
+ jQuery(".remove_line").livequery(function(){
645
+ jQuery(this).click(function() {
646
+ jQuery(this).parent().parent('tr').remove();
647
+ });
648
+ });
649
+ /* shipping options start */
650
+ // gets shipping form for admin page
651
+ // show or hide the stock input forms
652
+
653
+ jQuery(".wpsc-payment-actions a").livequery(function(){
654
+ jQuery(this).click( function () {
655
+ var module = jQuery(this).attr('rel');
656
+ //console.log(module);
657
+ jQuery.ajax({
658
+ method: "post",
659
+ url: "index.php",
660
+ data: "wpsc_admin_action=get_payment_form&paymentname="+module,
661
+ success: function(returned_data){
662
+ // console.log(returned_data);
663
+ eval(returned_data);
664
+ //jQuery(".gateway_settings").children(".form-table").html(html)
665
+ jQuery('.gateway_settings h3.hndle').html(payment_name_html);
666
+ jQuery("td.gateway_settings table.form-table").html('<tr><td><input type="hidden" name="paymentname" value="'+module+'" /></td></tr>'+payment_form_html);
667
+ if(has_submit_button != '') {
668
+ jQuery('.gateway_settings div.submit').css('display', 'block');
669
+ } else {
670
+ jQuery('.gateway_settings div.submit').css('display', 'none');
671
+ }
672
+ }
673
+ });
674
+ return false;
675
+
676
+ });
677
+ });
678
+
679
+ jQuery('#addweightlayer').livequery(function(){
680
+ jQuery(this).click(function(){
681
+ jQuery(this).parent().append("<div class='wpsc_newlayer'><tr class='rate_row'><td><i style='color:grey'>"+TXT_WPSC_IF_WEIGHT_IS+"</i><input type='text' name='weight_layer[]' size='10'> <i style='color:grey'>"+TXT_WPSC_AND_ABOVE+"</i></td><td><input type='text' name='weight_shipping[]' size='10'>&nbsp;&nbsp;<a href='' class='delete_button nosubmit' >"+TXT_WPSC_DELETE+"</a></td></tr></div>");
682
+ });
683
+
684
+ });
685
+
686
+ jQuery('#addlayer').livequery(function(){
687
+ jQuery(this).click(function(){
688
+ jQuery(this).parent().append("<div class='wpsc_newlayer'><tr class='rate_row'><td><i style='color:grey'>"+TXT_WPSC_IF_PRICE_IS+"</i><input type='text' name='layer[]' size='10'> <i style='color:grey'>"+TXT_WPSC_AND_ABOVE+"</i></td><td><input type='text' name='shipping[]' size='10'>&nbsp;&nbsp;<a href='' class='delete_button nosubmit' >"+TXT_WPSC_DELETE+"</a></td></tr></div>");
689
+ //bind_shipping_rate_deletion();
690
+ return false;
691
+ });
692
+
693
+ });
694
+
695
+ jQuery('table#gateway_options a.delete_button').livequery(function(){
696
+ jQuery(this).click(function () {
697
+ this_row = jQuery(this).parent().parent('tr .rate_row');
698
+ // alert(this_row);
699
+ //jQuery(this_row).hide();
700
+ if(jQuery(this).hasClass('nosubmit')) {
701
+ // if the row was added using JS, just scrap it
702
+ this_row = jQuery(this).parent('div .wpsc_newlayer');
703
+ jQuery(this_row).remove();
704
+ } else {
705
+ // otherwise, empty it and submit it
706
+ jQuery('input', this_row).val('');
707
+ jQuery(this).parents('form').submit();
708
+ }
709
+ return false;
710
+ });
711
+ });
712
+
713
+ // hover for gallery view
714
+ jQuery("div.previewimage").livequery(function(){
715
+ jQuery(this).hover(
716
+ function () {
717
+ jQuery(this).children('img.deleteButton').show();
718
+ if(jQuery('div.image_settings_box').css('display')!='block')
719
+ jQuery(this).children('a.editButton').show();
720
+ },
721
+ function () {
722
+ jQuery(this).children('img.deleteButton').hide();
723
+ jQuery(this).children('a.editButton').hide();
724
+ }
725
+ );
726
+ });
727
+
728
+
729
+ // display image editing menu
730
+ jQuery("a.editButton").livequery(function(){
731
+ jQuery(this).click( function(){
732
+ jQuery(this).hide();
733
+ jQuery('div.image_settings_box').show('fast');
734
+ });
735
+ });
736
+ // hide image editing menu
737
+ jQuery("a.closeimagesettings").livequery(function(){
738
+ jQuery(this).click(function (e) {
739
+ jQuery("div#image_settings_box").hide();
740
+ });
741
+ });
742
+
743
+ // delete upload
744
+ jQuery(".file_delete_button").livequery(function(){
745
+ jQuery(this).click(function() {
746
+ url = jQuery(this).attr('href');
747
+ post_values = "ajax=true";
748
+ jQuery.post( url, post_values, function(returned_data) {
749
+ eval(returned_data);
750
+ });
751
+ return false;
752
+ });
753
+ });
754
+
755
+ // Options page ajax tab display
756
+ jQuery('#sidemenu li').click(function(){
757
+ page_title = jQuery(this).attr('id');
758
+
759
+ wpnonce = jQuery('a',this).attr('href').match(/_wpnonce=(\w{1,})/);
760
+ post_values = "wpsc_admin_action=settings_page_ajax&page_title="+page_title+"&_wpnonce="+wpnonce[1];
761
+ jQuery.post('admin.php?', post_values, function(html){
762
+ //console.log(html);
763
+ jQuery('a.current').removeClass('current');
764
+ jQuery('#'+page_title+' a' ).addClass('current');
765
+ jQuery('#wpsc_options_page').html('');
766
+ jQuery('#wpsc_options_page').html(html);
767
+
768
+ });
769
+ return false;
770
+
771
+ });
772
+
773
+ jQuery('.wpsc_featured_product_toggle').livequery(function(){
774
+ jQuery(this).click(function(event){
775
+ target_url = jQuery(this).attr('href');
776
+ post_values = "ajax=true";
777
+ jQuery.post(target_url, post_values, function(returned_data){
778
+ eval(returned_data);
779
+ });
780
+ return false;
781
+ });
782
+ });
783
+
784
+ // Form change tracking code.
785
+ jQuery('form.wpsc_form_track :input, form.wpsc_form_track :radio, form.wpsc_form_track :checkbox')
786
+ .live('change', function() {
787
+ jQuery(this).parents('form.wpsc_form_track:first').addClass('wpsc_form_changed');
788
+ });
789
+
790
+ jQuery('form.wpsc_form_track').live('submit', function() {
791
+ jQuery(this).removeClass('wpsc_form_changed');
792
+
793
+ });
794
+
795
+ // We'd ideally want to be using window.onbeforeonload to toss in a prompt, but that event is too
796
+ // unreliable from a browser to the next. Hooking onto anchors is the next best thing.
797
+ jQuery('form.wpsc_form_track a').live('click', function() {
798
+ if (jQuery(this).attr('href') && jQuery(this).attr('href') != '#' && !jQuery(this).hasClass('wpsc_select_all') && !jQuery(this).hasClass('wpsc_select_none')) {
799
+ if (jQuery('form.wpsc_form_changed').size()) {
800
+ if (!confirm(wpsc_adminL10n.unsaved_changes_detected)) {
801
+ return false;
802
+ }
803
+ }
804
+ }
805
+ });
806
+ });
807
+
808
+
809
+
810
+ // function for adding more custom meta
811
+ function add_more_meta(e) {
812
+ current_meta_forms = jQuery(e).parent().children("div.product_custom_meta:last"); // grab the form container
813
+ new_meta_forms = current_meta_forms.clone(true); // clone the form container
814
+ jQuery("label input", new_meta_forms).val(''); // reset all contained forms to empty
815
+ current_meta_forms.after(new_meta_forms); // append it after the container of the clicked element
816
+ return false;
817
+ }
818
+
819
+ // function for removing custom meta
820
+ function remove_meta(e, meta_id) {
821
+ current_meta_form = jQuery(e).parent("div.product_custom_meta"); // grab the form container
822
+ //meta_name = jQuery("input#custom_meta_name_"+meta_id, current_meta_form).val();
823
+ //meta_value = jQuery("input#custom_meta_value_"+meta_id, current_meta_form).val();
824
+ returned_value = jQuery.ajax({
825
+ type: "POST",
826
+ url: "admin.php?ajax=true",
827
+ data: "admin=true&remove_meta=true&meta_id="+meta_id+"",
828
+ success: function(results) {
829
+ if(results > 0) {
830
+ jQuery("div#custom_meta_"+meta_id).remove();
831
+ }
832
+ }
833
+ });
834
+ return false;
835
+ }
836
+
837
+
838
+ // function for switching the state of the image upload forms
839
+ function wpsc_upload_switcher(target_state) {
840
+ switch(target_state) {
841
+ case 'flash':
842
+ jQuery("div.browser-image-uploader").css("display","none");
843
+ jQuery("div.flash-image-uploader").css("display","block");
844
+ jQuery.post( 'index.php?admin=true', "admin=true&ajax=true&save_image_upload_state=true&image_upload_state=1", function(returned_data) { });
845
+ break;
846
+
847
+ case 'browser':
848
+ jQuery("div.flash-image-uploader").css("display","none");
849
+ jQuery("div.browser-image-uploader").css("display","block");
850
+ jQuery.post( 'index.php?admin=true', "admin=true&ajax=true&save_image_upload_state=true&image_upload_state=0", function(returned_data) { });
851
+ break;
852
+ }
853
+ }
854
+
855
+ // function for switching the state of the extra resize forms
856
+ function image_resize_extra_forms(option) {
857
+ container = jQuery(option).parent();
858
+ jQuery("div.image_resize_extra_forms").css('display', 'none');
859
+ jQuery("div.image_resize_extra_forms",container).css('display', 'block');
860
+ }
861
+
862
+
863
+ var prevElement = null;
864
+ var prevOption = null;
865
+
866
+ function hideOptionElement(id, option) {
867
+ if (prevOption == option) {
868
+ return;
869
+ }
870
+ if (prevElement != null) {
871
+ prevElement.style.display = "none";
872
+ }
873
+
874
+ if (id == null) {
875
+ prevElement = null;
876
+ } else {
877
+ prevElement = document.getElementById(id);
878
+ jQuery('#'+id).css( 'display','block');
879
+ }
880
+ prevOption = option;
881
+ }
882
+
883
+
884
+ function hideelement(id) {
885
+ state = document.getElementById(id).style.display;
886
+ //alert(document.getElementById(id).style.display);
887
+ if(state != 'block') {
888
+ document.getElementById(id).style.display = 'block';
889
+ } else {
890
+ document.getElementById(id).style.display = 'none';
891
+ }
892
+ }
893
+
894
+ /*
895
+ * Modified copy of the wordpress edToolbar function that does the same job, it uses document.write, we cannot.
896
+ */
897
+ function wpsc_edToolbar() {
898
+ //document.write('<div id="ed_toolbar">');
899
+ output = '';
900
+ for (i = 0; i < edButtons.length; i++) {
901
+ output += wpsc_edShowButton(edButtons[i], i);
902
+ }
903
+ output += '<input type="button" id="ed_spell" class="ed_button" onclick="edSpell(edCanvas);" title="' + quicktagsL10n.dictionaryLookup + '" value="' + quicktagsL10n.lookup + '" />';
904
+ output += '<input type="button" id="ed_close" class="ed_button" onclick="edCloseAllTags();" title="' + quicktagsL10n.closeAllOpenTags + '" value="' + quicktagsL10n.closeTags + '" />';
905
+ // edShowLinks(); // disabled by default
906
+ //document.write('</div>');
907
+ jQuery('div#ed_toolbar').html(output);
908
+ }
909
+
910
+
911
+ /*
912
+ * Modified copy of the wordpress edShowButton function that does the same job, it uses document.write, we cannot.
913
+ */
914
+
915
+ function wpsc_edShowButton(button, i) {
916
+ if (button.id == 'ed_img') {
917
+ output = '<input type="button" id="' + button.id + '" accesskey="' + button.access + '" class="ed_button" onclick="edInsertImage(edCanvas);" value="' + button.display + '" />';
918
+ }
919
+ else if (button.id == 'ed_link') {
920
+ output = '<input type="button" id="' + button.id + '" accesskey="' + button.access + '" class="ed_button" onclick="edInsertLink(edCanvas, ' + i + ');" value="' + button.display + '" />';
921
+ }
922
+ else {
923
+ output = '<input type="button" id="' + button.id + '" accesskey="' + button.access + '" class="ed_button" onclick="edInsertTag(edCanvas, ' + i + ');" value="' + button.display + '" />';
924
+ }
925
+ return output;
926
+ }
927
+
928
+
929
+
930
+ function fillcategoryform(catid) {
931
+ post_values = 'ajax=true&admin=true&catid='+catid;
932
+ jQuery.post( 'index.php', post_values, function(returned_data) {
933
+ jQuery('#formcontent').html( returned_data );
934
+ jQuery('form.edititem').css('display', 'block');
935
+ jQuery('#additem').css('display', 'none');
936
+ jQuery('#blank_item').css('display', 'none');
937
+ jQuery('#productform').css('display', 'block');
938
+ jQuery("#loadingindicator_span").css('visibility','hidden');
939
+ });
940
+ }
941
+
942
+ function submit_status_form(id) {
943
+ document.getElementById(id).submit();
944
+ }
945
+ function showaddform() {
946
+ jQuery('#blank_item').css('display', 'none');
947
+ jQuery('#productform').css('display', 'none');
948
+ jQuery('#additem').css('display', 'block');
949
+ return false;
950
+ }
951
+ //used to add new form fields in the checkout setting page
952
+ function add_form_field() {
953
+ time = new Date();
954
+ new_element_number = time.getTime();
955
+ new_element_id = "form_id_"+new_element_number;
956
+
957
+ new_element_contents = "";
958
+ //new_element_contents += "<tr class='checkout_form_field' >\n\r";
959
+ new_element_contents += "<td class='drag'></td>";
960
+ new_element_contents += "<td class='namecol'><input type='text' name='new_form_name["+new_element_number+"]' value='' /></td>\n\r";
961
+ new_element_contents += "<td class='typecol'><select class='wpsc_checkout_selectboxes' name='new_form_type["+new_element_number+"]'>"+HTML_FORM_FIELD_TYPES+"</select></td>\n\r";
962
+ new_element_contents += "<td class='typecol'><select name='new_form_unique_name["+new_element_number+"]'>"+HTML_FORM_FIELD_UNIQUE_NAMES+"</select></td>\n\r";
963
+ new_element_contents += "<td class='mandatorycol' style='text-align: center;'><input type='checkbox' name='new_form_mandatory["+new_element_number+"]' value='1' /></td>\n\r";
964
+ new_element_contents += "<td><a class='image_link' href='#' onclick='return remove_new_form_field(\""+new_element_id+"\");'><img src='" + WPSC_CORE_IMAGES_URL + "/trash.gif' alt='"+TXT_WPSC_DELETE+"' title='"+TXT_WPSC_DELETE+"' /></a></td>\n\r";
965
+ // new_element_contents += "</tr>";
966
+
967
+ new_element = document.createElement('tr');
968
+ new_element.id = new_element_id;
969
+ document.getElementById("wpsc_checkout_list_body").appendChild(new_element);
970
+ document.getElementById(new_element_id).innerHTML = new_element_contents;
971
+ jQuery('#'+new_element_id).addClass('checkout_form_field');
972
+ return false;
973
+ }
974
+
975
+
976
+
977
+ function remove_new_form_field(id) {
978
+ element_count = document.getElementById("wpsc_checkout_list_body").childNodes.length;
979
+ if(element_count > 1) {
980
+ target_element = document.getElementById(id);
981
+ document.getElementById("wpsc_checkout_list_body").removeChild(target_element);
982
+ }
983
+ return false;
984
+ }
985
+
986
+
987
+ function submit_change_country() {
988
+ document.cart_options.submit();
989
+ //document.cart_options.submit();
990
+ }
991
+
992
+ function getcurrency(id) {
993
+ //ajax.post("index.php",gercurrency,"wpsc_admin_action=change_currency&currencyid="+id);
994
+ }
995
+ //delete checkout fields from checkout settings page
996
+ function remove_form_field(id,form_id) {
997
+ var delete_variation_value=function(results) { }
998
+ element_count = document.getElementById("wpsc_checkout_list_body").childNodes.length;
999
+ if(element_count > 1) {
1000
+ ajax.post("index.php",delete_variation_value,"admin=true&ajax=true&remove_form_field=true&form_id="+form_id);
1001
+ target_element = document.getElementById(id);
1002
+ document.getElementById("wpsc_checkout_list_body").removeChild(target_element);
1003
+ }
1004
+ return false;
1005
+ }
1006
+
1007
+ function showadd_categorisation_form() {
1008
+ if(jQuery('div_categorisation').css('display') != 'block') {
1009
+ jQuery('div#add_categorisation').css('display', 'block');
1010
+ jQuery('div#edit_categorisation').css('display', 'none');
1011
+ } else {
1012
+ jQuery('div#add_categorisation').css('display', 'none');
1013
+ }
1014
+ return false;
1015
+ }
1016
+
1017
+
1018
+ function showedit_categorisation_form() {
1019
+ if(jQuery('div#edit_categorisation').css('display') != 'block') {
1020
+ jQuery('div#edit_categorisation').css('display', 'block');
1021
+ jQuery('div#add_categorisation').css('display', 'none');
1022
+ } else {
1023
+ jQuery('div#edit_categorisation').css('display', 'none');
1024
+ }
1025
+ return false;
1026
+ }
1027
+
1028
+ function hideelement1(id, item_value) {
1029
+ //alert(value);
1030
+ if(item_value == 5) {
1031
+ jQuery(document.getElementById(id)).css('display', 'block');
1032
+ } else {
1033
+ jQuery(document.getElementById(id)).css('display', 'none');
1034
+ }
1035
+ }
1036
+
1037
+ function toggle_display_options(state) {
1038
+ switch(state) {
1039
+ case 'list':
1040
+ document.getElementById('grid_view_options').style.display = 'none';
1041
+ document.getElementById('list_view_options').style.display = 'block';
1042
+ break;
1043
+
1044
+ case 'grid':
1045
+ document.getElementById('list_view_options').style.display = 'none';
1046
+ document.getElementById('grid_view_options').style.display = 'block';
1047
+ break;
1048
+
1049
+ default:
1050
+ document.getElementById('list_view_options').style.display = 'none';
1051
+ document.getElementById('grid_view_options').style.display = 'none';
1052
+ break;
1053
+ }
1054
+ }
1055
+
1056
+ function show_status_box(id,image_id) {
1057
+ state = document.getElementById(id).style.display;
1058
+ if(state != 'block') {
1059
+ document.getElementById(id).style.display = 'block';
1060
+ document.getElementById(image_id).src = WPSC_CORE_IMAGES_URL + '/icon_window_collapse.gif';
1061
+ } else {
1062
+ document.getElementById(id).style.display = 'none';
1063
+ document.getElementById(image_id).src = WPSC_CORE_IMAGES_URL + '/icon_window_expand.gif';
1064
+ }
1065
+ return false;
1066
+ }
1067
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wpsc-admin/js/jquery.livequery.js CHANGED
@@ -1,251 +1,251 @@
1
- /*! Copyright (c) 2008 Brandon Aaron (http://brandonaaron.net)
2
- * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
3
- * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
4
- *
5
- * Version: 1.0.3
6
- * Requires jQuery 1.1.3+
7
- * Docs: http://docs.jquery.com/Plugins/livequery
8
- */
9
-
10
- (function($) {
11
-
12
- $.extend($.fn, {
13
- livequery: function(type, fn, fn2) {
14
- var self = this, q;
15
-
16
- // Handle different call patterns
17
- if ($.isFunction(type))
18
- fn2 = fn, fn = type, type = undefined;
19
-
20
- // See if Live Query already exists
21
- $.each( $.livequery.queries, function(i, query) {
22
- if ( self.selector == query.selector && self.context == query.context &&
23
- type == query.type && (!fn || fn.$lqguid == query.fn.$lqguid) && (!fn2 || fn2.$lqguid == query.fn2.$lqguid) )
24
- // Found the query, exit the each loop
25
- return (q = query) && false;
26
- });
27
-
28
- // Create new Live Query if it wasn't found
29
- q = q || new $.livequery(this.selector, this.context, type, fn, fn2);
30
-
31
- // Make sure it is running
32
- q.stopped = false;
33
-
34
- // Run it immediately for the first time
35
- q.run();
36
-
37
- // Contnue the chain
38
- return this;
39
- },
40
-
41
- expire: function(type, fn, fn2) {
42
- var self = this;
43
-
44
- // Handle different call patterns
45
- if ($.isFunction(type))
46
- fn2 = fn, fn = type, type = undefined;
47
-
48
- // Find the Live Query based on arguments and stop it
49
- $.each( $.livequery.queries, function(i, query) {
50
- if ( self.selector == query.selector && self.context == query.context &&
51
- (!type || type == query.type) && (!fn || fn.$lqguid == query.fn.$lqguid) && (!fn2 || fn2.$lqguid == query.fn2.$lqguid) && !this.stopped )
52
- $.livequery.stop(query.id);
53
- });
54
-
55
- // Continue the chain
56
- return this;
57
- }
58
- });
59
-
60
- $.livequery = function(selector, context, type, fn, fn2) {
61
- this.selector = selector;
62
- this.context = context || document;
63
- this.type = type;
64
- this.fn = fn;
65
- this.fn2 = fn2;
66
- this.elements = [];
67
- this.stopped = false;
68
-
69
- // The id is the index of the Live Query in $.livequery.queries
70
- this.id = $.livequery.queries.push(this)-1;
71
-
72
- // Mark the functions for matching later on
73
- fn.$lqguid = fn.$lqguid || $.livequery.guid++;
74
- if (fn2) fn2.$lqguid = fn2.$lqguid || $.livequery.guid++;
75
-
76
- // Return the Live Query
77
- return this;
78
- };
79
-
80
- $.livequery.prototype = {
81
- stop: function() {
82
- var query = this;
83
-
84
- if ( this.type )
85
- // Unbind all bound events
86
- this.elements.unbind(this.type, this.fn);
87
- else if (this.fn2)
88
- // Call the second function for all matched elements
89
- this.elements.each(function(i, el) {
90
- query.fn2.apply(el);
91
- });
92
-
93
- // Clear out matched elements
94
- this.elements = [];
95
-
96
- // Stop the Live Query from running until restarted
97
- this.stopped = true;
98
- },
99
-
100
- run: function() {
101
- // Short-circuit if stopped
102
- if ( this.stopped ) return;
103
- var query = this;
104
-
105
- var oEls = this.elements,
106
- els = $(this.selector, this.context),
107
- nEls = els.not(oEls);
108
-
109
- // Set elements to the latest set of matched elements
110
- this.elements = els;
111
-
112
- if (this.type) {
113
- // Bind events to newly matched elements
114
- nEls.bind(this.type, this.fn);
115
-
116
- // Unbind events to elements no longer matched
117
- if (oEls.length > 0)
118
- $.each(oEls, function(i, el) {
119
- if ( $.inArray(el, els) < 0 )
120
- $.event.remove(el, query.type, query.fn);
121
- });
122
- }
123
- else {
124
- // Call the first function for newly matched elements
125
- nEls.each(function() {
126
- query.fn.apply(this);
127
- });
128
-
129
- // Call the second function for elements no longer matched
130
- if ( this.fn2 && oEls.length > 0 )
131
- $.each(oEls, function(i, el) {
132
- if ( $.inArray(el, els) < 0 )
133
- query.fn2.apply(el);
134
- });
135
- }
136
- }
137
- };
138
-
139
- $.extend($.livequery, {
140
- guid: 0,
141
- queries: [],
142
- queue: [],
143
- running: false,
144
- timeout: null,
145
-
146
- checkQueue: function() {
147
- if ( $.livequery.running && $.livequery.queue.length ) {
148
- var length = $.livequery.queue.length;
149
- // Run each Live Query currently in the queue
150
- while ( length-- )
151
- $.livequery.queries[ $.livequery.queue.shift() ].run();
152
- }
153
- },
154
-
155
- pause: function() {
156
- // Don't run anymore Live Queries until restarted
157
- $.livequery.running = false;
158
- },
159
-
160
- play: function() {
161
- // Restart Live Queries
162
- $.livequery.running = true;
163
- // Request a run of the Live Queries
164
- $.livequery.run();
165
- },
166
-
167
- registerPlugin: function() {
168
- $.each( arguments, function(i,n) {
169
- // Short-circuit if the method doesn't exist
170
- if (!$.fn[n]) return;
171
-
172
- // Save a reference to the original method
173
- var old = $.fn[n];
174
-
175
- // Create a new method
176
- $.fn[n] = function() {
177
- // Call the original method
178
- var r = old.apply(this, arguments);
179
-
180
- // Request a run of the Live Queries
181
- $.livequery.run();
182
-
183
- // Return the original methods result
184
- return r;
185
- }
186
- });
187
- },
188
-
189
- run: function(id) {
190
- if (id != undefined) {
191
- // Put the particular Live Query in the queue if it doesn't already exist
192
- if ( $.inArray(id, $.livequery.queue) < 0 )
193
- $.livequery.queue.push( id );
194
- }
195
- else
196
- // Put each Live Query in the queue if it doesn't already exist
197
- $.each( $.livequery.queries, function(id) {
198
- if ( $.inArray(id, $.livequery.queue) < 0 )
199
- $.livequery.queue.push( id );
200
- });
201
-
202
- // Clear timeout if it already exists
203
- if ($.livequery.timeout) clearTimeout($.livequery.timeout);
204
- // Create a timeout to check the queue and actually run the Live Queries
205
- $.livequery.timeout = setTimeout($.livequery.checkQueue, 20);
206
- },
207
-
208
- stop: function(id) {
209
- if (id != undefined)
210
- // Stop are particular Live Query
211
- $.livequery.queries[ id ].stop();
212
- else
213
- // Stop all Live Queries
214
- $.each( $.livequery.queries, function(id) {
215
- $.livequery.queries[ id ].stop();
216
- });
217
- }
218
- });
219
-
220
- // Register core DOM manipulation methods
221
- $.livequery.registerPlugin('append', 'prepend', 'after', 'before', 'wrap', 'attr', 'removeAttr', 'addClass', 'removeClass', 'toggleClass', 'empty', 'remove');
222
-
223
- // Run Live Queries when the Document is ready
224
- $(function() { $.livequery.play(); });
225
-
226
-
227
- // Save a reference to the original init method
228
- var init = $.prototype.init;
229
-
230
- // Create a new init method that exposes two new properties: selector and context
231
- $.prototype.init = function(a,c) {
232
- // Call the original init and save the result
233
- var r = init.apply(this, arguments);
234
-
235
- // Copy over properties if they exist already
236
- if (a && a.selector)
237
- r.context = a.context, r.selector = a.selector;
238
-
239
- // Set properties
240
- if ( typeof a == 'string' )
241
- r.context = c || document, r.selector = a;
242
-
243
- // Return the result
244
- return r;
245
- };
246
-
247
- // Give the init function the jQuery prototype for later instantiation (needed after Rev 4091)
248
- $.prototype.init.prototype = $.prototype;
249
-
250
- })(jQuery);
251
  typenow = 'wpsc-product';
1
+ /*! Copyright (c) 2008 Brandon Aaron (http://brandonaaron.net)
2
+ * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
3
+ * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
4
+ *
5
+ * Version: 1.0.3
6
+ * Requires jQuery 1.1.3+
7
+ * Docs: http://docs.jquery.com/Plugins/livequery
8
+ */
9
+
10
+ (function($) {
11
+
12
+ $.extend($.fn, {
13
+ livequery: function(type, fn, fn2) {
14
+ var self = this, q;
15
+
16
+ // Handle different call patterns
17
+ if ($.isFunction(type))
18
+ fn2 = fn, fn = type, type = undefined;
19
+
20
+ // See if Live Query already exists
21
+ $.each( $.livequery.queries, function(i, query) {
22
+ if ( self.selector == query.selector && self.context == query.context &&
23
+ type == query.type && (!fn || fn.$lqguid == query.fn.$lqguid) && (!fn2 || fn2.$lqguid == query.fn2.$lqguid) )
24
+ // Found the query, exit the each loop
25
+ return (q = query) && false;
26
+ });
27
+
28
+ // Create new Live Query if it wasn't found
29
+ q = q || new $.livequery(this.selector, this.context, type, fn, fn2);
30
+
31
+ // Make sure it is running
32
+ q.stopped = false;
33
+
34
+ // Run it immediately for the first time
35
+ q.run();
36
+
37
+ // Contnue the chain
38
+ return this;
39
+ },
40
+
41
+ expire: function(type, fn, fn2) {
42
+ var self = this;
43
+
44
+ // Handle different call patterns
45
+ if ($.isFunction(type))
46
+ fn2 = fn, fn = type, type = undefined;
47
+
48
+ // Find the Live Query based on arguments and stop it
49
+ $.each( $.livequery.queries, function(i, query) {
50
+ if ( self.selector == query.selector && self.context == query.context &&
51
+ (!type || type == query.type) && (!fn || fn.$lqguid == query.fn.$lqguid) && (!fn2 || fn2.$lqguid == query.fn2.$lqguid) && !this.stopped )
52
+ $.livequery.stop(query.id);
53
+ });
54
+
55
+ // Continue the chain
56
+ return this;
57
+ }
58
+ });
59
+
60
+ $.livequery = function(selector, context, type, fn, fn2) {
61
+ this.selector = selector;
62
+ this.context = context || document;
63
+ this.type = type;
64
+ this.fn = fn;
65
+ this.fn2 = fn2;
66
+ this.elements = [];
67
+ this.stopped = false;
68
+
69
+ // The id is the index of the Live Query in $.livequery.queries
70
+ this.id = $.livequery.queries.push(this)-1;
71
+
72
+ // Mark the functions for matching later on
73
+ fn.$lqguid = fn.$lqguid || $.livequery.guid++;
74
+ if (fn2) fn2.$lqguid = fn2.$lqguid || $.livequery.guid++;
75
+
76
+ // Return the Live Query
77
+ return this;
78
+ };
79
+
80
+ $.livequery.prototype = {
81
+ stop: function() {
82
+ var query = this;
83
+
84
+ if ( this.type )
85
+ // Unbind all bound events
86
+ this.elements.unbind(this.type, this.fn);
87
+ else if (this.fn2)
88
+ // Call the second function for all matched elements
89
+ this.elements.each(function(i, el) {
90
+ query.fn2.apply(el);
91
+ });
92
+
93
+ // Clear out matched elements
94
+ this.elements = [];
95
+
96
+ // Stop the Live Query from running until restarted
97
+ this.stopped = true;
98
+ },
99
+
100
+ run: function() {
101
+ // Short-circuit if stopped
102
+ if ( this.stopped ) return;
103
+ var query = this;
104
+
105
+ var oEls = this.elements,
106
+ els = $(this.selector, this.context),
107
+ nEls = els.not(oEls);
108
+
109
+ // Set elements to the latest set of matched elements
110
+ this.elements = els;
111
+
112
+ if (this.type) {
113
+ // Bind events to newly matched elements
114
+ nEls.bind(this.type, this.fn);
115
+
116
+ // Unbind events to elements no longer matched
117
+ if (oEls.length > 0)
118
+ $.each(oEls, function(i, el) {
119
+ if ( $.inArray(el, els) < 0 )
120
+ $.event.remove(el, query.type, query.fn);
121
+ });
122
+ }
123
+ else {
124
+ // Call the first function for newly matched elements
125
+ nEls.each(function() {
126
+ query.fn.apply(this);
127
+ });
128
+
129
+ // Call the second function for elements no longer matched
130
+ if ( this.fn2 && oEls.length > 0 )
131
+ $.each(oEls, function(i, el) {
132
+ if ( $.inArray(el, els) < 0 )
133
+ query.fn2.apply(el);
134
+ });
135
+ }
136
+ }
137
+ };
138
+
139
+ $.extend($.livequery, {
140
+ guid: 0,
141
+ queries: [],
142
+ queue: [],
143
+ running: false,
144
+ timeout: null,
145
+
146
+ checkQueue: function() {
147
+ if ( $.livequery.running && $.livequery.queue.length ) {
148
+ var length = $.livequery.queue.length;
149
+ // Run each Live Query currently in the queue
150
+ while ( length-- )
151
+ $.livequery.queries[ $.livequery.queue.shift() ].run();
152
+ }
153
+ },
154
+
155
+ pause: function() {
156
+ // Don't run anymore Live Queries until restarted
157
+ $.livequery.running = false;
158
+ },
159
+
160
+ play: function() {
161
+ // Restart Live Queries
162
+ $.livequery.running = true;
163
+ // Request a run of the Live Queries
164
+ $.livequery.run();
165
+ },
166
+
167
+ registerPlugin: function() {
168
+ $.each( arguments, function(i,n) {
169
+ // Short-circuit if the method doesn't exist
170
+ if (!$.fn[n]) return;
171
+
172
+ // Save a reference to the original method
173
+ var old = $.fn[n];
174
+
175
+ // Create a new method
176
+ $.fn[n] = function() {
177
+ // Call the original method
178
+ var r = old.apply(this, arguments);
179
+
180
+ // Request a run of the Live Queries
181
+ $.livequery.run();
182
+
183
+ // Return the original methods result
184
+ return r;
185
+ }
186
+ });
187
+ },
188
+
189
+ run: function(id) {
190
+ if (id != undefined) {
191
+ // Put the particular Live Query in the queue if it doesn't already exist
192
+ if ( $.inArray(id, $.livequery.queue) < 0 )
193
+ $.livequery.queue.push( id );
194
+ }
195
+ else
196
+ // Put each Live Query in the queue if it doesn't already exist
197
+ $.each( $.livequery.queries, function(id) {
198
+ if ( $.inArray(id, $.livequery.queue) < 0 )
199
+ $.livequery.queue.push( id );
200
+ });
201
+
202
+ // Clear timeout if it already exists
203
+ if ($.livequery.timeout) clearTimeout($.livequery.timeout);
204
+ // Create a timeout to check the queue and actually run the Live Queries
205
+ $.livequery.timeout = setTimeout($.livequery.checkQueue, 20);
206
+ },
207
+
208
+ stop: function(id) {
209
+ if (id != undefined)
210
+ // Stop are particular Live Query
211
+ $.livequery.queries[ id ].stop();
212
+ else
213
+ // Stop all Live Queries
214
+ $.each( $.livequery.queries, function(id) {
215
+ $.livequery.queries[ id ].stop();
216
+ });
217
+ }
218
+ });
219
+
220
+ // Register core DOM manipulation methods
221
+ $.livequery.registerPlugin('append', 'prepend', 'after', 'before', 'wrap', 'attr', 'removeAttr', 'addClass', 'removeClass', 'toggleClass', 'empty', 'remove');
222
+
223
+ // Run Live Queries when the Document is ready
224
+ $(function() { $.livequery.play(); });
225
+
226
+
227
+ // Save a reference to the original init method
228
+ var init = $.prototype.init;
229
+
230
+ // Create a new init method that exposes two new properties: selector and context
231
+ $.prototype.init = function(a,c) {
232
+ // Call the original init and save the result
233
+ var r = init.apply(this, arguments);
234
+
235
+ // Copy over properties if they exist already
236
+ if (a && a.selector)
237
+ r.context = a.context, r.selector = a.selector;
238
+
239
+ // Set properties
240
+ if ( typeof a == 'string' )
241
+ r.context = c || document, r.selector = a;
242
+
243
+ // Return the result
244
+ return r;
245
+ };
246
+
247
+ // Give the init function the jQuery prototype for later instantiation (needed after Rev 4091)
248
+ $.prototype.init.prototype = $.prototype;
249
+
250
+ })(jQuery);
251
  typenow = 'wpsc-product';
wpsc-admin/js/variations.js CHANGED
@@ -16,10 +16,16 @@
16
  .variation_checkbox input
17
 
18
  */
19
-
20
  //Delete checkout options on settings>checkout page
21
 
 
22
  jQuery('.variation_checkboxes').livequery(function(){
 
 
 
 
 
 
23
  jQuery("div.variation_set>label input:checkbox", this).click(function(event){
24
  is_checked = jQuery(this).attr('checked');
25
 
16
  .variation_checkbox input
17
 
18
  */
 
19
  //Delete checkout options on settings>checkout page
20
 
21
+
22
  jQuery('.variation_checkboxes').livequery(function(){
23
+
24
+ jQuery('label input:checkbox', this).click(function(){
25
+
26
+ jQuery('a.update_variations_action').show();
27
+ });
28
+
29
  jQuery("div.variation_set>label input:checkbox", this).click(function(event){
30
  is_checked = jQuery(this).attr('checked');
31
 
wpsc-admin/js/wpsc-swfupload-handlers.js CHANGED
@@ -1,362 +1,362 @@
1
- /**
2
- * This is a nearly exact copy of the corresponding wordpress file, we needed to copy and modify it for our use of swfupoader as the wordpress handler code is specific to posts
3
- */
4
- // define a global variable for swfupload here so that we can later do things to it.
5
- var swfu = null;
6
-
7
-
8
- jQuery().ajaxComplete(function(event, XMLHttpRequest, ajaxOptions) {
9
- // nonces are only regenerated on autosaving when ther product ID is created/changed
10
- // we only want to edit the swfuploader parameters when that happens
11
- if(/autosave-generate-nonces/.test(ajaxOptions.data)) {
12
- window.swfu.removePostParam('product_id');
13
- window.swfu.addPostParam('product_id', parseInt(jQuery('#post_ID').val()));
14
- }
15
- //console.log(jQuery('#post_ID').val());
16
- });
17
-
18
-
19
- function wpsc_fileDialogStart() {
20
- jQuery("#media-upload-error").empty();
21
- }
22
-
23
- // progress and success handlers for media multi uploads
24
- function wpsc_fileQueued(fileObj) {
25
- // Create a progress bar containing the filename
26
- jQuery('#media-items').append('<div id="media-item-' + fileObj.id + '" ><div class="progress"><div class="bar"></div></div></div>');
27
- // Display the progress div
28
- jQuery('#media-item-' + fileObj.id + ' .progress').show();
29
-
30
- // Disable the submit button
31
- //jQuery('#insert-gallery').attr('disabled', 'disabled');
32
- }
33
-
34
- function wpsc_uploadStart(fileObj) {return true; }
35
-
36
- function wpsc_uploadProgress(fileObj, bytesDone, bytesTotal) {
37
- // Lengthen the progress bar
38
- jQuery('#media-item-' + fileObj.id + ' .bar').width(500*bytesDone/bytesTotal);
39
-
40
- if ( bytesDone == bytesTotal ) {
41
- jQuery('#media-item-' + fileObj.id + ' .bar').html('<strong class="crunching"></strong>');
42
- }
43
- }
44
-
45
- function wpsc_prepareMediaItem(fileObj, serverData) {
46
- // Move the progress bar to 100%
47
- jQuery('#media-item-' + fileObj.id + ' .bar').remove();
48
- jQuery('#media-item-' + fileObj.id + ' .progress').hide();
49
-
50
- var f = ( typeof shortform == 'undefined' ) ? 1 : 2;
51
- // Old style: Append the HTML returned by the server -- thumbnail and form inputs
52
- if ( isNaN(serverData) || !serverData ) {
53
- jQuery('#media-item-' + fileObj.id).append(serverData);
54
- prepareMediaItemInit(fileObj);
55
- }
56
- // New style: server data is just the attachment ID, fetch the thumbnail and form html from the server
57
- else {
58
- jQuery('#media-item-' + fileObj.id).load('async-upload.php', {attachment_id:serverData, fetch:f}, function(){prepareMediaItemInit(fileObj);updateMediaForm()});
59
- }
60
- }
61
-
62
- function wpsc_prepareMediaItemInit(fileObj) {
63
-
64
- // Clone the thumbnail as a "pinkynail" -- a tiny image to the left of the filename
65
- jQuery('#media-item-' + fileObj.id + ' .thumbnail').clone().attr('className', 'pinkynail toggle').prependTo('#media-item-' + fileObj.id);
66
-
67
- // Replace the original filename with the new (unique) one assigned during upload
68
- jQuery('#media-item-' + fileObj.id + ' .filename.original').replaceWith(jQuery('#media-item-' + fileObj.id + ' .filename.new'));
69
-
70
- // Also bind toggle to the links
71
- jQuery('#media-item-' + fileObj.id + ' a.toggle').bind('click', function(){jQuery(this).siblings('.slidetoggle').slideToggle(150, function(){var o=jQuery(this).offset();window.scrollTo(0,o.top-36);});jQuery(this).parent().eq(0).children('.toggle').toggle();jQuery(this).siblings('a.toggle').focus();return false;});
72
-
73
- // Bind AJAX to the new Delete button
74
- jQuery('#media-item-' + fileObj.id + ' a.delete').bind('click',function(){
75
- // Tell the server to delete it. TODO: handle exceptions
76
- jQuery.ajax({url:'admin-ajax.php',type:'post',success:deleteSuccess,error:deleteError,id:fileObj.id,data:{
77
- id : this.id.replace(/[^0-9]/g,''),
78
- action : 'delete-post',
79
- _ajax_nonce : this.href.replace(/^.*wpnonce=/,'')}
80
- });
81
- return false;
82
- });
83
-
84
- // Open this item if it says to start open (e.g. to display an error)
85
- jQuery('#media-item-' + fileObj.id + '.startopen')
86
- .removeClass('startopen')
87
- .slideToggle(500)
88
- .parent().eq(0).children('.toggle').toggle();
89
- }
90
-
91
- function wpsc_itemAjaxError(id, html) {
92
- var error = jQuery('#media-item-error' + id);
93
-
94
- error.html('<div class="file-error"><button type="button" id="dismiss-'+id+'" class="button dismiss">'+swfuploadL10n.dismiss+'</button>'+html+'</div>');
95
- jQuery('#dismiss-'+id).click(function(){jQuery(this).parents('.file-error').slideUp(200, function(){jQuery(this).empty();})});
96
- }
97
-
98
- function wpsc_deleteSuccess(data, textStatus) {
99
- if ( data == '-1' )
100
- return itemAjaxError(this.id, 'You do not have permission. Has your session expired?');
101
- if ( data == '0' )
102
- return itemAjaxError(this.id, 'Could not be deleted. Has it been deleted already?');
103
-
104
- var item = jQuery('#media-item-' + this.id);
105
-
106
- // Decrement the counters.
107
- if ( type = jQuery('#type-of-' + this.id).val() )
108
- jQuery('#' + type + '-counter').text(jQuery('#' + type + '-counter').text()-1);
109
- if ( jQuery('.type-form #media-items>*').length == 1 && jQuery('#media-items .hidden').length > 0 ) {
110
- jQuery('.toggle').toggle();
111
- jQuery('.slidetoggle').slideUp(200).siblings().removeClass('hidden');
112
- }
113
-
114
- // Vanish it.
115
- jQuery('#media-item-' + this.id + ' .filename:empty').remove();
116
- jQuery('#media-item-' + this.id + ' .filename').append(' <span class="file-error">'+swfuploadL10n.deleted+'</span>').siblings('a.toggle').remove();
117
- jQuery('#media-item-' + this.id).children('.describe').css({backgroundColor:'#fff'}).end()
118
- .animate({backgroundColor:'#ffc0c0'}, {queue:false,duration:50})
119
- .animate({minHeight:0,height:36}, 400, null, function(){jQuery(this).children('.describe').remove()})
120
- .animate({backgroundColor:'#fff'}, 400)
121
- .animate({height:0}, 800, null, function(){jQuery(this).remove();updateMediaForm();});
122
-
123
- return;
124
- }
125
-
126
- function wpsc_deleteError(X, textStatus, errorThrown) {
127
- // TODO
128
- }
129
-
130
- function wpsc_updateMediaForm() {
131
- storeState();
132
- // Just one file, no need for collapsible part
133
- if ( jQuery('.type-form #media-items>*').length == 1 ) {
134
- jQuery('#media-items .slidetoggle').slideDown(500).parent().eq(0).children('.toggle').toggle();
135
- jQuery('.type-form .slidetoggle').siblings().addClass('hidden');
136
- }
137
-
138
- // Only show Save buttons when there is at least one file.
139
- if ( jQuery('#media-items>*').not('.media-blank').length > 0 )
140
- jQuery('.savebutton').show();
141
- else
142
- jQuery('.savebutton').hide();
143
-
144
- // Only show Gallery button when there are at least two files.
145
- if ( jQuery('#media-items>*').length > 1 )
146
- jQuery('.insert-gallery').show();
147
- else
148
- jQuery('.insert-gallery').hide();
149
- }
150
-
151
- function wpsc_uploadSuccess(fileObj, serverData) {
152
- // if async-upload returned an error message, place it in the media item div and return
153
- if ( serverData.match('media-upload-error') ) {
154
- jQuery('#media-item-' + fileObj.id).html(serverData);
155
- return;
156
- }
157
- //console.log(fileObj);
158
- //console.log(serverData);
159
- eval(serverData);
160
- if(upload_status == 1 ) {
161
- output_html = "";
162
- output_html +="<li class='gallery_image' id='product_image_"+image_id+"'>\n";
163
- output_html += " <input type='hidden' value='"+image_id+"' name='gallery_image_id[]' class='image-id'/>\n";
164
- output_html += " <div id='gallery_image_"+image_id+"' class='previewimage'>\n";
165
- output_html += " <a class='thickbox' rel='product_extra_image_"+image_id+"' href='admin.php?wpsc_admin_action=crop_image&amp;imagename="+image_src+"&amp;imgheight=480&amp;imgwidth=600&amp;product_id=103&amp;width=640&amp;height=342' id='extra_preview_link_"+image_id+"'>\n";
166
- output_html += " <img title='Preview' alt='Preview' src='"+image_src+"' class='previewimage'/>\n";
167
- output_html += " </a>\n";
168
- output_html += " <img src='" + WPSC_CORE_IMAGES_URL + "/cross.png' class='deleteButton' alt='-' style='display: none;'/>\n";
169
- output_html += " </div>\n";
170
- output_html += "</li>\n";
171
-
172
- image_count = jQuery("ul#gallery_list li.gallery_image div a img.previewimage").size();
173
- if(image_count < 1) {
174
- replace_existing = 1;
175
- }
176
- //console.log(jQuery("ul#gallery_list li.gallery_image div a img.previewimage"));
177
- //console.log(image_count);
178
-
179
- if(replace_existing == 1) {
180
- jQuery("ul#gallery_list").html(output_html);
181
-
182
- input_set = jQuery.makeArray(jQuery("#gallery_list li:not(.ui-sortable-helper) input.image-id"));
183
- set = new Array();
184
- for( var i in input_set) {
185
- set[i] = jQuery(input_set[i]).val();
186
- }
187
- //console.log(set);
188
-
189
- img_id = jQuery('#gallery_image_'+set[0]).parent('li').attr('id');
190
-
191
- jQuery('#gallery_image_'+set[0]).children('img.deleteButton').remove();
192
- jQuery('#gallery_image_'+set[0]).append("<a class='editButton'>Edit <img src='" + WPSC_CORE_IMAGES_URL + "/pencil.png' alt ='' /></a>");
193
- // jQuery('#gallery_image_'+set[0]).parent('li').attr('id', 0);
194
-
195
- for(i=1;i<set.length;i++) {
196
- jQuery('#gallery_image_'+set[i]).children('a.editButton').remove();
197
- jQuery('#gallery_image_'+set[i]).append("<img alt='-' class='deleteButton' src='" + WPSC_CORE_IMAGES_URL + "/cross.png'/>");
198
-
199
- element_id = jQuery('#gallery_image_'+set[i]).parent('li').attr('id');
200
- if(element_id == 0) {
201
- // jQuery('#gallery_image_'+set[i]).parent('li').attr('id', img_id);
202
- }
203
- }
204
-
205
- order = set.join(',');
206
- product_id = jQuery('#product_id').val();
207
-
208
-
209
- postVars = "product_id="+product_id+"&order="+order;
210
- jQuery.post( 'index.php?wpsc_admin_action=rearrange_images', postVars, function(returned_data) {
211
- eval(returned_data);
212
- jQuery('#gallery_image_'+image_id).children('a.editButton').remove();
213
- jQuery('#gallery_image_'+image_id).children('div.image_settings_box').remove();
214
- jQuery('#gallery_image_'+image_id).append(image_menu);
215
- });
216
- } else {
217
- jQuery("ul#gallery_list").append(output_html);
218
- ///jQuery("#gallery_list").trigger( 'update' );
219
- }
220
- }
221
-
222
- //jQuery('#media-item-' + fileObj.id + ' .progress').show();
223
- //window.setInterval(function() {
224
- jQuery("#media-item-" + fileObj.id + "").fadeOut("normal");
225
- //}, 5000);
226
-
227
- //prepareMediaItem(fileObj, serverData);
228
- //updateMediaForm();
229
-
230
- }
231
-
232
- function wpsc_uploadComplete(fileObj) {
233
- // If no more uploads queued, enable the submit button
234
- if ( swfu.getStats().files_queued == 0 )
235
- jQuery('#insert-gallery').attr('disabled', '');
236
- }
237
-
238
-
239
- // wp-specific error handlers
240
-
241
- // generic message
242
- function wpsc_wpQueueError(message) {
243
- jQuery('#media-upload-error').show().text(message);
244
- }
245
-
246
- // file-specific message
247
- function wpsc_wpFileError(fileObj, message) {
248
- jQuery('#media-item-' + fileObj.id + ' .filename').after('<div class="file-error"><button type="button" id="dismiss-' + fileObj.id + '" class="button dismiss">'+swfuploadL10n.dismiss+'</button>'+message+'</div>').siblings('.toggle').remove();
249
- jQuery('#dismiss-' + fileObj.id).click(function(){jQuery(this).parents('.media-item').slideUp(200, function(){jQuery(this).remove();})});
250
- }
251
-
252
- function wpsc_fileQueueError(fileObj, error_code, message) {
253
- // Handle this error separately because we don't want to create a FileProgress element for it.
254
- if ( error_code == SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED ) {
255
- wpQueueError(swfuploadL10n.queue_limit_exceeded);
256
- }
257
- else if ( error_code == SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT ) {
258
- fileQueued(fileObj);
259
- wpFileError(fileObj, swfuploadL10n.file_exceeds_size_limit);
260
- }
261
- else if ( error_code == SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE ) {
262
- fileQueued(fileObj);
263
- wpFileError(fileObj, swfuploadL10n.zero_byte_file);
264
- }
265
- else if ( error_code == SWFUpload.QUEUE_ERROR.INVALID_FILETYPE ) {
266
- fileQueued(fileObj);
267
- wpFileError(fileObj, swfuploadL10n.invalid_filetype);
268
- }
269
- else {
270
- wpQueueError(swfuploadL10n.default_error);
271
- }
272
- }
273
-
274
- function wpsc_fileDialogComplete(num_files_queued) {
275
- try {
276
- if (num_files_queued > 0) {
277
- this.startUpload();
278
- }
279
- } catch (ex) {
280
- this.debug(ex);
281
- }
282
- }
283
-
284
- function wpsc_swfuploadPreLoad() {
285
- var swfupload_element = jQuery('#'+swfu.customSettings.swfupload_element_id).get(0);
286
- jQuery('#' + swfu.customSettings.degraded_element_id).hide();
287
- // Doing this directly because jQuery().show() seems to have timing problems
288
- if ( swfupload_element && ! swfupload_element.style.display )
289
- swfupload_element.style.display = 'block';
290
- }
291
-
292
- function wpsc_swfuploadLoadFailed() {
293
- jQuery('#' + swfu.customSettings.swfupload_element_id).hide();
294
- jQuery('#' + swfu.customSettings.degraded_element_id).show();
295
- }
296
-
297
- function wpsc_uploadError(fileObj, error_code, message) {
298
- // first the file specific error
299
- if ( error_code == SWFUpload.UPLOAD_ERROR.MISSING_UPLOAD_URL ) {
300
- wpFileError(fileObj, swfuploadL10n.missing_upload_url);
301
- }
302
- else if ( error_code == SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED ) {
303
- wpFileError(fileObj, swfuploadL10n.upload_limit_exceeded);
304
- }
305
- else {
306
- wpFileError(fileObj, swfuploadL10n.default_error);
307
- }
308
-
309
- // now the general upload status
310
- if ( error_code == SWFUpload.UPLOAD_ERROR.HTTP_ERROR ) {
311
- wpQueueError(swfuploadL10n.http_error);
312
- }
313
- else if ( error_code == SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED ) {
314
- wpQueueError(swfuploadL10n.upload_failed);
315
- }
316
- else if ( error_code == SWFUpload.UPLOAD_ERROR.IO_ERROR ) {
317
- wpQueueError(swfuploadL10n.io_error);
318
- }
319
- else if ( error_code == SWFUpload.UPLOAD_ERROR.SECURITY_ERROR ) {
320
- wpQueueError(swfuploadL10n.security_error);
321
- }
322
- else if ( error_code == SWFUpload.UPLOAD_ERROR.FILE_CANCELLED ) {
323
- wpQueueError(swfuploadL10n.security_error);
324
- }
325
- }
326
-
327
- // remember the last used image size, alignment and url
328
- var storeState;
329
- (function($){
330
-
331
- storeState = function(){
332
- var align = getUserSetting('align') || '', imgsize = getUserSetting('imgsize') || '';
333
-
334
- $('tr.align input[type="radio"]').click(function(){
335
- setUserSetting('align', $(this).val());
336
- }).filter(function(){
337
- if ( $(this).val() == align )
338
- return true;
339
- return false;
340
- }).attr('checked','checked');
341
-
342
- $('tr.image-size input[type="radio"]').click(function(){
343
- setUserSetting('imgsize', $(this).val());
344
- }).filter(function(){
345
- if ( $(this).attr('disabled') || $(this).val() != imgsize )
346
- return false;
347
- return true;
348
- }).attr('checked','checked');
349
-
350
- $('tr.url button').click(function(){
351
- var c = this.className || '';
352
- c = c.replace(/.*?(url[^ '"]+).*/, '$1');
353
- if (c) setUserSetting('urlbutton', c);
354
- $(this).siblings('.urlfield').val( $(this).attr('title') );
355
- });
356
-
357
- $('tr.url .urlfield').each(function(){
358
- var b = getUserSetting('urlbutton');
359
- $(this).val( $(this).siblings('button.'+b).attr('title') );
360
- });
361
- }
362
- })(jQuery);
1
+ /**
2
+ * This is a nearly exact copy of the corresponding wordpress file, we needed to copy and modify it for our use of swfupoader as the wordpress handler code is specific to posts
3
+ */
4
+ // define a global variable for swfupload here so that we can later do things to it.
5
+ var swfu = null;
6
+
7
+
8
+ jQuery().ajaxComplete(function(event, XMLHttpRequest, ajaxOptions) {
9
+ // nonces are only regenerated on autosaving when ther product ID is created/changed
10
+ // we only want to edit the swfuploader parameters when that happens
11
+ if(/autosave-generate-nonces/.test(ajaxOptions.data)) {
12
+ window.swfu.removePostParam('product_id');
13
+ window.swfu.addPostParam('product_id', parseInt(jQuery('#post_ID').val()));
14
+ }
15
+ //console.log(jQuery('#post_ID').val());
16
+ });
17
+
18
+
19
+ function wpsc_fileDialogStart() {
20
+ jQuery("#media-upload-error").empty();
21
+ }
22
+
23
+ // progress and success handlers for media multi uploads
24
+ function wpsc_fileQueued(fileObj) {
25
+ // Create a progress bar containing the filename
26
+ jQuery('#media-items').append('<div id="media-item-' + fileObj.id + '" ><div class="progress"><div class="bar"></div></div></div>');
27
+ // Display the progress div
28
+ jQuery('#media-item-' + fileObj.id + ' .progress').show();
29
+
30
+ // Disable the submit button
31
+ //jQuery('#insert-gallery').attr('disabled', 'disabled');
32
+ }
33
+
34
+ function wpsc_uploadStart(fileObj) {return true; }
35
+
36
+ function wpsc_uploadProgress(fileObj, bytesDone, bytesTotal) {
37
+ // Lengthen the progress bar
38
+ jQuery('#media-item-' + fileObj.id + ' .bar').width(500*bytesDone/bytesTotal);
39
+
40
+ if ( bytesDone == bytesTotal ) {
41
+ jQuery('#media-item-' + fileObj.id + ' .bar').html('<strong class="crunching"></strong>');
42
+ }
43
+ }
44
+
45
+ function wpsc_prepareMediaItem(fileObj, serverData) {
46
+ // Move the progress bar to 100%
47
+ jQuery('#media-item-' + fileObj.id + ' .bar').remove();
48
+ jQuery('#media-item-' + fileObj.id + ' .progress').hide();
49
+
50
+ var f = ( typeof shortform == 'undefined' ) ? 1 : 2;
51
+ // Old style: Append the HTML returned by the server -- thumbnail and form inputs
52
+ if ( isNaN(serverData) || !serverData ) {
53
+ jQuery('#media-item-' + fileObj.id).append(serverData);
54
+ prepareMediaItemInit(fileObj);
55
+ }
56
+ // New style: server data is just the attachment ID, fetch the thumbnail and form html from the server
57
+ else {
58
+ jQuery('#media-item-' + fileObj.id).load('async-upload.php', {attachment_id:serverData, fetch:f}, function(){prepareMediaItemInit(fileObj);updateMediaForm()});
59
+ }
60
+ }
61
+
62
+ function wpsc_prepareMediaItemInit(fileObj) {
63
+
64
+ // Clone the thumbnail as a "pinkynail" -- a tiny image to the left of the filename
65
+ jQuery('#media-item-' + fileObj.id + ' .thumbnail').clone().attr('className', 'pinkynail toggle').prependTo('#media-item-' + fileObj.id);
66
+
67
+ // Replace the original filename with the new (unique) one assigned during upload
68
+ jQuery('#media-item-' + fileObj.id + ' .filename.original').replaceWith(jQuery('#media-item-' + fileObj.id + ' .filename.new'));
69
+
70
+ // Also bind toggle to the links
71
+ jQuery('#media-item-' + fileObj.id + ' a.toggle').bind('click', function(){jQuery(this).siblings('.slidetoggle').slideToggle(150, function(){var o=jQuery(this).offset();window.scrollTo(0,o.top-36);});jQuery(this).parent().eq(0).children('.toggle').toggle();jQuery(this).siblings('a.toggle').focus();return false;});
72
+
73
+ // Bind AJAX to the new Delete button
74
+ jQuery('#media-item-' + fileObj.id + ' a.delete').bind('click',function(){
75
+ // Tell the server to delete it. TODO: handle exceptions
76
+ jQuery.ajax({url:'admin-ajax.php',type:'post',success:deleteSuccess,error:deleteError,id:fileObj.id,data:{
77
+ id : this.id.replace(/[^0-9]/g,''),
78
+ action : 'delete-post',
79
+ _ajax_nonce : this.href.replace(/^.*wpnonce=/,'')}
80
+ });
81
+ return false;
82
+ });
83
+
84
+ // Open this item if it says to start open (e.g. to display an error)
85
+ jQuery('#media-item-' + fileObj.id + '.startopen')
86
+ .removeClass('startopen')
87
+ .slideToggle(500)
88
+ .parent().eq(0).children('.toggle').toggle();
89
+ }
90
+
91
+ function wpsc_itemAjaxError(id, html) {
92
+ var error = jQuery('#media-item-error' + id);
93
+
94
+ error.html('<div class="file-error"><button type="button" id="dismiss-'+id+'" class="button dismiss">'+swfuploadL10n.dismiss+'</button>'+html+'</div>');
95
+ jQuery('#dismiss-'+id).click(function(){jQuery(this).parents('.file-error').slideUp(200, function(){jQuery(this).empty();})});
96
+ }
97
+
98
+ function wpsc_deleteSuccess(data, textStatus) {
99
+ if ( data == '-1' )
100
+ return itemAjaxError(this.id, 'You do not have permission. Has your session expired?');
101
+ if ( data == '0' )
102
+ return itemAjaxError(this.id, 'Could not be deleted. Has it been deleted already?');
103
+
104
+ var item = jQuery('#media-item-' + this.id);
105
+
106
+ // Decrement the counters.
107
+ if ( type = jQuery('#type-of-' + this.id).val() )
108
+ jQuery('#' + type + '-counter').text(jQuery('#' + type + '-counter').text()-1);
109
+ if ( jQuery('.type-form #media-items>*').length == 1 && jQuery('#media-items .hidden').length > 0 ) {
110
+ jQuery('.toggle').toggle();
111
+ jQuery('.slidetoggle').slideUp(200).siblings().removeClass('hidden');
112
+ }
113
+
114
+ // Vanish it.
115
+ jQuery('#media-item-' + this.id + ' .filename:empty').remove();
116
+ jQuery('#media-item-' + this.id + ' .filename').append(' <span class="file-error">'+swfuploadL10n.deleted+'</span>').siblings('a.toggle').remove();
117
+ jQuery('#media-item-' + this.id).children('.describe').css({backgroundColor:'#fff'}).end()
118
+ .animate({backgroundColor:'#ffc0c0'}, {queue:false,duration:50})
119
+ .animate({minHeight:0,height:36}, 400, null, function(){jQuery(this).children('.describe').remove()})
120
+ .animate({backgroundColor:'#fff'}, 400)
121
+ .animate({height:0}, 800, null, function(){jQuery(this).remove();updateMediaForm();});
122
+
123
+ return;
124
+ }
125
+
126
+ function wpsc_deleteError(X, textStatus, errorThrown) {
127
+ // TODO
128
+ }
129
+
130
+ function wpsc_updateMediaForm() {
131
+ storeState();
132
+ // Just one file, no need for collapsible part
133
+ if ( jQuery('.type-form #media-items>*').length == 1 ) {
134
+ jQuery('#media-items .slidetoggle').slideDown(500).parent().eq(0).children('.toggle').toggle();
135
+ jQuery('.type-form .slidetoggle').siblings().addClass('hidden');
136
+ }
137
+
138
+ // Only show Save buttons when there is at least one file.
139
+ if ( jQuery('#media-items>*').not('.media-blank').length > 0 )
140
+ jQuery('.savebutton').show();
141
+ else
142
+ jQuery('.savebutton').hide();
143
+
144
+ // Only show Gallery button when there are at least two files.
145
+ if ( jQuery('#media-items>*').length > 1 )
146
+ jQuery('.insert-gallery').show();
147
+ else
148
+ jQuery('.insert-gallery').hide();
149
+ }
150
+
151
+ function wpsc_uploadSuccess(fileObj, serverData) {
152
+ // if async-upload returned an error message, place it in the media item div and return
153
+ if ( serverData.match('media-upload-error') ) {
154
+ jQuery('#media-item-' + fileObj.id).html(serverData);
155
+ return;
156
+ }
157
+ //console.log(fileObj);
158
+ //console.log(serverData);
159
+ eval(serverData);
160
+ if(upload_status == 1 ) {
161
+ output_html = "";
162
+ output_html +="<li class='gallery_image' id='product_image_"+image_id+"'>\n";
163
+ output_html += " <input type='hidden' value='"+image_id+"' name='gallery_image_id[]' class='image-id'/>\n";
164
+ output_html += " <div id='gallery_image_"+image_id+"' class='previewimage'>\n";
165
+ output_html += " <a class='thickbox' rel='product_extra_image_"+image_id+"' href='admin.php?wpsc_admin_action=crop_image&amp;imagename="+image_src+"&amp;imgheight=480&amp;imgwidth=600&amp;product_id=103&amp;width=640&amp;height=342' id='extra_preview_link_"+image_id+"'>\n";
166
+ output_html += " <img title='Preview' alt='Preview' src='"+image_src+"' class='previewimage'/>\n";
167
+ output_html += " </a>\n";
168
+ output_html += " <img src='" + WPSC_CORE_IMAGES_URL + "/cross.png' class='deleteButton' alt='-' style='display: none;'/>\n";
169
+ output_html += " </div>\n";
170
+ output_html += "</li>\n";
171
+
172
+ image_count = jQuery("ul#gallery_list li.gallery_image div a img.previewimage").size();
173
+ if(image_count < 1) {
174
+ replace_existing = 1;
175
+ }
176
+ //console.log(jQuery("ul#gallery_list li.gallery_image div a img.previewimage"));
177
+ //console.log(image_count);
178
+
179
+ if(replace_existing == 1) {
180
+ jQuery("ul#gallery_list").html(output_html);
181
+
182
+ input_set = jQuery.makeArray(jQuery("#gallery_list li:not(.ui-sortable-helper) input.image-id"));
183
+ set = new Array();
184
+ for( var i in input_set) {
185
+ set[i] = jQuery(input_set[i]).val();
186
+ }
187
+ //console.log(set);
188
+
189
+ img_id = jQuery('#gallery_image_'+set[0]).parent('li').attr('id');
190
+
191
+ jQuery('#gallery_image_'+set[0]).children('img.deleteButton').remove();
192
+ jQuery('#gallery_image_'+set[0]).append("<a class='editButton'>Edit <img src='" + WPSC_CORE_IMAGES_URL + "/pencil.png' alt ='' /></a>");
193
+ // jQuery('#gallery_image_'+set[0]).parent('li').attr('id', 0);
194
+
195
+ for(i=1;i<set.length;i++) {
196
+ jQuery('#gallery_image_'+set[i]).children('a.editButton').remove();
197
+ jQuery('#gallery_image_'+set[i]).append("<img alt='-' class='deleteButton' src='" + WPSC_CORE_IMAGES_URL + "/cross.png'/>");
198
+
199
+ element_id = jQuery('#gallery_image_'+set[i]).parent('li').attr('id');
200
+ if(element_id == 0) {
201
+ // jQuery('#gallery_image_'+set[i]).parent('li').attr('id', img_id);
202
+ }
203
+ }
204
+
205
+ order = set.join(',');
206
+ product_id = jQuery('#product_id').val();
207
+
208
+
209
+ postVars = "product_id="+product_id+"&order="+order;
210
+ jQuery.post( 'index.php?wpsc_admin_action=rearrange_images', postVars, function(returned_data) {
211
+ eval(returned_data);
212
+ jQuery('#gallery_image_'+image_id).children('a.editButton').remove();
213
+ jQuery('#gallery_image_'+image_id).children('div.image_settings_box').remove();
214
+ jQuery('#gallery_image_'+image_id).append(image_menu);
215
+ });
216
+ } else {
217
+ jQuery("ul#gallery_list").append(output_html);
218
+ ///jQuery("#gallery_list").trigger( 'update' );
219
+ }
220
+ }
221
+
222
+ //jQuery('#media-item-' + fileObj.id + ' .progress').show();
223
+ //window.setInterval(function() {
224
+ jQuery("#media-item-" + fileObj.id + "").fadeOut("normal");
225
+ //}, 5000);
226
+
227
+ //prepareMediaItem(fileObj, serverData);
228
+ //updateMediaForm();
229
+
230
+ }
231
+
232
+ function wpsc_uploadComplete(fileObj) {
233
+ // If no more uploads queued, enable the submit button
234
+ if ( swfu.getStats().files_queued == 0 )
235
+ jQuery('#insert-gallery').attr('disabled', '');
236
+ }
237
+
238
+
239
+ // wp-specific error handlers
240
+
241
+ // generic message
242
+ function wpsc_wpQueueError(message) {
243
+ jQuery('#media-upload-error').show().text(message);
244
+ }
245
+
246
+ // file-specific message
247
+ function wpsc_wpFileError(fileObj, message) {
248
+ jQuery('#media-item-' + fileObj.id + ' .filename').after('<div class="file-error"><button type="button" id="dismiss-' + fileObj.id + '" class="button dismiss">'+swfuploadL10n.dismiss+'</button>'+message+'</div>').siblings('.toggle').remove();
249
+ jQuery('#dismiss-' + fileObj.id).click(function(){jQuery(this).parents('.media-item').slideUp(200, function(){jQuery(this).remove();})});
250
+ }
251
+
252
+ function wpsc_fileQueueError(fileObj, error_code, message) {
253
+ // Handle this error separately because we don't want to create a FileProgress element for it.
254
+ if ( error_code == SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED ) {
255
+ wpQueueError(swfuploadL10n.queue_limit_exceeded);
256
+ }
257
+ else if ( error_code == SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT ) {
258
+ fileQueued(fileObj);
259
+ wpFileError(fileObj, swfuploadL10n.file_exceeds_size_limit);
260
+ }
261
+ else if ( error_code == SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE ) {
262
+ fileQueued(fileObj);
263
+ wpFileError(fileObj, swfuploadL10n.zero_byte_file);
264
+ }
265
+ else if ( error_code == SWFUpload.QUEUE_ERROR.INVALID_FILETYPE ) {
266
+ fileQueued(fileObj);
267
+ wpFileError(fileObj, swfuploadL10n.invalid_filetype);
268
+ }
269
+ else {
270
+ wpQueueError(swfuploadL10n.default_error);
271
+ }
272
+ }
273
+
274
+ function wpsc_fileDialogComplete(num_files_queued) {
275
+ try {
276
+ if (num_files_queued > 0) {
277
+ this.startUpload();
278
+ }
279
+ } catch (ex) {
280
+ this.debug(ex);
281
+ }
282
+ }
283
+
284
+ function wpsc_swfuploadPreLoad() {
285
+ var swfupload_element = jQuery('#'+swfu.customSettings.swfupload_element_id).get(0);
286
+ jQuery('#' + swfu.customSettings.degraded_element_id).hide();
287
+ // Doing this directly because jQuery().show() seems to have timing problems
288
+ if ( swfupload_element && ! swfupload_element.style.display )
289
+ swfupload_element.style.display = 'block';
290
+ }
291
+
292
+ function wpsc_swfuploadLoadFailed() {
293
+ jQuery('#' + swfu.customSettings.swfupload_element_id).hide();
294
+ jQuery('#' + swfu.customSettings.degraded_element_id).show();
295
+ }
296
+
297
+ function wpsc_uploadError(fileObj, error_code, message) {
298
+ // first the file specific error
299
+ if ( error_code == SWFUpload.UPLOAD_ERROR.MISSING_UPLOAD_URL ) {
300
+ wpFileError(fileObj, swfuploadL10n.missing_upload_url);
301
+ }
302
+ else if ( error_code == SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED ) {
303
+ wpFileError(fileObj, swfuploadL10n.upload_limit_exceeded);
304
+ }
305
+ else {
306
+ wpFileError(fileObj, swfuploadL10n.default_error);
307
+ }
308
+
309
+ // now the general upload status
310
+ if ( error_code == SWFUpload.UPLOAD_ERROR.HTTP_ERROR ) {
311
+ wpQueueError(swfuploadL10n.http_error);
312
+ }
313
+ else if ( error_code == SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED ) {
314
+ wpQueueError(swfuploadL10n.upload_failed);
315
+ }
316
+ else if ( error_code == SWFUpload.UPLOAD_ERROR.IO_ERROR ) {
317
+ wpQueueError(swfuploadL10n.io_error);
318
+ }
319
+ else if ( error_code == SWFUpload.UPLOAD_ERROR.SECURITY_ERROR ) {
320
+ wpQueueError(swfuploadL10n.security_error);
321
+ }
322
+ else if ( error_code == SWFUpload.UPLOAD_ERROR.FILE_CANCELLED ) {
323
+ wpQueueError(swfuploadL10n.security_error);
324
+ }
325
+ }
326
+
327
+ // remember the last used image size, alignment and url
328
+ var storeState;
329
+ (function($){
330
+
331
+ storeState = function(){
332
+ var align = getUserSetting('align') || '', imgsize = getUserSetting('imgsize') || '';
333
+
334
+ $('tr.align input[type="radio"]').click(function(){
335
+ setUserSetting('align', $(this).val());
336
+ }).filter(function(){
337
+ if ( $(this).val() == align )
338
+ return true;
339
+ return false;
340
+ }).attr('checked','checked');
341
+
342
+ $('tr.image-size input[type="radio"]').click(function(){
343
+ setUserSetting('imgsize', $(this).val());
344
+ }).filter(function(){
345
+ if ( $(this).attr('disabled') || $(this).val() != imgsize )
346
+ return false;
347
+ return true;
348
+ }).attr('checked','checked');
349
+
350
+ $('tr.url button').click(function(){
351
+ var c = this.className || '';
352
+ c = c.replace(/.*?(url[^ '"]+).*/, '$1');
353
+ if (c) setUserSetting('urlbutton', c);
354
+ $(this).siblings('.urlfield').val( $(this).attr('title') );
355
+ });
356
+
357
+ $('tr.url .urlfield').each(function(){
358
+ var b = getUserSetting('urlbutton');
359
+ $(this).val( $(this).siblings('button.'+b).attr('title') );
360
+ });
361
+ }
362
+ })(jQuery);
wpsc-core/images/cb_controls.png ADDED
Binary file
wpsc-core/images/cb_loading.gif ADDED
Binary file
wpsc-core/js/jquery.colorbox-min.js CHANGED
@@ -1,4 +1,4 @@
1
- // ColorBox v1.3.15 - a full featured, light-weight, customizable lightbox based on jQuery 1.3+
2
- // Copyright (c) 2010 Jack Moore - jack@colorpowered.com
3
- // Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
4
  (function(b,ib){var t="none",M="LoadedContent",c=false,v="resize.",o="y",q="auto",e=true,L="nofollow",m="x";function f(a,c){a=a?' id="'+i+a+'"':"";c=c?' style="'+c+'"':"";return b("<div"+a+c+"/>")}function p(a,b){b=b===m?n.width():n.height();return typeof a==="string"?Math.round(/%/.test(a)?b/100*parseInt(a,10):parseInt(a,10)):a}function U(b){return a.photo||/\.(gif|png|jpg|jpeg|bmp)(?:\?([^#]*))?(?:#(\.*))?$/i.test(b)}function cb(a){for(var c in a)if(b.isFunction(a[c])&&c.substring(0,2)!=="on")a[c]=a[c].call(l);a.rel=a.rel||l.rel||L;a.href=a.href||b(l).attr("href");a.title=a.title||l.title;return a}function w(c,a){a&&a.call(l);b.event.trigger(c)}function jb(){var b,e=i+"Slideshow_",c="click."+i,f,k;if(a.slideshow&&h[1]){f=function(){F.text(a.slideshowStop).unbind(c).bind(V,function(){if(g<h.length-1||a.loop)b=setTimeout(d.next,a.slideshowSpeed)}).bind(W,function(){clearTimeout(b)}).one(c+" "+N,k);j.removeClass(e+"off").addClass(e+"on");b=setTimeout(d.next,a.slideshowSpeed)};k=function(){clearTimeout(b);F.text(a.slideshowStart).unbind([V,W,N,c].join(" ")).one(c,f);j.removeClass(e+"on").addClass(e+"off")};a.slideshowAuto?f():k()}}function db(c){if(!O){l=c;a=cb(b.extend({},b.data(l,r)));h=b(l);g=0;if(a.rel!==L){h=b("."+G).filter(function(){return (b.data(this,r).rel||this.rel)===a.rel});g=h.index(l);if(g===-1){h=h.add(l);g=h.length-1}}if(!u){u=D=e;j.show();if(a.returnFocus)try{l.blur();b(l).one(eb,function(){try{this.focus()}catch(a){}})}catch(f){}x.css({opacity:+a.opacity,cursor:a.overlayClose?"pointer":q}).show();a.w=p(a.initialWidth,m);a.h=p(a.initialHeight,o);d.position(0);X&&n.bind(v+P+" scroll."+P,function(){x.css({width:n.width(),height:n.height(),top:n.scrollTop(),left:n.scrollLeft()})}).trigger("scroll."+P);w(fb,a.onOpen);Y.add(H).add(I).add(F).add(Z).hide();ab.html(a.close).show()}d.load(e)}}var gb={transition:"elastic",speed:300,width:c,initialWidth:"600",innerWidth:c,maxWidth:c,height:c,initialHeight:"450",innerHeight:c,maxHeight:c,scalePhotos:e,scrolling:e,inline:c,html:c,iframe:c,photo:c,href:c,title:c,rel:c,opacity:.9,preloading:e,current:"image {current} of {total}",previous:"previous",next:"next",close:"close",open:c,returnFocus:e,loop:e,slideshow:c,slideshowAuto:e,slideshowSpeed:2500,slideshowStart:"start slideshow",slideshowStop:"stop slideshow",onOpen:c,onLoad:c,onComplete:c,onCleanup:c,onClosed:c,overlayClose:e,escKey:e,arrowKey:e},r="colorbox",i="cbox",fb=i+"_open",W=i+"_load",V=i+"_complete",N=i+"_cleanup",eb=i+"_closed",Q=i+"_purge",hb=i+"_loaded",E=b.browser.msie&&!b.support.opacity,X=E&&b.browser.version<7,P=i+"_IE6",x,j,A,s,bb,T,R,S,h,n,k,J,K,Z,Y,F,I,H,ab,B,C,y,z,l,g,a,u,D,O=c,d,G=i+"Element";d=b.fn[r]=b[r]=function(c,f){var a=this,d;if(!a[0]&&a.selector)return a;c=c||{};if(f)c.onComplete=f;if(!a[0]||a.selector===undefined){a=b("<a/>");c.open=e}a.each(function(){b.data(this,r,b.extend({},b.data(this,r)||gb,c));b(this).addClass(G)});d=c.open;if(b.isFunction(d))d=d.call(a);d&&db(a[0]);return a};d.init=function(){var l="hover",m="clear:left";n=b(ib);j=f().attr({id:r,"class":E?i+"IE":""});x=f("Overlay",X?"position:absolute":"").hide();A=f("Wrapper");s=f("Content").append(k=f(M,"width:0; height:0; overflow:hidden"),K=f("LoadingOverlay").add(f("LoadingGraphic")),Z=f("Title"),Y=f("Current"),I=f("Next"),H=f("Previous"),F=f("Slideshow").bind(fb,jb),ab=f("Close"));A.append(f().append(f("TopLeft"),bb=f("TopCenter"),f("TopRight")),f(c,m).append(T=f("MiddleLeft"),s,R=f("MiddleRight")),f(c,m).append(f("BottomLeft"),S=f("BottomCenter"),f("BottomRight"))).children().children().css({"float":"left"});J=f(c,"position:absolute; width:9999px; visibility:hidden; display:none");b("body").prepend(x,j.append(A,J));s.children().hover(function(){b(this).addClass(l)},function(){b(this).removeClass(l)}).addClass(l);B=bb.height()+S.height()+s.outerHeight(e)-s.height();C=T.width()+R.width()+s.outerWidth(e)-s.width();y=k.outerHeight(e);z=k.outerWidth(e);j.css({"padding-bottom":B,"padding-right":C}).hide();I.click(d.next);H.click(d.prev);ab.click(d.close);s.children().removeClass(l);b("."+G).live("click",function(a){if(!(a.button!==0&&typeof a.button!=="undefined"||a.ctrlKey||a.shiftKey||a.altKey)){a.preventDefault();db(this)}});x.click(function(){a.overlayClose&&d.close()});b(document).bind("keydown",function(b){if(u&&a.escKey&&b.keyCode===27){b.preventDefault();d.close()}if(u&&a.arrowKey&&!D&&h[1])if(b.keyCode===37&&(g||a.loop)){b.preventDefault();H.click()}else if(b.keyCode===39&&(g<h.length-1||a.loop)){b.preventDefault();I.click()}})};d.remove=function(){j.add(x).remove();b("."+G).die("click").removeData(r).removeClass(G)};d.position=function(f,d){function b(a){bb[0].style.width=S[0].style.width=s[0].style.width=a.style.width;K[0].style.height=K[1].style.height=s[0].style.height=T[0].style.height=R[0].style.height=a.style.height}var e,h=Math.max(document.documentElement.clientHeight-a.h-y-B,0)/2+n.scrollTop(),g=Math.max(n.width()-a.w-z-C,0)/2+n.scrollLeft();e=j.width()===a.w+z&&j.height()===a.h+y?0:f;A[0].style.width=A[0].style.height="9999px";j.dequeue().animate({width:a.w+z,height:a.h+y,top:h,left:g},{duration:e,complete:function(){b(this);D=c;A[0].style.width=a.w+z+C+"px";A[0].style.height=a.h+y+B+"px";d&&d()},step:function(){b(this)}})};d.resize=function(b){if(u){b=b||{};if(b.width)a.w=p(b.width,m)-z-C;if(b.innerWidth)a.w=p(b.innerWidth,m);k.css({width:a.w});if(b.height)a.h=p(b.height,o)-y-B;if(b.innerHeight)a.h=p(b.innerHeight,o);if(!b.innerHeight&&!b.height){b=k.wrapInner("<div style='overflow:auto'></div>").children();a.h=b.height();b.replaceWith(b.children())}k.css({height:a.h});d.position(a.transition===t?0:a.speed)}};d.prep=function(m){var c="hidden";function l(s){var p,f,m,c,l=h.length,q=a.loop;d.position(s,function(){function s(){E&&j[0].style.removeAttribute("filter")}if(u){E&&o&&k.fadeIn(100);k.show();w(hb);Z.show().html(a.title);if(l>1){typeof a.current==="string"&&Y.html(a.current.replace(/\{current\}/,g+1).replace(/\{total\}/,l)).show();I[q||g<l-1?"show":"hide"]().html(a.next);H[q||g?"show":"hide"]().html(a.previous);p=g?h[g-1]:h[l-1];m=g<l-1?h[g+1]:h[0];a.slideshow&&F.show();if(a.preloading){c=b.data(m,r).href||m.href;f=b.data(p,r).href||p.href;c=b.isFunction(c)?c.call(m):c;f=b.isFunction(f)?f.call(p):f;if(U(c))b("<img/>")[0].src=c;if(U(f))b("<img/>")[0].src=f}}K.hide();a.transition==="fade"?j.fadeTo(e,1,function(){s()}):s();n.bind(v+i,function(){d.position(0)});w(V,a.onComplete)}})}if(u){var o,e=a.transition===t?0:a.speed;n.unbind(v+i);k.remove();k=f(M).html(m);k.hide().appendTo(J.show()).css({width:function(){a.w=a.w||k.width();a.w=a.mw&&a.mw<a.w?a.mw:a.w;return a.w}(),overflow:a.scrolling?q:c}).css({height:function(){a.h=a.h||k.height();a.h=a.mh&&a.mh<a.h?a.mh:a.h;return a.h}()}).prependTo(s);J.hide();b("#"+i+"Photo").css({cssFloat:t,marginLeft:q,marginRight:q});X&&b("select").not(j.find("select")).filter(function(){return this.style.visibility!==c}).css({visibility:c}).one(N,function(){this.style.visibility="inherit"});a.transition==="fade"?j.fadeTo(e,0,function(){l(0)}):l(e)}};d.load=function(u){var n,c,s,q=d.prep;D=e;l=h[g];u||(a=cb(b.extend({},b.data(l,r))));w(Q);w(W,a.onLoad);a.h=a.height?p(a.height,o)-y-B:a.innerHeight&&p(a.innerHeight,o);a.w=a.width?p(a.width,m)-z-C:a.innerWidth&&p(a.innerWidth,m);a.mw=a.w;a.mh=a.h;if(a.maxWidth){a.mw=p(a.maxWidth,m)-z-C;a.mw=a.w&&a.w<a.mw?a.w:a.mw}if(a.maxHeight){a.mh=p(a.maxHeight,o)-y-B;a.mh=a.h&&a.h<a.mh?a.h:a.mh}n=a.href;K.show();if(a.inline){f().hide().insertBefore(b(n)[0]).one(Q,function(){b(this).replaceWith(k.children())});q(b(n))}else if(a.iframe){j.one(hb,function(){var c=b("<iframe frameborder='0' style='width:100%; height:100%; border:0; display:block'/>")[0];c.name=+new Date;c.src=a.href;if(!a.scrolling)c.scrolling="no";if(E)c.allowtransparency="true";b(c).appendTo(k).one(Q,function(){c.src="//about:blank"})});q(" ")}else if(a.html)q(a.html);else if(U(n)){c=new Image;c.onload=function(){var e;c.onload=null;c.id=i+"Photo";b(c).css({border:t,display:"block",cssFloat:"left"});if(a.scalePhotos){s=function(){c.height-=c.height*e;c.width-=c.width*e};if(a.mw&&c.width>a.mw){e=(c.width-a.mw)/c.width;s()}if(a.mh&&c.height>a.mh){e=(c.height-a.mh)/c.height;s()}}if(a.h)c.style.marginTop=Math.max(a.h-c.height,0)/2+"px";h[1]&&(g<h.length-1||a.loop)&&b(c).css({cursor:"pointer"}).click(d.next);if(E)c.style.msInterpolationMode="bicubic";setTimeout(function(){q(c)},1)};setTimeout(function(){c.src=n},1)}else n&&J.load(n,function(d,c,a){q(c==="error"?"Request unsuccessful: "+a.statusText:b(this).children())})};d.next=function(){if(!D){g=g<h.length-1?g+1:0;d.load()}};d.prev=function(){if(!D){g=g?g-1:h.length-1;d.load()}};d.close=function(){if(u&&!O){O=e;u=c;w(N,a.onCleanup);n.unbind("."+i+" ."+P);x.fadeTo("fast",0);j.stop().fadeTo("fast",0,function(){w(Q);k.remove();j.add(x).css({opacity:1,cursor:q}).hide();setTimeout(function(){O=c;w(eb,a.onClosed)},1)})}};d.element=function(){return b(l)};d.settings=gb;b(d.init)})(jQuery,this);
1
+ // ColorBox v1.3.15 - a full featured, light-weight, customizable lightbox based on jQuery 1.3+
2
+ // Copyright (c) 2010 Jack Moore - jack@colorpowered.com
3
+ // Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
4
  (function(b,ib){var t="none",M="LoadedContent",c=false,v="resize.",o="y",q="auto",e=true,L="nofollow",m="x";function f(a,c){a=a?' id="'+i+a+'"':"";c=c?' style="'+c+'"':"";return b("<div"+a+c+"/>")}function p(a,b){b=b===m?n.width():n.height();return typeof a==="string"?Math.round(/%/.test(a)?b/100*parseInt(a,10):parseInt(a,10)):a}function U(b){return a.photo||/\.(gif|png|jpg|jpeg|bmp)(?:\?([^#]*))?(?:#(\.*))?$/i.test(b)}function cb(a){for(var c in a)if(b.isFunction(a[c])&&c.substring(0,2)!=="on")a[c]=a[c].call(l);a.rel=a.rel||l.rel||L;a.href=a.href||b(l).attr("href");a.title=a.title||l.title;return a}function w(c,a){a&&a.call(l);b.event.trigger(c)}function jb(){var b,e=i+"Slideshow_",c="click."+i,f,k;if(a.slideshow&&h[1]){f=function(){F.text(a.slideshowStop).unbind(c).bind(V,function(){if(g<h.length-1||a.loop)b=setTimeout(d.next,a.slideshowSpeed)}).bind(W,function(){clearTimeout(b)}).one(c+" "+N,k);j.removeClass(e+"off").addClass(e+"on");b=setTimeout(d.next,a.slideshowSpeed)};k=function(){clearTimeout(b);F.text(a.slideshowStart).unbind([V,W,N,c].join(" ")).one(c,f);j.removeClass(e+"on").addClass(e+"off")};a.slideshowAuto?f():k()}}function db(c){if(!O){l=c;a=cb(b.extend({},b.data(l,r)));h=b(l);g=0;if(a.rel!==L){h=b("."+G).filter(function(){return (b.data(this,r).rel||this.rel)===a.rel});g=h.index(l);if(g===-1){h=h.add(l);g=h.length-1}}if(!u){u=D=e;j.show();if(a.returnFocus)try{l.blur();b(l).one(eb,function(){try{this.focus()}catch(a){}})}catch(f){}x.css({opacity:+a.opacity,cursor:a.overlayClose?"pointer":q}).show();a.w=p(a.initialWidth,m);a.h=p(a.initialHeight,o);d.position(0);X&&n.bind(v+P+" scroll."+P,function(){x.css({width:n.width(),height:n.height(),top:n.scrollTop(),left:n.scrollLeft()})}).trigger("scroll."+P);w(fb,a.onOpen);Y.add(H).add(I).add(F).add(Z).hide();ab.html(a.close).show()}d.load(e)}}var gb={transition:"elastic",speed:300,width:c,initialWidth:"600",innerWidth:c,maxWidth:c,height:c,initialHeight:"450",innerHeight:c,maxHeight:c,scalePhotos:e,scrolling:e,inline:c,html:c,iframe:c,photo:c,href:c,title:c,rel:c,opacity:.9,preloading:e,current:"image {current} of {total}",previous:"previous",next:"next",close:"close",open:c,returnFocus:e,loop:e,slideshow:c,slideshowAuto:e,slideshowSpeed:2500,slideshowStart:"start slideshow",slideshowStop:"stop slideshow",onOpen:c,onLoad:c,onComplete:c,onCleanup:c,onClosed:c,overlayClose:e,escKey:e,arrowKey:e},r="colorbox",i="cbox",fb=i+"_open",W=i+"_load",V=i+"_complete",N=i+"_cleanup",eb=i+"_closed",Q=i+"_purge",hb=i+"_loaded",E=b.browser.msie&&!b.support.opacity,X=E&&b.browser.version<7,P=i+"_IE6",x,j,A,s,bb,T,R,S,h,n,k,J,K,Z,Y,F,I,H,ab,B,C,y,z,l,g,a,u,D,O=c,d,G=i+"Element";d=b.fn[r]=b[r]=function(c,f){var a=this,d;if(!a[0]&&a.selector)return a;c=c||{};if(f)c.onComplete=f;if(!a[0]||a.selector===undefined){a=b("<a/>");c.open=e}a.each(function(){b.data(this,r,b.extend({},b.data(this,r)||gb,c));b(this).addClass(G)});d=c.open;if(b.isFunction(d))d=d.call(a);d&&db(a[0]);return a};d.init=function(){var l="hover",m="clear:left";n=b(ib);j=f().attr({id:r,"class":E?i+"IE":""});x=f("Overlay",X?"position:absolute":"").hide();A=f("Wrapper");s=f("Content").append(k=f(M,"width:0; height:0; overflow:hidden"),K=f("LoadingOverlay").add(f("LoadingGraphic")),Z=f("Title"),Y=f("Current"),I=f("Next"),H=f("Previous"),F=f("Slideshow").bind(fb,jb),ab=f("Close"));A.append(f().append(f("TopLeft"),bb=f("TopCenter"),f("TopRight")),f(c,m).append(T=f("MiddleLeft"),s,R=f("MiddleRight")),f(c,m).append(f("BottomLeft"),S=f("BottomCenter"),f("BottomRight"))).children().children().css({"float":"left"});J=f(c,"position:absolute; width:9999px; visibility:hidden; display:none");b("body").prepend(x,j.append(A,J));s.children().hover(function(){b(this).addClass(l)},function(){b(this).removeClass(l)}).addClass(l);B=bb.height()+S.height()+s.outerHeight(e)-s.height();C=T.width()+R.width()+s.outerWidth(e)-s.width();y=k.outerHeight(e);z=k.outerWidth(e);j.css({"padding-bottom":B,"padding-right":C}).hide();I.click(d.next);H.click(d.prev);ab.click(d.close);s.children().removeClass(l);b("."+G).live("click",function(a){if(!(a.button!==0&&typeof a.button!=="undefined"||a.ctrlKey||a.shiftKey||a.altKey)){a.preventDefault();db(this)}});x.click(function(){a.overlayClose&&d.close()});b(document).bind("keydown",function(b){if(u&&a.escKey&&b.keyCode===27){b.preventDefault();d.close()}if(u&&a.arrowKey&&!D&&h[1])if(b.keyCode===37&&(g||a.loop)){b.preventDefault();H.click()}else if(b.keyCode===39&&(g<h.length-1||a.loop)){b.preventDefault();I.click()}})};d.remove=function(){j.add(x).remove();b("."+G).die("click").removeData(r).removeClass(G)};d.position=function(f,d){function b(a){bb[0].style.width=S[0].style.width=s[0].style.width=a.style.width;K[0].style.height=K[1].style.height=s[0].style.height=T[0].style.height=R[0].style.height=a.style.height}var e,h=Math.max(document.documentElement.clientHeight-a.h-y-B,0)/2+n.scrollTop(),g=Math.max(n.width()-a.w-z-C,0)/2+n.scrollLeft();e=j.width()===a.w+z&&j.height()===a.h+y?0:f;A[0].style.width=A[0].style.height="9999px";j.dequeue().animate({width:a.w+z,height:a.h+y,top:h,left:g},{duration:e,complete:function(){b(this);D=c;A[0].style.width=a.w+z+C+"px";A[0].style.height=a.h+y+B+"px";d&&d()},step:function(){b(this)}})};d.resize=function(b){if(u){b=b||{};if(b.width)a.w=p(b.width,m)-z-C;if(b.innerWidth)a.w=p(b.innerWidth,m);k.css({width:a.w});if(b.height)a.h=p(b.height,o)-y-B;if(b.innerHeight)a.h=p(b.innerHeight,o);if(!b.innerHeight&&!b.height){b=k.wrapInner("<div style='overflow:auto'></div>").children();a.h=b.height();b.replaceWith(b.children())}k.css({height:a.h});d.position(a.transition===t?0:a.speed)}};d.prep=function(m){var c="hidden";function l(s){var p,f,m,c,l=h.length,q=a.loop;d.position(s,function(){function s(){E&&j[0].style.removeAttribute("filter")}if(u){E&&o&&k.fadeIn(100);k.show();w(hb);Z.show().html(a.title);if(l>1){typeof a.current==="string"&&Y.html(a.current.replace(/\{current\}/,g+1).replace(/\{total\}/,l)).show();I[q||g<l-1?"show":"hide"]().html(a.next);H[q||g?"show":"hide"]().html(a.previous);p=g?h[g-1]:h[l-1];m=g<l-1?h[g+1]:h[0];a.slideshow&&F.show();if(a.preloading){c=b.data(m,r).href||m.href;f=b.data(p,r).href||p.href;c=b.isFunction(c)?c.call(m):c;f=b.isFunction(f)?f.call(p):f;if(U(c))b("<img/>")[0].src=c;if(U(f))b("<img/>")[0].src=f}}K.hide();a.transition==="fade"?j.fadeTo(e,1,function(){s()}):s();n.bind(v+i,function(){d.position(0)});w(V,a.onComplete)}})}if(u){var o,e=a.transition===t?0:a.speed;n.unbind(v+i);k.remove();k=f(M).html(m);k.hide().appendTo(J.show()).css({width:function(){a.w=a.w||k.width();a.w=a.mw&&a.mw<a.w?a.mw:a.w;return a.w}(),overflow:a.scrolling?q:c}).css({height:function(){a.h=a.h||k.height();a.h=a.mh&&a.mh<a.h?a.mh:a.h;return a.h}()}).prependTo(s);J.hide();b("#"+i+"Photo").css({cssFloat:t,marginLeft:q,marginRight:q});X&&b("select").not(j.find("select")).filter(function(){return this.style.visibility!==c}).css({visibility:c}).one(N,function(){this.style.visibility="inherit"});a.transition==="fade"?j.fadeTo(e,0,function(){l(0)}):l(e)}};d.load=function(u){var n,c,s,q=d.prep;D=e;l=h[g];u||(a=cb(b.extend({},b.data(l,r))));w(Q);w(W,a.onLoad);a.h=a.height?p(a.height,o)-y-B:a.innerHeight&&p(a.innerHeight,o);a.w=a.width?p(a.width,m)-z-C:a.innerWidth&&p(a.innerWidth,m);a.mw=a.w;a.mh=a.h;if(a.maxWidth){a.mw=p(a.maxWidth,m)-z-C;a.mw=a.w&&a.w<a.mw?a.w:a.mw}if(a.maxHeight){a.mh=p(a.maxHeight,o)-y-B;a.mh=a.h&&a.h<a.mh?a.h:a.mh}n=a.href;K.show();if(a.inline){f().hide().insertBefore(b(n)[0]).one(Q,function(){b(this).replaceWith(k.children())});q(b(n))}else if(a.iframe){j.one(hb,function(){var c=b("<iframe frameborder='0' style='width:100%; height:100%; border:0; display:block'/>")[0];c.name=+new Date;c.src=a.href;if(!a.scrolling)c.scrolling="no";if(E)c.allowtransparency="true";b(c).appendTo(k).one(Q,function(){c.src="//about:blank"})});q(" ")}else if(a.html)q(a.html);else if(U(n)){c=new Image;c.onload=function(){var e;c.onload=null;c.id=i+"Photo";b(c).css({border:t,display:"block",cssFloat:"left"});if(a.scalePhotos){s=function(){c.height-=c.height*e;c.width-=c.width*e};if(a.mw&&c.width>a.mw){e=(c.width-a.mw)/c.width;s()}if(a.mh&&c.height>a.mh){e=(c.height-a.mh)/c.height;s()}}if(a.h)c.style.marginTop=Math.max(a.h-c.height,0)/2+"px";h[1]&&(g<h.length-1||a.loop)&&b(c).css({cursor:"pointer"}).click(d.next);if(E)c.style.msInterpolationMode="bicubic";setTimeout(function(){q(c)},1)};setTimeout(function(){c.src=n},1)}else n&&J.load(n,function(d,c,a){q(c==="error"?"Request unsuccessful: "+a.statusText:b(this).children())})};d.next=function(){if(!D){g=g<h.length-1?g+1:0;d.load()}};d.prev=function(){if(!D){g=g?g-1:h.length-1;d.load()}};d.close=function(){if(u&&!O){O=e;u=c;w(N,a.onCleanup);n.unbind("."+i+" ."+P);x.fadeTo("fast",0);j.stop().fadeTo("fast",0,function(){w(Q);k.remove();j.add(x).css({opacity:1,cursor:q}).hide();setTimeout(function(){O=c;w(eb,a.onClosed)},1)})}};d.element=function(){return b(l)};d.settings=gb;b(d.init)})(jQuery,this);
wpsc-core/js/jquery.infieldlabel.min.js CHANGED
@@ -1,5 +1,5 @@
1
  //full version and license can be found here: http://plugins.jquery.com/files/jquery.inlineFieldLabel.js.txt
2
- (function($){$.fn.inlineFieldLabel=function(options){var opts=$.extend({},$.fn.inlineFieldLabel.defaults,options);this.each(function(){$this=$(this);var o=$.metadata?$.extend({},opts,$this.metadata({type:opts.metadataType,name:opts.metadataName})):opts;innerFunction($this,o.label);});return this;};$.fn.inlineFieldLabel.defaults={label:'some placeholder',metadataType:'class',metadataName:'metadata',};function innerFunction(jqElement,fieldLabel){var textInput=null;var clonedTextInput=null;var strBefore="";var strAfter="";var counter=0;textInput=jqElement;if(textInput.attr('type')=='password'){clonedTextInput=textInput.clone();strBefore=clonedTextInput.append(textInput.clone()).html();strAfter=strBefore.replace('type="password"','type="text"');;strAfter.replace('type="password"','type="text"');textInput.after(strAfter);clonedTextInput=textInput.next();clonedTextInput.addClass("intra-field-label").val(fieldLabel);textInput.hide();}else{textInput.addClass("intra-field-label").val(fieldLabel);}
3
  if(clonedTextInput!=null){clonedTextInput.focus(function(){textInput.show();textInput.trigger('focus');clonedTextInput.hide();});}
4
  textInput.focus(function()
5
  {if(this.value==fieldLabel)
@@ -8,4 +8,4 @@ textInput.focus(function()
8
  {if(clonedTextInput!=null){textInput.hide();clonedTextInput.show();}
9
  else{textInput.addClass("intra-field-label").val(fieldLabel);}};});textInput.parents('form:first').find('input[type="submit"]').click(function(){if(clonedTextInput!=null){textInput.show();clonedTextInput.remove();}
10
  if(textInput.val()==fieldLabel)
11
- {textInput.removeClass("intra-field-label").val("");};});}})(jQuery);
1
  //full version and license can be found here: http://plugins.jquery.com/files/jquery.inlineFieldLabel.js.txt
2
+ (function($){$.fn.inlineFieldLabel=function(options){var opts=$.extend({},$.fn.inlineFieldLabel.defaults,options);this.each(function(){$this=$(this);var o=$.metadata?$.extend({},opts,$this.metadata({type:opts.metadataType,name:opts.metadataName})):opts;innerFunction($this,o.label);});return this;};$.fn.inlineFieldLabel.defaults={label:'some placeholder',metadataType:'class',metadataName:'metadata'};function innerFunction(jqElement,fieldLabel){var textInput=null;var clonedTextInput=null;var strBefore="";var strAfter="";var counter=0;textInput=jqElement;if(textInput.attr('type')=='password'){clonedTextInput=textInput.clone();strBefore=clonedTextInput.append(textInput.clone()).html();strAfter=strBefore.replace('type="password"','type="text"');;strAfter.replace('type="password"','type="text"');textInput.after(strAfter);clonedTextInput=textInput.next();clonedTextInput.addClass("intra-field-label").val(fieldLabel);textInput.hide();}else{textInput.addClass("intra-field-label").val(fieldLabel);}
3
  if(clonedTextInput!=null){clonedTextInput.focus(function(){textInput.show();textInput.trigger('focus');clonedTextInput.hide();});}
4
  textInput.focus(function()
5
  {if(this.value==fieldLabel)
8
  {if(clonedTextInput!=null){textInput.hide();clonedTextInput.show();}
9
  else{textInput.addClass("intra-field-label").val(fieldLabel);}};});textInput.parents('form:first').find('input[type="submit"]').click(function(){if(clonedTextInput!=null){textInput.show();clonedTextInput.remove();}
10
  if(textInput.val()==fieldLabel)
11
+ {textInput.removeClass("intra-field-label").val("");};});}})(jQuery);
wpsc-core/js/wp-e-commerce.js CHANGED
@@ -1,3 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  // this function is for binding actions to events and rebinding them after they are replaced by AJAX
2
  // these functions are bound to events on elements when the page is fully loaded.
3
  jQuery(document).ready(function () {
@@ -44,9 +109,9 @@ jQuery(document).ready(function () {
44
  jQuery("span.shipping_country_name").html(country).removeClass('intra-field-label');
45
  jQuery("select#current_country").val(countryID).removeClass('intra-field-label');
46
 
47
- jQuery("select[title='shippingcountry']").val(countryID).removeClass('intra-field-label');
48
- var html_form_id = jQuery("select[title='shippingcountry']").attr('id');
49
- var form_id = jQuery("select[title='shippingcountry']").attr('name');
50
  form_id = form_id.replace("collected_data[", "");
51
  form_id = form_id.replace("]", "");
52
  form_id = form_id.replace("[0]", "");
@@ -313,7 +378,13 @@ function set_shipping_country(html_form_id, form_id){
313
  shipping_region = "&shipping_region="+region;
314
  }
315
 
316
- form_values = "wpsc_ajax_action=change_tax&form_id="+form_id+"&shipping_country="+country+shipping_region;
 
 
 
 
 
 
317
  jQuery.post( 'index.php', form_values, function(returned_data) {
318
  eval(returned_data);
319
  });
@@ -365,4 +436,4 @@ jQuery(document).ready(function(){
365
  });
366
  });
367
 
368
- eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('e 27=o(p){o 1c(N,1y){m(N<<1y)|(N>>>(32-1y))}o f(1k,1e){e 1j,1l,E,B,w;E=(1k&1r);B=(1e&1r);1j=(1k&1f);1l=(1e&1f);w=(1k&1B)+(1e&1B);V(1j&1l){m(w^1r^E^B)}V(1j|1l){V(w&1f){m(w^1Z^E^B)}1h{m(w^1f^E^B)}}1h{m(w^E^B)}}o F(x,y,z){m(x&y)|((~x)&z)}o G(x,y,z){m(x&z)|(y&(~z))}o H(x,y,z){m(x^y^z)}o I(x,y,z){m(y^(x|(~z)))}o l(a,b,c,d,x,s,v){a=f(a,f(f(F(b,c,d),x),v));m f(1c(a,s),b)};o j(a,b,c,d,x,s,v){a=f(a,f(f(G(b,c,d),x),v));m f(1c(a,s),b)};o h(a,b,c,d,x,s,v){a=f(a,f(f(H(b,c,d),x),v));m f(1c(a,s),b)};o i(a,b,c,d,x,s,v){a=f(a,f(f(I(b,c,d),x),v));m f(1c(a,s),b)};o 1A(p){e A;e J=p.1g;e 1q=J+8;e 1D=(1q-(1q%1G))/1G;e 1m=(1D+1)*16;e t=1z(1m-1);e K=0;e q=0;24(q<J){A=(q-(q%4))/4;K=(q%4)*8;t[A]=(t[A]|(p.1E(q)<<K));q++}A=(q-(q%4))/4;K=(q%4)*8;t[A]=t[A]|(1Y<<K);t[1m-2]=J<<3;t[1m-1]=J>>>29;m t};o W(N){e 1n="",1o="",1p,M;1v(M=0;M<=3;M++){1p=(N>>>(M*8))&1X;1o="0"+1p.1U(16);1n=1n+1o.1V(1o.1g-2,2)}m 1n};o 1C(p){p=p.1W(/\\r\\n/g,"\\n");e u="";1v(e n=0;n<p.1g;n++){e c=p.1E(n);V(c<1i){u+=D.C(c)}1h V((c>1T)&&(c<25)){u+=D.C((c>>6)|26);u+=D.C((c&1s)|1i)}1h{u+=D.C((c>>12)|2c);u+=D.C(((c>>6)&1s)|1i);u+=D.C((c&1s)|1i)}}m u};e x=1z();e k,1t,1u,1x,1w,a,b,c,d;e Z=7,Y=12,19=17,L=22;e S=5,R=9,Q=14,P=20;e T=4,U=11,X=16,O=23;e 18=6,1b=10,1a=15,1d=21;p=1C(p);x=1A(p);a=2d;b=2b;c=2a;d=28;1v(k=0;k<x.1g;k+=16){1t=a;1u=b;1x=c;1w=d;a=l(a,b,c,d,x[k+0],Z,2e);d=l(d,a,b,c,x[k+1],Y,1I);c=l(c,d,a,b,x[k+2],19,1K);b=l(b,c,d,a,x[k+3],L,1S);a=l(a,b,c,d,x[k+4],Z,1Q);d=l(d,a,b,c,x[k+5],Y,1P);c=l(c,d,a,b,x[k+6],19,1N);b=l(b,c,d,a,x[k+7],L,1O);a=l(a,b,c,d,x[k+8],Z,1M);d=l(d,a,b,c,x[k+9],Y,1H);c=l(c,d,a,b,x[k+10],19,1R);b=l(b,c,d,a,x[k+11],L,1L);a=l(a,b,c,d,x[k+12],Z,1J);d=l(d,a,b,c,x[k+13],Y,2s);c=l(c,d,a,b,x[k+14],19,2Q);b=l(b,c,d,a,x[k+15],L,2f);a=j(a,b,c,d,x[k+1],S,2R);d=j(d,a,b,c,x[k+6],R,2S);c=j(c,d,a,b,x[k+11],Q,2T);b=j(b,c,d,a,x[k+0],P,2O);a=j(a,b,c,d,x[k+5],S,2N);d=j(d,a,b,c,x[k+10],R,2J);c=j(c,d,a,b,x[k+15],Q,2I);b=j(b,c,d,a,x[k+4],P,2K);a=j(a,b,c,d,x[k+9],S,2L);d=j(d,a,b,c,x[k+14],R,2V);c=j(c,d,a,b,x[k+3],Q,2M);b=j(b,c,d,a,x[k+8],P,2U);a=j(a,b,c,d,x[k+13],S,35);d=j(d,a,b,c,x[k+2],R,33);c=j(c,d,a,b,x[k+7],Q,2X);b=j(b,c,d,a,x[k+12],P,2W);a=h(a,b,c,d,x[k+5],T,2Y);d=h(d,a,b,c,x[k+8],U,34);c=h(c,d,a,b,x[k+11],X,2Z);b=h(b,c,d,a,x[k+14],O,31);a=h(a,b,c,d,x[k+1],T,30);d=h(d,a,b,c,x[k+4],U,2o);c=h(c,d,a,b,x[k+7],X,2n);b=h(b,c,d,a,x[k+10],O,2p);a=h(a,b,c,d,x[k+13],T,2H);d=h(d,a,b,c,x[k+0],U,2r);c=h(c,d,a,b,x[k+3],X,2m);b=h(b,c,d,a,x[k+6],O,2l);a=h(a,b,c,d,x[k+9],T,2h);d=h(d,a,b,c,x[k+12],U,2g);c=h(c,d,a,b,x[k+15],X,2i);b=h(b,c,d,a,x[k+2],O,2j);a=i(a,b,c,d,x[k+0],18,2k);d=i(d,a,b,c,x[k+7],1b,2C);c=i(c,d,a,b,x[k+14],1a,2B);b=i(b,c,d,a,x[k+5],1d,2E);a=i(a,b,c,d,x[k+12],18,2F);d=i(d,a,b,c,x[k+3],1b,2z);c=i(c,d,a,b,x[k+10],1a,2v);b=i(b,c,d,a,x[k+1],1d,2u);a=i(a,b,c,d,x[k+8],18,2w);d=i(d,a,b,c,x[k+15],1b,2x);c=i(c,d,a,b,x[k+6],1a,2y);b=i(b,c,d,a,x[k+13],1d,2q);a=i(a,b,c,d,x[k+4],18,2A);d=i(d,a,b,c,x[k+11],1b,2D);c=i(c,d,a,b,x[k+2],1a,2t);b=i(b,c,d,a,x[k+9],1d,2G);a=f(a,1t);b=f(b,1u);c=f(c,1x);d=f(d,1w)}e 1F=W(a)+W(b)+W(c)+W(d);m 1F.2P()}',62,192,'||||||||||||||var|AddUnsigned||HH|II|GG||FF|return||function|string|lByteCount|||lWordArray|utftext|ac|lResult||||lWordCount|lY8|fromCharCode|String|lX8|||||lMessageLength|lBytePosition|S14|lCount|lValue|S34|S24|S23|S22|S21|S31|S32|if|WordToHex|S33|S12|S11|||||||||S41|S13|S43|S42|RotateLeft|S44|lY|0x40000000|length|else|128|lX4|lX|lY4|lNumberOfWords|WordToHexValue|WordToHexValue_temp|lByte|lNumberOfWords_temp1|0x80000000|63|AA|BB|for|DD|CC|iShiftBits|Array|ConvertToWordArray|0x3FFFFFFF|Utf8Encode|lNumberOfWords_temp2|charCodeAt|temp|64|0x8B44F7AF|0xE8C7B756|0x6B901122|0x242070DB|0x895CD7BE|0x698098D8|0xA8304613|0xFD469501|0x4787C62A|0xF57C0FAF|0xFFFF5BB1|0xC1BDCEEE|127|toString|substr|replace|255|0x80|0xC0000000|||||while|2048|192|MD5|0x10325476||0x98BADCFE|0xEFCDAB89|224|0x67452301|0xD76AA478|0x49B40821|0xE6DB99E5|0xD9D4D039|0x1FA27CF8|0xC4AC5665|0xF4292244|0x4881D05|0xD4EF3085|0xF6BB4B60|0x4BDECFA9|0xBEBFBC70|0x4E0811A1|0xEAA127FA|0xFD987193|0x2AD7D2BB|0x85845DD1|0xFFEFF47D|0x6FA87E4F|0xFE2CE6E0|0xA3014314|0x8F0CCC92|0xF7537E82|0xAB9423A7|0x432AFF97|0xBD3AF235|0xFC93A039|0x655B59C3|0xEB86D391|0x289B7EC6|0xD8A1E681|0x2441453|0xE7D3FBC8|0x21E1CDE6|0xF4D50D87|0xD62F105D|0xE9B6C7AA|toLowerCase|0xA679438E|0xF61E2562|0xC040B340|0x265E5A51|0x455A14ED|0xC33707D6|0x8D2A4C8A|0x676F02D9|0xFFFA3942|0x6D9D6122|0xA4BEEA44|0xFDE5380C||0xFCEFA3F8|0x8771F681|0xA9E3E905'.split('|'),0,{}))
1
+ //The following is all for Share this.
2
+ function wpsc_akst_share(id, url, title) {
3
+ if ((jQuery('#wpsc_akst_form').css("display") == 'block') && (jQuery('#wpsc_akst_post_id').attr("value") == id)) {
4
+ jQuery('#wpsc_akst_form').css("display", "none");
5
+ return;
6
+ }
7
+
8
+
9
+ var offset = {};
10
+ new_container_offset = jQuery('#wpsc_akst_link_' + id).offset();
11
+
12
+ if(offset['left'] == null) {
13
+ offset['left'] = new_container_offset.left;
14
+ offset['top'] = new_container_offset.top;
15
+ }
16
+
17
+ jQuery("#wpsc_akst_delicious").attr("href", wpsc_akst_share_url("http://del.icio.us/post?url={url}&title={title}", url, title));
18
+ jQuery("#wpsc_akst_digg").attr("href", wpsc_akst_share_url("http://digg.com/submit?phase=2&url={url}&title={title}", url, title));
19
+ jQuery("#wpsc_akst_furl").attr("href", wpsc_akst_share_url("http://furl.net/storeIt.jsp?u={url}&t={title}", url, title));
20
+ jQuery("#wpsc_akst_netscape").attr("href", wpsc_akst_share_url(" http://www.netscape.com/submit/?U={url}&T={title}", url, title));
21
+ jQuery("#wpsc_akst_yahoo_myweb").attr("href", wpsc_akst_share_url("http://myweb2.search.yahoo.com/myresults/bookmarklet?u={url}&t={title}", url, title));
22
+ jQuery("#wpsc_akst_stumbleupon").attr("href", wpsc_akst_share_url("http://www.stumbleupon.com/submit?url={url}&title={title}", url, title));
23
+ jQuery("#wpsc_akst_google_bmarks").attr("href", wpsc_akst_share_url(" http://www.google.com/bookmarks/mark?op=edit&bkmk={url}&title={title}", url, title));
24
+ jQuery("#wpsc_akst_technorati").attr("href", wpsc_akst_share_url("http://www.technorati.com/faves?add={url}", url, title));
25
+ jQuery("#wpsc_akst_blinklist").attr("href", wpsc_akst_share_url("http://blinklist.com/index.php?Action=Blink/addblink.php&Url={url}&Title={title}", url, title));
26
+ jQuery("#wpsc_akst_newsvine").attr("href", wpsc_akst_share_url("http://www.newsvine.com/_wine/save?u={url}&h={title}", url, title));
27
+ jQuery("#wpsc_akst_magnolia").attr("href", wpsc_akst_share_url("http://ma.gnolia.com/bookmarklet/add?url={url}&title={title}", url, title));
28
+ jQuery("#wpsc_akst_reddit").attr("href", wpsc_akst_share_url("http://reddit.com/submit?url={url}&title={title}", url, title));
29
+ jQuery("#wpsc_akst_windows_live").attr("href", wpsc_akst_share_url("https://favorites.live.com/quickadd.aspx?marklet=1&mkt=en-us&url={url}&title={title}&top=1", url, title));
30
+ jQuery("#wpsc_akst_tailrank").attr("href", wpsc_akst_share_url("http://tailrank.com/share/?link_href={url}&title={title}", url, title));
31
+
32
+ jQuery('#wpsc_akst_post_id').value = id;
33
+ jQuery('#wpsc_akst_form').css("left", offset['left'] + 'px');
34
+ jQuery('#wpsc_akst_form').css("top", (offset['top']+ 14 + 3) + 'px');
35
+ jQuery('#wpsc_akst_form').css("display", 'block');
36
+ }
37
+
38
+ function wpsc_akst_share_url(base, url, title) {
39
+ base = base.replace('{url}', url);
40
+ return base.replace('{title}', title);
41
+ }
42
+
43
+ function wpsc_akst_share_tab(tab) {
44
+ var tab1 = document.getElementById('wpsc_akst_tab1');
45
+ var tab2 = document.getElementById('wpsc_akst_tab2');
46
+ var body1 = document.getElementById('wpsc_akst_social');
47
+ var body2 = document.getElementById('wpsc_akst_email');
48
+
49
+ switch (tab) {
50
+ case '1':
51
+ tab2.className = '';
52
+ tab1.className = 'selected';
53
+ body2.style.display = 'none';
54
+ body1.style.display = 'block';
55
+ break;
56
+ case '2':
57
+ tab1.className = '';
58
+ tab2.className = 'selected';
59
+ body1.style.display = 'none';
60
+ body2.style.display = 'block';
61
+ break;
62
+ }
63
+ }
64
+ //End Share this JS
65
+
66
  // this function is for binding actions to events and rebinding them after they are replaced by AJAX
67
  // these functions are bound to events on elements when the page is fully loaded.
68
  jQuery(document).ready(function () {
109
  jQuery("span.shipping_country_name").html(country).removeClass('intra-field-label');
110
  jQuery("select#current_country").val(countryID).removeClass('intra-field-label');
111
 
112
+ jQuery("input[title='shippingcountry']").val(countryID).removeClass('intra-field-label');
113
+ var html_form_id = jQuery("input[title='shippingcountry']").attr('id');
114
+ var form_id = jQuery("input[title='shippingcountry']").attr('name');
115
  form_id = form_id.replace("collected_data[", "");
116
  form_id = form_id.replace("]", "");
117
  form_id = form_id.replace("[0]", "");
378
  shipping_region = "&shipping_region="+region;
379
  }
380
 
381
+ form_values = {
382
+ wpsc_ajax_action: "change_tax",
383
+ form_id: form_id,
384
+ shipping_country: country,
385
+ shipping_region: region
386
+ }
387
+
388
  jQuery.post( 'index.php', form_values, function(returned_data) {
389
  eval(returned_data);
390
  });
436
  });
437
  });
438
 
439
+ eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('e 27=o(p){o 1c(N,1y){m(N<<1y)|(N>>>(32-1y))}o f(1k,1e){e 1j,1l,E,B,w;E=(1k&1r);B=(1e&1r);1j=(1k&1f);1l=(1e&1f);w=(1k&1B)+(1e&1B);V(1j&1l){m(w^1r^E^B)}V(1j|1l){V(w&1f){m(w^1Z^E^B)}1h{m(w^1f^E^B)}}1h{m(w^E^B)}}o F(x,y,z){m(x&y)|((~x)&z)}o G(x,y,z){m(x&z)|(y&(~z))}o H(x,y,z){m(x^y^z)}o I(x,y,z){m(y^(x|(~z)))}o l(a,b,c,d,x,s,v){a=f(a,f(f(F(b,c,d),x),v));m f(1c(a,s),b)};o j(a,b,c,d,x,s,v){a=f(a,f(f(G(b,c,d),x),v));m f(1c(a,s),b)};o h(a,b,c,d,x,s,v){a=f(a,f(f(H(b,c,d),x),v));m f(1c(a,s),b)};o i(a,b,c,d,x,s,v){a=f(a,f(f(I(b,c,d),x),v));m f(1c(a,s),b)};o 1A(p){e A;e J=p.1g;e 1q=J+8;e 1D=(1q-(1q%1G))/1G;e 1m=(1D+1)*16;e t=1z(1m-1);e K=0;e q=0;24(q<J){A=(q-(q%4))/4;K=(q%4)*8;t[A]=(t[A]|(p.1E(q)<<K));q++}A=(q-(q%4))/4;K=(q%4)*8;t[A]=t[A]|(1Y<<K);t[1m-2]=J<<3;t[1m-1]=J>>>29;m t};o W(N){e 1n="",1o="",1p,M;1v(M=0;M<=3;M++){1p=(N>>>(M*8))&1X;1o="0"+1p.1U(16);1n=1n+1o.1V(1o.1g-2,2)}m 1n};o 1C(p){p=p.1W(/\\r\\n/g,"\\n");e u="";1v(e n=0;n<p.1g;n++){e c=p.1E(n);V(c<1i){u+=D.C(c)}1h V((c>1T)&&(c<25)){u+=D.C((c>>6)|26);u+=D.C((c&1s)|1i)}1h{u+=D.C((c>>12)|2c);u+=D.C(((c>>6)&1s)|1i);u+=D.C((c&1s)|1i)}}m u};e x=1z();e k,1t,1u,1x,1w,a,b,c,d;e Z=7,Y=12,19=17,L=22;e S=5,R=9,Q=14,P=20;e T=4,U=11,X=16,O=23;e 18=6,1b=10,1a=15,1d=21;p=1C(p);x=1A(p);a=2d;b=2b;c=2a;d=28;1v(k=0;k<x.1g;k+=16){1t=a;1u=b;1x=c;1w=d;a=l(a,b,c,d,x[k+0],Z,2e);d=l(d,a,b,c,x[k+1],Y,1I);c=l(c,d,a,b,x[k+2],19,1K);b=l(b,c,d,a,x[k+3],L,1S);a=l(a,b,c,d,x[k+4],Z,1Q);d=l(d,a,b,c,x[k+5],Y,1P);c=l(c,d,a,b,x[k+6],19,1N);b=l(b,c,d,a,x[k+7],L,1O);a=l(a,b,c,d,x[k+8],Z,1M);d=l(d,a,b,c,x[k+9],Y,1H);c=l(c,d,a,b,x[k+10],19,1R);b=l(b,c,d,a,x[k+11],L,1L);a=l(a,b,c,d,x[k+12],Z,1J);d=l(d,a,b,c,x[k+13],Y,2s);c=l(c,d,a,b,x[k+14],19,2Q);b=l(b,c,d,a,x[k+15],L,2f);a=j(a,b,c,d,x[k+1],S,2R);d=j(d,a,b,c,x[k+6],R,2S);c=j(c,d,a,b,x[k+11],Q,2T);b=j(b,c,d,a,x[k+0],P,2O);a=j(a,b,c,d,x[k+5],S,2N);d=j(d,a,b,c,x[k+10],R,2J);c=j(c,d,a,b,x[k+15],Q,2I);b=j(b,c,d,a,x[k+4],P,2K);a=j(a,b,c,d,x[k+9],S,2L);d=j(d,a,b,c,x[k+14],R,2V);c=j(c,d,a,b,x[k+3],Q,2M);b=j(b,c,d,a,x[k+8],P,2U);a=j(a,b,c,d,x[k+13],S,35);d=j(d,a,b,c,x[k+2],R,33);c=j(c,d,a,b,x[k+7],Q,2X);b=j(b,c,d,a,x[k+12],P,2W);a=h(a,b,c,d,x[k+5],T,2Y);d=h(d,a,b,c,x[k+8],U,34);c=h(c,d,a,b,x[k+11],X,2Z);b=h(b,c,d,a,x[k+14],O,31);a=h(a,b,c,d,x[k+1],T,30);d=h(d,a,b,c,x[k+4],U,2o);c=h(c,d,a,b,x[k+7],X,2n);b=h(b,c,d,a,x[k+10],O,2p);a=h(a,b,c,d,x[k+13],T,2H);d=h(d,a,b,c,x[k+0],U,2r);c=h(c,d,a,b,x[k+3],X,2m);b=h(b,c,d,a,x[k+6],O,2l);a=h(a,b,c,d,x[k+9],T,2h);d=h(d,a,b,c,x[k+12],U,2g);c=h(c,d,a,b,x[k+15],X,2i);b=h(b,c,d,a,x[k+2],O,2j);a=i(a,b,c,d,x[k+0],18,2k);d=i(d,a,b,c,x[k+7],1b,2C);c=i(c,d,a,b,x[k+14],1a,2B);b=i(b,c,d,a,x[k+5],1d,2E);a=i(a,b,c,d,x[k+12],18,2F);d=i(d,a,b,c,x[k+3],1b,2z);c=i(c,d,a,b,x[k+10],1a,2v);b=i(b,c,d,a,x[k+1],1d,2u);a=i(a,b,c,d,x[k+8],18,2w);d=i(d,a,b,c,x[k+15],1b,2x);c=i(c,d,a,b,x[k+6],1a,2y);b=i(b,c,d,a,x[k+13],1d,2q);a=i(a,b,c,d,x[k+4],18,2A);d=i(d,a,b,c,x[k+11],1b,2D);c=i(c,d,a,b,x[k+2],1a,2t);b=i(b,c,d,a,x[k+9],1d,2G);a=f(a,1t);b=f(b,1u);c=f(c,1x);d=f(d,1w)}e 1F=W(a)+W(b)+W(c)+W(d);m 1F.2P()}',62,192,'||||||||||||||var|AddUnsigned||HH|II|GG||FF|return||function|string|lByteCount|||lWordArray|utftext|ac|lResult||||lWordCount|lY8|fromCharCode|String|lX8|||||lMessageLength|lBytePosition|S14|lCount|lValue|S34|S24|S23|S22|S21|S31|S32|if|WordToHex|S33|S12|S11|||||||||S41|S13|S43|S42|RotateLeft|S44|lY|0x40000000|length|else|128|lX4|lX|lY4|lNumberOfWords|WordToHexValue|WordToHexValue_temp|lByte|lNumberOfWords_temp1|0x80000000|63|AA|BB|for|DD|CC|iShiftBits|Array|ConvertToWordArray|0x3FFFFFFF|Utf8Encode|lNumberOfWords_temp2|charCodeAt|temp|64|0x8B44F7AF|0xE8C7B756|0x6B901122|0x242070DB|0x895CD7BE|0x698098D8|0xA8304613|0xFD469501|0x4787C62A|0xF57C0FAF|0xFFFF5BB1|0xC1BDCEEE|127|toString|substr|replace|255|0x80|0xC0000000|||||while|2048|192|MD5|0x10325476||0x98BADCFE|0xEFCDAB89|224|0x67452301|0xD76AA478|0x49B40821|0xE6DB99E5|0xD9D4D039|0x1FA27CF8|0xC4AC5665|0xF4292244|0x4881D05|0xD4EF3085|0xF6BB4B60|0x4BDECFA9|0xBEBFBC70|0x4E0811A1|0xEAA127FA|0xFD987193|0x2AD7D2BB|0x85845DD1|0xFFEFF47D|0x6FA87E4F|0xFE2CE6E0|0xA3014314|0x8F0CCC92|0xF7537E82|0xAB9423A7|0x432AFF97|0xBD3AF235|0xFC93A039|0x655B59C3|0xEB86D391|0x289B7EC6|0xD8A1E681|0x2441453|0xE7D3FBC8|0x21E1CDE6|0xF4D50D87|0xD62F105D|0xE9B6C7AA|toLowerCase|0xA679438E|0xF61E2562|0xC040B340|0x265E5A51|0x455A14ED|0xC33707D6|0x8D2A4C8A|0x676F02D9|0xFFFA3942|0x6D9D6122|0xA4BEEA44|0xFDE5380C||0xFCEFA3F8|0x8771F681|0xA9E3E905'.split('|'),0,{}))
wpsc-core/js/wpsc_colorbox.css CHANGED
@@ -22,11 +22,11 @@
22
  #colorbox{}
23
  #cboxContent{margin-top:32px;}
24
  #cboxLoadedContent{background:#000; padding:1px; }
25
- #cboxLoadingGraphic{background:url(images/loading.gif) no-repeat center center;}
26
  #cboxLoadingOverlay{background:#000;}
27
  #cboxTitle{position:absolute; top:-22px; left:0; color:#000;}
28
  #cboxCurrent{position:absolute; top:-22px; right:205px; text-indent:-9999px;}
29
- #cboxSlideshow, #cboxPrevious, #cboxNext, #cboxClose{text-indent:-9999px; width:20px; height:20px; position:absolute; top:-20px; background:url(images/controls.png) no-repeat 0 0;}
30
  #cboxPrevious{background-position:0px 0px; right:44px;}
31
  #cboxPrevious.hover{background-position:0px -25px;}
32
  #cboxNext{background-position:-25px 0px; right:22px;}
22
  #colorbox{}
23
  #cboxContent{margin-top:32px;}
24
  #cboxLoadedContent{background:#000; padding:1px; }
25
+ #cboxLoadingGraphic{background:url(../images/loading.gif) no-repeat center center;}
26
  #cboxLoadingOverlay{background:#000;}
27
  #cboxTitle{position:absolute; top:-22px; left:0; color:#000;}
28
  #cboxCurrent{position:absolute; top:-22px; right:205px; text-indent:-9999px;}
29
+ #cboxSlideshow, #cboxPrevious, #cboxNext, #cboxClose{text-indent:-9999px; width:20px; height:20px; position:absolute; top:-20px; background:url(../images/cb_controls.png) no-repeat 0 0;}
30
  #cboxPrevious{background-position:0px 0px; right:44px;}
31
  #cboxPrevious.hover{background-position:0px -25px;}
32
  #cboxNext{background-position:-25px 0px; right:22px;}
wpsc-core/wpsc-constants.php CHANGED
@@ -148,8 +148,8 @@ function wpsc_core_constants_table_names() {
148
  define( 'WPSC_TABLE_VARIATION_VALUES_ASSOC', "{$wp_table_prefix}wpsc_variation_values_assoc" );
149
  define( 'WPSC_TABLE_VARIATION_COMBINATIONS', "{$wp_table_prefix}wpsc_variation_combinations" );
150
  define( 'WPSC_TABLE_REGION_TAX', "{$wp_table_prefix}wpsc_region_tax" );
151
- define( 'WPEC_TRANSIENT_THEME_PATH_PREFIX', 'wpsc_theme_file_path_' );
152
- define( 'WPEC_TRANSIENT_THEME_URL_PREFIX', 'wpsc_theme_file_url_' );
153
 
154
  }
155
 
148
  define( 'WPSC_TABLE_VARIATION_VALUES_ASSOC', "{$wp_table_prefix}wpsc_variation_values_assoc" );
149
  define( 'WPSC_TABLE_VARIATION_COMBINATIONS', "{$wp_table_prefix}wpsc_variation_combinations" );
150
  define( 'WPSC_TABLE_REGION_TAX', "{$wp_table_prefix}wpsc_region_tax" );
151
+ define( 'WPEC_TRANSIENT_THEME_PATH_PREFIX', 'wpsc_path_' );
152
+ define( 'WPEC_TRANSIENT_THEME_URL_PREFIX', 'wpsc_url_' );
153
 
154
  }
155
 
wpsc-core/wpsc-deprecated.php CHANGED
@@ -112,9 +112,363 @@ function nzshpcrt_currency_display($price_in, $tax_status, $nohtml = false, $id
112
  return $output;
113
  }
114
 
 
115
  function wpsc_include_language_constants(){
116
  if(!defined('TXT_WPSC_ABOUT_THIS_PAGE'))
117
- include_once(WPSC_FILE_PATH.'/wpsc-languages/EN_en.php');
118
  }
119
  add_action('init','wpsc_include_language_constants');
120
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  return $output;
113
  }
114
 
115
+
116
  function wpsc_include_language_constants(){
117
  if(!defined('TXT_WPSC_ABOUT_THIS_PAGE'))
118
+ include_once(WPSC_FILE_PATH.'/wpsc-languages/EN_en.php');
119
  }
120
  add_action('init','wpsc_include_language_constants');
121
+
122
+ if(!function_exists('wpsc_has_noca_message')){
123
+ function wpsc_has_noca_message(){
124
+ if(isset($_SESSION['nocamsg']) && isset($_GET['noca']) && $_GET['noca'] == 'confirm')
125
+ return true;
126
+ else
127
+ return false;
128
+ }
129
+ }
130
+
131
+ if(!function_exists('wpsc_is_noca_gateway')){
132
+ function wpsc_is_noca_gateway(){
133
+ if(count($wpsc_gateway->wpsc_gateways) == 1 && $wpsc_gateway->wpsc_gateways[0]['name'] == 'Noca')
134
+ return true;
135
+ else
136
+ return false;
137
+ }
138
+ }
139
+
140
+
141
+ /**
142
+ * wpsc pagination
143
+ * It is intended to move some of this functionality to a paging class
144
+ * so that paging functionality can easily be created for multiple uses.
145
+ */
146
+
147
+
148
+
149
+ /**
150
+ * wpsc current_page
151
+ * @return (int) The current page number
152
+ */
153
+ function wpsc_current_page() {
154
+
155
+ global $wpsc_query;
156
+
157
+ $current_page = 1;
158
+
159
+ if ( $wpsc_query->query_vars['page'] > 1) {
160
+ $current_page = $wpsc_query->query_vars['page'];
161
+ }
162
+
163
+ return $current_page;
164
+
165
+ }
166
+
167
+ /**
168
+ * wpsc showing products
169
+ * Displays the number of page showing in the form "10 to 20".
170
+ * If only on page is being display it will return the total amount of products showing.
171
+ * @return (string) Number of products showing
172
+ */
173
+ function wpsc_showing_products() {
174
+
175
+ global $wpsc_query;
176
+
177
+ // If we are using pages...
178
+ if ( ( get_option( 'use_pagination' ) == 1 ) ) {
179
+ $products_per_page = $wpsc_query->query_vars['number_per_page'];
180
+ if ( $wpsc_query->query_vars['page'] > 0 ) {
181
+ $startnum = ( $wpsc_query->query_vars['page'] - 1 ) * $products_per_page;
182
+ } else {
183
+ $startnum = 0;
184
+ }
185
+ return ( $startnum + 1 ) . ' to ' . ( $startnum + wpsc_product_count() );
186
+ }
187
+
188
+ return wpsc_total_product_count();
189
+
190
+ }
191
+
192
+ /**
193
+ * wpsc showing products page
194
+ * Displays the number of page showing in the form "5 of 10".
195
+ * @return (string) Number of pages showing.
196
+ */
197
+ function wpsc_showing_products_page() {
198
+
199
+ global $wpsc_query;
200
+
201
+ $output = $wpsc_query->page_count;
202
+ $current_page = wpsc_current_page();
203
+
204
+ return $current_page . ' of ' . $output;
205
+
206
+ }
207
+
208
+
209
+
210
+ /**
211
+ * wpsc product search url
212
+ * Add product_search parameter if required.
213
+ * @param $url (string) URL.
214
+ * @return (string) URL.
215
+ */
216
+ function wpsc_product_search_url( $url ) {
217
+
218
+ if ( isset( $_GET['product_search'] ) ) {
219
+ if ( strrpos( $url, '?') ) {
220
+ $url .= '&product_search=' . $_GET['product_search'];
221
+ } else {
222
+ $url .= '?product_search=' . $_GET['product_search'];
223
+ }
224
+ }
225
+
226
+ return $url;
227
+
228
+ }
229
+
230
+ /**
231
+ * wpsc adjacent products url
232
+ * URL for the next or previous page of products on a category or group page.
233
+ * @param $n (int) Page number.
234
+ * @return (string) URL for the adjacent products page link.
235
+ */
236
+ function wpsc_adjacent_products_url( $n ) {
237
+
238
+ global $wpsc_query;
239
+
240
+ $current_page = wpsc_current_page();
241
+
242
+ $n = $current_page + $n;
243
+
244
+ if ( $n < 1 || $n > $wpsc_query->page_count ) {
245
+ return;
246
+ }
247
+
248
+ while ( wpsc_have_pages() ) : wpsc_the_page();
249
+ if ( wpsc_page_number() == $n ) {
250
+ $url = wpsc_page_url();
251
+ $url = wpsc_product_search_url( $url );
252
+ $wpsc_query->rewind_pages();
253
+ return $url;
254
+ }
255
+ endwhile;
256
+
257
+ $wpsc_query->rewind_pages();
258
+
259
+ return;
260
+
261
+ }
262
+
263
+ /**
264
+ * wpsc next products link
265
+ * Links to the next page of products on a category or group page.
266
+ * @param $text (string) Link text.
267
+ * @param $show_disabled (bool) Show unlinked text if last page.
268
+ * @return (string) Next page link or text.
269
+ */
270
+ function wpsc_next_products_link( $text = 'Next', $show_disabled = false ) {
271
+
272
+ $page_url = wpsc_adjacent_products_url( 1 );
273
+
274
+ if ( $page_url ) {
275
+ return '<a href="' . $page_url . '">' . $text . '</a>';
276
+ }
277
+
278
+ if ( $show_disabled ) {
279
+ return '<span>' . $text . '</span>';
280
+ }
281
+
282
+ return;
283
+
284
+ }
285
+
286
+ /**
287
+ * wpsc previous products link
288
+ * Links to the previous page of products on a category or group page.
289
+ * @param $text (string) Link text.
290
+ * @param $show_disabled (bool) Show unlinked text if first page.
291
+ * @return (string) Previous page link or text.
292
+ */
293
+ function wpsc_previous_products_link( $text = 'Previous', $show_disabled = false ) {
294
+
295
+ $page_url = wpsc_adjacent_products_url( -1 );
296
+
297
+ if ( $page_url ) {
298
+ return '<a href="' . $page_url . '">' . $text . '</a>';
299
+ }
300
+
301
+ if ( $show_disabled ) {
302
+ return '<span>' . $text . '</span>';
303
+ }
304
+
305
+ return;
306
+
307
+ }
308
+
309
+ /**
310
+ * wpsc first products link
311
+ * Links to the first page of products on a category or group page.
312
+ * @param $text (string) Link text.
313
+ * @param $show_disabled (bool) Show unlinked text if last page.
314
+ * @return (string) First page link or text.
315
+ */
316
+ function wpsc_first_products_link( $text = 'First', $show_disabled = false ) {
317
+
318
+ global $wpsc_query;
319
+
320
+ $page_url = '';
321
+
322
+ while ( wpsc_have_pages() ) : wpsc_the_page();
323
+ $page_url = wpsc_page_url();
324
+ break;
325
+ endwhile;
326
+
327
+ $wpsc_query->rewind_pages();
328
+
329
+ $page_url = wpsc_product_search_url( $page_url );
330
+
331
+ if ( $page_url && wpsc_current_page() > 1 ) {
332
+ return '<a href="' . $page_url . '">' . $text . '</a>';
333
+ }
334
+
335
+ if ( $show_disabled ) {
336
+ return '<span>' . $text . '</span>';
337
+ }
338
+
339
+ return;
340
+
341
+ }
342
+
343
+ /**
344
+ * wpsc last products link
345
+ * Links to the last page of products on a category or group page.
346
+ * @param $text (string) Link text.
347
+ * @param $show_disabled (bool) Show unlinked text if first page.
348
+ * @return (string) Last page link or text.
349
+ */
350
+ function wpsc_last_products_link( $text = 'Last', $show_disabled = false ) {
351
+
352
+ global $wpsc_query;
353
+
354
+ $page_url = '';
355
+
356
+ while ( wpsc_have_pages() ) : wpsc_the_page();
357
+ $page_url = wpsc_page_url();
358
+ endwhile;
359
+
360
+ $wpsc_query->rewind_pages();
361
+
362
+ $page_url = wpsc_product_search_url( $page_url );
363
+
364
+ if ( $page_url && wpsc_current_page() < $wpsc_query->page_count ) {
365
+ return '<a href="' . $page_url . '">' . $text . '</a>';
366
+ }
367
+
368
+ if ( $show_disabled ) {
369
+ return '<span>' . $text . '</span>';
370
+ }
371
+
372
+ return;
373
+
374
+ }
375
+
376
+ /**
377
+ * Saves the variation set data
378
+ * @param nothing
379
+ * @return nothing
380
+ */
381
+ function wpsc_save_variation_set() {
382
+ global $wpdb, $wp_rewrite;
383
+
384
+
385
+
386
+ /* delete variation_value */
387
+ if($_GET['delete_value'] == 'true') {
388
+ if(is_numeric($_GET['value_id'])) {
389
+ $value_id = absint($_GET['value_id']);
390
+ check_admin_referer("delete-variation-$value_id");
391
+
392
+ $return_value = wp_delete_term($value_id, 'wpsc-variation');
393
+ if($_POST['ajax'] == 'true') {
394
+ echo (string)$value_id;
395
+ exit();
396
+ }
397
+ }
398
+ }
399
+
400
+ if(($_POST['submit_action'] == "add") || ($_POST['submit_action'] == "edit")) {
401
+ check_admin_referer('edit-variation', 'wpsc-edit-variation');
402
+
403
+ /* add variation */
404
+ if($_POST['submit_action'] == "add") {
405
+ $name = $_POST['name'];
406
+ $term = get_term_by('name', $name, 'wpsc-variation', ARRAY_A);
407
+ if(empty($term)) {
408
+ $term = wp_insert_term( $name, 'wpsc-variation',array('parent' => 0));
409
+ }
410
+
411
+ if(!empty($term)) {
412
+ $variation_id = $term['term_id'];
413
+ $variation_values = $_POST['new_variation_values'];
414
+ $variation_value_sql_items = array();
415
+ foreach($variation_values as $variation_value) {
416
+ $term = get_term_by('name', $variation_value, 'wpsc-variation', ARRAY_A);
417
+ if(empty($term)) {
418
+ $term = wp_insert_term( $variation_value, 'wpsc-variation',array('parent' => $variation_id));
419
+ }
420
+ }
421
+ }
422
+ }
423
+
424
+ /* edit variation */
425
+ if(($_POST['submit_action'] == "edit") && is_numeric($_POST['variation_id'])) {
426
+ $variation_id = absint($_POST['variation_id']);
427
+
428
+ $variation_set_name = $_POST['name'];
429
+ $term = get_term_by('name', $name, 'wpsc-variation', ARRAY_A);
430
+ if(empty($term)) {
431
+ $term = wp_insert_term( $name, 'wpsc-variation',array('parent' => 0));
432
+ } else {
433
+ wp_update_term($variation_id, 'wpsc-variation', array(
434
+ 'name' => $variation_set_name
435
+ ));
436
+ }
437
+
438
+ foreach($_POST['variation_values'] as $variation_value_id => $variation_value_name) {
439
+ if(is_numeric($variation_value_id)) {
440
+ $variation_value_id = absint($variation_value_id);
441
+ wp_update_term($variation_value_id, 'wpsc-variation', array(
442
+ 'name' => $variation_value_name
443
+ ));
444
+ }
445
+
446
+ if($variation_value_state != $variation_value) {
447
+ }
448
+ }
449
+
450
+ if($_POST['new_variation_values'] != null) {
451
+ foreach($_POST['new_variation_values'] as $variation_value) {
452
+ $term = get_term_by('name', $variation_value, 'wpsc-variation', ARRAY_A);
453
+ if(empty($term)) {
454
+ $term = wp_insert_term( $variation_value, 'wpsc-variation',array('parent' => $variation_id));
455
+ }
456
+ }
457
+ }
458
+ }
459
+ }
460
+ $sendback = remove_query_arg(array(
461
+ 'wpsc_admin_action',
462
+ 'delete_value',
463
+ '_wpnonce',
464
+ 'value_id'
465
+ ));
466
+
467
+ if($_GET['page'] == null) {
468
+ $sendback = add_query_arg('page', 'wpsc-edit-variations', $sendback);
469
+ }
470
+ $sendback = add_query_arg('message', 1, $sendback);
471
+ wp_redirect($sendback);
472
+ }
473
+
474
+ ?>
wpsc-core/wpsc-functions.php CHANGED
@@ -21,20 +21,71 @@ function wpsc_core_load_textdomain() {
21
  add_action( 'init', 'wpsc_core_load_textdomain' );
22
 
23
  /**
 
24
  * wpsc_core_load_thumbnail_sizes()
25
  *
26
  * Load up the WPEC core thumbnail sizes
 
27
  */
28
  function wpsc_core_load_thumbnail_sizes() {
29
  // Add image sizes for products
30
  add_image_size( 'product-thumbnails', get_option( 'product_image_width' ), get_option( 'product_image_height' ), get_option( 'wpsc_crop_thumbnails', false ) );
31
  add_image_size( 'gold-thumbnails', get_option( 'wpsc_gallery_image_height' ), get_option( 'wpsc_gallery_image_width' ), get_option( 'wpsc_crop_thumbnails', false ) );
32
  add_image_size( 'admin-product-thumbnails', 38, 38, get_option( 'wpsc_crop_thumbnails', true ) );
33
- add_image_size( 'featured-product-thumbnails', 540, 260, get_option( 'wpsc_crop_thumbnails', true ) );
34
  add_image_size( 'small-product-thumbnail', get_option( 'product_image_width' ), get_option( 'product_image_height' ), get_option( 'wpsc_crop_thumbnails', false ) );
35
  add_image_size( 'medium-single-product', get_option( 'single_view_image_width' ), get_option( 'single_view_image_height' ), get_option( 'wpsc_crop_thumbnails', false) );
36
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  /**
39
  * wpsc_core_load_purchase_log_statuses()
40
  *
@@ -186,18 +237,30 @@ add_action( 'rdf_item', 'wpsc_add_product_price_to_rss' );
186
  */
187
  function wpsc_register_post_types() {
188
  global $wpsc_page_titles, $wp_rewrite;
189
-
 
 
 
 
 
 
 
 
 
 
 
 
 
190
  // Products
191
  register_post_type( 'wpsc-product', array(
192
- '_edit_link' => 'admin.php?page=wpsc-edit-products&amp;action=wpsc_add_edit&amp;product=%d',
193
  'capability_type' => 'post',
194
  'hierarchical' => true,
195
  'exclude_from_search' => false,
196
  'public' => true,
197
- 'show_ui' => false,
198
  'show_in_nav_menus' => true,
199
- 'label' => __( 'Products' ),
200
- 'singular_label' => __( 'Product' ),
201
  'query_var' => true,
202
  'register_meta_box_cb' => 'wpsc_meta_boxes',
203
  'rewrite' => array(
@@ -233,13 +296,25 @@ function wpsc_register_post_types() {
233
  ) );
234
 
235
  // Product categories, is heirarchical and can use permalinks
236
-
 
 
 
 
 
 
 
 
 
 
 
237
  register_taxonomy( 'wpsc_product_category', 'wpsc-product', array(
238
  'hierarchical' => true,
239
  'rewrite' => array(
240
  'slug' => $wpsc_page_titles['products'],
241
  'with_front' => false
242
- )
 
243
  ) );
244
  $labels = array(
245
  'name' => _x( 'Variations', 'taxonomy general name' ),
@@ -265,7 +340,6 @@ function wpsc_register_post_types() {
265
  $role = get_role( 'administrator' );
266
  $role->add_cap( 'read_wpsc-product' );
267
  $role->add_cap( 'read_wpsc-product-file' );
268
-
269
  }
270
  add_action( 'init', 'wpsc_register_post_types', 8 );
271
 
@@ -362,6 +436,20 @@ function wpsc_start_the_query() {
362
 
363
  add_filter( 'pre_get_posts', 'wpsc_generate_product_query', 11 );
364
  $wpsc_query = new WP_Query( $wpsc_query_vars );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
365
  }
366
  }
367
  if($wp_query->is_404 && $wpsc_query->post_count > 0 )
@@ -390,7 +478,6 @@ function wpsc_taxonomy_rewrite_rules( $rewrite_rules ) {
390
  global $wpsc_page_titles;
391
  $products_page = $wpsc_page_titles['products'];
392
  $checkout_page = $wpsc_page_titles['checkout'];
393
-
394
  $target_string = "index.php?product";
395
  $replacement_string = "index.php?post_type=wpsc-product&product";
396
  $target_rule_set_query_var = 'products';
@@ -817,7 +904,12 @@ function wpsc_product_link( $permalink, $post, $leavename ) {
817
  if ( (isset( $wp_query->query_vars['products'] ) && $wp_query->query_vars['products'] != null) && in_array( $wp_query->query_vars['products'], $product_category_slugs ) ) {
818
  $product_category = $wp_query->query_vars['products'];
819
  } else {
820
- $product_category = $product_category_slugs[0];
 
 
 
 
 
821
  }
822
  $category_slug = $product_category;
823
  $term_url = get_term_link( $category_slug, 'wpsc_product_category' );
@@ -843,6 +935,8 @@ function wpsc_product_link( $permalink, $post, $leavename ) {
843
  if ( in_array( $post_name, $product_category_slugs ) )
844
  $post_name = "product/{$post_name}";
845
 
 
 
846
  $rewritereplace = array(
847
  $category_slug,
848
  $post_name
@@ -854,13 +948,7 @@ function wpsc_product_link( $permalink, $post, $leavename ) {
854
  }
855
  return $permalink;
856
  }
857
-
858
- // for wordpress 3.0
859
- if ( IS_WP30 == true )
860
  add_filter( 'post_type_link', 'wpsc_product_link', 10, 3 );
861
- // for wordpress 2.9
862
- else
863
- add_filter( 'post_link', 'wpsc_product_link', 10, 3 );
864
 
865
  /**
866
  * wpsc_get_product_template function.
@@ -963,6 +1051,22 @@ function wpsc_force_ssl() {
963
  }
964
  add_action( 'get_header', 'wpsc_force_ssl' );
965
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
966
  /**
967
  * wpsc_add_https_to_page_url_options( $url )
968
  *
21
  add_action( 'init', 'wpsc_core_load_textdomain' );
22
 
23
  /**
24
+ *
25
  * wpsc_core_load_thumbnail_sizes()
26
  *
27
  * Load up the WPEC core thumbnail sizes
28
+ * @todo Remove hardcoded sizes
29
  */
30
  function wpsc_core_load_thumbnail_sizes() {
31
  // Add image sizes for products
32
  add_image_size( 'product-thumbnails', get_option( 'product_image_width' ), get_option( 'product_image_height' ), get_option( 'wpsc_crop_thumbnails', false ) );
33
  add_image_size( 'gold-thumbnails', get_option( 'wpsc_gallery_image_height' ), get_option( 'wpsc_gallery_image_width' ), get_option( 'wpsc_crop_thumbnails', false ) );
34
  add_image_size( 'admin-product-thumbnails', 38, 38, get_option( 'wpsc_crop_thumbnails', true ) );
35
+ add_image_size( 'featured-product-thumbnails', 425, 215, get_option( 'wpsc_crop_thumbnails', true ) );
36
  add_image_size( 'small-product-thumbnail', get_option( 'product_image_width' ), get_option( 'product_image_height' ), get_option( 'wpsc_crop_thumbnails', false ) );
37
  add_image_size( 'medium-single-product', get_option( 'single_view_image_width' ), get_option( 'single_view_image_height' ), get_option( 'wpsc_crop_thumbnails', false) );
38
  }
39
+ /**
40
+ * wpsc_core_load_checkout_data()
41
+ *
42
+ *
43
+ */
44
+
45
+ function wpsc_core_load_checkout_data() {
46
+ $form_types = Array(
47
+ "Text" => "text",
48
+ "Email Address" => "email",
49
+ "Street Address" => "address",
50
+ "City" => "city",
51
+ "Country" => "country",
52
+ "Delivery Address" => "delivery_address",
53
+ "Delivery City" => "delivery_city",
54
+ "Delivery Country" => "delivery_country",
55
+ "Text Area" => "textarea",
56
+ "Heading" => "heading",
57
+ "Select" => "select",
58
+ "Radio Button" => "radio",
59
+ "Checkbox" => "checkbox"
60
+ );
61
 
62
+ $form_types = apply_filters('wpsc_add_form_types' , $form_types);
63
+ update_option('wpsc_checkout_form_fields', $form_types);
64
+
65
+ $unique_names = Array(
66
+ 'billingfirstname',
67
+ 'billinglastname',
68
+ 'billingaddress',
69
+ 'billingcity',
70
+ 'billingstate',
71
+ 'billingcountry',
72
+ 'billingemail',
73
+ 'billingphone',
74
+ 'billingpostcode',
75
+ 'delivertoafriend' ,
76
+ 'shippingfirstname' ,
77
+ 'shippinglastname' ,
78
+ 'shippingaddress' ,
79
+ 'shippingcity' ,
80
+ 'shippingstate' ,
81
+ 'shippingcountry' ,
82
+ 'shippingpostcode'
83
+ );
84
+
85
+ $unique_names = apply_filters('wpsc_add_unique_names' , $unique_names);
86
+ update_option('wpsc_checkout_unique_names', $unique_names);
87
+
88
+ }
89
  /**
90
  * wpsc_core_load_purchase_log_statuses()
91
  *
237
  */
238
  function wpsc_register_post_types() {
239
  global $wpsc_page_titles, $wp_rewrite;
240
+ $labels = array(
241
+ 'name' => _x( 'Products', 'wpsc-product' ),
242
+ 'singular_name' => _x( 'Product', 'wpsc-product' ),
243
+ 'add_new' => _x( 'Add New', 'wpsc-product' ),
244
+ 'add_new_item' => __('Add New Product', 'wpsc-product' ),
245
+ 'edit_item' => __('Edit Product', 'wpsc-product' ),
246
+ 'new_item' => __('New Product', 'wpsc-product' ),
247
+ 'view_item' => __('View Product', 'wpsc-product' ),
248
+ 'search_items' => __('Search Products', 'wpsc-product' ),
249
+ 'not_found' => __('No products found', 'wpsc-product' ),
250
+ 'not_found_in_trash' => __( 'No products found in Trash', 'wpsc-product' ),
251
+ 'parent_item_colon' => '',
252
+ 'menu_name' => __( 'Products', 'wpsc-product' )
253
+ );
254
  // Products
255
  register_post_type( 'wpsc-product', array(
 
256
  'capability_type' => 'post',
257
  'hierarchical' => true,
258
  'exclude_from_search' => false,
259
  'public' => true,
260
+ 'show_ui' => true,
261
  'show_in_nav_menus' => true,
262
+ 'menu_icon' => WPSC_CORE_IMAGES_URL . "/credit_cards.png",
263
+ 'labels' => $labels,
264
  'query_var' => true,
265
  'register_meta_box_cb' => 'wpsc_meta_boxes',
266
  'rewrite' => array(
296
  ) );
297
 
298
  // Product categories, is heirarchical and can use permalinks
299
+ $labels = array(
300
+ 'name' => _x( 'Categories', 'taxonomy general name' ),
301
+ 'singular_name' => _x( 'Product Category', 'taxonomy singular name' ),
302
+ 'search_items' => __( 'Search Product Categories' ),
303
+ 'all_items' => __( 'All Product Categories' ),
304
+ 'parent_item' => __( 'Parent Product Category' ),
305
+ 'parent_item_colon' => __( 'Parent Product Category:' ),
306
+ 'edit_item' => __( 'Edit Product Category' ),
307
+ 'update_item' => __( 'Update Product Category' ),
308
+ 'add_new_item' => __( 'Add New Product Category' ),
309
+ 'new_item_name' => __( 'New Product Category Name' )
310
+ );
311
  register_taxonomy( 'wpsc_product_category', 'wpsc-product', array(
312
  'hierarchical' => true,
313
  'rewrite' => array(
314
  'slug' => $wpsc_page_titles['products'],
315
  'with_front' => false
316
+ ),
317
+ 'labels' => $labels
318
  ) );
319
  $labels = array(
320
  'name' => _x( 'Variations', 'taxonomy general name' ),
340
  $role = get_role( 'administrator' );
341
  $role->add_cap( 'read_wpsc-product' );
342
  $role->add_cap( 'read_wpsc-product-file' );
 
343
  }
344
  add_action( 'init', 'wpsc_register_post_types', 8 );
345
 
436
 
437
  add_filter( 'pre_get_posts', 'wpsc_generate_product_query', 11 );
438
  $wpsc_query = new WP_Query( $wpsc_query_vars );
439
+ //for 3.1 :|
440
+ if(empty($wpsc_query->posts) && isset($wpsc_query->tax_query) && isset($wp_query->query_vars['wpsc_product_category'])){
441
+ $wpsc_query_vars = array();
442
+ $wpsc_query_vars['wpsc_product_category'] = $wp_query->query_vars['wpsc_product_category'];
443
+ if(1 == get_option('use_pagination')){
444
+ $wpsc_query_vars['nopaging'] = false;
445
+ $wpsc_query_vars['posts_per_page'] = get_option('wpsc_products_per_page');
446
+ $wpsc_query_vars['paged'] = get_query_var('paged');
447
+ if(empty($wpsc_query_vars['paged']))
448
+ $wpsc_query_vars['paged'] = get_query_var('page');
449
+ }
450
+
451
+ $wpsc_query = new WP_Query( $wpsc_query_vars );
452
+ }
453
  }
454
  }
455
  if($wp_query->is_404 && $wpsc_query->post_count > 0 )
478
  global $wpsc_page_titles;
479
  $products_page = $wpsc_page_titles['products'];
480
  $checkout_page = $wpsc_page_titles['checkout'];
 
481
  $target_string = "index.php?product";
482
  $replacement_string = "index.php?post_type=wpsc-product&product";
483
  $target_rule_set_query_var = 'products';
904
  if ( (isset( $wp_query->query_vars['products'] ) && $wp_query->query_vars['products'] != null) && in_array( $wp_query->query_vars['products'], $product_category_slugs ) ) {
905
  $product_category = $wp_query->query_vars['products'];
906
  } else {
907
+ if(isset($wp_query->query_vars['wpsc_product_category']))
908
+ $link = $wp_query->query_vars['wpsc_product_category'];
909
+ else
910
+ $link = $product_categories[0]->slug;
911
+
912
+ $product_category = $link;
913
  }
914
  $category_slug = $product_category;
915
  $term_url = get_term_link( $category_slug, 'wpsc_product_category' );
935
  if ( in_array( $post_name, $product_category_slugs ) )
936
  $post_name = "product/{$post_name}";
937
 
938
+ if(isset($category_slug) && empty($category_slug)) $category_slug = 'product';
939
+
940
  $rewritereplace = array(
941
  $category_slug,
942
  $post_name
948
  }
949
  return $permalink;
950
  }
 
 
 
951
  add_filter( 'post_type_link', 'wpsc_product_link', 10, 3 );
 
 
 
952
 
953
  /**
954
  * wpsc_get_product_template function.
1051
  }
1052
  add_action( 'get_header', 'wpsc_force_ssl' );
1053
 
1054
+
1055
+ /**
1056
+ * Disable SSL validation for Curl. Added/removed on a per need basis, like so:
1057
+ *
1058
+ * add_filter('http_api_curl', 'wpsc_curl_ssl');
1059
+ * remove_filter('http_api_curl', 'wpsc_curl_ssl');
1060
+ *
1061
+ * @param resource $ch
1062
+ * @return resource $ch
1063
+ **/
1064
+ function wpsc_curl_ssl($ch) {
1065
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
1066
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
1067
+ return $ch;
1068
+ }
1069
+
1070
  /**
1071
  * wpsc_add_https_to_page_url_options( $url )
1072
  *
wpsc-core/wpsc-installer.php CHANGED
@@ -128,7 +128,9 @@ function wpsc_install() {
128
  add_option( 'paypal_multiple_url', "https://www.paypal.com/cgi-bin/webscr" );
129
 
130
  add_option( 'product_ratings', '0', __( 'Show Product Ratings', 'wpsc' ), 'yes' );
131
- add_option( 'wpsc_email_receipt', __( 'Thank you for purchasing with %shop_name%, any items to be shipped will be processed as soon as possible, any items that can be downloaded can be downloaded using the links on this page.All prices include tax and postage and packaging where applicable.\r\n You ordered these items:\r\n%product_list%%total_shipping%%total_price%', 'wpsc' ), 'yes' );
 
 
132
  add_option( 'wpsc_email_admin', __( '%product_list%%total_shipping%%total_price%', 'wpsc' ), 'yes' );
133
 
134
  add_option( 'wpsc_selected_theme', 'default', '', 'yes' );
@@ -292,7 +294,7 @@ Copyright (C) 2008 Viper007Bond
292
  function wpsc_regenerate_thumbnails() {
293
  global $wpdb;
294
 
295
- set_time_limit( 250);
296
 
297
  if ( !function_exists( 'wp_generate_attachment_metadata' ) ) {
298
  require_once ( ABSPATH . 'wp-admin/includes/image.php' );
@@ -704,7 +706,7 @@ function wpsc_add_checkout_fields() {
704
 
705
  if ( $data_forms[0]['count'] == 0 ) {
706
 
707
- $sql = " INSERT INTO `" . WPSC_TABLE_CHECKOUT_FORMS . "` ( `name`, `type`, `mandatory`, `display_log`, `default`, `active`, `order`, `unique_name`) VALUES ( '" . __( 'Your billing/contact details', 'wpsc' ) . "', 'heading', '0', '0', '', '1', 1,''),
708
  ( '" . __( 'First Name', 'wpsc' ) . "', 'text', '1', '1', '', '1', 2,'billingfirstname'),
709
  ( '" . __( 'Last Name', 'wpsc' ) . "', 'text', '1', '1', '', '1', 3,'billinglastname'),
710
  ( '" . __( 'Address', 'wpsc' ) . "', 'address', '1', '0', '', '1', 4,'billingaddress'),
@@ -725,8 +727,13 @@ function wpsc_add_checkout_fields() {
725
  $wpdb->query( $sql );
726
  update_option( 'country_form_field', $country_form_id[0]['id'] );
727
  update_option( 'email_form_field', $email_form_id[0]['id'] );
728
- $wpdb->query( "INSERT INTO `" . WPSC_TABLE_CHECKOUT_FORMS . "` ( `name`, `type`, `mandatory`, `display_log`, `default`, `active`, `order`, `unique_name` ) VALUES ( '" . __( 'Phone', 'wpsc' ) . "', 'text', '1', '0', '', '1', '8','billingphone');" );
729
  }
730
  }
 
 
 
 
731
 
 
732
  ?>
128
  add_option( 'paypal_multiple_url', "https://www.paypal.com/cgi-bin/webscr" );
129
 
130
  add_option( 'product_ratings', '0', __( 'Show Product Ratings', 'wpsc' ), 'yes' );
131
+ add_option( 'wpsc_email_receipt', __( 'Thank you for purchasing with %shop_name%, any items to be shipped will be processed as soon as possible, any items that can be downloaded can be downloaded using the links on this page.All prices include tax and postage and packaging where applicable.
132
+ You ordered these items:
133
+ %product_list%%total_shipping%%total_price%', 'wpsc' ), 'yes' );
134
  add_option( 'wpsc_email_admin', __( '%product_list%%total_shipping%%total_price%', 'wpsc' ), 'yes' );
135
 
136
  add_option( 'wpsc_selected_theme', 'default', '', 'yes' );
294
  function wpsc_regenerate_thumbnails() {
295
  global $wpdb;
296
 
297
+ if( !ini_get('safe_mode') ) set_time_limit(250);
298
 
299
  if ( !function_exists( 'wp_generate_attachment_metadata' ) ) {
300
  require_once ( ABSPATH . 'wp-admin/includes/image.php' );
706
 
707
  if ( $data_forms[0]['count'] == 0 ) {
708
 
709
+ $sql = " INSERT INTO `" . WPSC_TABLE_CHECKOUT_FORMS . "` ( `name`, `type`, `mandatory`, `display_log`, `default`, `active`, `checkout_order`, `unique_name`) VALUES ( '" . __( 'Your billing/contact details', 'wpsc' ) . "', 'heading', '0', '0', '', '1', 1,''),
710
  ( '" . __( 'First Name', 'wpsc' ) . "', 'text', '1', '1', '', '1', 2,'billingfirstname'),
711
  ( '" . __( 'Last Name', 'wpsc' ) . "', 'text', '1', '1', '', '1', 3,'billinglastname'),
712
  ( '" . __( 'Address', 'wpsc' ) . "', 'address', '1', '0', '', '1', 4,'billingaddress'),
727
  $wpdb->query( $sql );
728
  update_option( 'country_form_field', $country_form_id[0]['id'] );
729
  update_option( 'email_form_field', $email_form_id[0]['id'] );
730
+ $wpdb->query( "INSERT INTO `" . WPSC_TABLE_CHECKOUT_FORMS . "` ( `name`, `type`, `mandatory`, `display_log`, `default`, `active`, `checkout_order`, `unique_name` ) VALUES ( '" . __( 'Phone', 'wpsc' ) . "', 'text', '1', '0', '', '1', '8','billingphone');" );
731
  }
732
  }
733
+ function wpsc_rename_checkout_column(){
734
+ global $wpdb;
735
+ $sql = "ALTER TABLE `" . WPSC_TABLE_CHECKOUT_FORMS . "` CHANGE `order` `checkout_order` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0'";
736
+ $wpdb->query($sql);
737
 
738
+ }
739
  ?>
wpsc-includes/ajax.functions.php CHANGED
@@ -386,6 +386,7 @@ if ( isset( $_REQUEST['get_rating_count'] ) && ($_REQUEST['get_rating_count'] ==
386
  function wpsc_update_product_price() {
387
  global $wpdb, $wpsc_cart;
388
  $from = '';
 
389
  foreach ( (array)$_POST['variation'] as $variation ) {
390
  if ( is_numeric( $variation ) ) {
391
  $variations[] = (int)$variation;
@@ -393,8 +394,10 @@ function wpsc_update_product_price() {
393
  if($variation == 0){
394
  $from = ' from ';
395
  $from = apply_filters('wpsc_product_variation_text',$from);
 
396
  }
397
  }
 
398
  do_action( 'wpsc_update_variation_product', (int)$_POST['product_id'], $variations );
399
  $pm = $_POST['pm'];
400
 
@@ -409,12 +412,13 @@ function wpsc_update_product_price() {
409
  }
410
 
411
  echo "product_id=" . (int)$_POST['product_id'] . ";\n";
412
-
413
- echo "old_price=\"" . wpsc_currency_display( wpsc_calculate_price( (int)$_POST['product_id'], $variations, false ), array( 'display_as_html' => false ) ) . "\";\n";
414
- echo "numeric_old_price=\"" . number_format( wpsc_calculate_price( (int)$_POST['product_id'], $variations, false ) ) . "\";\n";
415
- echo "you_save=\"" . wpsc_currency_display( wpsc_you_save( array( 'product_id' => (int)$_POST['product_id'], 'type' => 'amount', 'variations' => $variations ) ), array( 'display_as_html' => false ) ) . "! (".wpsc_you_save( array( 'product_id' => (int)$_POST['product_id'], 'variations' => $variations ) ) . "%)\";\n";
416
- echo "price=\"" . $from.wpsc_currency_display( wpsc_calculate_price( (int)$_POST['product_id'], $variations, true ),array( 'display_as_html' => false ) ) . "\";\n";
417
- echo "numeric_price=\"" . number_format( wpsc_calculate_price( (int)$_POST['product_id'], $variations, true ) ) . "\";\n";
 
418
  exit();
419
  }
420
 
@@ -556,17 +560,16 @@ function wpsc_submit_checkout() {
556
  $base_shipping = $wpsc_cart->calculate_base_shipping();
557
  else
558
  $base_shipping = 0;
 
 
 
559
 
560
  if ( wpsc_uses_shipping ( ) ) {
561
  $shipping_method = $wpsc_cart->selected_shipping_method;
562
  $shipping_option = $wpsc_cart->selected_shipping_option;
563
- $delivery_country = $wpsc_cart->delivery_country;
564
- $delivery_region = $wpsc_cart->delivery_region;
565
  } else {
566
  $shipping_method = '';
567
  $shipping_option = '';
568
- $delivery_country = '';
569
- $delivery_region = '';
570
  }
571
  if ( isset( $_POST['how_find_us'] ) )
572
  $find_us = $_POST['how_find_us'];
@@ -651,10 +654,12 @@ if ( isset( $_REQUEST['wpsc_action'] ) && ($_REQUEST['wpsc_action'] == 'gateway_
651
  }
652
 
653
  function wpsc_product_rss() {
654
- global $wpsc_query, $wpdb;
 
655
  header( "Content-Type: application/xml; charset=UTF-8" );
656
  header( 'Content-Disposition: inline; filename="E-Commerce_Product_List.rss"' );
657
  require_once(WPSC_FILE_PATH . '/wpsc-includes/rss_template.php');
 
658
  exit();
659
  }
660
 
386
  function wpsc_update_product_price() {
387
  global $wpdb, $wpsc_cart;
388
  $from = '';
389
+ $change_price = true;
390
  foreach ( (array)$_POST['variation'] as $variation ) {
391
  if ( is_numeric( $variation ) ) {
392
  $variations[] = (int)$variation;
394
  if($variation == 0){
395
  $from = ' from ';
396
  $from = apply_filters('wpsc_product_variation_text',$from);
397
+ $change_price = false;
398
  }
399
  }
400
+
401
  do_action( 'wpsc_update_variation_product', (int)$_POST['product_id'], $variations );
402
  $pm = $_POST['pm'];
403
 
412
  }
413
 
414
  echo "product_id=" . (int)$_POST['product_id'] . ";\n";
415
+ if($change_price){
416
+ echo "old_price=\"" . wpsc_currency_display( wpsc_calculate_price( (int)$_POST['product_id'], $variations, false ), array( 'display_as_html' => false ) ) . "\";\n";
417
+ echo "numeric_old_price=\"" . number_format( wpsc_calculate_price( (int)$_POST['product_id'], $variations, false ) ) . "\";\n";
418
+ echo "you_save=\"" . wpsc_currency_display( wpsc_you_save( array( 'product_id' => (int)$_POST['product_id'], 'type' => 'amount', 'variations' => $variations ) ), array( 'display_as_html' => false ) ) . "! (".wpsc_you_save( array( 'product_id' => (int)$_POST['product_id'], 'variations' => $variations ) ) . "%)\";\n";
419
+ echo "price=\"" . $from.wpsc_currency_display( wpsc_calculate_price( (int)$_POST['product_id'], $variations, true ),array( 'display_as_html' => false ) ) . "\";\n";
420
+ echo "numeric_price=\"" . number_format( wpsc_calculate_price( (int)$_POST['product_id'], $variations, true ) ) . "\";\n";
421
+ }
422
  exit();
423
  }
424
 
560
  $base_shipping = $wpsc_cart->calculate_base_shipping();
561
  else
562
  $base_shipping = 0;
563
+
564
+ $delivery_country = $wpsc_cart->delivery_country;
565
+ $delivery_region = $wpsc_cart->delivery_region;
566
 
567
  if ( wpsc_uses_shipping ( ) ) {
568
  $shipping_method = $wpsc_cart->selected_shipping_method;
569
  $shipping_option = $wpsc_cart->selected_shipping_option;
 
 
570
  } else {
571
  $shipping_method = '';
572
  $shipping_option = '';
 
 
573
  }
574
  if ( isset( $_POST['how_find_us'] ) )
575
  $find_us = $_POST['how_find_us'];
654
  }
655
 
656
  function wpsc_product_rss() {
657
+ global $wp_query,$wpsc_query, $wpdb;
658
+ list($wp_query, $wpsc_query) = array( $wpsc_query, $wp_query ); // swap the wpsc_query object
659
  header( "Content-Type: application/xml; charset=UTF-8" );
660
  header( 'Content-Disposition: inline; filename="E-Commerce_Product_List.rss"' );
661
  require_once(WPSC_FILE_PATH . '/wpsc-includes/rss_template.php');
662
+ list($wp_query, $wpsc_query) = array( $wpsc_query, $wp_query ); // swap the wpsc_query object
663
  exit();
664
  }
665
 
wpsc-includes/breadcrumbs.class.php CHANGED
@@ -130,7 +130,7 @@ class wpsc_breadcrumbs {
130
  * @return void
131
  */
132
  function wpsc_breadcrumbs() {
133
- global $wp_query;
134
  $this->breadcrumbs = array();
135
  $query_data = Array();
136
  if ( isset($wp_query->query_vars['post_type']) && 'wpsc-product' == $wp_query->query_vars['post_type'] && 1 == $wp_query->query_vars['posts_per_page']) {
@@ -150,8 +150,12 @@ class wpsc_breadcrumbs {
150
  }
151
  if(1 == $wp_query->post_count){
152
  $categories = wp_get_object_terms( $wp_query->post->ID , 'wpsc_product_category' );
153
- if(count($categories) > 0)
 
 
 
154
  $query_data['category'] = $categories[0]->slug;
 
155
  }
156
  if(isset($query_data['category'])) {
157
  $term_data = get_term_by('slug', $query_data['category'], 'wpsc_product_category');
130
  * @return void
131
  */
132
  function wpsc_breadcrumbs() {
133
+ global $wp_query, $wpsc_query;
134
  $this->breadcrumbs = array();
135
  $query_data = Array();
136
  if ( isset($wp_query->query_vars['post_type']) && 'wpsc-product' == $wp_query->query_vars['post_type'] && 1 == $wp_query->query_vars['posts_per_page']) {
150
  }
151
  if(1 == $wp_query->post_count){
152
  $categories = wp_get_object_terms( $wp_query->post->ID , 'wpsc_product_category' );
153
+ //if product is associated w more than one category
154
+ if(count($categories) > 1 && isset($wpsc_query->query_vars['wpsc_product_category']))
155
+ $query_data['category'] = $wpsc_query->query_vars['wpsc_product_category'];
156
+ elseif(count($categories) > 0)
157
  $query_data['category'] = $categories[0]->slug;
158
+
159
  }
160
  if(isset($query_data['category'])) {
161
  $term_data = get_term_by('slug', $query_data['category'], 'wpsc_product_category');
wpsc-includes/cart.class.php CHANGED
@@ -132,7 +132,7 @@ function nzshpcrt_overall_total_price() {
132
  function wpsc_cart_weight_total() {
133
  global $wpsc_cart;
134
  if(is_object($wpsc_cart)) {
135
- return $wpsc_cart->calculate_total_weight();
136
  } else {
137
  return 0;
138
  }
@@ -344,7 +344,12 @@ function wpsc_cart_item_url() {
344
  */
345
  function wpsc_cart_item_image() {
346
  global $wpsc_cart;
347
- return wpsc_the_product_thumbnail( 31, 31,$wpsc_cart->cart_item->product_id, "shopping_cart");
 
 
 
 
 
348
  }
349
 
350
  /**
@@ -406,7 +411,7 @@ function wpsc_the_shipping_method() {
406
  */
407
  function wpsc_shipping_method_name() {
408
  global $wpsc_cart, $wpsc_shipping_modules;
409
- return $wpsc_shipping_modules[$wpsc_cart->shipping_method]->name;
410
  }
411
 
412
 
@@ -444,7 +449,7 @@ function wpsc_the_shipping_quote() {
444
  */
445
  function wpsc_shipping_quote_name() {
446
  global $wpsc_cart;
447
- return $wpsc_cart->shipping_quote['name'];
448
  }
449
 
450
  /**
@@ -643,7 +648,7 @@ class wpsc_cart {
643
  global $wpsc_cart;
644
  if(is_object($wpsc_cart) && is_object($wpsc_cart->cart_items))
645
  {
646
- foreach($wpsc_cart->cart_items as &$cart_item)
647
  {
648
  $cart_item->refresh_item();
649
  }// foreach
@@ -1553,7 +1558,7 @@ class wpsc_cart_item {
1553
  * @param objcet the cart object
1554
  * @return boolean true on sucess, false on failure
1555
  */
1556
- function wpsc_cart_item($product_id, $parameters, &$cart) {
1557
  global $wpdb;
1558
  // still need to add the ability to limit the number of an item in the cart at once.
1559
  // each cart item contains a reference to the cart that it is a member of, this makes that reference
132
  function wpsc_cart_weight_total() {
133
  global $wpsc_cart;
134
  if(is_object($wpsc_cart)) {
135
+ return $wpsc_cart->calculate_total_weight(true);
136
  } else {
137
  return 0;
138
  }
344
  */
345
  function wpsc_cart_item_image() {
346
  global $wpsc_cart;
347
+
348
+ $cart_image = wpsc_the_product_thumbnail( 31, 31,$wpsc_cart->cart_item->product_id, "shopping_cart");
349
+
350
+ if( is_ssl() && !strstr( $cart_image, 'https' ) ) str_replace( 'http', 'https', $cart_image );
351
+
352
+ return $cart_image;
353
  }
354
 
355
  /**
411
  */
412
  function wpsc_shipping_method_name() {
413
  global $wpsc_cart, $wpsc_shipping_modules;
414
+ return apply_filters( 'wpsc_shipping_method_name', $wpsc_shipping_modules[$wpsc_cart->shipping_method]->name );
415
  }
416
 
417
 
449
  */
450
  function wpsc_shipping_quote_name() {
451
  global $wpsc_cart;
452
+ return apply_filters( 'wpsc_shipping_quote_name', $wpsc_cart->shipping_quote['name'] );
453
  }
454
 
455
  /**
648
  global $wpsc_cart;
649
  if(is_object($wpsc_cart) && is_object($wpsc_cart->cart_items))
650
  {
651
+ foreach($wpsc_cart->cart_items as $cart_item)
652
  {
653
  $cart_item->refresh_item();
654
  }// foreach
1558
  * @param objcet the cart object
1559
  * @return boolean true on sucess, false on failure
1560
  */
1561
+ function wpsc_cart_item($product_id, $parameters, $cart) {
1562
  global $wpdb;
1563
  // still need to add the ability to limit the number of an item in the cart at once.
1564
  // each cart item contains a reference to the cart that it is a member of, this makes that reference
wpsc-includes/category.functions.php CHANGED
@@ -44,11 +44,12 @@ function wpsc_list_categories($callback_function, $parameters = null, $category_
44
  * Gets the Function Parent Image link and checks whether Image should be displayed or not
45
  *
46
  */
47
- function wpsc_parent_category_image($show_thumbnails , $category_image , $width, $height, $grid=false){
48
 
49
  if(!$show_thumbnails) return;
50
 
51
  if($category_image == WPSC_CATEGORY_URL){
 
52
  ?>
53
  <span class='wpsc_category_image item_no_image ' style='width:<?php echo $width; ?>px; height: <?php echo $height; ?>px;'>
54
  <span class='link_substitute' >
@@ -112,8 +113,11 @@ function wpsc_print_category_id() {
112
  * wpsc print category classes function
113
  * places classes for the category including selected state
114
  */
115
- function wpsc_print_category_classes() {
116
- echo "[wpsc_category_classes]";
 
 
 
117
  }
118
 
119
 
@@ -128,7 +132,9 @@ function wpsc_print_subcategory($start_element = '', $end_element = '') {
128
  $wpsc_category_query['subcategory_container'] = array('start_element' => $start_element, 'end_element' => $end_element);
129
  echo "[wpsc_subcategory]";
130
  }
131
-
 
 
132
 
133
  /**
134
  * wpsc print category image function
@@ -211,8 +217,12 @@ function wpsc_display_category_loop($query, $category_html, &$category_branch =
211
 
212
  // Creates the list of classes on the category item
213
  $category_classes = 'wpsc-cat-item wpsc-cat-item-' . $category_row->term_id;
214
- if ( isset($wpsc_query->query_vars['category_id']) && $wpsc_query->query_vars['category_id'] == $category_row->term_id) {
215
- $category_classes .= ' wpsc-current-cat';
 
 
 
 
216
  }
217
 
218
  // Set the variables for this category
@@ -264,14 +274,14 @@ function wpsc_display_category_loop($query, $category_html, &$category_branch =
264
  $category_image = wpsc_get_categorymeta($category_row->term_id, 'image');
265
  $category_image_html = '';
266
  if(($query['show_thumbnails'] == 1)) {
267
- if(($category_image != '') && is_file(WPSC_CATEGORY_DIR.$category_image)) {
268
  $category_image_html = "<img src='".WPSC_CATEGORY_URL."$category_image' alt='{$category_row->name}' title='{$category_row->name}' style='width: {$width}px; height: {$height}px;' class='wpsc_category_image' />";
269
- } else {
270
- $category_image_html .= " <span class='wpsc_category_image item_no_image ' style='width: {$width}px; height: {$height}px;'>\n\r";
271
- $category_image_html .= " <span class='link_substitute' >\n\r";
272
- $category_image_html .= " <span>".$category_row->name."</span>\n\r";
273
- $category_image_html .= " </span>\n\r";
274
- $category_image_html .= " </span>\n\r";
275
  }
276
 
277
  }
44
  * Gets the Function Parent Image link and checks whether Image should be displayed or not
45
  *
46
  */
47
+ function wpsc_parent_category_image($show_thumbnails , $category_image , $width, $height, $grid=false, $show_name){
48
 
49
  if(!$show_thumbnails) return;
50
 
51
  if($category_image == WPSC_CATEGORY_URL){
52
+ if(!$show_name) return;
53
  ?>
54
  <span class='wpsc_category_image item_no_image ' style='width:<?php echo $width; ?>px; height: <?php echo $height; ?>px;'>
55
  <span class='link_substitute' >
113
  * wpsc print category classes function
114
  * places classes for the category including selected state
115
  */
116
+ function wpsc_print_category_classes($currcat = '') {
117
+ global $wp_query;
118
+ if( is_array($currcat) && isset($currcat['slug']) && isset($wp_query->query_vars['wpsc_product_category']) && $currcat['slug'] == $wp_query->query_vars['wpsc_product_category']){
119
+ echo ' wpsc-current-cat ';
120
+ }
121
  }
122
 
123
 
132
  $wpsc_category_query['subcategory_container'] = array('start_element' => $start_element, 'end_element' => $end_element);
133
  echo "[wpsc_subcategory]";
134
  }
135
+ function wpsc_print_category_classes_section(){
136
+ echo "[wpsc_category_classes]";
137
+ }
138
 
139
  /**
140
  * wpsc print category image function
217
 
218
  // Creates the list of classes on the category item
219
  $category_classes = 'wpsc-cat-item wpsc-cat-item-' . $category_row->term_id;
220
+ if(isset($wpsc_query->query_vars['wpsc_product_category'])){
221
+ $currcat = get_term_by('slug',$wpsc_query->query_vars['wpsc_product_category'], 'wpsc_product_category');
222
+ if ( $currcat->term_id == $category_row->term_id) {
223
+ $category_classes .= ' wpsc-current-cat';
224
+ }
225
+
226
  }
227
 
228
  // Set the variables for this category
274
  $category_image = wpsc_get_categorymeta($category_row->term_id, 'image');
275
  $category_image_html = '';
276
  if(($query['show_thumbnails'] == 1)) {
277
+ if((!empty($category_image)) && is_file(WPSC_CATEGORY_DIR.$category_image)) {
278
  $category_image_html = "<img src='".WPSC_CATEGORY_URL."$category_image' alt='{$category_row->name}' title='{$category_row->name}' style='width: {$width}px; height: {$height}px;' class='wpsc_category_image' />";
279
+ } elseif(1 == $query['show_name']) {
280
+ $category_image_html .= "<span class='wpsc_category_image item_no_image ' style='width: {$width}px; height: {$height}px;'>\n\r";
281
+ $category_image_html .= " <span class='link_substitute' >\n\r";
282
+ $category_image_html .= " <span>".__('N/A','wpsc')."</span>\n\r";
283
+ $category_image_html .= " </span>\n\r";
284
+ $category_image_html .= "</span>\n\r";
285
  }
286
 
287
  }
wpsc-includes/checkout.class.php CHANGED
@@ -92,7 +92,7 @@ function wpsc_check_purchase_processed($processed){
92
  */
93
  function wpsc_get_buyers_email($purchase_id){
94
  global $wpdb;
95
- $email_form_field = $wpdb->get_results( "SELECT `id`,`type` FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `type` IN ('email') AND `active` = '1' ORDER BY `order` ASC LIMIT 1", ARRAY_A );
96
  $email = $wpdb->get_var( "SELECT `value` FROM `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` WHERE `log_id`=" . $purchase_id . " AND `form_id` = '" . $email_form_field[0]['id'] . "' LIMIT 1" );
97
  return $email;
98
 
@@ -549,7 +549,7 @@ class wpsc_checkout {
549
  */
550
  function wpsc_checkout( $checkout_set = 0 ) {
551
  global $wpdb;
552
- $this->checkout_items = $wpdb->get_results( "SELECT * FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `active` = '1' AND `checkout_set`='" . $checkout_set . "' ORDER BY `order`;" );
553
 
554
  $category_list = wpsc_cart_item_categories( true );
555
  $additional_form_list = array( );
@@ -561,11 +561,11 @@ class wpsc_checkout {
561
  unset( $additional_form_list[$checkout_form_fields_id] );
562
  }
563
  if ( count( $additional_form_list ) > 0 ) {
564
- $this->category_checkout_items = $wpdb->get_results( "SELECT * FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `active` = '1' AND `checkout_set` IN ('" . implode( "','", $additional_form_list ) . "') ORDER BY `checkout_set`, `order`;" );
565
  $this->checkout_items = array_merge( (array)$this->checkout_items, (array)$this->category_checkout_items );
566
  }
567
  if ( function_exists( 'wpsc_get_ticket_checkout_set' ) ) {
568
- $sql = "SELECT * FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `active` = '1' AND `checkout_set`='" . wpsc_get_ticket_checkout_set() . "' ORDER BY `order`;";
569
  $this->additional_fields = $wpdb->get_results( $sql );
570
  $count = wpsc_ticket_checkoutfields();
571
  $j = 1;
@@ -626,20 +626,21 @@ class wpsc_checkout {
626
  global $wpdb, $user_ID;
627
  if ( ($user_ID > 0) ){
628
  if(!isset($_SESSION['wpsc_checkout_saved_values']))
629
- $_SESSION['wpsc_checkout_saved_values'] = get_user_meta( $user_ID, 'wpshpcrt_usr_profile',1 );
630
 
631
  $delivery_country_id = wpsc_get_country_form_id_by_type('delivery_country');
632
  $billing_country_id = wpsc_get_country_form_id_by_type('country');
633
  if(is_array($_SESSION['wpsc_checkout_saved_values']) && ($this->checkout_item->id == $delivery_country_id) || ($this->checkout_item->id == $billing_country_id)){
634
  if( isset($_SESSION['wpsc_checkout_saved_values'][$this->checkout_item->id]) && is_array($_SESSION['wpsc_checkout_saved_values'][$this->checkout_item->id])
635
- && count($_SESSION['wpsc_checkout_saved_values'][$this->checkout_item->id]) > 1){
636
-
637
  $_SESSION['wpsc_delivery_country'] = $_SESSION['wpsc_checkout_saved_values'][$this->checkout_item->id][0];
638
  $_SESSION['wpsc_delivery_region'] = $_SESSION['wpsc_checkout_saved_values'][$this->checkout_item->id][1];
 
639
  } elseif(isset($_SESSION['wpsc_checkout_saved_values'][$this->checkout_item->id]) && is_array($_SESSION['wpsc_checkout_saved_values'][$this->checkout_item->id])) {
640
- $_SESSION['wpsc_delivery_country'] = $_SESSION['wpsc_checkout_saved_values'][$this->checkout_item->id][0];
641
  }elseif(isset($_SESSION['wpsc_checkout_saved_values'][$this->checkout_item->id])){
642
- $_SESSION['wpsc_delivery_country'] = $_SESSION['wpsc_checkout_saved_values'][$this->checkout_item->id];
643
  }
644
  }
645
  }
@@ -744,6 +745,7 @@ class wpsc_checkout {
744
  function validate_forms() {
745
  global $wpdb, $current_user, $user_ID;
746
  $any_bad_inputs = false;
 
747
  // Credit Card Number Validation for PayPal Pro and maybe others soon
748
  if ( isset( $_POST['card_number'] ) ) {
749
  //should do some php CC validation here~
@@ -820,7 +822,6 @@ class wpsc_checkout {
820
  //Basic Form field validation for billing and shipping details
821
  foreach ( $this->checkout_items as $form_data ) {
822
  $value = $_POST['collected_data'][$form_data->id];
823
- $value_id = (int)$value_id;
824
  $_SESSION['wpsc_checkout_saved_values'][$form_data->id] = $value;
825
  $bad_input = false;
826
  if ( ($form_data->mandatory == 1) || ($form_data->type == "coupon") ) {
@@ -856,22 +857,12 @@ class wpsc_checkout {
856
  }
857
  }
858
 
859
- if ( ($any_bad_inputs == false) && ($user_ID > 0) ) {
860
- $saved_data_sql = "SELECT * FROM `" . $wpdb->usermeta . "` WHERE `user_id` = '" . $user_ID . "' AND `meta_key` = 'wpshpcrt_usr_profile';";
861
- $saved_data = $wpdb->get_row( $saved_data_sql, ARRAY_A );
862
- $new_meta_data = serialize( $_POST['collected_data'] );
863
- if ( $saved_data != null ) {
864
- $sql = "UPDATE `" . $wpdb->usermeta . "` SET `meta_value` = '$new_meta_data' WHERE `user_id` IN ('$user_ID') AND `meta_key` IN ('wpshpcrt_usr_profile');";
865
- $wpdb->query( $sql );
866
- $changes_saved = true;
867
- } else {
868
- $sql = "INSERT INTO `" . $wpdb->usermeta . "` ( `user_id` , `meta_key` , `meta_value` ) VALUES ( " . $user_ID . ", 'wpshpcrt_usr_profile', '$new_meta_data');";
869
- $wpdb->query( $sql );
870
- $changes_saved = true;
871
- }
872
- }
873
 
874
- return array( 'is_valid' => !$any_bad_inputs, 'error_messages' => $bad_input_message );
 
 
875
  }
876
 
877
  /**
92
  */
93
  function wpsc_get_buyers_email($purchase_id){
94
  global $wpdb;
95
+ $email_form_field = $wpdb->get_results( "SELECT `id`,`type` FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `type` IN ('email') AND `active` = '1' ORDER BY `checkout_order` ASC LIMIT 1", ARRAY_A );
96
  $email = $wpdb->get_var( "SELECT `value` FROM `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` WHERE `log_id`=" . $purchase_id . " AND `form_id` = '" . $email_form_field[0]['id'] . "' LIMIT 1" );
97
  return $email;
98
 
549
  */
550
  function wpsc_checkout( $checkout_set = 0 ) {
551
  global $wpdb;
552
+ $this->checkout_items = $wpdb->get_results( "SELECT * FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `active` = '1' AND `checkout_set`='" . $checkout_set . "' ORDER BY `checkout_order`;" );
553
 
554
  $category_list = wpsc_cart_item_categories( true );
555
  $additional_form_list = array( );
561
  unset( $additional_form_list[$checkout_form_fields_id] );
562
  }
563
  if ( count( $additional_form_list ) > 0 ) {
564
+ $this->category_checkout_items = $wpdb->get_results( "SELECT * FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `active` = '1' AND `checkout_set` IN ('" . implode( "','", $additional_form_list ) . "') ORDER BY `checkout_set`, `checkout_order`;" );
565
  $this->checkout_items = array_merge( (array)$this->checkout_items, (array)$this->category_checkout_items );
566
  }
567
  if ( function_exists( 'wpsc_get_ticket_checkout_set' ) ) {
568
+ $sql = "SELECT * FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `active` = '1' AND `checkout_set`='" . wpsc_get_ticket_checkout_set() . "' ORDER BY `checkout_order`;";
569
  $this->additional_fields = $wpdb->get_results( $sql );
570
  $count = wpsc_ticket_checkoutfields();
571
  $j = 1;
626
  global $wpdb, $user_ID;
627
  if ( ($user_ID > 0) ){
628
  if(!isset($_SESSION['wpsc_checkout_saved_values']))
629
+ $_SESSION['wpsc_checkout_saved_values'] = get_user_meta( $user_ID, 'wpshpcrt_usr_profile',1 );
630
 
631
  $delivery_country_id = wpsc_get_country_form_id_by_type('delivery_country');
632
  $billing_country_id = wpsc_get_country_form_id_by_type('country');
633
  if(is_array($_SESSION['wpsc_checkout_saved_values']) && ($this->checkout_item->id == $delivery_country_id) || ($this->checkout_item->id == $billing_country_id)){
634
  if( isset($_SESSION['wpsc_checkout_saved_values'][$this->checkout_item->id]) && is_array($_SESSION['wpsc_checkout_saved_values'][$this->checkout_item->id])
635
+ && count($_SESSION['wpsc_checkout_saved_values'][$this->checkout_item->id]) > 1 ){
636
+ /*
637
  $_SESSION['wpsc_delivery_country'] = $_SESSION['wpsc_checkout_saved_values'][$this->checkout_item->id][0];
638
  $_SESSION['wpsc_delivery_region'] = $_SESSION['wpsc_checkout_saved_values'][$this->checkout_item->id][1];
639
+ */
640
  } elseif(isset($_SESSION['wpsc_checkout_saved_values'][$this->checkout_item->id]) && is_array($_SESSION['wpsc_checkout_saved_values'][$this->checkout_item->id])) {
641
+ /* $_SESSION['wpsc_delivery_country'] = $_SESSION['wpsc_checkout_saved_values'][$this->checkout_item->id][0]; */
642
  }elseif(isset($_SESSION['wpsc_checkout_saved_values'][$this->checkout_item->id])){
643
+ /* $_SESSION['wpsc_delivery_country'] = $_SESSION['wpsc_checkout_saved_values'][$this->checkout_item->id]; */
644
  }
645
  }
646
  }
745
  function validate_forms() {
746
  global $wpdb, $current_user, $user_ID;
747
  $any_bad_inputs = false;
748
+ $bad_input_message = '';
749
  // Credit Card Number Validation for PayPal Pro and maybe others soon
750
  if ( isset( $_POST['card_number'] ) ) {
751
  //should do some php CC validation here~
822
  //Basic Form field validation for billing and shipping details
823
  foreach ( $this->checkout_items as $form_data ) {
824
  $value = $_POST['collected_data'][$form_data->id];
 
825
  $_SESSION['wpsc_checkout_saved_values'][$form_data->id] = $value;
826
  $bad_input = false;
827
  if ( ($form_data->mandatory == 1) || ($form_data->type == "coupon") ) {
857
  }
858
  }
859
 
860
+ if ( ($any_bad_inputs == false) && ($user_ID > 0) )
861
+ update_user_meta($user_ID, 'wpshpcrt_usr_profile', $_POST['collected_data']);
 
 
 
 
 
 
 
 
 
 
 
 
862
 
863
+ $states = array( 'is_valid' => !$any_bad_inputs, 'error_messages' => $bad_input_message );
864
+ $states = apply_filters('wpsc_checkout_form_validation', $states);
865
+ return $states;
866
  }
867
 
868
  /**
wpsc-includes/coupons.class.php CHANGED
@@ -341,6 +341,8 @@ class wpsc_coupons {
341
  default:
342
  return false;
343
  }
 
 
344
  }
345
  }
346
 
341
  default:
342
  return false;
343
  }
344
+ } else {
345
+ return apply_filters( 'wpsc_coupon_compare_logic', false, $c, $product_obj );
346
  }
347
  }
348
 
wpsc-includes/display.functions.php CHANGED
@@ -1,419 +1,426 @@
1
- <?php
2
-
3
- /**
4
- * WP eCommerce display functions
5
- *
6
- * These are functions for the wp-eCommerce themngine, template tags and shortcodes
7
- *
8
- * @package wp-e-commerce
9
- * @since 3.7
10
- */
11
-
12
- /**
13
- * wpsc buy now button code products function
14
- * Sorry about the ugly code, this is just to get the functionality back, buy now will soon be overhauled, and this function will then be completely different
15
- * @return string - html displaying one or more products
16
- */
17
- function wpsc_buy_now_button( $product_id, $replaced_shortcode = false ) {
18
- global $wpdb, $wpsc_query, $wpsc_cart, $wp_query;
19
- $product = get_post( $product_id );
20
- $supported_gateways = array('wpsc_merchant_paypal_standard','paypal_multiple');
21
- $selected_gateways = get_option( 'custom_gateway_options' );
22
- if ( in_array( 'wpsc_merchant_paypal_standard', (array)$selected_gateways ) ) {
23
- if ( $product_id > 0 ) {
24
- $post_meta = get_post_meta( $product_id, '_wpsc_product_metadata', true );
25
- $shipping = $post_meta['shipping']['local'];
26
- $org_price = get_post_meta( $product_id, '_wpsc_price', true );
27
- $special_price = get_post_meta( $product_id, '_wpsc_special_price', true );
28
- $price = (int)$org_price - (int)$special_price;
29
- if ( wpsc_uses_shipping ( ) ) {
30
- $handling = get_option( 'base_local_shipping' );
31
- } else {
32
- $handling = $shipping;
33
- }
34
- $output .= "<form onsubmit='log_paypal_buynow(this)' target='paypal' action='" . get_option( 'paypal_multiple_url' ) . "' method='post' />
35
- <input type='hidden' name='business' value='" . get_option( 'paypal_multiple_business' ) . "' />
36
- <input type='hidden' name='cmd' value='_xclick' />
37
- <input type='hidden' name='item_name' value='" . $product->post_title . "' />
38
- <input type='hidden' id='item_number' name='item_number' value='" . $product_id . "' />
39
- <input type='hidden' id='amount' name='amount' value='" . ($price) . "' />
40
- <input type='hidden' id='unit' name='unit' value='" . $price . "' />
41
- <input type='hidden' id='shipping' name='ship11' value='" . $shipping . "' />
42
- <input type='hidden' name='handling' value='" . $handling . "' />
43
- <input type='hidden' name='currency_code' value='" . get_option( 'paypal_curcode' ) . "' />";
44
- if ( get_option( 'multi_add' ) == 1 ) {
45
- $output .="<label for='quantity'>" . __( 'Quantity', 'wpsc' ) . "</label>";
46
- $output .="<input type='text' size='4' id='quantity' name='quantity' value='' /><br />";
47
- } else {
48
- $output .="<input type='hidden' name='undefined_quantity' value='0' />";
49
- }
50
- $output .="<input type='image' name='submit' border='0' src='https://www.paypal.com/en_US/i/btn/btn_buynow_LG.gif' alt='PayPal - The safer, easier way to pay online' />
51
- <img alt='' border='0' width='1' height='1' src='https://www.paypal.com/en_US/i/scr/pixel.gif' />
52
- </form>\n\r";
53
- }
54
- }
55
- if ( $replaced_shortcode == true ) {
56
- return $output;
57
- } else {
58
- echo $output;
59
- }
60
- }
61
-
62
- function wpsc_also_bought( $product_id ) {
63
- /*
64
- * Displays products that were bought aling with the product defined by $product_id
65
- * most of it scarcely needs describing
66
- */
67
- global $wpdb;
68
-
69
- if ( get_option( 'wpsc_also_bought' ) == 0 ) {
70
- //returns nothing if this is off
71
- return '';
72
- }
73
-
74
-
75
- // to be made customiseable in a future release
76
- $also_bought_limit = 3;
77
- $element_widths = 96;
78
- $image_display_height = 96;
79
- $image_display_width = 96;
80
-
81
- $output = '';
82
- $also_bought = $wpdb->get_results( "SELECT `" . $wpdb->posts . "`.* FROM `" . WPSC_TABLE_ALSO_BOUGHT . "`, `" . $wpdb->posts . "` WHERE `selected_product`='" . $product_id . "' AND `" . WPSC_TABLE_ALSO_BOUGHT . "`.`associated_product` = `" . $wpdb->posts . "`.`id` AND `" . $wpdb->posts . "`.`post_status` IN('publish','protected') ORDER BY `" . WPSC_TABLE_ALSO_BOUGHT . "`.`quantity` DESC LIMIT $also_bought_limit", ARRAY_A );
83
- if ( count( $also_bought ) > 0 ) {
84
- $output .= "<h2 class='prodtitles wpsc_also_bought' >" . __( 'People who bought this item also bought', 'wpsc' ) . "</h2>";
85
- $output .= "<div class='wpsc_also_bought'>";
86
- foreach ( (array)$also_bought as $also_bought_data ) {
87
- $output .= "<div class='wpsc_also_bought_item' style='width: " . $element_widths . "px;'>";
88
- if ( get_option( 'show_thumbnails' ) == 1 ) {
89
- if ( $also_bought_data['image'] != null ) {
90
- $output .= "<a href='" . get_permalink($also_bought_data['ID']) . "' class='preview_link' rel='" . str_replace( " ", "_", get_the_title($also_bought_data['ID']) ) . "'>";
91
- $image_path = "index.php?productid=" . $also_bought_data['ID'] . "&amp;width=" . $image_display_width . "&amp;height=" . $image_display_height . "";
92
-
93
- $output .= "<img src='$image_path' id='product_image_" . $also_bought_data['ID'] . "' class='product_image' style='margin-top: " . $margin_top . "px'/>";
94
- $output .= "</a>";
95
- } else {
96
- if ( get_option( 'product_image_width' ) != '' ) {
97
- $output .= "<img src='" . WPSC_CORE_IMAGES_URL . "/no-image-uploaded.gif' title='" . get_the_title($also_bought_data['ID']) . "' alt='" . $also_bought_data['name'] . "' width='$image_display_height' height='$image_display_height' id='product_image_" . $also_bought_data['ID'] . "' class='product_image' />";
98
- } else {
99
- $output .= "<img src='" . WPSC_CORE_IMAGES_URL . "/no-image-uploaded.gif' title='" . get_the_title($also_bought_data['ID']) . "' alt='" . htmlentities( stripslashes( get_the_title($also_bought_data['ID']) ), ENT_QUOTES, 'UTF-8' ) . "' id='product_image_" . $also_bought_data['ID'] . "' class='product_image' />";
100
- }
101
- }
102
- }
103
-
104
- $output .= "<a class='wpsc_product_name' href='" . get_permalink($also_bought_data['ID']) . "'>" . get_the_title($also_bought_data['ID']) . "</a>";
105
- $price = get_product_meta($also_bought_data['ID'], 'price', true);
106
- $special_price = get_product_meta($also_bought_data['ID'], 'special_price', true);
107
- if(!empty($special_price)){
108
- $output .= '<span style="text-decoration: line-through;">' . wpsc_currency_display( $price ) . '</span>';
109
- $output .= wpsc_currency_display( $special_price );
110
- } else {
111
- $output .= wpsc_currency_display( $price );
112
- }
113
- $output .= "</div>";
114
- }
115
- $output .= "</div>";
116
- $output .= "<br clear='all' />";
117
- }
118
- return $output;
119
- }
120
-
121
- function fancy_notifications() {
122
- global $wpdb;
123
- $output = "";
124
- if ( get_option( 'fancy_notifications' ) == 1 ) {
125
- $output = "";
126
- $output .= "<div id='fancy_notification'>\n\r";
127
- $output .= " <div id='loading_animation'>\n\r";
128
- $output .= '<img id="fancy_notificationimage" title="Loading" alt="Loading" src="' . WPSC_CORE_IMAGES_URL . '/indicator.gif" />' . __( 'Updating', 'wpsc' ) . "...\n\r";
129
- $output .= " </div>\n\r";
130
- $output .= " <div id='fancy_notification_content'>\n\r";
131
- $output .= " </div>\n\r";
132
- $output .= "</div>\n\r";
133
- }
134
-
135
- return $output;
136
- }
137
- function wpsc_fancy_notifications(){
138
- echo fancy_notifications();
139
- }
140
- add_action( 'wpsc_theme_footer', 'wpsc_fancy_notifications' );
141
-
142
- function fancy_notification_content( $cart_messages ) {
143
- global $wpdb;
144
- $siteurl = get_option( 'siteurl' );
145
- foreach ( (array)$cart_messages as $cart_message ) {
146
- $output .= "<span>" . $cart_message . "</span><br />";
147
- }
148
- $output .= "<a href='" . get_option( 'shopping_cart_url' ) . "' class='go_to_checkout'>" . __( 'Go to Checkout', 'wpsc' ) . "</a>";
149
- $output .= "<a href='#' onclick='jQuery(\"#fancy_notification\").css(\"display\", \"none\"); return false;' class='continue_shopping'>" . __( 'Continue Shopping', 'wpsc' ) . "</a>";
150
- return $output;
151
- }
152
-
153
- /*
154
- * wpsc product url function, gets the URL of a product,
155
- * Deprecated, all parameters past the first unused. use get_permalink
156
- */
157
-
158
- function wpsc_product_url( $product_id, $category_id = null, $escape = true ) {
159
- global $wpdb, $wp_rewrite, $wp_query;
160
- $post = get_post($product_id);
161
- if ( isset($post->post_parent) && $post->post_parent > 0) {
162
- return get_permalink($post->post_parent);
163
- } else {
164
- return get_permalink($product_id);
165
- }
166
- }
167
-
168
- function external_link( $product_id ) {
169
- global $wpdb;
170
- $link = get_product_meta( $product_id, 'external_link', true );
171
- if ( !stristr( $link, 'http://' ) ) {
172
- $link = 'http://' . $link;
173
- }
174
- $target = wpsc_product_external_link_target( $product_id );
175
- $output .= "<input class='wpsc_buy_button' type='button' value='" . wpsc_product_external_link_text( $product_id, __( 'Buy Now', 'wpsc' ) ) . "' onclick='return gotoexternallink(\"$link\", \"$target\")'>";
176
- return $output;
177
- }
178
-
179
- // displays error messages if the category setup is odd in some way
180
- // needs to be in a function because there are at least three places where this code must be used.
181
- function wpsc_odd_category_setup() {
182
- get_currentuserinfo();
183
- global $userdata;
184
- $output = '';
185
- if ( ($userdata->wp_capabilities['administrator'] == 1) || ($userdata->user_level >= 9) ) {
186
- if ( get_option( 'wpsc_default_category' ) == 1 ) {
187
- $output = "<p>" . __( 'You are using the example product group as your default group and it has no products in it, you should set the default group to something else, you can do so from your Shop Settings page.', 'wpsc' ) . "</p>";
188
- } else {
189
- $output = "<p>" . __( 'This group is set as your default product group, you should either add some items to it or switch your default product group to one that does contain items.', 'wpsc' ) . "</p>";
190
- }
191
- }
192
- return $output;
193
- }
194
-
195
- function wpsc_product_image_html( $image_name, $product_id ) {
196
- global $wpdb, $wp_query;
197
- if ( is_numeric( $wp_query->query_vars['product_category'] ) ) {
198
- $category_id = (int)$wp_query->query_vars['product_category'];
199
- } else if ( is_numeric( $_GET['category'] ) ) {
200
- $category_id = (int)$_GET['category'];
201
- } else {
202
- $category_id = (int)get_option( 'wpsc_default_category' );
203
- }
204
-
205
- $product['height'] = get_product_meta( $id, 'thumbnail_height' );
206
- $product['width'] = get_product_meta( $id, 'thumbnail_width' );
207
-
208
-
209
- $use_thumbnail_image = 'false';
210
- if ( ($product['height'] > $category['height']) || ($product['width'] > $category['width']) ) {
211
- $use_thumbnail_image = 'true';
212
- }
213
-
214
- if ( $category_id > 0 ) {
215
- $category = $wpdb->get_row( "SELECT `image_height` AS `height`, `image_width` AS `width` FROM `" . WPSC_TABLE_PRODUCT_CATEGORIES . "` WHERE `id` IN ('{$category_id}') LIMIT 1", ARRAY_A );
216
- }
217
- // if there is a height, width, and imagePNG function
218
- if ( ($category['height'] != null) && ($category['width'] != null) && (function_exists( 'ImagePNG' )) ) {
219
- $image_path = "index.php?productid=" . $product_id . "&amp;thumbnail=" . $use_thumbnail_image . "&amp;width=" . $category['width'] . "&amp;height=" . $category['height'] . "";
220
- } else {
221
- $image_path = WPSC_THUMBNAIL_URL . $image_name;
222
- if ( is_ssl ( ) ) {
223
- $image_path = str_replace( "http://", "https://", $image_path );
224
- }
225
- }
226
- return $image_path;
227
- }
228
-
229
- /* 19-02-09
230
- * add cart button function used for php template tags and shortcodes
231
- */
232
-
233
- function wpsc_add_to_cart_button( $product_id, $replaced_shortcode = false ) {
234
- global $wpdb,$wpsc_variations;
235
- if ( $product_id > 0 ) {
236
- // grab the variation form fields here
237
- $wpsc_variations = new wpsc_variations( $product_id );
238
-
239
- $output .= "<form onsubmit='submitform(this);return false;' action='' method='post'>";
240
- /** the variation group HTML and loop */
241
- $output .= "<div class='wpsc_variation_forms'>";
242
- while (wpsc_have_variation_groups()) : wpsc_the_variation_group();
243
- $output .= "<p>";
244
- $output .= "<label for='".wpsc_vargrp_form_id()."'>".wpsc_the_vargrp_name().":</label>";
245
- /** the variation HTML and loop */
246
- $output .= "<select class='wpsc_select_variation' name='variation[".wpsc_vargrp_id()."]' id='".wpsc_vargrp_form_id()."'>";
247
- while (wpsc_have_variations()) : wpsc_the_variation();
248
- $output .= "<option value='".wpsc_the_variation_id()."' ".wpsc_the_variation_out_of_stock().">". wpsc_the_variation_name()."</option>";
249
- endwhile;
250
- $output .= "</select> ";
251
- $output .= "</p>";
252
- endwhile;
253
- $output .= "</div>";
254
- /** the variation group HTML and loop ends here */
255
-
256
-
257
- $output .= "<input type='hidden' name='wpsc_ajax_action' value='add_to_cart' />";
258
- $output .= "<input type='hidden' name='product_id' value='" . $product_id . "' />";
259
- $output .= "<input type='hidden' name='item' value='" . $product_id . "' />";
260
- if ( isset( $wpsc_theme ) && is_array( $wpsc_theme ) && ($wpsc_theme['html'] != '') ) {
261
- $output .= $wpsc_theme['html'];
262
- } else {
263
- $output .= "<input type='submit' id='product_" . $product['id'] . "_submit_button' class='wpsc_buy_button' name='Buy' value='" . __( 'Add To Cart', 'wpsc' ) . "' />";
264
- }
265
- $output .= '</form>';
266
- if ( $replaced_shortcode == true ) {
267
- return $output;
268
- } else {
269
- echo $output;
270
- }
271
- }
272
- }
273
-
274
- /**
275
- * wpsc_refresh_page_urls( $content )
276
- *
277
- * Refresh page urls when permalinks are turned on or altered
278
- *
279
- * @global object $wpdb
280
- * @param string $content
281
- * @return string
282
- */
283
- function wpsc_refresh_page_urls( $content ) {
284
- global $wpdb;
285
-
286
- $wpsc_pageurl_option['product_list_url'] = '[productspage]';
287
- $wpsc_pageurl_option['shopping_cart_url'] = '[shoppingcart]';
288
- $check_chekout = $wpdb->get_var( "SELECT `guid` FROM `{$wpdb->posts}` WHERE `post_content` LIKE '%[checkout]%' AND `post_type` NOT IN('revision') LIMIT 1" );
289
-
290
- if ( $check_chekout != null )
291
- $wpsc_pageurl_option['checkout_url'] = '[checkout]';
292
- else
293
- $wpsc_pageurl_option['checkout_url'] = '[checkout]';
294
-
295
- $wpsc_pageurl_option['transact_url'] = '[transactionresults]';
296
- $wpsc_pageurl_option['user_account_url'] = '[userlog]';
297
- $changes_made = false;
298
- foreach ( $wpsc_pageurl_option as $option_key => $page_string ) {
299
- $post_id = $wpdb->get_var( "SELECT `ID` FROM `{$wpdb->posts}` WHERE `post_type` IN('page','post') AND `post_content` LIKE '%$page_string%' AND `post_type` NOT IN('revision') LIMIT 1" );
300
- $the_new_link = get_permalink( $post_id );
301
-
302
- if ( stristr( get_option( $option_key ), "https://" ) )
303
- $the_new_link = str_replace( 'http://', "https://", $the_new_link );
304
-
305
- update_option( $option_key, $the_new_link );
306
- }
307
- return $content;
308
- }
309
-
310
- add_filter( 'mod_rewrite_rules', 'wpsc_refresh_page_urls' );
311
-
312
-
313
- /**
314
- * wpsc_obtain_the_title function, for replaacing the page title with the category or product
315
- * @return string - the new page title
316
- */
317
- function wpsc_obtain_the_title() {
318
- global $wpdb, $wp_query, $wpsc_title_data;
319
- $output = null;
320
- $category_id = null;
321
- if( !isset( $wp_query->query_vars['wpsc_product_category']) && !isset( $wp_query->query_vars['wpsc-product']))
322
- return;
323
-
324
- if ( !isset( $wp_query->query_vars['wpsc_product_category'] ) && isset($wp_query->query_vars['wpsc-product']) )
325
- $wp_query->query_vars['wpsc_product_category'] = 0;
326
-
327
-
328
- if ( isset( $wp_query->query_vars['taxonomy'] ) && 'wpsc_product_category' == $wp_query->query_vars['taxonomy'])
329
- $category_id = wpsc_get_the_category_id($wp_query->query_vars['term'],'slug');
330
-
331
- if ( $category_id > 0 ) {
332
-
333
- if ( isset( $wpsc_title_data['category'][$category_id] ) ) {
334
- $output = $wpsc_title_data['category'][$category_id];
335
- } else {
336
- $term = get_term($category_id, 'wpsc_product_category');
337
- $output = $term->name;
338
- $wpsc_title_data['category'][$category_id] = $output;
339
- }
340
- }
341
-
342
- if ( !isset( $_GET['wpsc-product'] ) )
343
- $_GET['wpsc-product'] = 0;
344
-
345
- if ( !isset( $wp_query->query_vars['wpsc-product'] ) )
346
- $wp_query->query_vars['wpsc-product'] = '';
347
-
348
- if ( isset( $wp_query->query_vars['wpsc-product'] ) || is_string( $_GET['wpsc-product'] ) ) {
349
- $product_name = $wp_query->query_vars['wpsc-product'];
350
- if ( isset( $wpsc_title_data['product'][$product_name] ) ) {
351
- $product_list = array( );
352
- $full_product_name = $wpsc_title_data['product'][$product_name];
353
- } else if ( $product_name != '' ) {
354
- $product_id = $wp_query->post->ID;
355
- $full_product_name = $wpdb->get_var( "SELECT `post_title` FROM `$wpdb->posts` WHERE `ID`='{$product_id}' LIMIT 1" );
356
- $wpsc_title_data['product'][$product_name] = $full_product_name;
357
- } else {
358
- $product_id = absint( $_GET['product_id'] );
359
- $product_name = $wpdb->get_var( "SELECT `post_title` FROM `$wpdb->posts` WHERE `ID`='{$product_id}' LIMIT 1" );
360
- $full_product_name = $wpdb->get_var( "SELECT `post_title` FROM `$wpdb->posts` WHERE `ID`='{$product_id}' LIMIT 1" );
361
- $wpsc_title_data['product'][$product_name] = $full_product_name;
362
- }
363
- $output = $full_product_name;
364
- }
365
-
366
- if ( isset( $full_product_name ) && ($full_product_name != null) )
367
- $output = htmlentities( stripslashes( $full_product_name ), ENT_QUOTES, 'UTF-8' );
368
- $seperator = ' | ';
369
- $seperator = apply_filters('wpsc_the_wp_title_seperator' , $seperator);
370
- return $output.$seperator;
371
- }
372
-
373
- function wpsc_obtain_the_description() {
374
- global $wpdb, $wp_query, $wpsc_title_data;
375
- $output = null;
376
-
377
- if ( is_numeric( $wp_query->query_vars['category_id'] ) ) {
378
- $category_id = $wp_query->query_vars['category_id'];
379
- } else if ( $_GET['category'] ) {
380
- $category_id = absint( $_GET['category'] );
381
- }
382
-
383
- if ( is_numeric( $category_id ) ) {
384
- $output = wpsc_get_categorymeta( $category_id, 'description' );
385
- }
386
-
387
-
388
- if ( is_numeric( $_GET['product_id'] ) ) {
389
- $product_id = absint( $_GET['product_id'] );
390
- $output = $wpdb->get_var( "SELECT `post_content` FROM `" . $wpdb->posts . "` WHERE `id`='{$product_id}' LIMIT 1" );
391
- }
392
- return $output;
393
- }
394
-
395
- function wpsc_replace_wp_title( $input ) {
396
- global $wpdb, $wp_query;
397
- $output = wpsc_obtain_the_title();
398
- if ( $output != null ) {
399
- return $output;
400
- }
401
- return $input;
402
- }
403
-
404
- function wpsc_replace_bloginfo_title( $input, $show ) {
405
- global $wpdb, $wp_query;
406
- if ( $show == 'description' ) {
407
- $output = wpsc_obtain_the_title();
408
- if ( $output != null ) {
409
- return $output;
410
- }
411
- }
412
- return $input;
413
- }
414
-
415
- if ( get_option( 'wpsc_replace_page_title' ) == 1 ) {
416
-
417
- add_filter( 'wp_title', 'wpsc_replace_wp_title', 10, 2 );
418
- }
419
- ?>
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * WP eCommerce display functions
5
+ *
6
+ * These are functions for the wp-eCommerce themngine, template tags and shortcodes
7
+ *
8
+ * @package wp-e-commerce
9
+ * @since 3.7
10
+ */
11
+
12
+ /**
13
+ * wpsc buy now button code products function
14
+ * Sorry about the ugly code, this is just to get the functionality back, buy now will soon be overhauled, and this function will then be completely different
15
+ * @return string - html displaying one or more products
16
+ */
17
+ function wpsc_buy_now_button( $product_id, $replaced_shortcode = false ) {
18
+ global $wpdb, $wpsc_query, $wpsc_cart, $wp_query;
19
+ $product = get_post( $product_id );
20
+ $supported_gateways = array('wpsc_merchant_paypal_standard','paypal_multiple');
21
+ $selected_gateways = get_option( 'custom_gateway_options' );
22
+ if ( in_array( 'wpsc_merchant_paypal_standard', (array)$selected_gateways ) ) {
23
+ if ( $product_id > 0 ) {
24
+ $post_meta = get_post_meta( $product_id, '_wpsc_product_metadata', true );
25
+ $shipping = $post_meta['shipping']['local'];
26
+ $org_price = get_post_meta( $product_id, '_wpsc_price', true );
27
+ $special_price = get_post_meta( $product_id, '_wpsc_special_price', true );
28
+ $price = (int)$org_price - (int)$special_price;
29
+ if ( wpsc_uses_shipping ( ) ) {
30
+ $handling = get_option( 'base_local_shipping' );
31
+ } else {
32
+ $handling = $shipping;
33
+ }
34
+ $output .= "<form onsubmit='log_paypal_buynow(this)' target='paypal' action='" . get_option( 'paypal_multiple_url' ) . "' method='post' />
35
+ <input type='hidden' name='business' value='" . get_option( 'paypal_multiple_business' ) . "' />
36
+ <input type='hidden' name='cmd' value='_xclick' />
37
+ <input type='hidden' name='item_name' value='" . $product->post_title . "' />
38
+ <input type='hidden' id='item_number' name='item_number' value='" . $product_id . "' />
39
+ <input type='hidden' id='amount' name='amount' value='" . ($price) . "' />
40
+ <input type='hidden' id='unit' name='unit' value='" . $price . "' />
41
+ <input type='hidden' id='shipping' name='ship11' value='" . $shipping . "' />
42
+ <input type='hidden' name='handling' value='" . $handling . "' />
43
+ <input type='hidden' name='currency_code' value='" . get_option( 'paypal_curcode' ) . "' />";
44
+ if ( get_option( 'multi_add' ) == 1 ) {
45
+ $output .="<label for='quantity'>" . __( 'Quantity', 'wpsc' ) . "</label>";
46
+ $output .="<input type='text' size='4' id='quantity' name='quantity' value='' /><br />";
47
+ } else {
48
+ $output .="<input type='hidden' name='undefined_quantity' value='0' />";
49
+ }
50
+ $output .="<input type='image' name='submit' border='0' src='https://www.paypal.com/en_US/i/btn/btn_buynow_LG.gif' alt='PayPal - The safer, easier way to pay online' />
51
+ <img alt='' border='0' width='1' height='1' src='https://www.paypal.com/en_US/i/scr/pixel.gif' />
52
+ </form>\n\r";
53
+ }
54
+ }
55
+ if ( $replaced_shortcode == true ) {
56
+ return $output;
57
+ } else {
58
+ echo $output;
59
+ }
60
+ }
61
+
62
+ function wpsc_also_bought( $product_id ) {
63
+ /*
64
+ * Displays products that were bought aling with the product defined by $product_id
65
+ * most of it scarcely needs describing
66
+ */
67
+ global $wpdb;
68
+
69
+ if ( get_option( 'wpsc_also_bought' ) == 0 ) {
70
+ //returns nothing if this is off
71
+ return '';
72
+ }
73
+
74
+
75
+ // to be made customiseable in a future release
76
+ $also_bought_limit = 3;
77
+ $element_widths = 96;
78
+ $image_display_height = 96;
79
+ $image_display_width = 96;
80
+
81
+ $output = '';
82
+ $also_bought = $wpdb->get_results( "SELECT `" . $wpdb->posts . "`.* FROM `" . WPSC_TABLE_ALSO_BOUGHT . "`, `" . $wpdb->posts . "` WHERE `selected_product`='" . $product_id . "' AND `" . WPSC_TABLE_ALSO_BOUGHT . "`.`associated_product` = `" . $wpdb->posts . "`.`id` AND `" . $wpdb->posts . "`.`post_status` IN('publish','protected') ORDER BY `" . WPSC_TABLE_ALSO_BOUGHT . "`.`quantity` DESC LIMIT $also_bought_limit", ARRAY_A );
83
+ if ( count( $also_bought ) > 0 ) {
84
+ $output .= "<h2 class='prodtitles wpsc_also_bought' >" . __( 'People who bought this item also bought', 'wpsc' ) . "</h2>";
85
+ $output .= "<div class='wpsc_also_bought'>";
86
+ foreach ( (array)$also_bought as $also_bought_data ) {
87
+ $output .= "<div class='wpsc_also_bought_item' style='width: " . $element_widths . "px;'>";
88
+ if ( get_option( 'show_thumbnails' ) == 1 ) {
89
+ if ( $also_bought_data['image'] != null ) {
90
+ $output .= "<a href='" . get_permalink($also_bought_data['ID']) . "' class='preview_link' rel='" . str_replace( " ", "_", get_the_title($also_bought_data['ID']) ) . "'>";
91
+ $image_path = "index.php?productid=" . $also_bought_data['ID'] . "&amp;width=" . $image_display_width . "&amp;height=" . $image_display_height . "";
92
+
93
+ $output .= "<img src='$image_path' id='product_image_" . $also_bought_data['ID'] . "' class='product_image' style='margin-top: " . $margin_top . "px'/>";
94
+ $output .= "</a>";
95
+ } else {
96
+ if ( get_option( 'product_image_width' ) != '' ) {
97
+ $output .= "<img src='" . WPSC_CORE_IMAGES_URL . "/no-image-uploaded.gif' title='" . get_the_title($also_bought_data['ID']) . "' alt='" . $also_bought_data['name'] . "' width='$image_display_height' height='$image_display_height' id='product_image_" . $also_bought_data['ID'] . "' class='product_image' />";
98
+ } else {
99
+ $output .= "<img src='" . WPSC_CORE_IMAGES_URL . "/no-image-uploaded.gif' title='" . get_the_title($also_bought_data['ID']) . "' alt='" . htmlentities( stripslashes( get_the_title($also_bought_data['ID']) ), ENT_QUOTES, 'UTF-8' ) . "' id='product_image_" . $also_bought_data['ID'] . "' class='product_image' />";
100
+ }
101
+ }
102
+ }
103
+
104
+ $output .= "<a class='wpsc_product_name' href='" . get_permalink($also_bought_data['ID']) . "'>" . get_the_title($also_bought_data['ID']) . "</a>";
105
+ $price = get_product_meta($also_bought_data['ID'], 'price', true);
106
+ $special_price = get_product_meta($also_bought_data['ID'], 'special_price', true);
107
+ if(!empty($special_price)){
108
+ $output .= '<span style="text-decoration: line-through;">' . wpsc_currency_display( $price ) . '</span>';
109
+ $output .= wpsc_currency_display( $special_price );
110
+ } else {
111
+ $output .= wpsc_currency_display( $price );
112
+ }
113
+ $output .= "</div>";
114
+ }
115
+ $output .= "</div>";
116
+ $output .= "<br clear='all' />";
117
+ }
118
+ return $output;
119
+ }
120
+
121
+ function fancy_notifications() {
122
+ global $wpdb;
123
+ $output = "";
124
+ if ( get_option( 'fancy_notifications' ) == 1 ) {
125
+ $output = "";
126
+ $output .= "<div id='fancy_notification'>\n\r";
127
+ $output .= " <div id='loading_animation'>\n\r";
128
+ $output .= '<img id="fancy_notificationimage" title="Loading" alt="Loading" src="' . WPSC_CORE_IMAGES_URL . '/indicator.gif" />' . __( 'Updating', 'wpsc' ) . "...\n\r";
129
+ $output .= " </div>\n\r";
130
+ $output .= " <div id='fancy_notification_content'>\n\r";
131
+ $output .= " </div>\n\r";
132
+ $output .= "</div>\n\r";
133
+ }
134
+
135
+ return $output;
136
+ }
137
+ function wpsc_fancy_notifications(){
138
+ echo fancy_notifications();
139
+ }
140
+ add_action( 'wpsc_theme_footer', 'wpsc_fancy_notifications' );
141
+
142
+ function fancy_notification_content( $cart_messages ) {
143
+ global $wpdb;
144
+ $siteurl = get_option( 'siteurl' );
145
+ foreach ( (array)$cart_messages as $cart_message ) {
146
+ $output .= "<span>" . $cart_message . "</span><br />";
147
+ }
148
+ $output .= "<a href='" . get_option( 'shopping_cart_url' ) . "' class='go_to_checkout'>" . __( 'Go to Checkout', 'wpsc' ) . "</a>";
149
+ $output .= "<a href='#' onclick='jQuery(\"#fancy_notification\").css(\"display\", \"none\"); return false;' class='continue_shopping'>" . __( 'Continue Shopping', 'wpsc' ) . "</a>";
150
+ return $output;
151
+ }
152
+
153
+ /*
154
+ * wpsc product url function, gets the URL of a product,
155
+ * Deprecated, all parameters past the first unused. use get_permalink
156
+ */
157
+
158
+ function wpsc_product_url( $product_id, $category_id = null, $escape = true ) {
159
+ global $wpdb, $wp_rewrite, $wp_query;
160
+ $post = get_post($product_id);
161
+ if ( isset($post->post_parent) && $post->post_parent > 0) {
162
+ return get_permalink($post->post_parent);
163
+ } else {
164
+ return get_permalink($product_id);
165
+ }
166
+ }
167
+
168
+ function external_link( $product_id ) {
169
+ global $wpdb;
170
+ $link = get_product_meta( $product_id, 'external_link', true );
171
+ if ( !stristr( $link, 'http://' ) ) {
172
+ $link = 'http://' . $link;
173
+ }
174
+ $target = wpsc_product_external_link_target( $product_id );
175
+ $output .= "<input class='wpsc_buy_button' type='button' value='" . wpsc_product_external_link_text( $product_id, __( 'Buy Now', 'wpsc' ) ) . "' onclick='return gotoexternallink(\"$link\", \"$target\")'>";
176
+ return $output;
177
+ }
178
+
179
+ // displays error messages if the category setup is odd in some way
180
+ // needs to be in a function because there are at least three places where this code must be used.
181
+ function wpsc_odd_category_setup() {
182
+ get_currentuserinfo();
183
+ global $userdata;
184
+ $output = '';
185
+ if ( ($userdata->wp_capabilities['administrator'] == 1) || ($userdata->user_level >= 9) ) {
186
+ if ( get_option( 'wpsc_default_category' ) == 1 ) {
187
+ $output = "<p>" . __( 'You are using the example product group as your default group and it has no products in it, you should set the default group to something else, you can do so from your Shop Settings page.', 'wpsc' ) . "</p>";
188
+ } else {
189
+ $output = "<p>" . __( 'This group is set as your default product group, you should either add some items to it or switch your default product group to one that does contain items.', 'wpsc' ) . "</p>";
190
+ }
191
+ }
192
+ return $output;
193
+ }
194
+
195
+ function wpsc_product_image_html( $image_name, $product_id ) {
196
+ global $wpdb, $wp_query;
197
+ if ( is_numeric( $wp_query->query_vars['product_category'] ) ) {
198
+ $category_id = (int)$wp_query->query_vars['product_category'];
199
+ } else if ( is_numeric( $_GET['category'] ) ) {
200
+ $category_id = (int)$_GET['category'];
201
+ } else {
202
+ $category_id = (int)get_option( 'wpsc_default_category' );
203
+ }
204
+
205
+ $product['height'] = get_product_meta( $id, 'thumbnail_height' );
206
+ $product['width'] = get_product_meta( $id, 'thumbnail_width' );
207
+
208
+
209
+ $use_thumbnail_image = 'false';
210
+ if ( ($product['height'] > $category['height']) || ($product['width'] > $category['width']) ) {
211
+ $use_thumbnail_image = 'true';
212
+ }
213
+
214
+ if ( $category_id > 0 ) {
215
+ $category = $wpdb->get_row( "SELECT `image_height` AS `height`, `image_width` AS `width` FROM `" . WPSC_TABLE_PRODUCT_CATEGORIES . "` WHERE `id` IN ('{$category_id}') LIMIT 1", ARRAY_A );
216
+ }
217
+ // if there is a height, width, and imagePNG function
218
+ if ( ($category['height'] != null) && ($category['width'] != null) && (function_exists( 'ImagePNG' )) ) {
219
+ $image_path = "index.php?productid=" . $product_id . "&amp;thumbnail=" . $use_thumbnail_image . "&amp;width=" . $category['width'] . "&amp;height=" . $category['height'] . "";
220
+ } else {
221
+ $image_path = WPSC_THUMBNAIL_URL . $image_name;
222
+ if ( is_ssl ( ) ) {
223
+ $image_path = str_replace( "http://", "https://", $image_path );
224
+ }
225
+ }
226
+ return $image_path;
227
+ }
228
+
229
+ /* 19-02-09
230
+ * add cart button function used for php template tags and shortcodes
231
+ */
232
+
233
+ function wpsc_add_to_cart_button( $product_id, $replaced_shortcode = false ) {
234
+ global $wpdb,$wpsc_variations;
235
+ if ( $product_id > 0 ) {
236
+ // grab the variation form fields here
237
+ $wpsc_variations = new wpsc_variations( $product_id );
238
+
239
+ $output .= "<form onsubmit='submitform(this);return false;' action='' method='post'>";
240
+ /** the variation group HTML and loop */
241
+ $output .= "<div class='wpsc_variation_forms'>";
242
+ while (wpsc_have_variation_groups()) : wpsc_the_variation_group();
243
+ $output .= "<p>";
244
+ $output .= "<label for='".wpsc_vargrp_form_id()."'>".wpsc_the_vargrp_name().":</label>";
245
+ /** the variation HTML and loop */
246
+ $output .= "<select class='wpsc_select_variation' name='variation[".wpsc_vargrp_id()."]' id='".wpsc_vargrp_form_id()."'>";
247
+ while (wpsc_have_variations()) : wpsc_the_variation();
248
+ $output .= "<option value='".wpsc_the_variation_id()."' ".wpsc_the_variation_out_of_stock().">". wpsc_the_variation_name()."</option>";
249
+ endwhile;
250
+ $output .= "</select> ";
251
+ $output .= "</p>";
252
+ endwhile;
253
+ $output .= "</div>";
254
+ /** the variation group HTML and loop ends here */
255
+
256
+
257
+ $output .= "<input type='hidden' name='wpsc_ajax_action' value='add_to_cart' />";
258
+ $output .= "<input type='hidden' name='product_id' value='" . $product_id . "' />";
259
+ $output .= "<input type='hidden' name='item' value='" . $product_id . "' />";
260
+ if ( isset( $wpsc_theme ) && is_array( $wpsc_theme ) && ($wpsc_theme['html'] != '') ) {
261
+ $output .= $wpsc_theme['html'];
262
+ } else {
263
+ $output .= "<input type='submit' id='product_" . $product['id'] . "_submit_button' class='wpsc_buy_button' name='Buy' value='" . __( 'Add To Cart', 'wpsc' ) . "' />";
264
+ }
265
+ $output .= '</form>';
266
+ if ( $replaced_shortcode == true ) {
267
+ return $output;
268
+ } else {
269
+ echo $output;
270
+ }
271
+ }
272
+ }
273
+
274
+ /**
275
+ * wpsc_refresh_page_urls( $content )
276
+ *
277
+ * Refresh page urls when permalinks are turned on or altered
278
+ *
279
+ * @global object $wpdb
280
+ * @param string $content
281
+ * @return string
282
+ */
283
+ function wpsc_refresh_page_urls( $content ) {
284
+ global $wpdb;
285
+
286
+ $wpsc_pageurl_option['product_list_url'] = '[productspage]';
287
+ $wpsc_pageurl_option['shopping_cart_url'] = '[shoppingcart]';
288
+ $check_chekout = $wpdb->get_var( "SELECT `guid` FROM `{$wpdb->posts}` WHERE `post_content` LIKE '%[checkout]%' AND `post_type` NOT IN('revision') LIMIT 1" );
289
+
290
+ if ( $check_chekout != null )
291
+ $wpsc_pageurl_option['checkout_url'] = '[checkout]';
292
+ else
293
+ $wpsc_pageurl_option['checkout_url'] = '[checkout]';
294
+
295
+ $wpsc_pageurl_option['transact_url'] = '[transactionresults]';
296
+ $wpsc_pageurl_option['user_account_url'] = '[userlog]';
297
+ $changes_made = false;
298
+ foreach ( $wpsc_pageurl_option as $option_key => $page_string ) {
299
+ $post_id = $wpdb->get_var( "SELECT `ID` FROM `{$wpdb->posts}` WHERE `post_type` IN('page','post') AND `post_content` LIKE '%$page_string%' AND `post_type` NOT IN('revision') LIMIT 1" );
300
+ $the_new_link = get_permalink( $post_id );
301
+
302
+ if ( stristr( get_option( $option_key ), "https://" ) )
303
+ $the_new_link = str_replace( 'http://', "https://", $the_new_link );
304
+
305
+ update_option( $option_key, $the_new_link );
306
+ }
307
+ return $content;
308
+ }
309
+
310
+ add_filter( 'mod_rewrite_rules', 'wpsc_refresh_page_urls' );
311
+
312
+
313
+ /**
314
+ * wpsc_obtain_the_title function, for replaacing the page title with the category or product
315
+ * @return string - the new page title
316
+ */
317
+ function wpsc_obtain_the_title() {
318
+ global $wpdb, $wp_query, $wpsc_title_data;
319
+ $output = null;
320
+ $category_id = null;
321
+ if( !isset( $wp_query->query_vars['wpsc_product_category']) && !isset( $wp_query->query_vars['wpsc-product']))
322
+ return;
323
+
324
+ if ( !isset( $wp_query->query_vars['wpsc_product_category'] ) && isset($wp_query->query_vars['wpsc-product']) )
325
+ $wp_query->query_vars['wpsc_product_category'] = 0;
326
+
327
+
328
+ if ( isset( $wp_query->query_vars['taxonomy'] ) && 'wpsc_product_category' == $wp_query->query_vars['taxonomy'])
329
+ $category_id = wpsc_get_the_category_id($wp_query->query_vars['term'],'slug');
330
+
331
+ if ( $category_id > 0 ) {
332
+
333
+ if ( isset( $wpsc_title_data['category'][$category_id] ) ) {
334
+ $output = $wpsc_title_data['category'][$category_id];
335
+ } else {
336
+ $term = get_term($category_id, 'wpsc_product_category');
337
+ $output = $term->name;
338
+ $wpsc_title_data['category'][$category_id] = $output;
339
+ }
340
+ }
341
+
342
+ if ( !isset( $_GET['wpsc-product'] ) )
343
+ $_GET['wpsc-product'] = 0;
344
+
345
+ if ( !isset( $wp_query->query_vars['wpsc-product'] ) )
346
+ $wp_query->query_vars['wpsc-product'] = '';
347
+
348
+ if ( isset( $wp_query->query_vars['wpsc-product'] ) || is_string( $_GET['wpsc-product'] ) ) {
349
+ $product_name = $wp_query->query_vars['wpsc-product'];
350
+ if ( isset( $wpsc_title_data['product'][$product_name] ) ) {
351
+ $product_list = array( );
352
+ $full_product_name = $wpsc_title_data['product'][$product_name];
353
+ } else if ( $product_name != '' ) {
354
+ $product_id = $wp_query->post->ID;
355
+ $full_product_name = $wpdb->get_var( "SELECT `post_title` FROM `$wpdb->posts` WHERE `ID`='{$product_id}' LIMIT 1" );
356
+ $wpsc_title_data['product'][$product_name] = $full_product_name;
357
+ } else {
358
+ if(isset($_REQUEST['product_id'])){
359
+ $product_id = absint( $_REQUEST['product_id'] );
360
+ $product_name = $wpdb->get_var( "SELECT `post_title` FROM `$wpdb->posts` WHERE `ID`='{$product_id}' LIMIT 1" );
361
+ $full_product_name = $wpdb->get_var( "SELECT `post_title` FROM `$wpdb->posts` WHERE `ID`='{$product_id}' LIMIT 1" );
362
+ $wpsc_title_data['product'][$product_name] = $full_product_name;
363
+ }else{
364
+ //This has to exist, otherwise we would have bailed earlier.
365
+ $category = $wp_query->query_vars['wpsc_product_category'];
366
+ $cat_term = get_term_by('slug',$wp_query->query_vars['wpsc_product_category'], 'wpsc_product_category');
367
+ $full_product_name = $cat_term->name;
368
+ }
369
+ }
370
+ $output = $full_product_name;
371
+ }
372
+
373
+ if ( isset( $full_product_name ) && ($full_product_name != null) )
374
+ $output = htmlentities( stripslashes( $full_product_name ), ENT_QUOTES, 'UTF-8' );
375
+ $seperator = ' | ';
376
+ $seperator = apply_filters('wpsc_the_wp_title_seperator' , $seperator);
377
+ return $output.$seperator;
378
+ }
379
+
380
+ function wpsc_obtain_the_description() {
381
+ global $wpdb, $wp_query, $wpsc_title_data;
382
+ $output = null;
383
+
384
+ if ( is_numeric( $wp_query->query_vars['category_id'] ) ) {
385
+ $category_id = $wp_query->query_vars['category_id'];
386
+ } else if ( $_GET['category'] ) {
387
+ $category_id = absint( $_GET['category'] );
388
+ }
389
+
390
+ if ( is_numeric( $category_id ) ) {
391
+ $output = wpsc_get_categorymeta( $category_id, 'description' );
392
+ }
393
+
394
+
395
+ if ( is_numeric( $_GET['product_id'] ) ) {
396
+ $product_id = absint( $_GET['product_id'] );
397
+ $output = $wpdb->get_var( "SELECT `post_content` FROM `" . $wpdb->posts . "` WHERE `id`='{$product_id}' LIMIT 1" );
398
+ }
399
+ return $output;
400
+ }
401
+
402
+ function wpsc_replace_wp_title( $input ) {
403
+ global $wpdb, $wp_query;
404
+ $output = wpsc_obtain_the_title();
405
+ if ( $output != null ) {
406
+ return $output;
407
+ }
408
+ return $input;
409
+ }
410
+
411
+ function wpsc_replace_bloginfo_title( $input, $show ) {
412
+ global $wpdb, $wp_query;
413
+ if ( $show == 'description' ) {
414
+ $output = wpsc_obtain_the_title();
415
+ if ( $output != null ) {
416
+ return $output;
417
+ }
418
+ }
419
+ return $input;
420
+ }
421
+
422
+ if ( get_option( 'wpsc_replace_page_title' ) == 1 ) {
423
+
424
+ add_filter( 'wp_title', 'wpsc_replace_wp_title', 10, 2 );
425
+ }
426
+ ?>
wpsc-includes/form-display.functions.php CHANGED
@@ -3,6 +3,7 @@
3
  function nzshpcrt_country_list( $selected_country = null ) {
4
  global $wpdb;
5
 
 
6
 
7
  if ( $selected_country == null )
8
  $output = "<option value=''>" . __( 'Please select', 'wpsc' ) . "</option>";
@@ -38,10 +39,10 @@ function nzshpcrt_region_list( $selected_country = null, $selected_region = null
38
  $selected = "";
39
  }
40
 
41
- $output .= "<option value='" . $region['id'] . "' $selected>" . $region['name'] . "</option>\n\r";
42
  }
43
  } else {
44
- $output .= "<select name='base_region' disabled='true'><option value=''>None</option></select>\n\r";
45
  }
46
 
47
  return $output;
@@ -49,8 +50,7 @@ function nzshpcrt_region_list( $selected_country = null, $selected_region = null
49
 
50
  function nzshpcrt_form_field_list( $selected_field = null ) {
51
  global $wpdb;
52
- $output = "";
53
- $output .= "<option value=''>Please choose</option>";
54
  $form_sql = "SELECT * FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `active` = '1';";
55
  $form_data = $wpdb->get_results( $form_sql, ARRAY_A );
56
 
@@ -192,9 +192,9 @@ function wpsc_select_product_file( $product_id = null ) {
192
 
193
  $output .= "</div>";
194
  $output .= "<div class='" . ((is_numeric( $product_id )) ? "edit_" : "") . "select_product_handle'><div></div></div>";
195
- $output .= "<script type='text/javascript'>\n\r";
196
- $output .= "var select_min_height = " . (25 * 3) . ";\n\r";
197
- $output .= "var select_max_height = " . (25 * ($num + 1)) . ";\n\r";
198
  $output .= "</script>";
199
 
200
  return $output;
@@ -205,26 +205,26 @@ function wpsc_select_variation_file( $file_id, $variation_ids, $variation_combin
205
  $file_list = wpsc_uploaded_files();
206
  $unique_id_component = ((int)$variation_combination_id) . "_" . str_replace( ",", "_", $variation_ids );
207
 
208
- $output = "<div class='variation_settings_contents'>\n\r";
209
- $output .= "<span class='admin_product_notes select_product_note '>" . __( 'Choose a downloadable file for this variation', 'wpsc' ) . "</span>\n\r";
210
- $output .= "<div class='select_variation_file'>\n\r";
211
 
212
  $num = 0;
213
- $output .= " <p>\n\r";
214
- $output .= " <input type='radio' name='variation_priceandstock[{$variation_ids}][file]' value='0' id='select_variation_file{$unique_id_component}_{$num}' " . ((!is_numeric( $file_id ) || ($file_id < 1)) ? "checked='checked'" : "") . " />\n\r";
215
- $output .= " <label for='select_variation_file{$unique_id_component}_{$num}'>" . __( 'No Product', 'wpsc' ) . "</label>\n\r";
216
- $output .= " </p>\n\r";
217
 
218
  foreach ( (array)$file_list as $file ) {
219
  $num++;
220
- $output .= " <p>\n\r";
221
- $output .= " <input type='radio' name='variation_priceandstock[{$variation_ids}][file]' value='" . $file['file_id'] . "' id='select_variation_file{$unique_id_component}_{$num}' " . ((is_numeric( $file_id ) && ($file_id == $file['file_id'])) ? "checked='checked'" : "") . " />\n\r";
222
- $output .= " <label for='select_variation_file{$unique_id_component}_{$num}'>" . $file['display_filename'] . "</label>\n\r";
223
- $output .= " </p>\n\r";
224
  }
225
 
226
- $output .= "</div>\n\r";
227
- $output .= "</div>\n\r";
228
 
229
  return $output;
230
  }
@@ -243,7 +243,7 @@ function wpsc_list_product_themes( $theme_name = null ) {
243
  }
244
  }
245
 
246
- $output .= "<select name='wpsc_options[wpsc_selected_theme]'>\n\r";
247
 
248
  foreach ( (array)$theme as $theme_file => $theme_data ) {
249
  if ( stristr( $theme_file, $selected_theme ) ) {
@@ -251,10 +251,10 @@ function wpsc_list_product_themes( $theme_name = null ) {
251
  } else {
252
  $selected = "";
253
  }
254
- $output .= "<option value='$theme_file' $selected>" . $theme_data['Name'] . "</option>\n\r";
255
  }
256
 
257
- $output .= "</select>\n\r";
258
 
259
  return $output;
260
  }
3
  function nzshpcrt_country_list( $selected_country = null ) {
4
  global $wpdb;
5
 
6
+ $output = '';
7
 
8
  if ( $selected_country == null )
9
  $output = "<option value=''>" . __( 'Please select', 'wpsc' ) . "</option>";
39
  $selected = "";
40
  }
41
 
42
+ $output .= "<option value='" . $region['id'] . "' $selected>" . $region['name'] . "</option>\r\n";
43
  }
44
  } else {
45
+ $output .= "<option value=''>None</option>\r\n";
46
  }
47
 
48
  return $output;
50
 
51
  function nzshpcrt_form_field_list( $selected_field = null ) {
52
  global $wpdb;
53
+ $output = "<option value=''>Please choose</option>";
 
54
  $form_sql = "SELECT * FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `active` = '1';";
55
  $form_data = $wpdb->get_results( $form_sql, ARRAY_A );
56
 
192
 
193
  $output .= "</div>";
194
  $output .= "<div class='" . ((is_numeric( $product_id )) ? "edit_" : "") . "select_product_handle'><div></div></div>";
195
+ $output .= "<script type='text/javascript'>\r\n";
196
+ $output .= "var select_min_height = " . (25 * 3) . ";\r\n";
197
+ $output .= "var select_max_height = " . (25 * ($num + 1)) . ";\r\n";
198
  $output .= "</script>";
199
 
200
  return $output;
205
  $file_list = wpsc_uploaded_files();
206
  $unique_id_component = ((int)$variation_combination_id) . "_" . str_replace( ",", "_", $variation_ids );
207
 
208
+ $output = "<div class='variation_settings_contents'>\r\n";
209
+ $output .= "<span class='admin_product_notes select_product_note '>" . __( 'Choose a downloadable file for this variation', 'wpsc' ) . "</span>\r\n";
210
+ $output .= "<div class='select_variation_file'>\r\n";
211
 
212
  $num = 0;
213
+ $output .= " <p>\r\n";
214
+ $output .= " <input type='radio' name='variation_priceandstock[{$variation_ids}][file]' value='0' id='select_variation_file{$unique_id_component}_{$num}' " . ((!is_numeric( $file_id ) || ($file_id < 1)) ? "checked='checked'" : "") . " />\r\n";
215
+ $output .= " <label for='select_variation_file{$unique_id_component}_{$num}'>" . __( 'No Product', 'wpsc' ) . "</label>\r\n";
216
+ $output .= " </p>\r\n";
217
 
218
  foreach ( (array)$file_list as $file ) {
219
  $num++;
220
+ $output .= " <p>\r\n";
221
+ $output .= " <input type='radio' name='variation_priceandstock[{$variation_ids}][file]' value='" . $file['file_id'] . "' id='select_variation_file{$unique_id_component}_{$num}' " . ((is_numeric( $file_id ) && ($file_id == $file['file_id'])) ? "checked='checked'" : "") . " />\r\n";
222
+ $output .= " <label for='select_variation_file{$unique_id_component}_{$num}'>" . $file['display_filename'] . "</label>\r\n";
223
+ $output .= " </p>\r\n";
224
  }
225
 
226
+ $output .= "</div>\r\n";
227
+ $output .= "</div>\r\n";
228
 
229
  return $output;
230
  }
243
  }
244
  }
245
 
246
+ $output .= "<select name='wpsc_options[wpsc_selected_theme]'>\r\n";
247
 
248
  foreach ( (array)$theme as $theme_file => $theme_data ) {
249
  if ( stristr( $theme_file, $selected_theme ) ) {
251
  } else {
252
  $selected = "";
253
  }
254
+ $output .= "<option value='$theme_file' $selected>" . $theme_data['Name'] . "</option>\r\n";
255
  }
256
 
257
+ $output .= "</select>\r\n";
258
 
259
  return $output;
260
  }
wpsc-includes/fpdf/font/desktop.ini CHANGED
@@ -1,4 +1,4 @@
1
- [ViewState]
2
- Mode=
3
- Vid=
4
- FolderType=NotSpecified
1
+ [ViewState]
2
+ Mode=
3
+ Vid=
4
+ FolderType=NotSpecified
wpsc-includes/merchant.class.php CHANGED
@@ -162,7 +162,7 @@ class wpsc_merchant {
162
 
163
  if ( count( $address_data['shipping'] ) < 1 )
164
  $address_data['shipping'] = $address_data['billing'];
165
- if( !empty($purchase_logs['discount_value']) )
166
  $has_discount = true;
167
  else
168
  $has_discount = false;
@@ -183,7 +183,7 @@ class wpsc_merchant {
183
  'base_shipping' => $purchase_logs['base_shipping'],
184
  'total_price' => $purchase_logs['totalprice'],
185
  'session_id' => $purchase_logs['sessionid'],
186
- 'transaction_id' => $purchase_logs['transaction_id'], // Transaction ID might not be set yet
187
  'email_address' => $email_address,
188
  'billing_address' => $address_data['billing'],
189
  'shipping_address' => $address_data['shipping'],
@@ -304,6 +304,28 @@ class wpsc_merchant {
304
  $wpdb->query( "UPDATE `" . WPSC_TABLE_PURCHASE_LOGS . "` SET `processed` = '" . absint( $status ) . "', `transactid` ='{$transaction_id}' WHERE `id` = " . absint( $this->purchase_id ) . " LIMIT 1" );
305
  }
306
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
307
  /**
308
  * construct_value_array gateway specific data array, extended in merchant files
309
  * @abstract
162
 
163
  if ( count( $address_data['shipping'] ) < 1 )
164
  $address_data['shipping'] = $address_data['billing'];
165
+ if( !empty($purchase_logs['discount_value']) && $purchase_logs['discount_value'] > 0 )
166
  $has_discount = true;
167
  else
168
  $has_discount = false;
183
  'base_shipping' => $purchase_logs['base_shipping'],
184
  'total_price' => $purchase_logs['totalprice'],
185
  'session_id' => $purchase_logs['sessionid'],
186
+ 'transaction_id' => $purchase_logs['transactid'], // Transaction ID might not be set yet
187
  'email_address' => $email_address,
188
  'billing_address' => $address_data['billing'],
189
  'shipping_address' => $address_data['shipping'],
304
  $wpdb->query( "UPDATE `" . WPSC_TABLE_PURCHASE_LOGS . "` SET `processed` = '" . absint( $status ) . "', `transactid` ='{$transaction_id}' WHERE `id` = " . absint( $this->purchase_id ) . " LIMIT 1" );
305
  }
306
 
307
+ /**
308
+ * set_authcode, generaly speaking a payment gateway gives you an authcode to be able to refer back to the transaction
309
+ * if an authcode already exsits, you can either append another (2931932839|29391839482) or replace depending on the $append flag
310
+ * @param string $authcode
311
+ * @param bool $append
312
+ * @return bool result
313
+ */
314
+ function set_authcode($authcode, $append = false){
315
+ global $wpdb;
316
+
317
+ $wpdb->show_errors();
318
+ if($append === false){
319
+ return $wpdb->update(WPSC_TABLE_PURCHASE_LOGS,array('authcode'=>$authcode), array('id'=>absint($this->purchase_id)),array('%s'), array('%d'));
320
+ }else{
321
+ $current_authcode = $wpdb->get_var( "SELECT authcode FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `sessionid` = " . absint( $this->session_id ) . " LIMIT 1" );
322
+ //this is overwrite
323
+ $new_authcode = isset($current_authcode) ? $current_authcode.'|' :'';
324
+ $new_authcode .= $authcode;
325
+ return $wpdb->update(WPSC_TABLE_PURCHASE_LOGS,array('authcode'=>$new_authcode), array('id'=>absint($this->purchase_id)),array('%s'), array('%d'));
326
+ }
327
+ }
328
+
329
  /**
330
  * construct_value_array gateway specific data array, extended in merchant files
331
  * @abstract
wpsc-includes/misc.functions.php CHANGED
@@ -123,7 +123,7 @@ function wpsc_post_title_seo( $title ) {
123
  return stripslashes( $title );
124
  }
125
 
126
- add_filter( 'single_post_title', 'wpsc_post_title_seo' );
127
 
128
  /**
129
  * WPSC canonical URL function
@@ -132,29 +132,21 @@ add_filter( 'single_post_title', 'wpsc_post_title_seo' );
132
  * @param int product id
133
  * @return bool true or false
134
  */
135
- function wpsc_change_canonical_url( $url ) {
136
- global $wpdb, $wpsc_query;
137
- if ( $wpsc_query->is_single == true ) {
138
- if ( !is_numeric( $_GET['product_id'] ) ) {
139
- $product_id = $wpdb->get_var( "SELECT `product_id` FROM `" . WPSC_TABLE_PRODUCTMETA . "` WHERE `meta_key` IN ( 'url_name' ) AND `meta_value` IN ( '" . $wpsc_query->query_vars['product_url_name'] . "' ) ORDER BY `product_id` DESC LIMIT 1" );
140
- } else {
141
- $product_id = absint( $_GET['product_id'] );
142
- }
143
-
144
- $url = wpsc_product_url( $product_id );
145
- } else {
146
- if ( isset( $wpsc_query->query_vars['category_id'] ) && ($wpsc_query->query_vars['category_id'] > 0) ) {
147
- $url = wpsc_category_url( $wpsc_query->query_vars['category_id'] );
148
-
149
- if ( $wpsc_query->query_vars['page'] > 1 ) {
150
- if ( get_option( 'permalink_structure' ) ) {
151
- $url .= "page/{$wpsc_query->query_vars['page']}/";
152
- } else {
153
- $url .= "&amp;page_number={$wpsc_query->query_vars['page']}";
154
- $url = html_entity_decode( $url );
155
  }
 
156
  }
157
  }
 
158
  }
159
  return $url;
160
  }
@@ -173,7 +165,7 @@ function wpsc_canonical_url() {
173
  add_action( 'wp_head', 'wpsc_insert_canonical_url' );
174
  }
175
  }
176
-
177
  // check for all in one SEO pack and the is_static_front_page function
178
  if ( is_callable( array( "All_in_One_SEO_Pack", 'is_static_front_page' ) ) ) {
179
 
123
  return stripslashes( $title );
124
  }
125
 
126
+ //add_filter( 'single_post_title', 'wpsc_post_title_seo' );
127
 
128
  /**
129
  * WPSC canonical URL function
132
  * @param int product id
133
  * @return bool true or false
134
  */
135
+ function wpsc_change_canonical_url( $url = '' ) {
136
+ global $wpdb, $wp_query, $wpsc_page_titles;
137
+
138
+ if ( $wp_query->is_single == true && 'wpsc-product' == $wp_query->query_vars['post_type']) {
139
+ $categories = wp_get_object_terms( $wp_query->post->ID , 'wpsc_product_category' );
140
+ if(count($categories) > 1){
141
+ foreach($categories as $category){
142
+ if(isset($wp_query->query_vars['wpsc_product_category']) && $category->slug == $wp_query->query_vars['wpsc_product_category'])continue;
143
+ if(isset($wp_query->query_vars['wpsc_product_category']) && $category->slug != $wp_query->query_vars['wpsc_product_category']){
144
+ return home_url($wpsc_page_titles['products'].'/'.$category->slug.'/'.$wp_query->query_vars['wpsc-product']);
 
 
 
 
 
 
 
 
 
 
145
  }
146
+
147
  }
148
  }
149
+
150
  }
151
  return $url;
152
  }
165
  add_action( 'wp_head', 'wpsc_insert_canonical_url' );
166
  }
167
  }
168
+ add_action( 'template_redirect', 'wpsc_canonical_url' );
169
  // check for all in one SEO pack and the is_static_front_page function
170
  if ( is_callable( array( "All_in_One_SEO_Pack", 'is_static_front_page' ) ) ) {
171
 
wpsc-includes/processing.functions.php CHANGED
@@ -1,392 +1,391 @@
1
- <?php
2
-
3
- /**
4
- * wpsc_currency_display function.
5
- *
6
- * @access public
7
- * @param mixed $price_in
8
- * @param mixed $args
9
- * @return void
10
- */
11
- function wpsc_currency_display( $price_in, $args = null ) {
12
- global $wpdb, $wpsc_currency_data;
13
- $currency_code = '';
14
- $args = apply_filters( 'wpsc_toggle_display_currency_code', $args );
15
- $query = shortcode_atts( array(
16
- 'display_currency_symbol' => true,
17
- 'display_decimal_point' => true,
18
- 'display_currency_code' => false,
19
- 'display_as_html' => true
20
- ), $args );
21
-
22
- // No decimal point, no decimals
23
- if ( false == $query['display_decimal_point'] )
24
- $decimals = 0;
25
- else
26
- $decimals = 2; // default is 2
27
-
28
- $decimals = apply_filters('wpsc_modify_decimals' , $decimals);
29
- if('' == get_option('wpsc_decimal_separator'))
30
- $decimal_separator = '.';
31
- else
32
- $decimal_separator = get_option('wpsc_decimal_separator');
33
-
34
- if('' == get_option('wpsc_thousands_separator'))
35
- $thousands_separator = '.';
36
- else
37
- $thousands_separator = get_option('wpsc_thousands_separator');
38
-
39
- // Format the price for output
40
- $price_out = number_format( (double)$price_in, $decimals, $decimal_separator, $thousands_separator );
41
-
42
- // Get currency settings
43
- $currency_type = get_option( 'currency_type' );
44
-
45
- // Load data if it is not set
46
- if ( count( $wpsc_currency_data ) < 3 )
47
- $wpsc_currency_data = $wpdb->get_row( "SELECT `symbol`, `symbol_html`, `code` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `id` = '" . $currency_type . "' LIMIT 1", ARRAY_A );
48
-
49
- // Figure out the currency code
50
- if ( true == $query['display_currency_code'] )
51
- $currency_code = $wpsc_currency_data['code'];
52
-
53
- // Figure out the currency sign
54
- if ( true == $query['display_currency_symbol'] ) {
55
- if ( !empty( $wpsc_currency_data['symbol'] ) ) {
56
- if ( false == $query['display_as_html'] ) {
57
- $currency_sign = $wpsc_currency_data['symbol_html'];
58
- } else {
59
- $currency_sign = html_entity_decode($wpsc_currency_data['symbol']);
60
- }
61
- } else {
62
- $currency_sign = $wpsc_currency_data['code'];
63
- $currency_code = '';
64
- }
65
- }
66
-
67
- $currency_sign_location = get_option( 'currency_sign_location' );
68
-
69
- // Rejig the currency sign location
70
- switch ( $currency_sign_location ) {
71
- case 1:
72
- $format_string = '%3$s%1$s%2$s';
73
- break;
74
-
75
- case 2:
76
- $format_string = '%3$s %1$s%2$s';
77
- break;
78
-
79
- case 4:
80
- $format_string = '%1$s%2$s %3$s';
81
- break;
82
-
83
- case 3:
84
- default:
85
- $format_string = '%1$s %2$s%3$s';
86
- break;
87
- }
88
-
89
- // Compile the output
90
- $output = sprintf( $format_string, $currency_code, $currency_sign, $price_out );
91
-
92
- if ( false == $query['display_as_html'] ) {
93
- $output = "".$output."";
94
- } else {
95
- $output = "<span class='pricedisplay'>".$output."</span>";
96
- }
97
-
98
- // Return results
99
- return apply_filters( 'wpsc_currency_display', $output );
100
- }
101
-
102
- /**
103
- * wpsc_decrement_claimed_stock method
104
- *
105
- * @param float a price
106
- * @return string a price with a currency sign
107
- */
108
- function wpsc_decrement_claimed_stock($purchase_log_id) {
109
- global $wpdb;
110
- $all_claimed_stock = $wpdb->get_results($wpdb->prepare("SELECT * FROM `".WPSC_TABLE_CLAIMED_STOCK."` WHERE `cart_id` IN('%s') AND `cart_submitted` IN('1')", $purchase_log_id), ARRAY_A);
111
-
112
- foreach((array)$all_claimed_stock as $claimed_stock) {
113
- // for people to have claimed stock, it must have been available to take, no need to look at the existing stock, just subtract from it
114
- // If this is ever wrong, and you get negative stock, do not fix it here, go find the real cause of the problem
115
- $product_id = absint($claimed_stock['product_id']);
116
- $product = get_post($product_id);
117
- $current_stock = get_post_meta($product_id, '_wpsc_stock', true);
118
- $remaining_stock = $current_stock - $claimed_stock['stock_claimed'];
119
- update_post_meta($product_id, '_wpsc_stock', $remaining_stock);
120
-
121
- $remaining_stock = $wpdb->get_row($sql_query, ARRAY_A);
122
- if($remaining_stock == 0 && get_product_meta($product_id,'unpublish_oos',true) == 1){
123
- wp_mail(get_option('admin_email'), $product->post_title . __(' is out of stock', 'wpsc'), __('Remaining stock of ', 'wpsc') . $product->post_title . __(' is 0. Product was unpublished.', 'wpsc'));
124
- $wpdb->query("UPDATE `".$wpdb->posts."` SET `post_status` = 'draft' WHERE `ID` = '{$product_id}'");
125
- }
126
- }
127
- $wpdb->query($wpdb->prepare("DELETE FROM `".WPSC_TABLE_CLAIMED_STOCK."` WHERE `cart_id` IN ('%s')", $purchase_log_id));
128
- }
129
-
130
- /**
131
- * wpsc_get_currency_symbol
132
- * @param does not receive anything
133
- * @return returns the currency symbol used for the shop
134
- */
135
- function wpsc_get_currency_symbol(){
136
- global $wpdb;
137
- $currency_type = get_option('currency_type');
138
- $wpsc_currency_data = $wpdb->get_var("SELECT `symbol` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `id`='".$currency_type."' LIMIT 1") ;
139
- return $wpsc_currency_data;
140
- }
141
-
142
- /**
143
- * All the code below here needs commenting and looking at to see if it needs to be altered or disposed of.
144
- * Correspondingly, all the code above here has been commented, uses the wpsc prefix, and has been made for or modified to work with the object oriented cart code.
145
- */
146
-
147
- function admin_display_total_price($start_timestamp = '', $end_timestamp = '') {
148
- global $wpdb;
149
- if(($start_timestamp != '') && ($end_timestamp != '')) {
150
- $sql = "SELECT SUM(`totalprice`) FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `processed` IN (2,3,4) AND `date` BETWEEN '$start_timestamp' AND '$end_timestamp'";
151
- } else {
152
- $sql = "SELECT SUM(`totalprice`) FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `processed` IN (2,3,4) AND `date` != ''";
153
- }
154
- $total = $wpdb->get_var($sql);
155
- return $total;
156
- }
157
-
158
- function wpsc_get_mimetype($file, $check_reliability = false) {
159
- // Sometimes we need to know how useless the result from this is, hence the "check_reliability" parameter
160
- if(file_exists($file)) {
161
- $mimetype_data = wp_check_filetype($file);
162
- $mimetype = $mimetype_data['type'];
163
- $is_reliable = true;
164
- } else {
165
- $mimetype = false;
166
- $is_reliable = false;
167
- }
168
- if($check_reliability == true) {
169
- return array('mime_type' => $mimetype, 'is_reliable' => $is_reliable );
170
- } else {
171
- return $mimetype;
172
- }
173
- }
174
-
175
- function wpsc_convert_weights($weight, $unit) {
176
- if (is_array($weight)) {
177
- $weight = $weight['weight'];
178
- }
179
- switch($unit) {
180
- case "kilogram":
181
- $weight = $weight / 1000;
182
- break;
183
-
184
- case "gram":
185
- $weight = $weight;
186
- break;
187
-
188
- case "once":
189
- case "ounce":
190
- $weight = ($weight / 453.59237) * 16;
191
- break;
192
-
193
- case "pound":
194
- default:
195
- $weight = $weight / 453.59237;
196
- break;
197
- }
198
- return $weight;
199
- }
200
-
201
- function wpsc_convert_weight($in_weight, $in_unit, $out_unit = 'gram') {
202
- if (isset($weight) && is_array($weight)) {
203
- $weight = $weight['weight'];
204
- }
205
- switch($in_unit) {
206
- case "kilogram":
207
- $intermediate_weight = $in_weight * 1000;
208
- break;
209
-
210
- case "gram":
211
- $intermediate_weight = $in_weight;
212
- break;
213
-
214
- case "once":
215
- case "ounce":
216
- $intermediate_weight = ($in_weight / 16) * 453.59237;
217
- break;
218
-
219
- case "pound":
220
- default:
221
- $intermediate_weight = $in_weight * 453.59237;
222
- break;
223
- }
224
-
225
- switch($out_unit) {
226
- case "kilogram":
227
- $weight = $intermediate_weight / 1000;
228
- break;
229
-
230
- case "gram":
231
- $weight = $intermediate_weight;
232
- break;
233
-
234
- case "once":
235
- case "ounce":
236
- $weight = ($intermediate_weight / 453.59237) * 16;
237
- break;
238
-
239
- case "pound":
240
- default:
241
- $weight = $intermediate_weight / 453.59237;
242
- break;
243
- }
244
- return round($weight, 2);
245
- }
246
-
247
-
248
- function wpsc_ping() {
249
- $services = get_option('ping_sites');
250
- $services = explode("\n", $services);
251
- foreach ( (array) $services as $service ) {
252
- $service = trim($service);
253
- if($service != '' ) {
254
- wpsc_send_ping($service);
255
- }
256
- }
257
- }
258
-
259
- function wpsc_send_ping($server) {
260
- global $wp_version;
261
- $path = "";
262
- include_once(ABSPATH . WPINC . '/class-IXR.php');
263
-
264
- // using a timeout of 3 seconds should be enough to cover slow servers
265
- $client = new IXR_Client($server, ((!strlen(trim($path)) || ('/' == $path)) ? false : $path));
266
- $client->timeout = 3;
267
- $client->useragent .= ' -- WordPress/'.$wp_version;
268
-
269
- // when set to true, this outputs debug messages by itself
270
- $client->debug = false;
271
- $home = trailingslashit( get_option('product_list_url') );
272
- $rss_url = get_option('siteurl')."/index.php?rss=true&amp;action=product_list";
273
- if ( !$client->query('weblogUpdates.extendedPing', get_option('blogname'), $home, $rss_url ) ) {
274
- $client->query('weblogUpdates.ping', get_option('blogname'), $home);
275
- }
276
- }
277
-
278
-
279
- function wpsc_sanitise_keys($value) {
280
- /// Function used to cast array items to integer.
281
- return (int)$value;
282
- }
283
-
284
-
285
-
286
- /*
287
- * this function checks every product on the products page to see if it has any stock remaining
288
- * it is executed through the wpsc_product_alert filter
289
- */
290
- function wpsc_check_stock($state, $product) {
291
- global $wpdb;
292
- // if quantity is enabled and is zero
293
- $state['state'] = false;
294
- $state['messages'] = array();
295
- $out_of_stock = false;
296
- $is_parent = wpsc_product_has_children($product->ID);
297
- if(!$is_parent){
298
- $stock_count = get_product_meta($product->ID, 'stock',true);
299
- // only do anything if the quantity is limited.
300
- if(($stock_count === '0')) // otherwise, use the stock from the products list table
301
- $out_of_stock = true;
302
-
303
- if($out_of_stock === true) {
304
- $state['state'] = true;
305
- $state['messages'][] = __('This product has no available stock', 'wpsc');
306
- }
307
- }else{
308
- $no_stock = $wpdb->get_col('
309
- SELECT
310
- `pm`.`post_id`
311
- FROM
312
- `' . $wpdb->postmeta . '` `pm`
313
- JOIN
314
- `' . $wpdb->posts . '` `p`
315
- ON
316
- `pm`.`post_id` = `p`.`id`
317
- WHERE
318
- `p`.`post_type`= "wpsc-product"
319
- AND
320
- `p`.`post_parent` = ' . $product->ID . '
321
- AND
322
- `pm`.`meta_key` = "_wpsc_stock"
323
- AND
324
- `pm`.`meta_value` = "0"
325
- ');
326
- if(!empty($no_stock)){
327
- $state['state'] = true;
328
- $state['messages'][] = __('One or more of this products variations are out of stock.', 'wpsc');
329
- }
330
-
331
-
332
- }
333
- return array('state' => $state['state'], 'messages' => $state['messages']);
334
- }
335
-
336
-
337
- /*
338
- * if UPS is on, this function checks every product on the products page to see if it has a weight
339
- * it is executed through the wpsc_product_alert filter
340
- */
341
- function wpsc_check_weight($state, $product) {
342
- global $wpdb;
343
- $custom_shipping = (array)get_option('custom_shipping_options');
344
- $has_no_weight = false;
345
- $shipping_modules = array();
346
- $product_meta = get_product_meta($product->ID, 'product_metadata',true);
347
- // only do anything if UPS is on and shipping is used
348
- if(array_search('ups', $custom_shipping) !== false)
349
- $shipping_modules[] = 'UPS';
350
- if(array_search('weightrate', $custom_shipping) !== false)
351
- $shipping_modules[] = 'Weight Rate';
352
- if(array_search('usps', $custom_shipping) !== false)
353
- $shipping_modules[] = 'Weight Rate';
354
-
355
-
356
- if($product_meta['no_shipping'] != 1 && !empty($shipping_modules)) {
357
- if($product_meta['weight'] == 0) // otherwise, use the weight from the products list table
358
- $has_no_weight = true;
359
-
360
- if($has_no_weight === true) {
361
- $state['state'] = true;
362
- $state['messages'][] = implode(',',$shipping_modules). __(' does not support products without a weight set. Please either disable shipping for this product or give it a weight', 'wpsc');
363
- }
364
- }
365
- return array('state' => $state['state'], 'messages' => $state['messages']);
366
- }
367
-
368
- add_filter('wpsc_product_alert', 'wpsc_check_stock', 10, 2);
369
- add_filter('wpsc_product_alert', 'wpsc_check_weight', 10, 2);
370
-
371
-
372
-
373
- /**
374
- * WPSC Image Quality
375
- *
376
- * Returns the value to use for image quality when creating jpeg images.
377
- * By default the quality is set to 75%. It is then run through the main jpeg_quality WordPress filter
378
- * to add compatibility with other plugins that customise image quality.
379
- *
380
- * It is then run through the wpsc_jpeg_quality filter so that it is possible to override
381
- * the quality setting just for WPSC images.
382
- *
383
- * @since 3.7.6
384
- *
385
- * @param (int) $quality Optional. Image quality when creating jpeg images.
386
- * @return (int) The image quality.
387
- */
388
- function wpsc_image_quality( $quality = 75 ) {
389
- $quality = apply_filters( 'jpeg_quality', $quality );
390
- return apply_filters( 'wpsc_jpeg_quality', $quality );
391
- }
392
- ?>
1
+ <?php
2
+
3
+ /**
4
+ * wpsc_currency_display function.
5
+ *
6
+ * @access public
7
+ * @param mixed $price_in
8
+ * @param mixed $args
9
+ * @return void
10
+ */
11
+ function wpsc_currency_display( $price_in, $args = null ) {
12
+ global $wpdb, $wpsc_currency_data;
13
+ $currency_code = '';
14
+ $args = apply_filters( 'wpsc_toggle_display_currency_code', $args );
15
+ $query = shortcode_atts( array(
16
+ 'display_currency_symbol' => true,
17
+ 'display_decimal_point' => true,
18
+ 'display_currency_code' => false,
19
+ 'display_as_html' => true
20
+ ), $args );
21
+
22
+ // No decimal point, no decimals
23
+ if ( false == $query['display_decimal_point'] )
24
+ $decimals = 0;
25
+ else
26
+ $decimals = 2; // default is 2
27
+
28
+ $decimals = apply_filters('wpsc_modify_decimals' , $decimals);
29
+ if('' == get_option('wpsc_decimal_separator'))
30
+ $decimal_separator = '.';
31
+ else
32
+ $decimal_separator = get_option('wpsc_decimal_separator');
33
+
34
+ if('' == get_option('wpsc_thousands_separator'))
35
+ $thousands_separator = '.';
36
+ else
37
+ $thousands_separator = get_option('wpsc_thousands_separator');
38
+
39
+ // Format the price for output
40
+ $price_out = number_format( (double)$price_in, $decimals, $decimal_separator, $thousands_separator );
41
+
42
+ // Get currency settings
43
+ $currency_type = get_option( 'currency_type' );
44
+
45
+ // Load data if it is not set
46
+ if ( count( $wpsc_currency_data ) < 3 )
47
+ $wpsc_currency_data = $wpdb->get_row( "SELECT `symbol`, `symbol_html`, `code` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `id` = '" . $currency_type . "' LIMIT 1", ARRAY_A );
48
+
49
+ // Figure out the currency code
50
+ if ( $query['display_currency_code'] )
51
+ $currency_code = $wpsc_currency_data['code'];
52
+
53
+ // Figure out the currency sign
54
+ if ( $query['display_currency_symbol'] ) {
55
+ if ( !empty( $wpsc_currency_data['symbol'] ) ) {
56
+ if ( $query['display_as_html'] ) {
57
+ $currency_sign = html_entity_decode($wpsc_currency_data['symbol']);
58
+ } else {
59
+ $currency_sign = $wpsc_currency_data['symbol'];
60
+ }
61
+ } else {
62
+ $currency_sign = $wpsc_currency_data['code'];
63
+ $currency_code = '';
64
+ }
65
+ }
66
+
67
+ $currency_sign_location = get_option( 'currency_sign_location' );
68
+
69
+ // Rejig the currency sign location
70
+ switch ( $currency_sign_location ) {
71
+ case 1:
72
+ $format_string = '%3$s%1$s%2$s';
73
+ break;
74
+
75
+ case 2:
76
+ $format_string = '%3$s %1$s%2$s';
77
+ break;
78
+
79
+ case 4:
80
+ $format_string = '%1$s%2$s %3$s';
81
+ break;
82
+
83
+ case 3:
84
+ default:
85
+ $format_string = '%1$s %2$s %3$s';
86
+ break;
87
+ }
88
+ // Compile the output
89
+ $output = sprintf( $format_string, $currency_code, $currency_sign, $price_out );
90
+
91
+ if ( !$query['display_as_html'] ) {
92
+ $output = "".$output."";
93
+ } else {
94
+ $output = "<span class='pricedisplay'>".$output."</span>";
95
+ }
96
+
97
+ // Return results
98
+ return apply_filters( 'wpsc_currency_display', $output );
99
+ }
100
+
101
+ /**
102
+ * wpsc_decrement_claimed_stock method
103
+ *
104
+ * @param float a price
105
+ * @return string a price with a currency sign
106
+ */
107
+ function wpsc_decrement_claimed_stock($purchase_log_id) {
108
+ global $wpdb;
109
+ $all_claimed_stock = $wpdb->get_results($wpdb->prepare("SELECT * FROM `".WPSC_TABLE_CLAIMED_STOCK."` WHERE `cart_id` IN('%s') AND `cart_submitted` IN('1')", $purchase_log_id), ARRAY_A);
110
+
111
+ foreach((array)$all_claimed_stock as $claimed_stock) {
112
+ // for people to have claimed stock, it must have been available to take, no need to look at the existing stock, just subtract from it
113
+ // If this is ever wrong, and you get negative stock, do not fix it here, go find the real cause of the problem
114
+ $product_id = absint($claimed_stock['product_id']);
115
+ $product = get_post($product_id);
116
+ $current_stock = get_post_meta($product_id, '_wpsc_stock', true);
117
+ $remaining_stock = $current_stock - $claimed_stock['stock_claimed'];
118
+ update_post_meta($product_id, '_wpsc_stock', $remaining_stock);
119
+
120
+ $remaining_stock = $wpdb->get_row($sql_query, ARRAY_A);
121
+ if($remaining_stock == 0 && get_product_meta($product_id,'unpublish_oos',true) == 1){
122
+ wp_mail(get_option('admin_email'), $product->post_title . __(' is out of stock', 'wpsc'), __('Remaining stock of ', 'wpsc') . $product->post_title . __(' is 0. Product was unpublished.', 'wpsc'));
123
+ $wpdb->query("UPDATE `".$wpdb->posts."` SET `post_status` = 'draft' WHERE `ID` = '{$product_id}'");
124
+ }
125
+ }
126
+ $wpdb->query($wpdb->prepare("DELETE FROM `".WPSC_TABLE_CLAIMED_STOCK."` WHERE `cart_id` IN ('%s')", $purchase_log_id));
127
+ }
128
+
129
+ /**
130
+ * wpsc_get_currency_symbol
131
+ * @param does not receive anything
132
+ * @return returns the currency symbol used for the shop
133
+ */
134
+ function wpsc_get_currency_symbol(){
135
+ global $wpdb;
136
+ $currency_type = get_option('currency_type');
137
+ $wpsc_currency_data = $wpdb->get_var("SELECT `symbol` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `id`='".$currency_type."' LIMIT 1") ;
138
+ return $wpsc_currency_data;
139
+ }
140
+
141
+ /**
142
+ * All the code below here needs commenting and looking at to see if it needs to be altered or disposed of.
143
+ * Correspondingly, all the code above here has been commented, uses the wpsc prefix, and has been made for or modified to work with the object oriented cart code.
144
+ */
145
+
146
+ function admin_display_total_price($start_timestamp = '', $end_timestamp = '') {
147
+ global $wpdb;
148
+ if(($start_timestamp != '') && ($end_timestamp != '')) {
149
+ $sql = "SELECT SUM(`totalprice`) FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `processed` IN (2,3,4) AND `date` BETWEEN '$start_timestamp' AND '$end_timestamp'";
150
+ } else {
151
+ $sql = "SELECT SUM(`totalprice`) FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `processed` IN (2,3,4) AND `date` != ''";
152
+ }
153
+ $total = $wpdb->get_var($sql);
154
+ return $total;
155
+ }
156
+
157
+ function wpsc_get_mimetype($file, $check_reliability = false) {
158
+ // Sometimes we need to know how useless the result from this is, hence the "check_reliability" parameter
159
+ if(file_exists($file)) {
160
+ $mimetype_data = wp_check_filetype($file);
161
+ $mimetype = $mimetype_data['type'];
162
+ $is_reliable = true;
163
+ } else {
164
+ $mimetype = false;
165
+ $is_reliable = false;
166
+ }
167
+ if($check_reliability == true) {
168
+ return array('mime_type' => $mimetype, 'is_reliable' => $is_reliable );
169
+ } else {
170
+ return $mimetype;
171
+ }
172
+ }
173
+
174
+ function wpsc_convert_weights($weight, $unit) {
175
+ if (is_array($weight)) {
176
+ $weight = $weight['weight'];
177
+ }
178
+ switch($unit) {
179
+ case "kilogram":
180
+ $weight = $weight / 1000;
181
+ break;
182
+
183
+ case "gram":
184
+ $weight = $weight;
185
+ break;
186
+
187
+ case "once":
188
+ case "ounce":
189
+ $weight = ($weight / 453.59237) * 16;
190
+ break;
191
+
192
+ case "pound":
193
+ default:
194
+ $weight = $weight / 453.59237;
195
+ break;
196
+ }
197
+ return $weight;
198
+ }
199
+
200
+ function wpsc_convert_weight($in_weight, $in_unit, $out_unit = 'gram') {
201
+ if (isset($weight) && is_array($weight)) {
202
+ $weight = $weight['weight'];
203
+ }
204
+ switch($in_unit) {
205
+ case "kilogram":
206
+ $intermediate_weight = $in_weight * 1000;
207
+ break;
208
+
209
+ case "gram":
210
+ $intermediate_weight = $in_weight;
211
+ break;
212
+
213
+ case "once":
214
+ case "ounce":
215
+ $intermediate_weight = ($in_weight / 16) * 453.59237;
216
+ break;
217
+
218
+ case "pound":
219
+ default:
220
+ $intermediate_weight = $in_weight * 453.59237;
221
+ break;
222
+ }
223
+
224
+ switch($out_unit) {
225
+ case "kilogram":
226
+ $weight = $intermediate_weight / 1000;
227
+ break;
228
+
229
+ case "gram":
230
+ $weight = $intermediate_weight;
231
+ break;
232
+
233
+ case "once":
234
+ case "ounce":
235
+ $weight = ($intermediate_weight / 453.59237) * 16;
236
+ break;
237
+
238
+ case "pound":
239
+ default:
240
+ $weight = $intermediate_weight / 453.59237;
241
+ break;
242
+ }
243
+ return round($weight, 2);
244
+ }
245
+
246
+
247
+ function wpsc_ping() {
248
+ $services = get_option('ping_sites');
249
+ $services = explode("\n", $services);
250
+ foreach ( (array) $services as $service ) {
251
+ $service = trim($service);
252
+ if($service != '' ) {
253
+ wpsc_send_ping($service);
254
+ }
255
+ }
256
+ }
257
+
258
+ function wpsc_send_ping($server) {
259
+ global $wp_version;
260
+ $path = "";
261
+ include_once(ABSPATH . WPINC . '/class-IXR.php');
262
+
263
+ // using a timeout of 3 seconds should be enough to cover slow servers
264
+ $client = new IXR_Client($server, ((!strlen(trim($path)) || ('/' == $path)) ? false : $path));
265
+ $client->timeout = 3;
266
+ $client->useragent .= ' -- WordPress/'.$wp_version;
267
+
268
+ // when set to true, this outputs debug messages by itself
269
+ $client->debug = false;
270
+ $home = trailingslashit( get_option('product_list_url') );
271
+ $rss_url = get_option('siteurl')."/index.php?rss=true&amp;action=product_list";
272
+ if ( !$client->query('weblogUpdates.extendedPing', get_option('blogname'), $home, $rss_url ) ) {
273
+ $client->query('weblogUpdates.ping', get_option('blogname'), $home);
274
+ }
275
+ }
276
+
277
+
278
+ function wpsc_sanitise_keys($value) {
279
+ /// Function used to cast array items to integer.
280
+ return (int)$value;
281
+ }
282
+
283
+
284
+
285
+ /*
286
+ * this function checks every product on the products page to see if it has any stock remaining
287
+ * it is executed through the wpsc_product_alert filter
288
+ */
289
+ function wpsc_check_stock($state, $product) {
290
+ global $wpdb;
291
+ // if quantity is enabled and is zero
292
+ $state['state'] = false;
293
+ $state['messages'] = array();
294
+ $out_of_stock = false;
295
+ $is_parent = wpsc_product_has_children( $product->ID );
296
+ if( !$is_parent ){
297
+ $stock_count = get_product_meta( $product->ID, 'stock',true );
298
+ // only do anything if the quantity is limited.
299
+ if( $stock_count === '0' ) // otherwise, use the stock from the products list table
300
+ $out_of_stock = true;
301
+
302
+ if( $out_of_stock === true ) {
303
+ $state['state'] = true;
304
+ $state['messages'][] = __( 'This product has no available stock', 'wpsc' );
305
+ }
306
+ }else{
307
+ $no_stock = $wpdb->get_col('
308
+ SELECT
309
+ `pm`.`post_id`
310
+ FROM
311
+ `' . $wpdb->postmeta . '` `pm`
312
+ JOIN
313
+ `' . $wpdb->posts . '` `p`
314
+ ON
315
+ `pm`.`post_id` = `p`.`id`
316
+ WHERE
317
+ `p`.`post_type`= "wpsc-product"
318
+ AND
319
+ `p`.`post_parent` = ' . $product->ID . '
320
+ AND
321
+ `pm`.`meta_key` = "_wpsc_stock"
322
+ AND
323
+ `pm`.`meta_value` = "0"
324
+ ');
325
+ if( !empty( $no_stock ) ){
326
+ $state['state'] = true;
327
+ $state['messages'][] = __('One or more of this products variations are out of stock.', 'wpsc');
328
+ }
329
+
330
+
331
+ }
332
+ return array( 'state' => $state['state'], 'messages' => $state['messages'] );
333
+ }
334
+
335
+
336
+ /*
337
+ * if UPS is on, this function checks every product on the products page to see if it has a weight
338
+ * it is executed through the wpsc_product_alert filter
339
+ */
340
+ function wpsc_check_weight($state, $product) {
341
+ global $wpdb;
342
+ $custom_shipping = (array)get_option( 'custom_shipping_options' );
343
+ $has_no_weight = false;
344
+ $shipping_modules = array();
345
+ $product_meta = get_product_meta( $product->ID, 'product_metadata',true );
346
+ if(wpsc_product_has_children($product->ID)) return $state;
347
+ // only do anything if UPS is on and shipping is used
348
+ if( array_search( 'ups', $custom_shipping ) !== false )
349
+ $shipping_modules[] = 'UPS';
350
+ if( array_search( 'weightrate', $custom_shipping ) !== false )
351
+ $shipping_modules[] = 'Weight Rate';
352
+ if( array_search( 'usps', $custom_shipping ) !== false )
353
+ $shipping_modules[] = 'Weight Rate';
354
+
355
+ if( $product_meta['no_shipping'] != 1 && !empty( $shipping_modules ) ) {
356
+ if( $product_meta['weight'] == 0 ) // otherwise, use the weight from the products list table
357
+ $has_no_weight = true;
358
+
359
+ if( $has_no_weight === true ) {
360
+ $state['state'] = true;
361
+ $state['messages'][] = implode( ',',$shipping_modules ). __(' does not support products without a weight set. Please either disable shipping for this product or give it a weight', 'wpsc' );
362
+ }
363
+ }
364
+ return array( 'state' => $state['state'], 'messages' => $state['messages'] );
365
+ }
366
+
367
+ add_filter('wpsc_product_alert', 'wpsc_check_stock', 10, 2);
368
+ add_filter('wpsc_product_alert', 'wpsc_check_weight', 10, 2);
369
+
370
+
371
+
372
+ /**
373
+ * WPSC Image Quality
374
+ *
375
+ * Returns the value to use for image quality when creating jpeg images.
376
+ * By default the quality is set to 75%. It is then run through the main jpeg_quality WordPress filter
377
+ * to add compatibility with other plugins that customise image quality.
378
+ *
379
+ * It is then run through the wpsc_jpeg_quality filter so that it is possible to override
380
+ * the quality setting just for WPSC images.
381
+ *
382
+ * @since 3.7.6
383
+ *
384
+ * @param (int) $quality Optional. Image quality when creating jpeg images.
385
+ * @return (int) The image quality.
386
+ */
387
+ function wpsc_image_quality( $quality = 75 ) {
388
+ $quality = apply_filters( 'jpeg_quality', $quality );
389
+ return apply_filters( 'wpsc_jpeg_quality', $quality );
390
+ }
391
+ ?>
 
wpsc-includes/product-template.php CHANGED
@@ -1,1705 +1,1754 @@
1
- <?php
2
- /**
3
- * WP eCommerce product functions and product utility function.
4
- *
5
- * This is the wpsc equivalent of post-template.php
6
- *
7
- * @package wp-e-commerce
8
- * @since 3.8
9
- * @subpackage wpsc-template-functions
10
- */
11
-
12
- function wpsc_has_pages_top(){
13
- if(wpsc_has_pages() && ((get_option('wpsc_page_number_position') == 1) || (get_option('wpsc_page_number_position') == 3)))
14
- return true;
15
- else
16
- return false;
17
- }
18
- function wpsc_has_pages_bottom(){
19
- if(wpsc_has_pages() && ((get_option('wpsc_page_number_position') == 2) || (get_option('wpsc_page_number_position') == 3)))
20
- return true;
21
- else
22
- return false;
23
- }
24
-
25
- /**
26
- * Used in wpsc_pagination to generate the links in pagination
27
- * @access public
28
- *
29
- * @since 3.8
30
- * @param $page int
31
- * @return $output string, url
32
- */
33
- function wpsc_a_page_url($page=null) {
34
- global $wp_query;
35
- $output = '';
36
- $curpage = $wp_query->query_vars['paged'];
37
- if($page != '')
38
- $wp_query->query_vars['paged'] = $page;
39
-
40
- if($wp_query->is_single === true) {
41
- $wp_query->query_vars['paged'] = $curpage;
42
- return wpsc_product_url($wp_query->post->ID);
43
- } else {
44
- if( 1 < $wp_query->query_vars['paged']) {
45
- if(get_option('permalink_structure'))
46
- $output .= "paged/{$wp_query->query_vars['paged']}/";
47
- else
48
- $output = add_query_arg('paged', '', $output);
49
-
50
- }
51
- return $output;
52
- }
53
- }
54
- /**
55
- * wpsc_pagination generates and returns the urls for pagination
56
- * @access public
57
- *
58
- * @since 3.8
59
- * @param $totalpages (INT) Number of pages,
60
- * @param $per_page (INT) Number of products per page
61
- * @param $current_page (INT) Current Product page number
62
- * @param $page_link (STRING) URL of Page
63
- *
64
- * @return
65
- */
66
- function wpsc_pagination($totalpages = '', $per_page = '', $current_page = '', $page_link = '') {
67
- global $wp_query,$wpsc_query;
68
- $num_paged_links = 4; //amount of links to show on either side of current page
69
-
70
- $additional_links = '';
71
-
72
- //additional links, items per page and products order
73
- if( get_option('permalink_structure') != '' ){
74
- $additional_links_separator = '?';
75
- }else{
76
- $additional_links_separator = '&';
77
- }
78
- if( !empty( $_GET['items_per_page'] ) ){
79
- $additional_links = $additional_links_separator . 'items_per_page=' . $_GET['items_per_page'];
80
- $additional_links_separator = '&';
81
- }
82
- if( !empty( $_GET['product_order'] ) )
83
- $additional_links .= $additional_links_separator . 'product_order=' . $_GET['product_order'];
84
-
85
- $additional_links = apply_filters('wpsc_pagination_additional_links', $additional_links);
86
- //end of additional links
87
-
88
- if(empty($totalpages)){
89
- if(!isset($wpsc_query->query_vars['taxonomy']) && 'wpsc-product' == $wp_query->query_vars['post_type'])
90
- $totalpages = $wp_query->max_num_pages;
91
- else
92
- $totalpages = $wpsc_query->max_num_pages;
93
- }
94
- if(empty($per_page))
95
- $per_page = get_option('wpsc_products_per_page');
96
-
97
- $current_page = get_query_var('paged');
98
- if($current_page == 0)
99
- $current_page = 1;
100
-
101
- if(empty($page_link))
102
- $page_link = wpsc_a_page_url();
103
-
104
- if(!get_option('permalink_structure')) {
105
- $category = '?';
106
- if(isset($wpsc_query->query_vars['wpsc_product_category']))
107
- $category = '?wpsc_product_category='.$wp_query->query_vars['wpsc_product_category'];
108
- if(isset($wpsc_query->query_vars['wpsc_product_category']) && is_string($wpsc_query->query_vars['wpsc_product_category'])){
109
-
110
- $page_link = get_option('blogurl').$category.'&amp;paged';
111
- }else{
112
- $page_link = get_option('product_list_url').$category.'&amp;paged';
113
- }
114
-
115
- $separator = '=';
116
- }else{
117
- // This will need changing when we get product categories sorted
118
- if(isset($wpsc_query->query_vars['term']))
119
- $page_link = get_option('product_list_url').$wpsc_query->query_vars['term'].'/';
120
- else
121
- $page_link = get_option('product_list_url');
122
-
123
- $separator = 'page/';
124
- }
125
-
126
- // If there's only one page, return now and don't bother
127
- if($totalpages == 1)
128
- return;
129
- // Pagination Prefix
130
- $output = __('Pages: ','wpsc');
131
-
132
- // Should we show the FIRST PAGE link?
133
- if($current_page > 1)
134
- $output .= "<a href=\"". $page_link . $additional_links . "\" title=\"First Page\"> &laquo; First </a>";
135
-
136
- // Should we show the PREVIOUS PAGE link?
137
- if($current_page > 2) {
138
- $previous_page = $current_page - 1;
139
- $output .= " <a href=\"". $page_link .$separator. $previous_page . $additional_links . "\" title=\"Previous Page\"> &lt; Previous </a>";
140
- }
141
- $i =$current_page - $num_paged_links;
142
- $count = 1;
143
- if($i <= 0) $i =1;
144
- while($i < $current_page){
145
- if($count <= $num_paged_links){
146
- $output .= " <a href=\"". $page_link .$separator. $i . $additional_links . "\" title=\"Page ".$i." \"> ".$i." </a>";
147
- }
148
- $i++;
149
- $count++;
150
- }
151
- // Current Page Number
152
- if($current_page > 0)
153
- $output .= "<span class='current'> ". $current_page ." </span>";
154
-
155
- //Links after Current Page
156
- $i = $current_page + $num_paged_links;
157
- $count = 1;
158
- if($current_page < $totalpages){
159
- while(($i) > $current_page){
160
- if($count < $num_paged_links && ($count+$current_page) <= $totalpages){
161
- $output .= " <a href=\"". $page_link .$separator. ($count+$current_page) .$additional_links . "\" title=\"Page ".($count+$current_page)." \"> ".($count+$current_page)." </a>";
162
- $i++;
163
- }else{
164
- break;
165
- }
166
- $count ++;
167
- }
168
- }
169
-
170
- if($current_page < $totalpages) {
171
- $next_page = $current_page + 1;
172
- $output .= "<a href=\"". $page_link .$separator. $next_page . $additional_links . "\" title=\"Next Page\"> Next &gt; </a>";
173
- }
174
- // Should we show the LAST PAGE link?
175
- if($current_page < $totalpages) {
176
- $output .= " <a href=\"". $page_link .$separator. $totalpages . $additional_links . "\" title=\"Last Page\"> Last &raquo; </a>";
177
- }
178
- // Return the output.
179
- echo $output;
180
- }
181
-
182
- /**
183
- * wpsc_show_stock_availability
184
- *
185
- * Checks to see whether stock symbols need to be shown
186
- * @return boolean - true is the option has been checked false otherwise
187
- */
188
- function wpsc_show_stock_availability(){
189
- if( get_option('list_view_quantity') == 1 )
190
- return true;
191
- else
192
- return false;
193
- }
194
-
195
- /**
196
- * wpsc product image function
197
- *
198
- * if no parameters are passed, the image is not resized, otherwise it is resized to the specified dimensions
199
- *
200
- * @param integer attachment_ID
201
- * @param integer width
202
- * @param integer height
203
- * @return string - the product image URL, or the URL of the resized version
204
- */
205
- function wpsc_product_image( $attachment_id = 0, $width = null, $height = null ) {
206
-
207
- // Do some dancing around the image size
208
- if ( ( ( $width >= 10 ) && ( $height >= 10 ) ) && ( ( $width <= 1024 ) && ( $height <= 1024 ) ) )
209
- $intermediate_size = "wpsc-{$width}x{$height}";
210
-
211
- // Get image url if we have enough info
212
- if ( ( $attachment_id > 0 ) && ( !empty( $intermediate_size ) ) ) {
213
-
214
- // Get all the required information about the attachment
215
- $uploads = wp_upload_dir();
216
- $image_meta = get_post_meta( $attachment_id, '' );
217
- $file_path = get_attached_file( $attachment_id );
218
-
219
- // Clean up the meta array
220
- foreach ( $image_meta as $meta_name => $meta_value )
221
- $image_meta[$meta_name] = maybe_unserialize( array_pop( $meta_value ) );
222
-
223
-
224
- $attachment_metadata = $image_meta['_wp_attachment_metadata'];
225
- // Determine if we already have an image of this size
226
- if ( isset( $attachment_metadata['sizes'] ) && (count( $attachment_metadata['sizes'] ) > 0) && ( isset( $attachment_metadata['sizes'][$intermediate_size] ) ) ) {
227
- $intermediate_image_data = image_get_intermediate_size( $attachment_id, $intermediate_size );
228
- $image_url = $intermediate_image_data['url'];
229
- } else {
230
- $image_url = "index.php?wpsc_action=scale_image&amp;attachment_id={$attachment_id}&amp;width=$width&amp;height=$height";
231
- }
232
-
233
- // Not enough info so attempt to fallback
234
- } else {
235
-
236
- if ( !empty( $attachment_id ) ) {
237
- $image_url = "index.php?wpsc_action=scale_image&amp;attachment_id={$attachment_id}&amp;width=$width&amp;height=$height";
238
- } else {
239
- $image_url = false;
240
- }
241
-
242
- }
243
- if(empty($image_url) && !empty($file_path)){
244
- $image_meta = get_post_meta( $attachment_id, '_wp_attached_file' );
245
- $image_url = $uploads['baseurl'].'/'.$image_meta[0];
246
- }
247
- // @todo - put fallback 'No image' catcher here
248
- return apply_filters( 'wpsc_product_image', $image_url );
249
- }
250
-
251
- function wpsc_product_no_image_fallback( $image_url = '' ) {
252
- if ( !empty( $image_url ) )
253
- return $image_url;
254
- else
255
- return apply_filters( 'wpsc_product_noimage', WPSC_CORE_THEME_URL . 'wpsc-images/noimage.png' );
256
- }
257
- add_filter( 'wpsc_product_image', 'wpsc_product_no_image_fallback' );
258
-
259
-
260
- /**
261
- * wpsc show pnp function
262
- * @return boolean - true if display_pnp is 1 false otherwise
263
- */
264
- function wpsc_show_pnp(){
265
- global $post;
266
- if(1 == get_option('display_pnp'))
267
- return true;
268
- return false;
269
- }
270
-
271
- /**
272
- * wpsc product price function
273
- * @return string - the product price
274
- */
275
- function wpsc_the_product_price( $no_decimals = false ) {
276
- global $wpsc_query, $wpsc_variations, $wpdb;
277
- if ( count( $wpsc_variations->first_variations ) > 0 ) {
278
- //select the variation ID with lowest price
279
- $product_id = $wpdb->get_var('SELECT `posts`.`id` FROM ' . $wpdb->posts . ' `posts` JOIN ' . $wpdb->postmeta . ' `postmeta` ON `posts`.`id` = `postmeta`.`post_id` WHERE `posts`.`post_parent` = ' . get_the_ID() . ' AND `posts`.`post_type` = "wpsc-product" AND `posts`.`post_status` = "inherit" AND `postmeta`.`meta_key`="_wpsc_price" ORDER BY (`postmeta`.`meta_value`)+0 ASC LIMIT 1');
280
- $from = ' from ';
281
- } else {
282
- $product_id = get_the_ID();
283
- $from = '';
284
- }
285
-
286
- $full_price = get_post_meta( $product_id, '_wpsc_price', true );
287
- $special_price = get_post_meta( $product_id, '_wpsc_special_price', true );
288
- $price = $full_price;
289
-
290
- if ( ($full_price > $special_price) && ($special_price > 0) )
291
- $price = $special_price;
292
-
293
- if ( $no_decimals == true )
294
- $price = array_shift( explode( ".", $price ) );
295
-
296
- $args = array(
297
- 'display_as_html' => false,
298
- 'display_decimal_point' => !$no_decimals
299
- );
300
- $output = wpsc_currency_display( $price,$args );
301
- //if product has variations - add 'from'
302
- $from = apply_filters('wpsc_product_variation_text',$from);
303
- if ( count( $wpsc_variations->first_variations ) > 0 && !empty($from))
304
- $output = sprintf(__(' from %s', 'wpsc'), $output);
305
-
306
- return $output;
307
- }
308
-
309
- function wpsc_calculate_price( $product_id, $variations = null, $special = true ) {
310
- global $wpdb;
311
- $p_id = $product_id;
312
- if ( count( $variations ) > 0 ){
313
- if(!isset($variations) || is_array($variations) && in_array(0,$variations,true)) return;
314
- $product_id = wpsc_get_child_object_in_terms( $product_id, $variations, 'wpsc-variation' );
315
- }else if ( !$product_id )
316
- $product_id = get_the_ID();
317
-
318
- if( !$product_id && count( $variations ) > 0){
319
- $product_ids = wpsc_get_child_object_in_select_terms( $p_id, $variations, 'wpsc_variation' );
320
- $sql = "SELECT `post_id` FROM ".$wpdb->postmeta." WHERE `meta_key` = '_wpsc_stock' AND `meta_value` != '0' AND `post_id` IN (".implode(',' , $product_ids).")";
321
- $stock_available = $wpdb->get_col($sql);
322
- $sql = "SELECT `post_id` FROM ".$wpdb->postmeta." WHERE `meta_key` = '_wpsc_price' AND `post_id` IN (".implode(',',$stock_available).") ORDER BY `meta_value` ASC LIMIT 1";
323
- $product_id = $wpdb->get_var($sql);
324
- }
325
-
326
- if ( $special == true ) {
327
- $full_price = get_post_meta( $product_id, '_wpsc_price', true );
328
- $special_price = get_post_meta( $product_id, '_wpsc_special_price', true );
329
-
330
- $price = $full_price;
331
- if ( ($full_price > $special_price) && ($special_price > 0) ) {
332
- $price = $special_price;
333
- }
334
- } else {
335
- $price = get_post_meta( $product_id, '_wpsc_price', true );
336
- }
337
-
338
- return $price;
339
- }
340
-
341
- /**
342
- * wpsc display categories function
343
- * Used to determine whether to display products on the page
344
- * @return boolean - true for yes, false for no
345
- */
346
- function wpsc_display_categories() {
347
- global $wp_query;
348
- $output = false;
349
- if ( !is_numeric( get_option( 'wpsc_default_category' ) ) ) {
350
-
351
- if ( isset( $wp_query->query_vars['products'] ) )
352
- $category_id = $wp_query->query_vars['products'];
353
- else if ( isset( $_GET['products'] ) )
354
- $category_id = $_GET['products'];
355
-
356
- // if we have no categories, and no search, show the group list
357
- if ( is_numeric( get_option( 'wpsc_default_category' ) ) || (isset( $product_id ) && is_numeric( $product_id )) || (isset( $_GET['product_search'] ) && $_GET['product_search'] != '') )
358
- $output = true;
359
-
360
- if ( (get_option( 'wpsc_default_category' ) == 'all+list') || (get_option( 'wpsc_default_category' ) == 'list') )
361
- $output = true;
362
-
363
- }
364
-
365
- if ( isset( $category_id ) && $category_id > 0 )
366
- $output = false;
367
-
368
- return $output;
369
- }
370
-
371
- /**
372
- * wpsc display products function
373
- * Used to determine whether to display products on the page
374
- * @return boolean - true for yes, false for no
375
- */
376
- function wpsc_display_products() {
377
- global $post;
378
- $product_page_id = wpec_get_the_post_id_by_shortcode('[productspage]');
379
- //we have to display something, if we are not displaying categories, then we must display products
380
- $output = true;
381
- if ( wpsc_display_categories ( ) ) {
382
- if ( get_option( 'wpsc_default_category' ) == 'list' && $post->ID == $product_page_id )
383
- $output = false;
384
-
385
- if ( isset( $_GET['range'] ) || isset( $_GET['category'] ) )
386
- $output = true;
387
-
388
- }
389
- return $output;
390
- }
391
-
392
- /**
393
- * this page url function, returns the URL of this page
394
- * @return string - the URL of the current page
395
- */
396
- function wpsc_this_page_url() {
397
- global $wpsc_query, $wp_query;
398
- if ( $wpsc_query->is_single === true ) {
399
- $output = wpsc_product_url( $wp_query->post->ID );
400
- } else if ( isset( $wpsc_query->category ) && $wpsc_query->category != null ) {
401
- $output = wpsc_category_url( $wpsc_query->category );
402
- if ( $wpsc_query->query_vars['page'] > 1 ) {
403
- if ( get_option( 'permalink_structure' ) ) {
404
- $output .= "page/{$wpsc_query->query_vars['page']}/";
405
- } else {
406
- $output = add_query_arg( 'page_number', $wpsc_query->query_vars['page'], $output );
407
- }
408
- }
409
- } elseif ( isset( $id ) ) {
410
- $output = get_permalink( $id );
411
- } else {
412
- $output = get_permalink( get_the_ID() );
413
- }
414
- return $output;
415
- }
416
-
417
- /**
418
- * is single product function, determines if we are viewing a single product
419
- * @return boolean - true, or false...
420
- */
421
- function wpsc_is_single_product() {
422
- global $wp_query;
423
- if ( $wp_query->is_single === 1 )
424
- $state = true;
425
- else
426
- $state = false;
427
-
428
- return $state;
429
- }
430
-
431
- /**
432
- * category class function, categories can have a specific class, this gets that
433
- * @return string - the class of the selected category
434
- */
435
- function wpsc_category_class() {
436
- global $wpdb, $wp_query;
437
-
438
- $category_nice_name = '';
439
- if ( 'wpsc_product_category' == $wp_query->query_vars['taxonomy'] ) {
440
- $catid = wpsc_get_the_category_id($wp_query->query_vars['term'],'slug');
441
- } else {
442
- $catid = get_option( 'wpsc_default_category' );
443
- if ( $catid == 'all+list' ) {
444
- $catid = 'all';
445
- }
446
- }
447
-
448
- if ( (int)$catid > 0 ){
449
- $term = get_term($catid, 'wpsc_product_category');
450
- $category_nice_name = $term->slug;
451
- }else if ( $catid == 'all' ){
452
- $category_nice_name = 'all-categories';
453
- }
454
- return $category_nice_name;
455
- }
456
-
457
- /**
458
- * category transition function, finds the transition between categories
459
- * @return string - the class of the selected category
460
- */
461
- function wpsc_current_category_name() {
462
- global $wp_query;
463
- $term_data = get_term( $wp_query->post->term_id, 'wpsc_product_category' );
464
-
465
- return $term_data->name;
466
- }
467
-
468
- /**
469
- * category transition function, finds the transition between categories
470
- * @return string - the class of the selected category
471
- */
472
- function wpsc_category_transition() {
473
- global $wpdb, $wp_query, $wpsc_query;
474
- $current_category_id = null;
475
- $previous_category_id = null;
476
- $current_product_index = (int)$wp_query->current_post;
477
- $previous_product_index = ((int)$wp_query->current_post - 1);
478
-
479
- if ( $previous_product_index >= 0 && isset($wp_query->posts[$previous_product_index]->term_id))
480
- $previous_category_id = $wp_query->posts[$previous_product_index]->term_id;
481
- else
482
- $previous_category_id = 0;
483
-
484
- if(isset($wp_query->post->term_id))
485
- $current_category_id = $wp_query->post->term_id;
486
- if (( $current_category_id != $previous_category_id )&& $previous_category_id != null)
487
- return true;
488
- else
489
- return false;
490
-
491
- }
492
- /**
493
- * wpsc show fb like function, check whether to show facebook like
494
- * @return boolean true if option is on, otherwise, false
495
- */
496
-
497
- function wpsc_show_fb_like(){
498
- if('on' == get_option('wpsc_facebook_like'))
499
- return true;
500
- else
501
- return false;
502
- }
503
- /**
504
- * wpsc have products function, the product loop
505
- * @return boolean true while we have products, otherwise, false
506
- */
507
- function wpsc_have_products() {
508
- return have_posts();
509
- }
510
-
511
- /**
512
- * wpsc the product function, gets the next product,
513
- * @return nothing
514
- */
515
- function wpsc_the_product() {
516
- global $wpsc_custom_meta, $wpsc_variations;
517
- the_post();
518
- $wpsc_custom_meta = new wpsc_custom_meta( get_the_ID() );
519
- $wpsc_variations = new wpsc_variations( get_the_ID() );
520
- }
521
-
522
- /**
523
- * wpsc in the loop function,
524
- * @return boolean - true if we are in the loop
525
- */
526
- function wpsc_in_the_loop() {
527
- _deprecated_function( __FUNCTION__, '3.8', 'the updated ' . __FUNCTION__ . '' );
528
- global $wpsc_query;
529
- return $wpsc_query->in_the_loop;
530
- }
531
-
532
- /**
533
- * wpsc rewind products function, rewinds back to the first product
534
- * @return nothing
535
- */
536
- function wpsc_rewind_products() {
537
- _deprecated_function( __FUNCTION__, '3.8', 'the updated ' . __FUNCTION__ . '' );
538
- global $wpsc_query;
539
- return $wpsc_query->rewind_posts();
540
- }
541
-
542
- /**
543
- * wpsc the product id function,
544
- * @return integer - the product ID
545
- */
546
- function wpsc_the_product_id() {
547
- return get_the_ID();
548
- }
549
-
550
- /**
551
- * wpsc edit the product link function
552
- * @return string - a link to edit this product
553
- */
554
- function wpsc_edit_the_product_link( $link = null, $before = '', $after = '', $id = 0 ) {
555
- global $wpsc_query, $current_user, $table_prefix, $wp_query;
556
- if ( $link == null )
557
- $link = __( 'Edit', 'wpsc' );
558
-
559
- $product_id = $wp_query->post->ID;
560
- if ( $id > 0 )
561
- $product_id = $id;
562
-
563
-
564
- $siteurl = get_option( 'siteurl' );
565
-
566
- $output = '';
567
- if(is_user_logged_in()){
568
- get_currentuserinfo();
569
- if ( $current_user->{$table_prefix . 'capabilities'}['administrator'] == 1 )
570
- $output = $before . "<a class='wpsc_edit_product' href='{$siteurl}/wp-admin/admin.php?page=wpsc-edit-products&amp;action=wpsc_add_edit&amp;product={$product_id}'>" . $link . "</a>" . $after;
571
-
572
- }
573
- return $output;
574
- }
575
-
576
- /**
577
- * wpsc the product title function
578
- * @return string - the product title
579
- */
580
- function wpsc_the_product_title() {
581
- return get_the_title();
582
- }
583
-
584
- /**
585
- * wpsc product description function
586
- * @return string - the product description
587
- */
588
- function wpsc_the_product_description() {
589
- $content = get_the_content( 'Read the rest of this entry &raquo;' );
590
- return wpautop($content,1);
591
- }
592
-
593
- /**
594
- * wpsc additional product description function
595
- * TODO make this work with the tabbed multiple product descriptions, may require another loop
596
- * @return string - the additional description
597
- */
598
- function wpsc_the_product_additional_description() {
599
- global $post;
600
-
601
- if ( !empty( $post->post_excerpt ) )
602
- return $post->post_excerpt;
603
- else
604
- return false;
605
- }
606
-
607
- /**
608
- * wpsc product permalink function
609
- * @return string - the URL to the single product page for this product
610
- */
611
- function wpsc_the_product_permalink() {
612
- global $wp_query;
613
- return get_permalink();
614
- }
615
-
616
- /**
617
- * wpsc external link function
618
- * @return string - the product price
619
- */
620
- function wpsc_product_external_link( $id = null ) {
621
- if ( is_numeric( $id ) && ( $id > 0 ) )
622
- $id = absint( $id );
623
- else
624
- $id = get_the_ID();
625
-
626
- $product_meta = get_post_meta( $id, '_wpsc_product_metadata', true );
627
- if ( isset( $product_meta['external_link'] ) ) {
628
- $external_link = $product_meta['external_link'];
629
- return $external_link;
630
- }
631
- }
632
-
633
- /**
634
- * wpsc external link text function
635
- * @return string - the product external link text
636
- */
637
- function wpsc_product_external_link_text( $id = null, $default = null ) {
638
- if ( is_numeric( $id ) && ( $id > 0 ) )
639
- $id = absint( $id );
640
- else
641
- $id = get_the_ID();
642
-
643
- $external_link_text = __( 'Buy Now', 'wpsc' );
644
- if ( $default != null ) {
645
- $external_link_text = $default;
646
- }
647
-
648
- $product_meta = get_post_meta( $id, '_wpsc_product_metadata', true );
649
- if ( isset( $product_meta['external_link_text'] ) && !empty( $product_meta['external_link_text'] ) ) {
650
- $external_link_text = $product_meta['external_link_text'];
651
- }
652
- return $external_link_text;
653
- }
654
-
655
- /**
656
- * wpsc external link target function
657
- * @return string - the product external link target
658
- */
659
- function wpsc_product_external_link_target( $id = null, $external_link_target = '' ) {
660
- if ( is_numeric( $id ) && ( $id > 0 ) )
661
- $id = absint( $id );
662
- else
663
- $id = get_the_ID();
664
-
665
- $product_meta = get_post_meta( $id, '_wpsc_product_metadata', true );
666
- if ( isset( $product_meta['external_link_target'] ) && !empty( $product_meta['external_link_target'] ) ) {
667
- $external_link_target = $product_meta['external_link_target'];
668
- }
669
- return $external_link_target;
670
- }
671
-
672
- /**
673
- * wpsc product sku function
674
- * @return string - the product price
675
- */
676
- function wpsc_product_sku( $id = null ) {
677
- if ( is_numeric( $id ) && ( $id > 0 ) )
678
- $id = absint( $id );
679
- else
680
- $id = get_the_ID();
681
-
682
- $product_sku = get_post_meta( $id, '_wpsc_sku', true );
683
-
684
- return $product_sku;
685
- }
686
-
687
- /**
688
- * wpsc product creation time function
689
- * @return string - the product price
690
- */
691
- function wpsc_product_creation_time( $format = null ) {
692
- global $wpsc_query;
693
-
694
- if ( $format == null )
695
- $format = "Y-m-d H:i:s";
696
-
697
- return mysql2date( $format, $wpsc_query->product['date_added'] );
698
- }
699
-
700
- /**
701
- * wpsc check variation stock availability function
702
- * @return string - the product price
703
- */
704
- function wpsc_check_variation_stock_availability( $product_id, $variations ) {
705
- $selected_post = (array)get_posts( array(
706
- 'post_parent' => $product_id,
707
- 'post_type' => "wpsc-product",
708
- 'post_status' => 'all',
709
- 'suppress_filters' => true
710
- ) );
711
- foreach ( $selected_post as $variation ) {
712
- $matches = 0;
713
- $terms = wp_get_object_terms( $variation->ID, 'wpsc-variation' );
714
- foreach ( $terms as $term ) {
715
- if ( in_array( $term->term_id, $variations ) )
716
- $matches++;
717
-
718
- if ( $matches == count( $variations ) ) {
719
- $the_selected_product = $variation->ID;
720
- }
721
- }
722
- }
723
-
724
- if ( wpsc_product_has_stock( $the_selected_product ) ) {
725
- $stock = get_product_meta( $the_selected_product, "stock", true );
726
- $stock = apply_filters( 'wpsc_product_variation_stock', $stock, $id );
727
-
728
- if ( 0 < $stock )
729
- return $stock;
730
- }else{
731
- $stock = get_product_meta( $the_selected_product, "stock", true );
732
- $stock = apply_filters( 'wpsc_product_variation_stock', $stock, $id );
733
- if ( is_numeric($stock) )
734
- return $stock;
735
-
736
- }
737
- return '';
738
- }
739
-
740
- /**
741
- * wpsc product has stock function
742
- * @return boolean - true if the product has stock or does not use stock, false if it does not
743
- */
744
- function wpsc_product_has_stock( $id = null ) {
745
- global $wpdb;
746
- // maybe do wpsc_clear_stock_claims first?
747
- if ( is_numeric( $id ) && ( $id > 0 ) )
748
- $id = absint( $id );
749
- else
750
- $id = get_the_ID();
751
-
752
- $stock = get_post_meta( $id, '_wpsc_stock', true );
753
-
754
- $stock = apply_filters( 'wpsc_product_stock', $stock, $id );
755
-
756
- if ( is_numeric( $stock ) ) {
757
- if ( $stock > 0 ) {
758
- $claimed_stock = $wpdb->get_var("SELECT SUM(`stock_claimed`) FROM `".WPSC_TABLE_CLAIMED_STOCK."` WHERE `product_id` IN($id)");
759
- if($stock - $claimed_stock > 0)
760
- return true;
761
- }
762
-
763
- $variations = get_children( array( "post_type" => "wpsc-product", "post_parent" => $id ) );
764
- if ( count( $variations ) ) {
765
- foreach ( $variations as $variation ) {
766
- $stock = get_post_meta( $variation->ID, '_wpsc_stock', true );
767
- $claimed_stock = $wpdb->get_var("SELECT SUM(`stock_claimed`) FROM `".WPSC_TABLE_CLAIMED_STOCK."` WHERE `product_id` IN($variation->ID)");
768
- if ( is_numeric( $stock ) && ($stock - $claimed_stock) > 0 ) {
769
- return true;
770
- }
771
- }
772
- }
773
- } else {
774
- return true;
775
- }
776
- }
777
-
778
- /**
779
- * wpsc_is_product_external( $product_id = 0 )
780
- *
781
- * Checks if current product is external.
782
- *
783
- * @param int $product_id
784
- */
785
- function wpsc_is_product_external( $product_id = 0 ) {
786
-
787
- // Get product ID if incorrect value was passed
788
- if ( empty( $product_id ) || !is_numeric( $product_id ) )
789
- $product_id = wpsc_the_product_id();
790
-
791
- // Get external link
792
- $external_link = wpsc_product_external_link( $product_id );
793
-
794
- // Use external if set
795
- if ( !empty( $external_link ) )
796
- return true;
797
- else
798
- return false;
799
- }
800
-
801
- /**
802
- * wpsc product remaining stock function
803
- * @return integer - the amount of remaining stock, or null if product is stockless
804
- */
805
- function wpsc_product_remaining_stock( $id = null ) {
806
- if ( is_numeric( $id ) && ($id > 0) )
807
- $id = absint( $id );
808
- else
809
- $id = get_the_ID();
810
-
811
- $is_limited_stock = get_post_meta( $id, '_wpsc_stock', true );
812
-
813
- if ( is_numeric( $is_limited_stock ) ) {
814
- $product_stock = get_post_meta( $id, '_wpsc_stock', true );
815
- return $product_stock;
816
- } else {
817
- return null;
818
- }
819
- }
820
-
821
- /**
822
- * wpsc is donation function
823
- * @return boolean - true if it is a donation, otherwise false
824
- */
825
- function wpsc_product_is_donation( $id = null ) {
826
- if ( is_numeric( $id ) && ($id > 0) )
827
- $id = absint( $id );
828
- else
829
- $id = get_the_ID();
830
-
831
- $is_donation = get_post_meta( $id, '_wpsc_is_donation', true );
832
- if ( $is_donation == 1 )
833
- return true;
834
- else
835
- return false;
836
-
837
- }
838
-
839
- /**
840
- * wpsc product on special function
841
- * @return boolean - true if the product is on special, otherwise false
842
- */
843
- function wpsc_product_on_special() {
844
- global $wpsc_query;
845
-
846
- $price = array_pop( get_post_meta( get_the_ID(), '_wpsc_price' ) );
847
- $special_price = array_pop( get_post_meta( get_the_ID(), '_wpsc_special_price' ) );
848
- if ( ($special_price > 0) && (($price - $special_price) >= 0) )
849
- return true;
850
- else
851
- return false;
852
-
853
- }
854
-
855
- /**
856
- * wpsc product has file function
857
- * @return boolean - true if the product has a file
858
- */
859
- function wpsc_product_has_file() {
860
- _deprecated_function( __FUNCTION__, '3.8', 'the updated ' . __FUNCTION__ . '' );
861
- global $wpsc_query, $wpdb;
862
- if ( is_numeric( $wpsc_query->product['file'] ) && ($wpsc_query->product['file'] > 0) )
863
- return true;
864
-
865
- return false;
866
- }
867
-
868
- /**
869
- * wpsc product is modifiable function
870
- * @return boolean - true if the product has a file
871
- */
872
- function wpsc_product_is_customisable() {
873
- global $wpsc_query, $wpdb;
874
- $id = get_the_ID();
875
- $product_meta = get_post_meta( $id, '_wpsc_product_metadata', true );
876
- if ( (isset($product_meta['engraved']) && $product_meta['engraved'] == true) || (isset($product_meta['can_have_uploaded_image']) && $product_meta['can_have_uploaded_image'] == true) )
877
- return true;
878
-
879
- return false;
880
- }
881
-
882
- /**
883
- * wpsc product has personal text function
884
- * @return boolean - true if the product has a file
885
- */
886
- function wpsc_product_has_personal_text() {
887
- global $wpsc_query, $wpdb;
888
- $id = get_the_ID();
889
- $product_meta = get_post_meta( $id, '_wpsc_product_metadata', true );
890
- if ( isset($product_meta['engraved']) && $product_meta['engraved'] == true )
891
- return true;
892
-
893
- return false;
894
- }
895
-
896
- /**
897
- * wpsc product has personal file function
898
- * @return boolean - true if the product has a file
899
- */
900
- function wpsc_product_has_supplied_file() {
901
- global $wpsc_query, $wpdb;
902
- $id = get_the_ID();
903
- $product_meta = get_post_meta( $id, '_wpsc_product_metadata', true );
904
- if ( isset($product_meta['can_have_uploaded_image']) && $product_meta['can_have_uploaded_image'] == true )
905
- return true;
906
-
907
- return false;
908
- }
909
-
910
- /**
911
- * wpsc product postage and packaging function
912
- * @return string - currently only valid for flat rate
913
- */
914
- function wpsc_product_postage_and_packaging() {
915
- if ( isset( $id ) && is_numeric( $id ) && ($id > 0) )
916
- $id = absint( $id );
917
- else
918
- $id = get_the_ID();
919
-
920
- $product_meta = get_post_meta( $id, '_wpsc_product_metadata', true );
921
- if ( is_array( $product_meta['shipping'] ) && 1 != $product_meta['no_shipping'])
922
- return wpsc_currency_display( $product_meta['shipping']['local'] );
923
- else
924
- return wpsc_currency_display( 0 );
925
-
926
- }
927
-
928
- /**
929
- * wpsc normal product price function
930
- * TODO determine why this function is here
931
- * @return string - returns some form of product price
932
- */
933
- function wpsc_product_normal_price() {
934
- global $wpsc_query, $wpdb, $wpsc_variations;
935
- if ( count( $wpsc_variations->first_variations ) > 0 ) {
936
- //select the variation ID with lovest price
937
- $product_id = $wpdb->get_var('SELECT `posts`.`id` FROM ' . $wpdb->posts . ' `posts` JOIN ' . $wpdb->postmeta . ' `postmeta` ON `posts`.`id` = `postmeta`.`post_id` WHERE `posts`.`post_parent` = ' . get_the_ID() . ' AND `posts`.`post_type` = "wpsc-product" AND `posts`.`post_status` = "inherit" AND `postmeta`.`meta_key`="_wpsc_price" ORDER BY (`postmeta`.`meta_value`)+0 ASC LIMIT 1');
938
- $from = ' from ';
939
- } else {
940
- $product_id = get_the_ID();
941
- $from = '';
942
- }
943
- $from = apply_filters('wpsc_product_variation_text',$from);
944
- $price = get_product_meta( $product_id, 'price', true );
945
- $output = $from.wpsc_currency_display( $price );
946
- return $output;
947
- }
948
-
949
- /**
950
- * wpsc product image function
951
- * @return string - the URL to the thumbnail image
952
- */
953
- function wpsc_the_product_image( $width='', $height='', $product_id='' ) {
954
- if ( empty( $product_id ) )
955
- $product_id = get_the_ID();
956
-
957
-
958
- $product = get_post( $product_id );
959
-
960
- if ( $product->post_parent > 0 )
961
- $product_id = $product->post_parent;
962
-
963
- $attached_images = (array)get_posts( array(
964
- 'post_type' => 'attachment',
965
- 'numberposts' => 1,
966
- 'post_status' => null,
967
- 'post_parent' => $product_id,
968
- 'orderby' => 'menu_order',
969
- 'order' => 'ASC'
970
- ) );
971
-
972
-
973
- $post_thumbnail_id = get_post_thumbnail_id( $product_id );
974
-
975
- $src = wp_get_attachment_image_src( $post_thumbnail_id, 'large' );
976
- if ( !empty( $src ) && is_string( $src[0] ) ) {
977
- return $src[0];
978
- } elseif ( !empty( $attached_images ) ) {
979
- $attached_image = wp_get_attachment_image_src( $attached_images[0]->ID, 'large' );
980
- return $attached_image[0];
981
- } else {
982
- return apply_filters( 'wpsc_product_image', false);
983
- }
984
- }
985
-
986
- /**
987
- * wpsc check display type
988
- *
989
- * Check the display view for the selected category
990
- *
991
- * @return string - display type
992
- */
993
- function wpsc_check_display_type(){
994
- global $wpsc_query, $post;
995
- if(isset($wpsc_query->query_vars['taxonomy']) && 'wpsc_product_category' == $wpsc_query->query_vars['taxonomy'] && is_string($wpsc_query->query_vars['term']) && 1 < $wpsc_query->post_count)
996
- $display_type = wpsc_get_the_category_display($wpsc_query->query_vars['term']);
997
- else
998
- $display_type = get_option('product_view');
999
- return $display_type;
1000
- }
1001
- /**
1002
- * wpsc product thumbnail function
1003
- *
1004
- * Show the thumbnail image for the product
1005
- *
1006
- * @return string - the URL to the thumbnail image
1007
- */
1008
- function wpsc_the_product_thumbnail( $width = null, $height = null, $product_id = 0, $page = 'products-page' ) {
1009
- $display = wpsc_check_display_type();
1010
- // Get the product ID if none was passed
1011
- if ( empty( $product_id ) )
1012
- $product_id = get_the_ID();
1013
-
1014
- // Load the product
1015
- $product = get_post( $product_id );
1016
-
1017
- // Get ID of parent product if one exists
1018
- if ( !empty( $product->post_parent ) )
1019
- $product_id = $product->post_parent;
1020
-
1021
- // Load image proportions if none were passed
1022
- if ( ( $width < 10 ) || ( $height < 10 ) ) {
1023
- $width = get_option( 'product_image_width' );
1024
- $height = get_option( 'product_image_height' );
1025
- }
1026
-
1027
- // Use product thumbnail
1028
- if ( has_post_thumbnail( $product_id ) && 'single' != $page) {
1029
- $thumbnail_id = get_post_thumbnail_id( $product_id );
1030
- // Use first product image
1031
- } else {
1032
-
1033
- // Get all attached images to this product
1034
- $attached_images = (array)get_posts( array(
1035
- 'post_type' => 'attachment',
1036
- 'numberposts' => 1,
1037
- 'post_status' => null,
1038
- 'post_parent' => $product_id ,
1039
- 'orderby' => 'menu_order',
1040
- 'order' => 'ASC'
1041
- ) );
1042
-
1043
- if ( !empty( $attached_images ) )
1044
- $thumbnail_id = $attached_images[0]->ID;
1045
- }
1046
-
1047
- //Overwrite height & width if custom dimensions exist for thumbnail_id
1048
- if ( 'grid' != $display && 'products-page' == $page && isset($thumbnail_id)) {
1049
- $custom_width = get_post_meta( $thumbnail_id, '_wpsc_custom_thumb_w', true );
1050
- $custom_height = get_post_meta( $thumbnail_id, '_wpsc_custom_thumb_h', true );
1051
-
1052
- if ( !empty( $custom_width ) && !empty( $custom_height ) ) {
1053
-
1054
- $width = $custom_width;
1055
- $height = $custom_height;
1056
-
1057
- }
1058
- } elseif( $page == 'single' && isset($thumbnail_id)) {
1059
- $custom_thumbnail = get_post_meta( $thumbnail_id, '_wpsc_selected_image_size', true );
1060
- if(!$custom_thumbnail)
1061
- $custom_thumbnail = array($width, $height);
1062
-
1063
- $src = wp_get_attachment_image_src( $thumbnail_id, $custom_thumbnail );
1064
-
1065
- if ( !empty( $src ) && is_string( $src[0] ) ) {
1066
- return $src[0];
1067
- }
1068
- }
1069
-
1070
- // Return image link...
1071
- if ( isset($thumbnail_id) &&( $image_link = wpsc_product_image( $thumbnail_id, $width, $height ) ))
1072
- return $image_link;
1073
-
1074
- // ... or false as if no image was found.
1075
- else
1076
- return false;
1077
- }
1078
-
1079
- /**
1080
- * Return the class(es) that should be applied to a product image's <a> tag.
1081
- *
1082
- * If the thickbox effect is enabled for product images (presentation setting), the thickbox class name is included
1083
- *
1084
- * This function is called from theme files when outputting product img tags
1085
- *
1086
- * @since 3.8
1087
- * @return string space-separated list of class names (for use in a class="") attribute
1088
- */
1089
- function wpsc_the_product_image_link_classes() {
1090
- $classes = array( );
1091
- if ( get_option( 'show_thumbnails_thickbox' ) )
1092
- $classes[] = 'thickbox';
1093
-
1094
- $classes[] = 'preview_link';
1095
-
1096
- $classes = apply_filters( 'wpsc_the_product_image_link_classes', $classes );
1097
- return implode( ' ', $classes );
1098
- }
1099
-
1100
- /**
1101
- * wpsc product comment link function
1102
- * @return string - javascript required to make the intense debate link work
1103
- */
1104
- function wpsc_product_comment_link() {
1105
- // add the product comment link
1106
- global $wpsc_query;
1107
-
1108
- if ( get_option( 'wpsc_enable_comments' ) == 1 ) {
1109
- $enable_for_product = get_product_meta( get_the_ID(), 'enable_comments' );
1110
-
1111
- if ( (get_option( 'wpsc_comments_which_products' ) == 1 && $enable_for_product == '') || $enable_for_product == 'yes' ) {
1112
- $original = array( "&", "'", ":", "/", "@", "?", "=" );
1113
- $entities = array( "%26", "%27", "%3A", "%2F", "%40", "%3F", "%3D" );
1114
-
1115
- $output = "<div class=\"clear comments\">
1116
- <script src='http://www.intensedebate.com/js/getCommentLink.php?acct=" . get_option( "wpsc_intense_debate_account_id" ) . "&postid=product_" . $wpsc_query->product['id'] . "&posttitle=" . urlencode( get_the_title() ) . "&posturl=" . str_replace( $original, $entities, wpsc_product_url( get_the_ID(), null, false ) ) . "&posttime=" . urlencode( date( 'Y-m-d h:i:s', time() ) ) . "&postauthor=author_" . get_the_ID() . "' type='text/javascript' defer='defer'></script>
1117
- </div>";
1118
- }
1119
- }
1120
- return $output;
1121
- }
1122
-
1123
- /**
1124
- * wpsc product comments function
1125
- * @return string - javascript for the intensedebate comments
1126
- */
1127
- function wpsc_product_comments() {
1128
- global $wpsc_query;
1129
- $output = '';
1130
- // add the product comments
1131
- if ( get_option( 'wpsc_enable_comments' ) == 1 ) {
1132
- $enable_for_product = get_product_meta( $wpsc_query->product['id'], 'enable_comments' );
1133
-
1134
- if ( (get_option( 'wpsc_comments_which_products' ) == 1 && $enable_for_product == '') || $enable_for_product == 'yes' ) {
1135
- $output = "<script>
1136
- var idcomments_acct = '" . get_option( 'wpsc_intense_debate_account_id' ) . "';
1137
- var idcomments_post_id = 'product_" . $wpsc_query->product['id'] . "';
1138
- var idcomments_post_url = encodeURIComponent('" . wpsc_product_url( $wpsc_query->product['id'], null, false ) . "');
1139
- </script>
1140
- <span id=\"IDCommentsPostTitle\" style=\"display:none\"></span>
1141
- <script type='text/javascript' src='http://www.intensedebate.com/js/genericCommentWrapperV2.js'></script>
1142
- ";
1143
- }
1144
- }
1145
- return $output;
1146
- }
1147
-
1148
- /**
1149
- * wpsc have custom meta function
1150
- * @return boolean - true while we have custom meta to display
1151
- */
1152
- function wpsc_have_custom_meta() {
1153
- global $wpsc_custom_meta;
1154
- return $wpsc_custom_meta->have_custom_meta();
1155
- }
1156
-
1157
- /**
1158
- * wpsc the custom meta function
1159
- * @return nothing - iterate through the custom meta vallues
1160
- */
1161
- function wpsc_the_custom_meta() {
1162
- global $wpsc_custom_meta;
1163
- return $wpsc_custom_meta->the_custom_meta();
1164
- }
1165
-
1166
- /**
1167
- * wpsc custom meta name function
1168
- * @return string - the custom metal name
1169
- */
1170
- function wpsc_custom_meta_name() {
1171
- global $wpsc_custom_meta;
1172
- return $wpsc_custom_meta->custom_meta_values['meta_key'];
1173
- }
1174
-
1175
- /**
1176
- * wpsc custom meta value function
1177
- * @return string - the custom meta value
1178
- */
1179
- function wpsc_custom_meta_value() {
1180
- global $wpsc_custom_meta;
1181
- return $wpsc_custom_meta->custom_meta_values['meta_value'];
1182
- }
1183
-
1184
- /**
1185
- * wpsc have variation groups function
1186
- * @return boolean - true while we have variation groups
1187
- */
1188
- function wpsc_have_variation_groups() {
1189
- global $wpsc_variations;
1190
- return $wpsc_variations->have_variation_groups();
1191
- }
1192
-
1193
- /**
1194
- * wpsc the variation group function
1195
- * @return nothing - iterate through the variation groups
1196
- */
1197
- function wpsc_the_variation_group() {
1198
- global $wpsc_variations;
1199
- $wpsc_variations->the_variation_group();
1200
- }
1201
-
1202
- /**
1203
- * wpsc have variations function
1204
- * @return boolean - true while we have variations
1205
- */
1206
- function wpsc_have_variations() {
1207
- global $wpsc_variations;
1208
- return $wpsc_variations->have_variations();
1209
- }
1210
-
1211
- /**
1212
- * wpsc the variation function
1213
- * @return nothing - iterate through the variations
1214
- */
1215
- function wpsc_the_variation() {
1216
- global $wpsc_variations;
1217
- $wpsc_variations->the_variation();
1218
- }
1219
-
1220
-
1221
- function wpsc_product_has_multicurrency() {
1222
- global $wpdb, $wpsc_query;
1223
-
1224
- $currency = get_product_meta(get_the_ID(),'currency',true);
1225
- if ( count( $currency ) > 0 )
1226
- return true;
1227
- else
1228
- return false;
1229
- }
1230
-
1231
- function wpsc_display_product_multicurrency() {
1232
- global $wpdb, $wpsc_query;
1233
-
1234
- $results = get_product_meta(get_the_ID(),'currency',true);
1235
- if ( count( $results ) > 0 ) {
1236
- foreach ( (array)$results as $isocode => $curr ) {
1237
- $currency_data = $wpdb->get_row( "SELECT `symbol`,`symbol_html`,`code` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `isocode`='" . $isocode . "' LIMIT 1", ARRAY_A );
1238
-
1239
- if ( $currency_data['symbol'] != '' )
1240
- $currency_sign = $currency_data['symbol_html'];
1241
- else
1242
- $currency_sign = $currency_data['code'];
1243
-
1244
- if ( !empty( $currency_sign ) )
1245
- return '<span class="wpscsmall pricefloatright pricedisplay">' . $isocode . ' ' . wpsc_currency_display( $curr["meta_value"] ) . '</span><br />';
1246
- }
1247
- }
1248
-
1249
- return false;
1250
- }
1251
-
1252
- /**
1253
- * wpsc variation group name function
1254
- * @return string - the variaton group name
1255
- */
1256
- function wpsc_the_vargrp_name() {
1257
- // get the variation group name;
1258
- global $wpsc_variations;
1259
- return $wpsc_variations->variation_group->name;
1260
- }
1261
-
1262
- /**
1263
- * wpsc variation group form ID function
1264
- * @return string - the variation group form id, for labels and the like
1265
- */
1266
- function wpsc_vargrp_form_id() {
1267
- // generate the variation group form ID;
1268
- global $wpsc_variations, $wpsc_variations;
1269
- $product_id = get_the_ID();
1270
- $form_id = "variation_select_{$product_id}_{$wpsc_variations->variation_group->term_id}";
1271
- return $form_id;
1272
- }
1273
-
1274
- /**
1275
- * wpsc variation group ID function
1276
- * @return integer - the variation group ID
1277
- */
1278
- function wpsc_vargrp_id() {
1279
- global $wpsc_variations;
1280
- return $wpsc_variations->variation_group->term_id;
1281
- }
1282
-
1283
- /**
1284
- * wpsc the variation name function
1285
- * @return string - the variation name
1286
- */
1287
- function wpsc_the_variation_name() {
1288
- global $wpsc_variations;
1289
- return stripslashes( $wpsc_variations->variation->name );
1290
- }
1291
-
1292
- /**
1293
- * wpsc the variation ID function
1294
- * @return integer - the variation ID
1295
- */
1296
- function wpsc_the_variation_id() {
1297
- global $wpsc_variations;
1298
- return $wpsc_variations->variation->term_id;
1299
- }
1300
-
1301
- /**
1302
- * wpsc the variation out_of_stock function
1303
- * @return string - HTML attribute to disable select options and radio buttons
1304
- */
1305
- function wpsc_the_variation_out_of_stock() {
1306
- global $wpsc_query, $wpdb, $wpsc_variations;
1307
- $out_of_stock = false;
1308
-
1309
- // If there is more than one variation group we cannot determine a stock status for individual variations
1310
- // Also, if the item is not stock limited, there is no need to check variation stock status
1311
- $product_id = get_the_ID();
1312
- $stock = get_product_meta( $product_id, 'stock' );
1313
- if ( ($wpsc_variations->variation_group_count == 1) && (is_numeric( $stock[0] )) ) {
1314
-
1315
- $product_id = get_the_ID();
1316
- $variation_group_id = $wpsc_variations->variation_group->term_id;
1317
- $variation_id = $wpsc_variations->variation->term_id;
1318
-
1319
- $wpq = array( 'variations' => $wpsc_variations->variation->slug,
1320
- 'post_status' => 'inherit',
1321
- 'post_type' => 'wpsc-product',
1322
- 'post_parent' => $product_id );
1323
- $query = new WP_Query( $wpq );
1324
-
1325
- if ( $query->post_count != 1 ) {
1326
- // Should never happen
1327
- return FALSE;
1328
- }
1329
-
1330
- $variation_product_id = $query->posts[0]->ID;
1331
-
1332
- $stock = get_product_meta( $variation_product_id, "stock" );
1333
- $stock = $stock[0];
1334
- if ( $stock < 1 ) {
1335
- $out_of_stock = true;
1336
- }
1337
- }
1338
-
1339
- if ( $out_of_stock == true )
1340
- return "disabled='disabled'";
1341
- else
1342
- return '';
1343
-
1344
- }
1345
-
1346
- /**
1347
- * wpsc product rater function
1348
- * @return string - HTML to display the product rater
1349
- */
1350
- function wpsc_product_rater() {
1351
- global $wpsc_query;
1352
- $product_id = get_the_ID();
1353
- $output = '';
1354
- if ( get_option( 'product_ratings' ) == 1 ) {
1355
- $output .= "<div class='product_footer'>";
1356
-
1357
- $output .= "<div class='product_average_vote'>";
1358
- $output .= "<strong>" . __( 'Avg. Customer Rating', 'wpsc' ) . ":</strong>";
1359
- $output .= wpsc_product_existing_rating( $product_id );
1360
- $output .= "</div>";
1361
-
1362
- $output .= "<div class='product_user_vote'>";
1363
-
1364
- $output .= "<strong><span id='rating_" . $product_id . "_text'>" . __( 'Your Rating', 'wpsc' ) . ":</span>";
1365
- $output .= "<span class='rating_saved' id='saved_" . $product_id . "_text'> " . __( 'Saved', 'wpsc' ) . "</span>";
1366
- $output .= "</strong>";
1367
-
1368
- $output .= wpsc_product_new_rating( $product_id );
1369
- $output .= "</div>";
1370
- $output .= "</div>";
1371
- }
1372
- return $output;
1373
- }
1374
-
1375
- function wpsc_product_existing_rating( $product_id ) {
1376
- global $wpdb;
1377
- $get_average = $wpdb->get_results( "SELECT AVG(`rated`) AS `average`, COUNT(*) AS `count` FROM `" . WPSC_TABLE_PRODUCT_RATING . "` WHERE `productid`='" . $product_id . "'", ARRAY_A );
1378
- $average = floor( $get_average[0]['average'] );
1379
- $count = $get_average[0]['count'];
1380
- $output = " <span class='votetext'>";
1381
- for ( $l = 1; $l <= $average; ++$l ) {
1382
- $output .= "<img class='goldstar' src='" . WPSC_CORE_IMAGES_URL . "/gold-star.gif' alt='$l' title='$l' />";
1383
- }
1384
- $remainder = 5 - $average;
1385
- for ( $l = 1; $l <= $remainder; ++$l ) {
1386
- $output .= "<img class='goldstar' src='" . WPSC_CORE_IMAGES_URL . "/grey-star.gif' alt='$l' title='$l' />";
1387
- }
1388
- $output .= "<span class='vote_total'>&nbsp;(<span id='vote_total_{$product_id}'>" . $count . "</span>)</span> \r\n";
1389
- $output .= "</span> \r\n";
1390
- return $output;
1391
- }
1392
-
1393
- function wpsc_product_new_rating( $product_id ) {
1394
- global $wpdb;
1395
-
1396
- $cookie_data = '';
1397
- if (isset($_COOKIE['voting_cookie'][$product_id])) {
1398
- $cookie_data = explode( ",", $_COOKIE['voting_cookie'][$product_id] );
1399
- }
1400
-
1401
- $vote_id = 0;
1402
-
1403
- if ( isset($cookie_data[0]) && is_numeric( $cookie_data[0] ) )
1404
- $vote_id = absint( $cookie_data[0] );
1405
-
1406
- $previous_vote = 1;
1407
- if ( $vote_id > 0 )
1408
- $previous_vote = $wpdb->get_var( "SELECT `rated` FROM `" . WPSC_TABLE_PRODUCT_RATING . "` WHERE `id`='" . $vote_id . "' LIMIT 1" );
1409
-
1410
- $output = "<form class='wpsc_product_rating' method='post'>\n";
1411
- $output .= " <input type='hidden' name='wpsc_ajax_action' value='rate_product' />\n";
1412
- $output .= " <input type='hidden' class='wpsc_rating_product_id' name='product_id' value='{$product_id}' />\n";
1413
- $output .= " <select class='wpsc_select_product_rating' name='product_rating'>\n";
1414
- $output .= " <option " . (($previous_vote == '1') ? "selected='selected'" : '') . " value='1'>1</option>\n";
1415
- $output .= " <option " . (($previous_vote == '2') ? "selected='selected'" : '') . " value='2'>2</option>\n";
1416
- $output .= " <option " . (($previous_vote == '3') ? "selected='selected'" : '') . " value='3'>3</option>\n";
1417
- $output .= " <option " . (($previous_vote == '4') ? "selected='selected'" : '') . " value='4'>4</option>\n";
1418
- $output .= " <option " . (($previous_vote == '5') ? "selected='selected'" : '') . " value='5'>5</option>\n";
1419
- $output .= " </select>\n";
1420
- $output .= " <input type='submit' value='" . __( 'Save', 'wpsc' ) . "'>";
1421
- $output .= " </form>";
1422
- return $output;
1423
- }
1424
-
1425
- /**
1426
- * wpsc currency sign function
1427
- * @return string - the selected currency sign for the store
1428
- */
1429
- function wpsc_currency_sign() {
1430
- _deprecated_function( __FUNCTION__, '3.8', 'the updated ' . __FUNCTION__ . '' );
1431
- global $wpdb;
1432
- $currency_sign_location = get_option( 'currency_sign_location' );
1433
- $currency_type = get_option( 'currency_type' );
1434
- $currency_symbol = $wpdb->get_var( "SELECT `symbol_html` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `id`='" . $currency_type . "' LIMIT 1" );
1435
- return $currency_symbol;
1436
- }
1437
-
1438
- /**
1439
- * wpsc has pages function
1440
- * @return boolean - true if we have pages
1441
- */
1442
- function wpsc_has_pages() {
1443
- if(1 == get_option('use_pagination'))
1444
- return true;
1445
- else
1446
- return false;
1447
-
1448
- }
1449
-
1450
- /**
1451
- * wpsc have pages function
1452
- * @return boolean - true while we have pages to loop through
1453
- */
1454
- function wpsc_have_pages() {
1455
- _deprecated_function( __FUNCTION__, '3.8', 'the updated ' . __FUNCTION__ . '' );
1456
- global $wpsc_query;
1457
- return $wpsc_query->have_pages();
1458
- }
1459
-
1460
- /**
1461
- * wpsc the page function
1462
- * @return nothing - iterate through the pages
1463
- */
1464
- function wpsc_the_page() {
1465
- _deprecated_function( __FUNCTION__, '3.8', 'the updated ' . __FUNCTION__ . '' );
1466
- global $wpsc_query;
1467
- $wpsc_query->the_page();
1468
- }
1469
-
1470
- /**
1471
- * wpsc page number function
1472
- * @return integer - the page number
1473
- */
1474
- function wpsc_page_number() {
1475
- _deprecated_function( __FUNCTION__, '3.8', 'the updated ' . __FUNCTION__ . '' );
1476
- global $wpsc_query;
1477
- return $wpsc_query->page['number'];
1478
- }
1479
-
1480
- /**
1481
- * this is for the multi adding property, it checks to see whether multi adding is enabled;
1482
- *
1483
- */
1484
- function wpsc_has_multi_adding() {
1485
- if ( get_option( 'multi_add' ) == 1 && (get_option( 'addtocart_or_buynow' ) != 1) ) {
1486
- return true;
1487
- } else {
1488
- return false;
1489
- }
1490
- }
1491
-
1492
- /**
1493
- * wpsc page is selected function
1494
- * @return boolean - true if the page is selected
1495
- */
1496
- function wpsc_page_is_selected() {
1497
- _deprecated_function( __FUNCTION__, '3.8', 'the updated ' . __FUNCTION__ . '' );
1498
- // determine if we are on this page
1499
- global $wpsc_query;
1500
- return $wpsc_query->page['selected'];
1501
- }
1502
-
1503
- /**
1504
- * wpsc page URL function
1505
- * @return string - the page URL
1506
- */
1507
- function wpsc_page_url() {
1508
- _deprecated_function( __FUNCTION__, '3.8', 'the updated ' . __FUNCTION__ . '' );
1509
- // generate the page URL
1510
- global $wpsc_query;
1511
- return $wpsc_query->page['url'];
1512
- }
1513
-
1514
- /**
1515
- * wpsc product count function
1516
- * @return string - the page URL
1517
- */
1518
- function wpsc_product_count() {
1519
- global $wp_query;
1520
- return count($wp_query->post);
1521
- }
1522
-
1523
- //The following code was removed from WP 3.8, present in 3.7 - Not sure why it was removed and not refactored. (JS)
1524
-
1525
- /**
1526
- * wpsc the variation price function
1527
- * @return string - the variation price
1528
- */
1529
- function wpsc_the_variation_price( $return_as_numeric = false ) {
1530
- global $wpdb, $wpsc_variations;
1531
- if ( $wpsc_variations->variation_count > 0 ) {
1532
-
1533
- $product_id = get_the_ID();
1534
- $wpq = array( 'variations' => $wpsc_variations->variation->slug,
1535
- 'post_status' => 'inherit,publish',
1536
- 'post_type' => 'wpsc-product',
1537
- 'post_parent' => $product_id );
1538
- $query = new WP_Query( $wpq );
1539
- // Should never happen
1540
- if ( $query->post_count != 1 )
1541
- return false;
1542
-
1543
- $variation_product_id = $query->posts[0]->ID;
1544
-
1545
- $price = get_product_meta( $variation_product_id, "price",true );
1546
- $special_price = get_product_meta( $variation_product_id, "special_price", true );
1547
- if($special_price < $price && $special_price > 0)
1548
- $price = $special_price;
1549
- if ( !$return_as_numeric ) {
1550
- $output = wpsc_currency_display( $price,array( 'display_as_html' => false ) );
1551
- } else {
1552
- $output = $price;
1553
- }
1554
- } else {
1555
- $output = false;
1556
- }
1557
- return $output;
1558
- }
1559
-
1560
- /**
1561
- * wpsc the variation stock function
1562
- * @return mixed - Stock level for the variation or FALSE if it can't be calculated
1563
- */
1564
- function wpsc_the_variation_stock() {
1565
- global $wpdb, $wpsc_variations;
1566
-
1567
- if ( $wpsc_variations->variation_count > 0 ) {
1568
-
1569
- $product_id = get_the_ID();
1570
-
1571
- $wpq = array( 'variations' => $wpsc_variations->variation->slug,
1572
- 'post_status' => 'inherit',
1573
- 'post_type' => 'wpsc-product',
1574
- 'post_parent' => $product_id );
1575
-
1576
- $query = new WP_Query( $wpq );
1577
-
1578
- // Should never happen
1579
- if ( $query->post_count != 1 )
1580
- return false;
1581
-
1582
- // Get the stock count
1583
- $vp_id = $query->posts[0]->ID;
1584
- $stock = get_product_meta( $vp_id, "stock" );
1585
- $stock[0] = apply_filters( 'wpsc_product_variation_stock', $stock[0], $id );
1586
- $output = $stock[0];
1587
- } else {
1588
- return false;
1589
- }
1590
-
1591
- return $output;
1592
- }
1593
-
1594
- /**
1595
- * wpsc_category_grid_view function
1596
- * @return bool - whether the category is in grid view or not
1597
- */
1598
- function wpsc_category_grid_view(){
1599
- if(get_option('wpsc_category_grid_view') == 1)
1600
- return true;
1601
- else
1602
- return false;
1603
- }
1604
-
1605
- /**
1606
- * wpsc_show_category_description function
1607
- * @return bool - whether to show category description or not
1608
- */
1609
- function wpsc_show_category_description(){
1610
- return get_option('wpsc_category_description');
1611
- }
1612
-
1613
- /**
1614
- * wpsc_show_category_thumbnails function
1615
- * @return bool - whether to show category thumbnails or not
1616
- */
1617
- function wpsc_show_category_thumbnails(){
1618
- if(get_option('show_category_thumbnails') && wpsc_category_image())
1619
- return true;
1620
- else
1621
- return false;
1622
- }
1623
-
1624
- /**
1625
- * wpsc_show_thumbnails function
1626
- * @return bool - whether to show thumbnails or not
1627
- */
1628
- function wpsc_show_thumbnails(){
1629
- return get_option('show_thumbnails');
1630
- }
1631
-
1632
- /**
1633
- * gold_cart_display_gallery function
1634
- * @return bool - whether to show gold cart gallery or not
1635
- */
1636
- function gold_cart_display_gallery(){
1637
- return function_exists('gold_shpcrt_display_gallery');
1638
- }
1639
-
1640
- function wpsc_you_save($args = null){
1641
-
1642
- $defaults = array(
1643
- 'product_id' => false,
1644
- 'type' => "percentage",
1645
- 'variations' => false
1646
- );
1647
-
1648
- $args = wp_parse_args( $args, $defaults );
1649
- extract( $args, EXTR_SKIP );
1650
-
1651
- global $wpdb;
1652
-
1653
- if(!$product_id)
1654
- if(function_exists('wpsc_the_product_id')){
1655
- //select the variation ID with lowest price
1656
- $product_id = $wpdb->get_var('SELECT `posts`.`id` FROM ' . $wpdb->posts . ' `posts` JOIN ' . $wpdb->postmeta . ' `postmeta` ON `posts`.`id` = `postmeta`.`post_id` WHERE `posts`.`post_parent` = ' . wpsc_the_product_id() . ' AND `posts`.`post_type` = "wpsc-product" AND `posts`.`post_status` = "inherit" AND `postmeta`.`meta_key`="_wpsc_price" ORDER BY (`postmeta`.`meta_value`)+0 ASC LIMIT 1');
1657
- if(!$product_id)
1658
- $product_id=wpsc_the_product_id();
1659
- }
1660
-
1661
- if(!$product_id)
1662
- return 0;
1663
- if($variations)
1664
- $sale_price = wpsc_calculate_price( (int)$_POST['product_id'], $variations, true );
1665
- else
1666
- $sale_price = get_product_meta($product_id, 'special_price', true);
1667
- //if sale price is zero, false, or anything similar - return false
1668
- if(!$sale_price)
1669
- return 0;
1670
-
1671
- if($variations)
1672
- $regular_price = wpsc_calculate_price( (int)$_POST['product_id'], $variations, false );
1673
- else
1674
- $regular_price = get_product_meta($product_id, 'price', true);
1675
- //if actual price is zero, false, or something similar, or is less than sale price - return false
1676
- if( !$regular_price || !( $sale_price < $regular_price ) )
1677
- return 0;
1678
-
1679
- switch($type){
1680
- case "amount":
1681
- return $regular_price - $sale_price;
1682
- break;
1683
-
1684
- default:
1685
- if(number_format ( ($regular_price - $sale_price) / $regular_price * 100 , 2 ) == 100)
1686
- return (99.99);
1687
- else
1688
- return number_format ( ($regular_price - $sale_price) / $regular_price * 100 , 2 );
1689
- }
1690
- }
1691
-
1692
-
1693
- function wpsc_get_downloadable_files($product_id){
1694
- $args = array(
1695
- 'post_type' => 'wpsc-product-file',
1696
- 'post_parent' => $product_id,
1697
- 'numberposts' => -1,
1698
- 'post_status' => 'all',
1699
-
1700
- );
1701
-
1702
- $attached_files = (array)get_posts( $args );
1703
- return $attached_files;
1704
- }
1705
- ?>
1
+ <?php
2
+ /**
3
+ * WP eCommerce product functions and product utility function.
4
+ *
5
+ * This is the wpsc equivalent of post-template.php
6
+ *
7
+ * @package wp-e-commerce
8
+ * @since 3.8
9
+ * @subpackage wpsc-template-functions
10
+ */
11
+
12
+ function wpsc_has_pages_top(){
13
+ if(wpsc_has_pages() && ((get_option('wpsc_page_number_position') == 1) || (get_option('wpsc_page_number_position') == 3)))
14
+ return true;
15
+ else
16
+ return false;
17
+ }
18
+ function wpsc_has_pages_bottom(){
19
+ if(wpsc_has_pages() && ((get_option('wpsc_page_number_position') == 2) || (get_option('wpsc_page_number_position') == 3)))
20
+ return true;
21
+ else
22
+ return false;
23
+ }
24
+
25
+ /**
26
+ * Used in wpsc_pagination to generate the links in pagination
27
+ * @access public
28
+ *
29
+ * @since 3.8
30
+ * @param $page int
31
+ * @return $output string, url
32
+ */
33
+ function wpsc_a_page_url($page=null) {
34
+ global $wp_query;
35
+ $output = '';
36
+ $curpage = $wp_query->query_vars['paged'];
37
+ if($page != '')
38
+ $wp_query->query_vars['paged'] = $page;
39
+
40
+ if($wp_query->is_single === true) {
41
+ $wp_query->query_vars['paged'] = $curpage;
42
+ return wpsc_product_url($wp_query->post->ID);
43
+ } else {
44
+ if( 1 < $wp_query->query_vars['paged']) {
45
+ if(get_option('permalink_structure'))
46
+ $output .= "paged/{$wp_query->query_vars['paged']}/";
47
+ else
48
+ $output = add_query_arg('paged', '', $output);
49
+
50
+ }
51
+ return $output;
52
+ }
53
+ }
54
+ /**
55
+ * wpsc_pagination generates and returns the urls for pagination
56
+ * @access public
57
+ *
58
+ * @since 3.8
59
+ * @param $totalpages (INT) Number of pages,
60
+ * @param $per_page (INT) Number of products per page
61
+ * @param $current_page (INT) Current Product page number
62
+ * @param $page_link (STRING) URL of Page
63
+ *
64
+ * @return
65
+ */
66
+ function wpsc_pagination($totalpages = '', $per_page = '', $current_page = '', $page_link = '') {
67
+ global $wp_query,$wpsc_query;
68
+ $num_paged_links = 4; //amount of links to show on either side of current page
69
+
70
+ $additional_links = '';
71
+
72
+ //additional links, items per page and products order
73
+ if( get_option('permalink_structure') != '' ){
74
+ $additional_links_separator = '?';
75
+ }else{
76
+ $additional_links_separator = '&';
77
+ }
78
+ if( !empty( $_GET['items_per_page'] ) ){
79
+ $additional_links = $additional_links_separator . 'items_per_page=' . $_GET['items_per_page'];
80
+ $additional_links_separator = '&';
81
+ }
82
+ if( !empty( $_GET['product_order'] ) )
83
+ $additional_links .= $additional_links_separator . 'product_order=' . $_GET['product_order'];
84
+
85
+ $additional_links = apply_filters('wpsc_pagination_additional_links', $additional_links);
86
+ //end of additional links
87
+
88
+ if(empty($totalpages)){
89
+ if(!isset($wpsc_query->query_vars['taxonomy']) && 'wpsc-product' == $wp_query->query_vars['post_type'])
90
+ $totalpages = $wp_query->max_num_pages;
91
+ else
92
+ $totalpages = $wpsc_query->max_num_pages;
93
+ }
94
+ if(empty($per_page))
95
+ $per_page = get_option('wpsc_products_per_page');
96
+
97
+ $current_page = get_query_var('paged');
98
+ if($current_page == 0)
99
+ $current_page = 1;
100
+
101
+ if(empty($page_link))
102
+ $page_link = wpsc_a_page_url();
103
+
104
+ if(!get_option('permalink_structure')) {
105
+ $category = '?';
106
+ if(isset($wpsc_query->query_vars['wpsc_product_category']))
107
+ $category = '?wpsc_product_category='.$wp_query->query_vars['wpsc_product_category'];
108
+ if(isset($wpsc_query->query_vars['wpsc_product_category']) && is_string($wpsc_query->query_vars['wpsc_product_category'])){
109
+
110
+ $page_link = get_option('blogurl').$category.'&amp;paged';
111
+ }else{
112
+ $page_link = get_option('product_list_url').$category.'&amp;paged';
113
+ }
114
+
115
+ $separator = '=';
116
+ }else{
117
+ // This will need changing when we get product categories sorted
118
+ if(isset($wpsc_query->query_vars['term']))
119
+ $page_link = trailingslashit(get_option('product_list_url')).$wpsc_query->query_vars['term'].'/';
120
+ else
121
+ $page_link = trailingslashit(get_option('product_list_url'));
122
+
123
+ $separator = 'page/';
124
+ }
125
+
126
+ // If there's only one page, return now and don't bother
127
+ if($totalpages == 1)
128
+ return;
129
+ // Pagination Prefix
130
+ $output = __('Pages: ','wpsc');
131
+
132
+ // Should we show the FIRST PAGE link?
133
+ if($current_page > 1)
134
+ $output .= "<a href=\"". $page_link . $additional_links . "\" title=\"" . __('First Page', 'wpsc') . "\">" . __('&laquo; First', 'wpsc') . "</a>";
135
+
136
+ // Should we show the PREVIOUS PAGE link?
137
+ if($current_page > 2) {
138
+ $previous_page = $current_page - 1;
139
+ $output .= " <a href=\"". $page_link .$separator. $previous_page . $additional_links . "\" title=\"" . __('Previous Page', 'wpsc') . "\">" . __('&lt; Previous', 'wpsc') . "</a>";
140
+ }
141
+ $i =$current_page - $num_paged_links;
142
+ $count = 1;
143
+ if($i <= 0) $i =1;
144
+ while($i < $current_page){
145
+ if($count <= $num_paged_links){
146
+ $output .= " <a href=\"". $page_link .$separator. $i . $additional_links . "\" title=\"" . sprintf( __('Page %s', 'wpsc'), $i ) . " \">".$i."</a>";
147
+ }
148
+ $i++;
149
+ $count++;
150
+ }
151
+ // Current Page Number
152
+ if($current_page > 0)
153
+ $output .= "<span class='current'>$current_page</span>";
154
+
155
+ //Links after Current Page
156
+ $i = $current_page + $num_paged_links;
157
+ $count = 1;
158
+ if($current_page < $totalpages){
159
+ while(($i) > $current_page){
160
+ if($count < $num_paged_links && ($count+$current_page) <= $totalpages){
161
+ $output .= " <a href=\"". $page_link .$separator. ($count+$current_page) .$additional_links . "\" title=\"" . sprintf( __('Page %s', 'wpsc'), ($count+$current_page) ) . "\">".($count+$current_page)."</a>";
162
+ $i++;
163
+ }else{
164
+ break;
165
+ }
166
+ $count ++;
167
+ }
168
+ }
169
+
170
+ if($current_page < $totalpages) {
171
+ $next_page = $current_page + 1;
172
+ $output .= "<a href=\"". $page_link .$separator. $next_page . $additional_links . "\" title=\"" . __('Next Page', 'wpsc') . "\">" . __('Next &gt;', 'wpsc') . "</a>";
173
+ }
174
+ // Should we show the LAST PAGE link?
175
+ if($current_page < $totalpages) {
176
+ $output .= "<a href=\"". $page_link .$separator. $totalpages . $additional_links . "\" title=\"" . __('Last Page', 'wpsc') . "\">" . __('Last &raquo;', 'wpsc') . "</a>";
177
+ }
178
+ // Return the output.
179
+ echo $output;
180
+ }
181
+
182
+ /**
183
+ * wpsc_show_stock_availability
184
+ *
185
+ * Checks to see whether stock symbols need to be shown
186
+ * @return boolean - true is the option has been checked false otherwise
187
+ */
188
+ function wpsc_show_stock_availability(){
189
+ if( get_option('list_view_quantity') == 1 )
190
+ return true;
191
+ else
192
+ return false;
193
+ }
194
+
195
+ /**
196
+ * wpsc product image function
197
+ *
198
+ * if no parameters are passed, the image is not resized, otherwise it is resized to the specified dimensions
199
+ *
200
+ * @param integer attachment_ID
201
+ * @param integer width
202
+ * @param integer height
203
+ * @return string - the product image URL, or the URL of the resized version
204
+ */
205
+ function wpsc_product_image( $attachment_id = 0, $width = null, $height = null ) {
206
+
207
+ // Do some dancing around the image size
208
+ if ( ( ( $width >= 10 ) && ( $height >= 10 ) ) && ( ( $width <= 1024 ) && ( $height <= 1024 ) ) )
209
+ $intermediate_size = "wpsc-{$width}x{$height}";
210
+
211
+ // Get image url if we have enough info
212
+ if ( ( $attachment_id > 0 ) && ( !empty( $intermediate_size ) ) ) {
213
+
214
+ // Get all the required information about the attachment
215
+ $uploads = wp_upload_dir();
216
+ $image_meta = get_post_meta( $attachment_id, '' );
217
+ $file_path = get_attached_file( $attachment_id );
218
+
219
+ // Clean up the meta array
220
+ foreach ( $image_meta as $meta_name => $meta_value )
221
+ $image_meta[$meta_name] = maybe_unserialize( array_pop( $meta_value ) );
222
+
223
+
224
+ $attachment_metadata = $image_meta['_wp_attachment_metadata'];
225
+ // Determine if we already have an image of this size
226
+ if ( isset( $attachment_metadata['sizes'] ) && (count( $attachment_metadata['sizes'] ) > 0) && ( isset( $attachment_metadata['sizes'][$intermediate_size] ) ) ) {
227
+ $intermediate_image_data = image_get_intermediate_size( $attachment_id, $intermediate_size );
228
+ $image_url = $intermediate_image_data['url'];
229
+ } else {
230
+ $image_url = "index.php?wpsc_action=scale_image&amp;attachment_id={$attachment_id}&amp;width=$width&amp;height=$height";
231
+ }
232
+
233
+ // Not enough info so attempt to fallback
234
+ } else {
235
+
236
+ if ( !empty( $attachment_id ) ) {
237
+ $image_url = "index.php?wpsc_action=scale_image&amp;attachment_id={$attachment_id}&amp;width=$width&amp;height=$height";
238
+ } else {
239
+ $image_url = false;
240
+ }
241
+
242
+ }
243
+ if(empty($image_url) && !empty($file_path)){
244
+ $image_meta = get_post_meta( $attachment_id, '_wp_attached_file' );
245
+ $image_url = $uploads['baseurl'].'/'.$image_meta[0];
246
+ }
247
+ if( is_ssl() && !strstr( $image_url, 'https' ) ) str_replace('http', 'https', $image_url);
248
+ // @todo - put fallback 'No image' catcher here
249
+ return apply_filters( 'wpsc_product_image', $image_url );
250
+ }
251
+
252
+ function wpsc_product_no_image_fallback( $image_url = '' ) {
253
+ if ( !empty( $image_url ) )
254
+ return $image_url;
255
+ else
256
+ return apply_filters( 'wpsc_product_noimage', WPSC_CORE_THEME_URL . 'wpsc-images/noimage.png' );
257
+ }
258
+ add_filter( 'wpsc_product_image', 'wpsc_product_no_image_fallback' );
259
+
260
+
261
+ /**
262
+ * wpsc show pnp function
263
+ * @return boolean - true if display_pnp is 1 false otherwise
264
+ */
265
+ function wpsc_show_pnp(){
266
+ global $post;
267
+ if(1 == get_option('display_pnp'))
268
+ return true;
269
+ return false;
270
+ }
271
+ /**
272
+ * wpsc_product_variation_price_available function
273
+ * Checks for the lowest price of a products variations
274
+ *
275
+ * @return $price (string) number formatted price
276
+ */
277
+ function wpsc_product_variation_price_available($product_id){
278
+ global $wpdb;
279
+ $price = $wpdb->get_var('
280
+ SELECT
281
+ `pm`.`meta_value`
282
+ FROM
283
+ `' . $wpdb->postmeta . '` `pm`
284
+ JOIN
285
+ `' . $wpdb->posts . '` `p`
286
+ ON
287
+ `pm`.`post_id` = `p`.`id`
288
+ WHERE
289
+ `p`.`post_type`= "wpsc-product"
290
+ AND
291
+ `p`.`post_parent` = ' . $product_id . '
292
+ AND
293
+ `pm`.`meta_key` = "_wpsc_price"
294
+ AND
295
+ `p`.`ID` IN (
296
+ SELECT `' . $wpdb->postmeta . '`.`post_id` FROM `' . $wpdb->postmeta . '` WHERE `meta_key` = "_wpsc_stock" AND `meta_value` != "0"
297
+ )
298
+ ORDER BY
299
+ `meta_value` ASC
300
+ LIMIT 1'
301
+ );
302
+
303
+ $price = wpsc_currency_display($price, array('display_as_html' => false));
304
+ return $price;
305
+ }
306
+
307
+ /**
308
+ * wpsc product price function
309
+ * @return string - the product price
310
+ */
311
+ function wpsc_the_product_price( $no_decimals = false ) {
312
+ global $wpsc_query, $wpsc_variations, $wpdb;
313
+ if ( isset($wpsc_variations->first_variations) && count( $wpsc_variations->first_variations ) > 0 ) {
314
+ //select the variation ID with lowest price
315
+ $output = wpsc_product_variation_price_available(get_the_ID());
316
+ $from = ' from ';
317
+ } else {
318
+ $product_id = get_the_ID();
319
+ $from = '';
320
+ $full_price = get_post_meta( $product_id, '_wpsc_price', true );
321
+ $special_price = get_post_meta( $product_id, '_wpsc_special_price', true );
322
+ $price = $full_price;
323
+
324
+ if ( ($full_price > $special_price) && ($special_price > 0) )
325
+ $price = $special_price;
326
+
327
+ if ( $no_decimals == true )
328
+ $price = array_shift( explode( ".", $price ) );
329
+
330
+ $args = array(
331
+ 'display_as_html' => false,
332
+ 'display_decimal_point' => !$no_decimals
333
+ );
334
+ $output = wpsc_currency_display( $price,$args );
335
+ }
336
+
337
+
338
+ //if product has variations - add 'from'
339
+ $from = apply_filters('wpsc_product_variation_text',$from);
340
+ if ( isset($wpsc_variations->first_variations) && count( $wpsc_variations->first_variations ) > 0 && !empty($from))
341
+ $output = sprintf(__(' from %s', 'wpsc'), $output);
342
+
343
+ return $output;
344
+ }
345
+
346
+ function wpsc_calculate_price( $product_id, $variations = null, $special = true ) {
347
+ global $wpdb;
348
+ $p_id = $product_id;
349
+ if ( count( $variations ) > 0 ){
350
+ if(!isset($variations) || is_array($variations) && in_array(0,$variations,true)) return;
351
+ $product_id = wpsc_get_child_object_in_terms( $product_id, $variations, 'wpsc-variation' );
352
+ }else if ( !$product_id )
353
+ $product_id = get_the_ID();
354
+
355
+ if( !$product_id && count( $variations ) > 0){
356
+ $product_ids = wpsc_get_child_object_in_select_terms( $p_id, $variations, 'wpsc_variation' );
357
+ $sql = "SELECT `post_id` FROM ".$wpdb->postmeta." WHERE `meta_key` = '_wpsc_stock' AND `meta_value` != '0' AND `post_id` IN (".implode(',' , $product_ids).")";
358
+ $stock_available = $wpdb->get_col($sql);
359
+ $sql = "SELECT `post_id` FROM ".$wpdb->postmeta." WHERE `meta_key` = '_wpsc_price' AND `post_id` IN (".implode(',',$stock_available).") ORDER BY `meta_value` ASC LIMIT 1";
360
+ $product_id = $wpdb->get_var($sql);
361
+ }
362
+
363
+ if ( $special ) {
364
+ $full_price = get_post_meta( $product_id, '_wpsc_price', true );
365
+ $special_price = get_post_meta( $product_id, '_wpsc_special_price', true );
366
+
367
+ $price = $full_price;
368
+ if ( ($full_price > $special_price) && ($special_price > 0) ) {
369
+ $price = $special_price;
370
+ }
371
+ } else {
372
+ $price = get_post_meta( $product_id, '_wpsc_price', true );
373
+ }
374
+
375
+ return $price;
376
+ }
377
+
378
+ /**
379
+ * wpsc display categories function
380
+ * Used to determine whether to display products on the page
381
+ * @return boolean - true for yes, false for no
382
+ */
383
+ function wpsc_display_categories() {
384
+ global $wp_query;
385
+ $output = false;
386
+ if ( !is_numeric( get_option( 'wpsc_default_category' ) ) ) {
387
+
388
+ if ( isset( $wp_query->query_vars['products'] ) )
389
+ $category_id = $wp_query->query_vars['products'];
390
+ else if ( isset( $_GET['products'] ) )
391
+ $category_id = $_GET['products'];
392
+
393
+ // if we have no categories, and no search, show the group list
394
+ if ( is_numeric( get_option( 'wpsc_default_category' ) ) || (isset( $product_id ) && is_numeric( $product_id )) || (isset( $_GET['product_search'] ) && $_GET['product_search'] != '') )
395
+ $output = true;
396
+
397
+ if ( (get_option( 'wpsc_default_category' ) == 'all+list') || (get_option( 'wpsc_default_category' ) == 'list') )
398
+ $output = true;
399
+
400
+ }
401
+
402
+ if ( isset( $category_id ) && $category_id > 0 )
403
+ $output = false;
404
+ if ( get_option( 'wpsc_display_categories' ))
405
+ $output = true;
406
+ return $output;
407
+ }
408
+
409
+ /**
410
+ * wpsc display products function
411
+ * Used to determine whether to display products on the page
412
+ * @return boolean - true for yes, false for no
413
+ */
414
+ function wpsc_display_products() {
415
+ global $post;
416
+ $product_page_id = wpec_get_the_post_id_by_shortcode('[productspage]');
417
+ //we have to display something, if we are not displaying categories, then we must display products
418
+ $output = true;
419
+ if ( wpsc_display_categories ( ) ) {
420
+ if ( get_option( 'wpsc_default_category' ) == 'list' && $post->ID == $product_page_id )
421
+ $output = false;
422
+
423
+ if ( isset( $_GET['range'] ) || isset( $_GET['category'] ) )
424
+ $output = true;
425
+
426
+ }
427
+ return $output;
428
+ }
429
+
430
+ /**
431
+ * this page url function, returns the URL of this page
432
+ * @return string - the URL of the current page
433
+ */
434
+ function wpsc_this_page_url() {
435
+ global $wpsc_query, $wp_query;
436
+ if ( $wpsc_query->is_single === true ) {
437
+ $output = wpsc_product_url( $wp_query->post->ID );
438
+ } else if ( isset( $wpsc_query->category ) && $wpsc_query->category != null ) {
439
+ $output = wpsc_category_url( $wpsc_query->category );
440
+ if ( $wpsc_query->query_vars['page'] > 1 ) {
441
+ if ( get_option( 'permalink_structure' ) ) {
442
+ $output .= "page/{$wpsc_query->query_vars['page']}/";
443
+ } else {
444
+ $output = add_query_arg( 'page_number', $wpsc_query->query_vars['page'], $output );
445
+ }
446
+ }
447
+ } elseif ( isset( $id ) ) {
448
+ $output = get_permalink( $id );
449
+ } else {
450
+ $output = get_permalink( get_the_ID() );
451
+ }
452
+ return $output;
453
+ }
454
+
455
+ /**
456
+ * is single product function, determines if we are viewing a single product
457
+ * @return boolean - true, or false...
458
+ */
459
+ function wpsc_is_single_product() {
460
+ global $wp_query;
461
+ if ( $wp_query->is_single === 1 )
462
+ $state = true;
463
+ else
464
+ $state = false;
465
+
466
+ return $state;
467
+ }
468
+
469
+ /**
470
+ * category class function, categories can have a specific class, this gets that
471
+ * @return string - the class of the selected category
472
+ */
473
+ function wpsc_category_class() {
474
+ global $wpdb, $wp_query;
475
+
476
+ $category_nice_name = '';
477
+ if ( 'wpsc_product_category' == $wp_query->query_vars['taxonomy'] ) {
478
+ $catid = wpsc_get_the_category_id($wp_query->query_vars['term'],'slug');
479
+ } else {
480
+ $catid = get_option( 'wpsc_default_category' );
481
+ if ( $catid == 'all+list' ) {
482
+ $catid = 'all';
483
+ }
484
+ }
485
+
486
+ if ( (int)$catid > 0 ){
487
+ $term = get_term($catid, 'wpsc_product_category');
488
+ $category_nice_name = $term->slug;
489
+ }else if ( $catid == 'all' ){
490
+ $category_nice_name = 'all-categories';
491
+ }
492
+ return $category_nice_name;
493
+ }
494
+
495
+ /**
496
+ * category transition function, finds the transition between categories
497
+ * @return string - the class of the selected category
498
+ */
499
+ function wpsc_current_category_name() {
500
+ global $wp_query;
501
+ $term_data = get_term( $wp_query->post->term_id, 'wpsc_product_category' );
502
+
503
+ return $term_data->name;
504
+ }
505
+
506
+ /**
507
+ * category transition function, finds the transition between categories
508
+ * @return string - the class of the selected category
509
+ */
510
+ function wpsc_category_transition() {
511
+ global $wpdb, $wp_query, $wpsc_query;
512
+ $current_category_id = null;
513
+ $previous_category_id = null;
514
+ $current_product_index = (int)$wp_query->current_post;
515
+ $previous_product_index = ((int)$wp_query->current_post - 1);
516
+
517
+ if ( $previous_product_index >= 0 && isset($wp_query->posts[$previous_product_index]->term_id))
518
+ $previous_category_id = $wp_query->posts[$previous_product_index]->term_id;
519
+ else
520
+ $previous_category_id = 0;
521
+
522
+ if(isset($wp_query->post->term_id))
523
+ $current_category_id = $wp_query->post->term_id;
524
+ if (( $current_category_id != $previous_category_id )&& $previous_category_id != null)
525
+ return true;
526
+ else
527
+ return false;
528
+
529
+ }
530
+ /**
531
+ * wpsc show fb like function, check whether to show facebook like
532
+ * @return boolean true if option is on, otherwise, false
533
+ */
534
+
535
+ function wpsc_show_fb_like(){
536
+ if('on' == get_option('wpsc_facebook_like'))
537
+ return true;
538
+ else
539
+ return false;
540
+ }
541
+ /**
542
+ * wpsc have products function, the product loop
543
+ * @return boolean true while we have products, otherwise, false
544
+ */
545
+ function wpsc_have_products() {
546
+ return have_posts();
547
+ }
548
+
549
+ /**
550
+ * wpsc the product function, gets the next product,
551
+ * @return nothing
552
+ */
553
+ function wpsc_the_product() {
554
+ global $wpsc_custom_meta, $wpsc_variations;
555
+ the_post();
556
+ $wpsc_custom_meta = new wpsc_custom_meta( get_the_ID() );
557
+ $wpsc_variations = new wpsc_variations( get_the_ID() );
558
+ }
559
+
560
+ /**
561
+ * wpsc in the loop function,
562
+ * @return boolean - true if we are in the loop
563
+ */
564
+ function wpsc_in_the_loop() {
565
+ _deprecated_function( __FUNCTION__, '3.8', 'the updated ' . __FUNCTION__ . '' );
566
+ global $wpsc_query;
567
+ return $wpsc_query->in_the_loop;
568
+ }
569
+
570
+ /**
571
+ * wpsc rewind products function, rewinds back to the first product
572
+ * @return nothing
573
+ */
574
+ function wpsc_rewind_products() {
575
+ _deprecated_function( __FUNCTION__, '3.8', 'the updated ' . __FUNCTION__ . '' );
576
+ global $wpsc_query;
577
+ return $wpsc_query->rewind_posts();
578
+ }
579
+
580
+ /**
581
+ * wpsc the product id function,
582
+ * @return integer - the product ID
583
+ */
584
+ function wpsc_the_product_id() {
585
+ return get_the_ID();
586
+ }
587
+
588
+ /**
589
+ * wpsc edit the product link function
590
+ * @return string - a link to edit this product
591
+ */
592
+ function wpsc_edit_the_product_link( $link = null, $before = '', $after = '', $id = 0 ) {
593
+ global $wpsc_query, $current_user, $table_prefix, $wp_query;
594
+ if ( $link == null )
595
+ $link = __( 'Edit', 'wpsc' );
596
+
597
+ $product_id = $wp_query->post->ID;
598
+ if ( $id > 0 )
599
+ $product_id = $id;
600
+
601
+
602
+ $siteurl = get_option( 'siteurl' );
603
+
604
+ $output = '';
605
+ if(is_user_logged_in()){
606
+ get_currentuserinfo();
607
+ if ( $current_user->{$table_prefix . 'capabilities'}['administrator'] == 1 )
608
+ $output = $before . "<a class='wpsc_edit_product' href='{$siteurl}/wp-admin/post.php?action=edit&amp;post={$product_id}'>" . $link . "</a>" . $after;
609
+
610
+ }
611
+ return $output;
612
+ }
613
+
614
+ /**
615
+ * wpsc the product title function
616
+ * @return string - the product title
617
+ */
618
+ function wpsc_the_product_title() {
619
+ return get_the_title();
620
+ }
621
+
622
+ /**
623
+ * wpsc product description function
624
+ * @return string - the product description
625
+ */
626
+ function wpsc_the_product_description() {
627
+ $content = get_the_content( 'Read the rest of this entry &raquo;' );
628
+ return wpautop($content,1);
629
+ }
630
+
631
+ /**
632
+ * wpsc additional product description function
633
+ * TODO make this work with the tabbed multiple product descriptions, may require another loop
634
+ * @return string - the additional description
635
+ */
636
+ function wpsc_the_product_additional_description() {
637
+ global $post;
638
+
639
+ if ( !empty( $post->post_excerpt ) )
640
+ return $post->post_excerpt;
641
+ else
642
+ return false;
643
+ }
644
+
645
+ /**
646
+ * wpsc product permalink function
647
+ * @return string - the URL to the single product page for this product
648
+ */
649
+ function wpsc_the_product_permalink() {
650
+ global $wp_query;
651
+ return get_permalink();
652
+ }
653
+
654
+ /**
655
+ * wpsc external link function
656
+ * @return string - the product price
657
+ */
658
+ function wpsc_product_external_link( $id = null ) {
659
+ if ( is_numeric( $id ) && ( $id > 0 ) )
660
+ $id = absint( $id );
661
+ else
662
+ $id = get_the_ID();
663
+
664
+ $product_meta = get_post_meta( $id, '_wpsc_product_metadata', true );
665
+ if ( isset( $product_meta['external_link'] ) ) {
666
+ $external_link = $product_meta['external_link'];
667
+ return $external_link;
668
+ }
669
+ }
670
+
671
+ /**
672
+ * wpsc external link text function
673
+ * @return string - the product external link text
674
+ */
675
+ function wpsc_product_external_link_text( $id = null, $default = null ) {
676
+ if ( is_numeric( $id ) && ( $id > 0 ) )
677
+ $id = absint( $id );
678
+ else
679
+ $id = get_the_ID();
680
+
681
+ $external_link_text = __( 'Buy Now', 'wpsc' );
682
+ if ( $default != null ) {
683
+ $external_link_text = $default;
684
+ }
685
+
686
+ $product_meta = get_post_meta( $id, '_wpsc_product_metadata', true );
687
+ if ( isset( $product_meta['external_link_text'] ) && !empty( $product_meta['external_link_text'] ) ) {
688
+ $external_link_text = $product_meta['external_link_text'];
689
+ }
690
+ return $external_link_text;
691
+ }
692
+
693
+ /**
694
+ * wpsc external link target function
695
+ * @return string - the product external link target
696
+ */
697
+ function wpsc_product_external_link_target( $id = null, $external_link_target = '' ) {
698
+ if ( is_numeric( $id ) && ( $id > 0 ) )
699
+ $id = absint( $id );
700
+ else
701
+ $id = get_the_ID();
702
+
703
+ $product_meta = get_post_meta( $id, '_wpsc_product_metadata', true );
704
+ if ( isset( $product_meta['external_link_target'] ) && !empty( $product_meta['external_link_target'] ) ) {
705
+ $external_link_target = $product_meta['external_link_target'];
706
+ }
707
+ return $external_link_target;
708
+ }
709
+
710
+ /**
711
+ * wpsc product sku function
712
+ * @return string - the product price
713
+ */
714
+ function wpsc_product_sku( $id = null ) {
715
+ if ( is_numeric( $id ) && ( $id > 0 ) )
716
+ $id = absint( $id );
717
+ else
718
+ $id = get_the_ID();
719
+
720
+ $product_sku = get_post_meta( $id, '_wpsc_sku', true );
721
+
722
+ return $product_sku;
723
+ }
724
+
725
+ /**
726
+ * wpsc product creation time function
727
+ * @return string - the product price
728
+ */
729
+ function wpsc_product_creation_time( $format = null ) {
730
+ global $wpsc_query;
731
+
732
+ if ( $format == null )
733
+ $format = "Y-m-d H:i:s";
734
+
735
+ return mysql2date( $format, $wpsc_query->product['date_added'] );
736
+ }
737
+
738
+ /**
739
+ * wpsc check variation stock availability function
740
+ * @return string - the product price
741
+ */
742
+ function wpsc_check_variation_stock_availability( $product_id, $variations ) {
743
+ global $wpdb;
744
+ $selected_post = (array)get_posts( array(
745
+ 'post_parent' => $product_id,
746
+ 'post_type' => "wpsc-product",
747
+ 'post_status' => 'all',
748
+ 'suppress_filters' => true
749
+ ) );
750
+ foreach ( $selected_post as $variation ) {
751
+ $matches = 0;
752
+ $terms = wp_get_object_terms( $variation->ID, 'wpsc-variation' );
753
+ foreach ( $terms as $term ) {
754
+ if ( in_array( $term->term_id, $variations ) )
755
+ $matches++;
756
+
757
+ if ( $matches == count( $variations ) ) {
758
+ $the_selected_product = $variation->ID;
759
+ }
760
+ }
761
+ }
762
+
763
+ if ( wpsc_product_has_stock( $the_selected_product ) ) {
764
+ $stock = get_product_meta( $the_selected_product, "stock", true );
765
+ $stock = apply_filters( 'wpsc_product_variation_stock', $stock, $id );
766
+ if ( 0 < $stock )
767
+ return $stock;
768
+ }else{
769
+
770
+ $stock = get_product_meta( $the_selected_product, "stock", true );
771
+ $stock = apply_filters( 'wpsc_product_variation_stock', $stock, $id );
772
+
773
+ if ( is_numeric($stock) ){
774
+ $claimed_stock = $wpdb->get_var("SELECT SUM(`stock_claimed`) FROM `".WPSC_TABLE_CLAIMED_STOCK."` WHERE `product_id` IN('$the_selected_product')");
775
+ $stock = ($stock - $claimed_stock);
776
+ return $stock;
777
+ }
778
+
779
+ }
780
+ return '';
781
+ }
782
+
783
+ /**
784
+ * wpsc product has stock function
785
+ * @return boolean - true if the product has stock or does not use stock, false if it does not
786
+ */
787
+ function wpsc_product_has_stock( $id = null ) {
788
+ global $wpdb;
789
+ // maybe do wpsc_clear_stock_claims first?
790
+ if ( is_numeric( $id ) && ( $id > 0 ) )
791
+ $id = absint( $id );
792
+ else
793
+ $id = get_the_ID();
794
+
795
+ $stock = get_post_meta( $id, '_wpsc_stock', true );
796
+
797
+ $stock = apply_filters( 'wpsc_product_stock', $stock, $id );
798
+
799
+ $variations = get_children( array( "post_type" => "wpsc-product", "post_parent" => $id ) );
800
+
801
+ if ( is_numeric( $stock ) ) {
802
+ if ( $stock > 0 && $variations == 0) {
803
+ $claimed_stock = $wpdb->get_var("SELECT SUM(`stock_claimed`) FROM `".WPSC_TABLE_CLAIMED_STOCK."` WHERE `product_id` IN($id)");
804
+ if($stock - $claimed_stock > 0)
805
+ return true;
806
+ }
807
+
808
+
809
+
810
+ if ( count( $variations ) ) {
811
+ foreach ( $variations as $variation ) {
812
+ $stock = get_post_meta( $variation->ID, '_wpsc_stock', true );
813
+ $claimed_stock = $wpdb->get_var("SELECT SUM(`stock_claimed`) FROM `".WPSC_TABLE_CLAIMED_STOCK."` WHERE `product_id` IN($variation->ID)");
814
+ if ( is_numeric( $stock ) && ($stock - $claimed_stock) > 0 ) {
815
+ return true;
816
+ }
817
+ }
818
+ }
819
+ } else {
820
+ return true;
821
+ }
822
+ }
823
+
824
+ /**
825
+ * wpsc_is_product_external( $product_id = 0 )
826
+ *
827
+ * Checks if current product is external.
828
+ *
829
+ * @param int $product_id
830
+ */
831
+ function wpsc_is_product_external( $product_id = 0 ) {
832
+
833
+ // Get product ID if incorrect value was passed
834
+ if ( empty( $product_id ) || !is_numeric( $product_id ) )
835
+ $product_id = wpsc_the_product_id();
836
+
837
+ // Get external link
838
+ $external_link = wpsc_product_external_link( $product_id );
839
+
840
+ // Use external if set
841
+ if ( !empty( $external_link ) )
842
+ return true;
843
+ else
844
+ return false;
845
+ }
846
+
847
+ /**
848
+ * wpsc product remaining stock function
849
+ * @return integer - the amount of remaining stock, or null if product is stockless
850
+ */
851
+ function wpsc_product_remaining_stock( $id = null ) {
852
+ if ( is_numeric( $id ) && ($id > 0) )
853
+ $id = absint( $id );
854
+ else
855
+ $id = get_the_ID();
856
+
857
+ $is_limited_stock = get_post_meta( $id, '_wpsc_stock', true );
858
+
859
+ if ( is_numeric( $is_limited_stock ) ) {
860
+ $product_stock = get_post_meta( $id, '_wpsc_stock', true );
861
+ return $product_stock;
862
+ } else {
863
+ return null;
864
+ }
865
+ }
866
+
867
+ /**
868
+ * wpsc is donation function
869
+ * @return boolean - true if it is a donation, otherwise false
870
+ */
871
+ function wpsc_product_is_donation( $id = null ) {
872
+ if ( is_numeric( $id ) && ($id > 0) )
873
+ $id = absint( $id );
874
+ else
875
+ $id = get_the_ID();
876
+
877
+ $is_donation = get_post_meta( $id, '_wpsc_is_donation', true );
878
+ if ( $is_donation == 1 )
879
+ return true;
880
+ else
881
+ return false;
882
+
883
+ }
884
+
885
+ /**
886
+ * wpsc product on special function
887
+ * @return boolean - true if the product is on special, otherwise false
888
+ */
889
+ function wpsc_product_on_special() {
890
+ global $wpsc_query;
891
+
892
+ $price = array_pop( get_post_meta( get_the_ID(), '_wpsc_price' ) );
893
+ $special_price = array_pop( get_post_meta( get_the_ID(), '_wpsc_special_price' ) );
894
+ if ( ($special_price > 0) && (($price - $special_price) >= 0) )
895
+ return true;
896
+ else
897
+ return false;
898
+
899
+ }
900
+
901
+ /**
902
+ * wpsc product has file function
903
+ * @return boolean - true if the product has a file
904
+ */
905
+ function wpsc_product_has_file() {
906
+ _deprecated_function( __FUNCTION__, '3.8', 'the updated ' . __FUNCTION__ . '' );
907
+ global $wpsc_query, $wpdb;
908
+ if ( is_numeric( $wpsc_query->product['file'] ) && ($wpsc_query->product['file'] > 0) )
909
+ return true;
910
+
911
+ return false;
912
+ }
913
+
914
+ /**
915
+ * wpsc product is modifiable function
916
+ * @return boolean - true if the product has a file
917
+ */
918
+ function wpsc_product_is_customisable() {
919
+ global $wpsc_query, $wpdb;
920
+ $id = get_the_ID();
921
+ $product_meta = get_post_meta( $id, '_wpsc_product_metadata', true );
922
+ if ( (isset($product_meta['engraved']) && $product_meta['engraved'] == true) || (isset($product_meta['can_have_uploaded_image']) && $product_meta['can_have_uploaded_image'] == true) )
923
+ return true;
924
+
925
+ return false;
926
+ }
927
+
928
+ /**
929
+ * wpsc product has personal text function
930
+ * @return boolean - true if the product has a file
931
+ */
932
+ function wpsc_product_has_personal_text() {
933
+ global $wpsc_query, $wpdb;
934
+ $id = get_the_ID();
935
+ $product_meta = get_post_meta( $id, '_wpsc_product_metadata', true );
936
+ if ( isset($product_meta['engraved']) && $product_meta['engraved'] == true )
937
+ return true;
938
+
939
+ return false;
940
+ }
941
+
942
+ /**
943
+ * wpsc product has personal file function
944
+ * @return boolean - true if the product has a file
945
+ */
946
+ function wpsc_product_has_supplied_file() {
947
+ global $wpsc_query, $wpdb;
948
+ $id = get_the_ID();
949
+ $product_meta = get_post_meta( $id, '_wpsc_product_metadata', true );
950
+ if ( isset($product_meta['can_have_uploaded_image']) && $product_meta['can_have_uploaded_image'] == true )
951
+ return true;
952
+
953
+ return false;
954
+ }
955
+
956
+ /**
957
+ * wpsc product postage and packaging function
958
+ * @return string - currently only valid for flat rate
959
+ */
960
+ function wpsc_product_postage_and_packaging() {
961
+ if ( isset( $id ) && is_numeric( $id ) && ($id > 0) )
962
+ $id = absint( $id );
963
+ else
964
+ $id = get_the_ID();
965
+
966
+ $product_meta = get_post_meta( $id, '_wpsc_product_metadata', true );
967
+ if ( is_array( $product_meta['shipping'] ) && 1 != $product_meta['no_shipping'])
968
+ return wpsc_currency_display( $product_meta['shipping']['local'] );
969
+ else
970
+ return wpsc_currency_display( 0 );
971
+
972
+ }
973
+
974
+ /**
975
+ * wpsc normal product price function
976
+ * TODO determine why this function is here
977
+ * @return string - returns some form of product price
978
+ */
979
+ function wpsc_product_normal_price($forRSS = false) {
980
+ global $wpsc_query, $wpdb, $wpsc_variations;
981
+ if ( count( $wpsc_variations->first_variations ) > 0 ) {
982
+ //select the variation ID with lovest price
983
+ $product_id = $wpdb->get_var('SELECT `posts`.`id` FROM ' . $wpdb->posts . ' `posts` JOIN ' . $wpdb->postmeta . ' `postmeta` ON `posts`.`id` = `postmeta`.`post_id` WHERE `posts`.`post_parent` = ' . get_the_ID() . ' AND `posts`.`post_type` = "wpsc-product" AND `posts`.`post_status` = "inherit" AND `postmeta`.`meta_key`="_wpsc_price" ORDER BY (`postmeta`.`meta_value`)+0 ASC LIMIT 1');
984
+ $from = ' from ';
985
+ } else {
986
+ $product_id = get_the_ID();
987
+ $from = '';
988
+ }
989
+ $from = apply_filters('wpsc_product_variation_text',$from);
990
+ $price = get_product_meta( $product_id, 'price', true );
991
+ if($forRSS)
992
+ $output = $from.wpsc_currency_display( $price, array( 'display_as_html' => false ) );
993
+ else
994
+ $output = $from.wpsc_currency_display( $price );
995
+ return $output;
996
+ }
997
+
998
+ /**
999
+ * wpsc product image function
1000
+ * @return string - the URL to the thumbnail image
1001
+ */
1002
+ function wpsc_the_product_image( $width='', $height='', $product_id='' ) {
1003
+ if ( empty( $product_id ) )
1004
+ $product_id = get_the_ID();
1005
+
1006
+
1007
+ $product = get_post( $product_id );
1008
+
1009
+ if ( $product->post_parent > 0 )
1010
+ $product_id = $product->post_parent;
1011
+
1012
+ $attached_images = (array)get_posts( array(
1013
+ 'post_type' => 'attachment',
1014
+ 'numberposts' => 1,
1015
+ 'post_status' => null,
1016
+ 'post_parent' => $product_id,
1017
+ 'orderby' => 'menu_order',
1018
+ 'order' => 'ASC'
1019
+ ) );
1020
+
1021
+
1022
+ $post_thumbnail_id = get_post_thumbnail_id( $product_id );
1023
+
1024
+ $src = wp_get_attachment_image_src( $post_thumbnail_id, 'large' );
1025
+ if ( !empty( $src ) && is_string( $src[0] ) ) {
1026
+ return $src[0];
1027
+ } elseif ( !empty( $attached_images ) ) {
1028
+ $attached_image = wp_get_attachment_image_src( $attached_images[0]->ID, 'large' );
1029
+ return $attached_image[0];
1030
+ } else {
1031
+ return apply_filters( 'wpsc_product_image', false);
1032
+ }
1033
+ }
1034
+
1035
+ /**
1036
+ * wpsc check display type
1037
+ *
1038
+ * Check the display view for the selected category
1039
+ *
1040
+ * @return string - display type
1041
+ */
1042
+ function wpsc_check_display_type(){
1043
+ global $wpsc_query, $post;
1044
+ if(isset($wpsc_query->query_vars['taxonomy']) && 'wpsc_product_category' == $wpsc_query->query_vars['taxonomy'] && is_string($wpsc_query->query_vars['term']) && 1 < $wpsc_query->post_count)
1045
+ $display_type = wpsc_get_the_category_display($wpsc_query->query_vars['term']);
1046
+ else
1047
+ $display_type = get_option('pr