WP eCommerce - Version 3.8beta2

Version Description

Download this release

Release Info

Developer JustinSainton
Plugin Icon 128x128 WP eCommerce
Version 3.8beta2
Comparing to
See all releases

Code changes from version 3.8beta1 to 3.8beta2

Files changed (67) hide show
  1. admin-form-functions.php +6 -1
  2. edit-profile.php +1 -1
  3. homepage_products_functions.php +243 -243
  4. image_processing.php +2 -0
  5. insertcate.php +1 -1
  6. languages/wpsc-pt_PT.mo +0 -0
  7. languages/wpsc-pt_PT.po +4014 -0
  8. merchants/chronopay.php +2 -2
  9. merchants/paypal-pro.merchant.php +2 -1
  10. merchants/paypal_certified.php +8 -3
  11. share-this.php +4 -1
  12. shipping/flatrate.php +2 -0
  13. shipping/tablerate.php +3 -0
  14. shipping/ups.php +2 -0
  15. shipping/usps.php +3 -0
  16. shipping/weightrate.php +2 -0
  17. shopping_cart_functions.php +8 -4
  18. tagging_functions.php +3 -3
  19. themes/default.old/shopping_cart_page.php +1 -1
  20. themes/default/checkout.php +1 -1
  21. themes/default/shopping_cart_page.php +419 -360
  22. themes/default/single_product.php +224 -224
  23. themes/iShop/shopping_cart_page.php +1 -1
  24. themes/marketplace/shopping_cart_page.php +1 -1
  25. themes/single-wpsc-product.php +20 -10
  26. widgets/admin_menu_widget.php +2 -2
  27. widgets/category_widget.27.php +2 -2
  28. widgets/donations_widget.php +3 -3
  29. widgets/latest_product_widget.php +3 -3
  30. widgets/price_range_widget.php +3 -3
  31. widgets/product_tag_widget.php +3 -3
  32. widgets/shopping_cart_widget.php +4 -4
  33. widgets/specials_widget.php +3 -3
  34. wp-shopping-cart.php +29 -13
  35. wpec-taxes/controllers/taxes_controller.class.php +599 -0
  36. wpec-taxes/models/taxes.class.php +324 -0
  37. wpec-taxes/taxes_module.php +165 -0
  38. wpec-taxes/view/js/taxes-functions.js +160 -0
  39. wpec-taxes/view/taxes-settings.php +168 -0
  40. wpsc-admin/admin.php +837 -831
  41. wpsc-admin/ajax-and-init.php +2249 -1958
  42. wpsc-admin/css/admin.css +18 -9
  43. wpsc-admin/display-coupons.php +13 -10
  44. wpsc-admin/display-groups.page.php +516 -443
  45. wpsc-admin/display-items.page.php +50 -57
  46. wpsc-admin/display-options-settings.page.php +21 -19
  47. wpsc-admin/display-sales-logs.php +43 -20
  48. wpsc-admin/display-update.page.php +3 -3
  49. wpsc-admin/display-upgrades.page.php +1 -1
  50. wpsc-admin/display-variations.page.php +1 -1
  51. wpsc-admin/includes/display-items-functions.php +1664 -1533
  52. wpsc-admin/includes/product-functions.php +1229 -1088
  53. wpsc-admin/includes/products.php +16 -6
  54. wpsc-admin/includes/purchlogs_upgrade.php +2 -2
  55. wpsc-admin/includes/save-data.functions.php +364 -292
  56. wpsc-admin/includes/settings-pages/checkout.php +9 -7
  57. wpsc-admin/includes/settings-pages/gateway.php +11 -2
  58. wpsc-admin/includes/settings-pages/general.php +187 -184
  59. wpsc-admin/includes/settings-pages/import.php +3 -2
  60. wpsc-admin/includes/settings-pages/presentation.php +13 -12
  61. wpsc-admin/includes/settings-pages/shipping.php +12 -5
  62. wpsc-admin/includes/updating-functions.php +10 -5
  63. wpsc-admin/js/admin.js +21 -4
  64. wpsc-admin/js/variations.js +1 -0
  65. wpsc-includes/ajax.functions.php +952 -935
  66. wpsc-includes/breadcrumbs.class.php +11 -8
  67. wpsc-includes/cart.class.php +237 -235
admin-form-functions.php CHANGED
@@ -205,7 +205,7 @@ function wpsc_right_now() {
205
 
206
 
207
  $sales_count = $wpdb->get_var("SELECT COUNT(*) FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `date` BETWEEN '".$start_timestamp."' AND '".$end_timestamp."'");
208
- $replace_values[":salecount:"] = $sales_count. " ".(($replace_values[":salecount:"] == 1) ? __('sale', 'wpsc') : __('sales', 'wpsc'));
209
  $sales_unit = (($replace_values[":salecount:"] == 1) ? __('sale', 'wpsc') : __('sales', 'wpsc'));
210
 
211
  $replace_values[":monthtotal:"] = nzshpcrt_currency_display(admin_display_total_price($start_timestamp, $end_timestamp),1);
@@ -492,6 +492,11 @@ function wpsc_packing_slip($purchase_id) {
492
  echo '<table class="packing-slip-totals">';
493
  echo '<tr><th>Base Shipping</th><td>' . nzshpcrt_currency_display( $purch_data['base_shipping'], 1 ) . '</td></tr>';
494
  echo '<tr><th>Total Shipping</th><td>' . nzshpcrt_currency_display( $purch_data['base_shipping'] + $total_shipping, 1 ) . '</td></tr>';
 
 
 
 
 
495
  echo '<tr><th>Total Price</th><td>' . nzshpcrt_currency_display( $purch_data['totalprice'], 1 ) . '</td></tr>';
496
  echo '</table>';
497
 
205
 
206
 
207
  $sales_count = $wpdb->get_var("SELECT COUNT(*) FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `date` BETWEEN '".$start_timestamp."' AND '".$end_timestamp."'");
208
+ $replace_values[":salecount:"] = $sales_count. " ".((isset($replace_values[":salecount:"]) && ($replace_values[":salecount:"] == 1)) ? __('sale', 'wpsc') : __('sales', 'wpsc'));
209
  $sales_unit = (($replace_values[":salecount:"] == 1) ? __('sale', 'wpsc') : __('sales', 'wpsc'));
210
 
211
  $replace_values[":monthtotal:"] = nzshpcrt_currency_display(admin_display_total_price($start_timestamp, $end_timestamp),1);
492
  echo '<table class="packing-slip-totals">';
493
  echo '<tr><th>Base Shipping</th><td>' . nzshpcrt_currency_display( $purch_data['base_shipping'], 1 ) . '</td></tr>';
494
  echo '<tr><th>Total Shipping</th><td>' . nzshpcrt_currency_display( $purch_data['base_shipping'] + $total_shipping, 1 ) . '</td></tr>';
495
+ //wpec_taxes
496
+ if($purch_data['wpec_taxes_total'] != 0.00)
497
+ {
498
+ echo '<tr><th>Taxes</th><td>' . nzshpcrt_currency_display( $purch_data['wpec_taxes_total'], 1 ) . '</td></tr>';
499
+ }
500
  echo '<tr><th>Total Price</th><td>' . nzshpcrt_currency_display( $purch_data['totalprice'], 1 ) . '</td></tr>';
501
  echo '</table>';
502
 
edit-profile.php CHANGED
@@ -93,7 +93,7 @@ $meta_data = null;
93
  $saved_data_sql = "SELECT * FROM `".$wpdb->usermeta."` WHERE `user_id` = '".$user_ID."' AND `meta_key` = 'wpshpcrt_usr_profile';";
94
  $saved_data = $wpdb->get_row($saved_data_sql,ARRAY_A);
95
 
96
- $meta_data = get_usermeta($user_ID, 'wpshpcrt_usr_profile');
97
 
98
  $form_sql = "SELECT * FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `active` = '1' ORDER BY `order`;";
99
  $form_data = $wpdb->get_results($form_sql,ARRAY_A);
93
  $saved_data_sql = "SELECT * FROM `".$wpdb->usermeta."` WHERE `user_id` = '".$user_ID."' AND `meta_key` = 'wpshpcrt_usr_profile';";
94
  $saved_data = $wpdb->get_row($saved_data_sql,ARRAY_A);
95
 
96
+ $meta_data = get_user_meta($user_ID, 'wpshpcrt_usr_profile');
97
 
98
  $form_sql = "SELECT * FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `active` = '1' ORDER BY `order`;";
99
  $form_data = $wpdb->get_results($form_sql,ARRAY_A);
homepage_products_functions.php CHANGED
@@ -1,244 +1,244 @@
1
- <?php
2
- function nszhpcrt_homepage_products($content = '') {
3
- global $wpdb;
4
- $siteurl = get_option('siteurl');
5
- if(get_option('permalink_structure') != '') {
6
- $seperator ="?";
7
- } else {
8
- $seperator ="&amp;";
9
- }
10
- $sql = "SELECT * FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE `display_frontpage` IN('1') AND `active` IN('1')";
11
- //$product_list = $wpdb->get_results($sql,ARRAY_A);
12
-
13
- $output = "<div id='homepage_products'>\n\r";
14
- foreach((array)$product_list as $product) {
15
- $output .= "<div class='frontpage_product'>\n\r";
16
- $output .= "<a href='".wpsc_product_url($product['id'])."'>";
17
- if($product['image'] != '') {
18
- $output .= "<img src='".WPSC_THUMBNAIL_URL.$product['image']."' title='".$product['name']."' alt='".$product['name']."' />\n\r";
19
- $output .= "<p>\n\r";
20
- $output .= stripslashes($product['name']);
21
- $output .= "<span class='front_page_price'>\n\r";
22
- if($product['special']==1) {
23
- $output .= "<span class='oldprice'>".nzshpcrt_currency_display($product['price'], $product['notax'])."</span><br />\n\r";
24
- $output .= nzshpcrt_currency_display(($product['price'] - $product['special_price']), $product['notax'],false,$product['id']);
25
- } else {
26
- $output .= "".nzshpcrt_currency_display($product['price'], $product['notax']);
27
- }
28
- $output .= "</span>\n\r";
29
- $output .= "</p>\n\r";
30
- }
31
- $output .= "</a>";
32
- $output .= "</div>\n\r";
33
- }
34
- $output .= "</div>\n\r";
35
- $output .= "<br style='clear: left;'>\n\r";
36
- return preg_replace("/\[homepage_products\]/", $output, $content);
37
- }
38
-
39
-
40
-
41
- function nszhpcrt_category_tag($content = '') {
42
- global $wpdb;
43
- if(preg_match_all("/\[wpsc_category_exclude=([\d]+),*(full)?\]/", $content, $matches)) {
44
- foreach($matches[1] as $key => $category_id) {
45
- $categories[$key]['id'] = $category_id;
46
- $categories[$key]['display'] = $matches[2][$key];
47
- $categories[$key]['original_string'] = $matches[0][$key];
48
- }
49
- foreach ($categories as $category) {
50
- $sql1 = "SELECT DISTINCT `".WPSC_TABLE_PRODUCT_LIST."`.*, `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."`.`category_id`,`".WPSC_TABLE_PRODUCT_ORDER."`.`order`, IF(ISNULL(`".WPSC_TABLE_PRODUCT_ORDER."`.`order`), 0, 1) AS `order_state` FROM `".WPSC_TABLE_PRODUCT_LIST."` LEFT JOIN `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."` ON `".WPSC_TABLE_PRODUCT_LIST."`.`id` = `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."`.`product_id` LEFT JOIN `".WPSC_TABLE_PRODUCT_ORDER."` ON ( ( `".WPSC_TABLE_PRODUCT_LIST."`.`id` = `".WPSC_TABLE_PRODUCT_ORDER."`.`product_id` ) AND ( `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."`.`category_id` = `".WPSC_TABLE_PRODUCT_ORDER."`.`category_id` ) ) WHERE `".WPSC_TABLE_PRODUCT_LIST."`.`active` = '1' AND `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."`.`category_id` NOT IN ('".$category['id']."') $no_donations_sql ORDER BY `order_state` DESC,`".WPSC_TABLE_PRODUCT_ORDER."`.`order` ASC";
51
- $product_list1 = $wpdb->get_results($sql1,ARRAY_A);
52
- if(function_exists('product_display_list') && (get_option('product_view') == 'list')) {
53
- $output1= product_display_list($product_list1, $group_type, $group_sql, $search_sql);
54
- } else if(function_exists('product_display_grid') && (get_option('product_view') == 'grid')) {
55
- $output1= product_display_grid($product_list1, $group_type, $group_sql, $search_sql);
56
- } else {
57
- $output1= product_display_default($product_list1,'');
58
- }
59
- }
60
- $content = str_replace($category['original_string'], $output1, $content);
61
- }
62
- if(preg_match_all("/\[wpsc_category=([\d]+),*(full)?\]/", $content, $matches)) {
63
- foreach($matches[1] as $key => $category_id) {
64
- $categories[$key]['id'] = $category_id;
65
- //$categories[$key]['display'] = $matches[2][$key];
66
- $original_string = $matches[0][$key];
67
- $query = array('category_id' => $category_id);
68
-
69
- $content = str_replace($original_string, wpsc_display_products_page($query), $content);
70
-
71
- }
72
-
73
-
74
- return $content;
75
-
76
- //echo("<pre>".print_r($categories,true)."</pre>");
77
- $siteurl = get_option('siteurl');
78
- if(get_option('permalink_structure') != '') {
79
- $seperator ="?";
80
- } else {
81
- $seperator ="&amp;";
82
- }
83
-
84
- foreach((array)$activated_widgets as $widget_container) {
85
- if(is_array($widget_container) && array_search(__('Product Donations', 'wpsc'), $widget_container)) {
86
- $no_donations_sql = "AND `".WPSC_TABLE_PRODUCT_LIST."`.`donation` != '1'";
87
- break;
88
- }
89
- }
90
- foreach((array)$categories as $category) {
91
- $full_view = null;
92
- if($category['display'] == 'full') {
93
- $sql = "SELECT DISTINCT `".WPSC_TABLE_PRODUCT_LIST."`.*, `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."`.`category_id`,`".WPSC_TABLE_PRODUCT_ORDER."`.`order`, IF(ISNULL(`".WPSC_TABLE_PRODUCT_ORDER."`.`order`), 0, 1) AS `order_state` FROM `".WPSC_TABLE_PRODUCT_LIST."` LEFT JOIN `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."` ON `".WPSC_TABLE_PRODUCT_LIST."`.`id` = `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."`.`product_id` LEFT JOIN `".WPSC_TABLE_PRODUCT_ORDER."` ON ( ( `".WPSC_TABLE_PRODUCT_LIST."`.`id` = `".WPSC_TABLE_PRODUCT_ORDER."`.`product_id` ) AND ( `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."`.`category_id` = `".WPSC_TABLE_PRODUCT_ORDER."`.`category_id` ) ) WHERE `".WPSC_TABLE_PRODUCT_LIST."`.`active` = '1' AND `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."`.`category_id` IN ('".$category['id']."') $no_donations_sql ORDER BY `order_state` DESC,`".WPSC_TABLE_PRODUCT_ORDER."`.`order` ASC";
94
-
95
- $product_list = $wpdb->get_results($sql,ARRAY_A);
96
- // sorry about the global variable, but it was the best way I could think of to avoid people having to upgrade the gold cart
97
- $GLOBALS['wpsc_category_id'] = $category['id'];
98
- if(function_exists('product_display_list') && (get_option('product_view') == 'list')) {
99
- $output .= product_display_list($product_list, $group_type, $group_sql, $search_sql);
100
- } else if(function_exists('product_display_grid') && (get_option('product_view') == 'grid')) {
101
- $output .= product_display_grid($product_list, $group_type, $group_sql, $search_sql);
102
- } else {
103
- $output .= product_display_default($product_list, $group_type, $group_sql, $search_sql);
104
- }
105
-
106
- } else {
107
- $sql = "SELECT DISTINCT `".WPSC_TABLE_PRODUCT_LIST."`.*, `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."`.`category_id`,`".WPSC_TABLE_PRODUCT_ORDER."`.`order`, IF(ISNULL(`".WPSC_TABLE_PRODUCT_ORDER."`.`order`), 0, 1) AS `order_state` FROM `".WPSC_TABLE_PRODUCT_LIST."` LEFT JOIN `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."` ON `".WPSC_TABLE_PRODUCT_LIST."`.`id` = `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."`.`product_id` LEFT JOIN `".WPSC_TABLE_PRODUCT_ORDER."` ON ( ( `".WPSC_TABLE_PRODUCT_LIST."`.`id` = `".WPSC_TABLE_PRODUCT_ORDER."`.`product_id` ) AND ( `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."`.`category_id` = `".WPSC_TABLE_PRODUCT_ORDER."`.`category_id` ) ) WHERE `".WPSC_TABLE_PRODUCT_LIST."`.`active` = '1' AND `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."`.`category_id` IN ('".$category['id']."') $no_donations_sql ORDER BY `order_state` DESC,`".WPSC_TABLE_PRODUCT_ORDER."`.`order` ASC";
108
-
109
- $product_list = $wpdb->get_results($sql,ARRAY_A);
110
- $output = "<div id='products_page_container' class='wrap wpsc_container'>\n\r";
111
- $output .= "<div id='homepage_products'>\n\r";
112
- if ($full_view != null){
113
- $output .= "<table class='productdisplay'>";
114
- }
115
- foreach((array)$product_list as $product) {
116
- if(function_exists('wpsc_theme_html')) {
117
- $wpsc_theme = wpsc_theme_html($product);
118
- }
119
- if ($full_view == null) {
120
- $output .= "<div class='category_view_product'>\n\r";
121
- } else {
122
- /* product image is here */
123
- $output .= "<tr>";
124
- $output .= "<td class='imagecol'>";
125
- }
126
- $output .="<a href='".WPSC_IMAGE_URL.$product['image']."' class='thickbox preview_link' rel='".str_replace(" ", "_",$product['name'])."'>";
127
- if($product['image'] != '') {
128
- $output .= "<img class='product_image' src='".WPSC_THUMBNAIL_URL.$product['image']."' title='".$product['name']."' alt='".$product['name']."' />\n\r";
129
- }
130
- $output .= "</a>";
131
- if ($full_view != null) {
132
- $output .= "</td><td class='textcol'>";
133
- } else {
134
- $output .= "<div class='product_details'>";
135
- }
136
- if (get_option('hide_name_link')!=1) {
137
- if(($product['special']==1) && ($variations_output[1] === null)) {
138
- $output .= "<a href='".wpsc_product_url($product['id'])."' class='wpsc_product_title' >$special<strong class='special'>Special / Sale Price - </strong><strong>" . stripslashes($product['name']) . "</strong></a>";
139
- } else {
140
- $output .= "<a href='".wpsc_product_url($product['id'])."' class='wpsc_product_title' >$special<strong>" . stripslashes($product['name']) . "</strong></a>";
141
- }
142
- } else {
143
- if(($product['special']==1) && ($variations_output[1] === null)) {
144
- $output .= "<a class='wpsc_product_title' >$special<strong class='special'>Special / Sale Price - </strong><strong>" . stripslashes($product['name']) . "</strong></a>";
145
- } else {
146
- $output .= "<a class='wpsc_product_title' >$special<strong>" . stripslashes($product['name']) . "</strong></a>";
147
- }
148
- }
149
- if ($full_view !=null) {
150
- if($product['description'] != '') {
151
- $output .= "<p class='wpsc_description'>".nl2br(stripslashes($product['description'])) . "</p>";
152
- }
153
-
154
- if($product['additional_description'] != '') {
155
- $output .= "<a href='#' class='additional_description_link' onclick='return show_additional_description(\"additionaldescription".$product['id']."\",\"link_icon".$product['id']."\");'>";
156
- $output .= "<img id='link_icon".$product['id']."' class='additional_description_button' src='".WPSC_URL."/images/icon_window_expand.gif' title='".$product['name']."' alt='".$product['name']."' />";
157
- $output .= __('More Details', 'wpsc')."</a>";
158
-
159
- $output .= "<span class='additional_description' id='additionaldescription".$product['id']."'><br />";
160
- $output .= nl2br(stripslashes($product['additional_description'])) . "";
161
- $output .= "</span><br />";
162
- }
163
- }
164
- /*
165
- adding to cart stuff
166
- */
167
- $output .= "<form id='product_".$product['id']."' name='product_".$product['id']."' method='post' action='".get_option('product_list_url').$seperator."category=".$_GET['category']."' onsubmit='submitform(this);return false;' >";
168
- $output .= "<input type='hidden' name='prodid' value='".$product['id']."' />";
169
- $output .= "<input type='hidden' name='item' value='".$product['id']."' />";
170
-
171
- $variations_procesor = new nzshpcrt_variations;
172
-
173
- $variations_output = $variations_procesor->display_product_variations($product['id'],false, false, true);
174
- $output .= $variations_output[0];
175
- if($variations_output[1] !== null) {
176
- $product['price'] = $variations_output[1];
177
- }
178
-
179
- if(($product['special']==1) && ($variations_output[1] === null)) {
180
- $output .= "<span class='oldprice'>".nzshpcrt_currency_display($product['price'], $product['notax']) . "</span><br />";
181
- $output .= nzshpcrt_currency_display(($product['price'] - $product['special_price']), $product['notax'],false,$product['id']) . "<br />";
182
- } else {
183
- $output .= "<span id='product_price_".$product['id']."'>" . nzshpcrt_currency_display($product['price'], $product['notax']) . "</span><br />";
184
- }
185
- if(((get_option('hide_addtocart_button') !='1') || (get_option('payment_gateway') !='google'))) {
186
- if(isset($wpsc_theme) && is_array($wpsc_theme) && ($wpsc_theme['html'] !='')) {
187
- $output .= $wpsc_theme['html'];
188
- } else {
189
- $output .= "<input type='submit' id='product_".$product['id']."_submit_button' class='wpsc_buy_button' name='Buy' value='".__('Add To Cart', 'wpsc')."' />";
190
- }
191
- }
192
- $output .= "</form>";
193
- if (get_option('addtocart_or_buynow')=='1') {
194
- if (get_option('payment_gateway')=='google') {
195
- $output .= google_buynow($product['id']);
196
- }
197
- }
198
-
199
-
200
- if ($full_view != null) {
201
- if(get_option('product_ratings') == 1) {
202
- $output .= "<div class='product_footer'>";
203
-
204
- $output .= "<div class='product_average_vote'>";
205
- $output .= "<strong>".__('Avg. Customer Rating', 'wpsc').":</strong>";
206
- $output .= nzshpcrt_product_rating($product['id']);
207
- $output .= "</div>";
208
-
209
- $output .= "<div class='product_user_vote'>";
210
- $vote_output = nzshpcrt_product_vote($product['id'],"onmouseover='hide_save_indicator(\"saved_".$product['id']."_text\");'");
211
- if($vote_output[1] == 'voted') {
212
- $output .= "<strong><span id='rating_".$product['id']."_text'>".__('Your Rating', 'wpsc').":</span>";
213
- $output .= "<span class='rating_saved' id='saved_".$product['id']."_text'> ".__('Saved', 'wpsc')."</span>";
214
- $output .= "</strong>";
215
- } else if($vote_output[1] == 'voting') {
216
- $output .= "<strong><span id='rating_".$product['id']."_text'>".__('Rate This item', 'wpsc').":</span>";
217
- $output .= "<span class='rating_saved' id='saved_".$product['id']."_text'> ".__('Saved', 'wpsc')."</span>";
218
- $output .= "</strong>";
219
- }
220
- $output .= $vote_output[0];
221
- $output .= "</div>";
222
- $output .= "</div>";
223
- }
224
-
225
- $output .="</td>";
226
- $output .="</tr>";
227
- } else {
228
- $output .= "</div>\n\r";
229
- $output .= "</div>";
230
- }
231
- }
232
- if ($full_view != null) {
233
- $output .= "</table>";
234
- }
235
- $output .= "</div>\n\r";
236
- $output .= "<br style='clear: left;'>\n\r";
237
- $output .= "</div>\n\r";
238
- }
239
- $content = str_replace($category['original_string'], $output, $content);
240
- }
241
- }
242
- return $content;
243
- }
244
  ?>
1
+ <?php
2
+ function nszhpcrt_homepage_products($content = '') {
3
+ global $wpdb;
4
+ $siteurl = get_option('siteurl');
5
+ if(get_option('permalink_structure') != '') {
6
+ $seperator ="?";
7
+ } else {
8
+ $seperator ="&amp;";
9
+ }
10
+ $sql = "SELECT * FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE `display_frontpage` IN('1') AND `active` IN('1')";
11
+ //$product_list = $wpdb->get_results($sql,ARRAY_A);
12
+ $product_list = array();
13
+ $output = "<div id='homepage_products'>\n\r";
14
+ foreach((array)$product_list as $product) {
15
+ $output .= "<div class='frontpage_product'>\n\r";
16
+ $output .= "<a href='".wpsc_product_url($product['id'])."'>";
17
+ if($product['image'] != '') {
18
+ $output .= "<img src='".WPSC_THUMBNAIL_URL.$product['image']."' title='".$product['name']."' alt='".$product['name']."' />\n\r";
19
+ $output .= "<p>\n\r";
20
+ $output .= stripslashes($product['name']);
21
+ $output .= "<span class='front_page_price'>\n\r";
22
+ if($product['special']==1) {
23
+ $output .= "<span class='oldprice'>".nzshpcrt_currency_display($product['price'], $product['notax'])."</span><br />\n\r";
24
+ $output .= nzshpcrt_currency_display(($product['price'] - $product['special_price']), $product['notax'],false,$product['id']);
25
+ } else {
26
+ $output .= "".nzshpcrt_currency_display($product['price'], $product['notax']);
27
+ }
28
+ $output .= "</span>\n\r";
29
+ $output .= "</p>\n\r";
30
+ }
31
+ $output .= "</a>";
32
+ $output .= "</div>\n\r";
33
+ }
34
+ $output .= "</div>\n\r";
35
+ $output .= "<br style='clear: left;'>\n\r";
36
+ return preg_replace("/\[homepage_products\]/", $output, $content);
37
+ }
38
+
39
+
40
+
41
+ function nszhpcrt_category_tag($content = '') {
42
+ global $wpdb;
43
+ if(preg_match_all("/\[wpsc_category_exclude=([\d]+),*(full)?\]/", $content, $matches)) {
44
+ foreach($matches[1] as $key => $category_id) {
45
+ $categories[$key]['id'] = $category_id;
46
+ $categories[$key]['display'] = $matches[2][$key];
47
+ $categories[$key]['original_string'] = $matches[0][$key];
48
+ }
49
+ foreach ($categories as $category) {
50
+ $sql1 = "SELECT DISTINCT `".WPSC_TABLE_PRODUCT_LIST."`.*, `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."`.`category_id`,`".WPSC_TABLE_PRODUCT_ORDER."`.`order`, IF(ISNULL(`".WPSC_TABLE_PRODUCT_ORDER."`.`order`), 0, 1) AS `order_state` FROM `".WPSC_TABLE_PRODUCT_LIST."` LEFT JOIN `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."` ON `".WPSC_TABLE_PRODUCT_LIST."`.`id` = `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."`.`product_id` LEFT JOIN `".WPSC_TABLE_PRODUCT_ORDER."` ON ( ( `".WPSC_TABLE_PRODUCT_LIST."`.`id` = `".WPSC_TABLE_PRODUCT_ORDER."`.`product_id` ) AND ( `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."`.`category_id` = `".WPSC_TABLE_PRODUCT_ORDER."`.`category_id` ) ) WHERE `".WPSC_TABLE_PRODUCT_LIST."`.`active` = '1' AND `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."`.`category_id` NOT IN ('".$category['id']."') $no_donations_sql ORDER BY `order_state` DESC,`".WPSC_TABLE_PRODUCT_ORDER."`.`order` ASC";
51
+ $product_list1 = $wpdb->get_results($sql1,ARRAY_A);
52
+ if(function_exists('product_display_list') && (get_option('product_view') == 'list')) {
53
+ $output1= product_display_list($product_list1, $group_type, $group_sql, $search_sql);
54
+ } else if(function_exists('product_display_grid') && (get_option('product_view') == 'grid')) {
55
+ $output1= product_display_grid($product_list1, $group_type, $group_sql, $search_sql);
56
+ } else {
57
+ $output1= product_display_default($product_list1,'');
58
+ }
59
+ }
60
+ $content = str_replace($category['original_string'], $output1, $content);
61
+ }
62
+ if(preg_match_all("/\[wpsc_category=([\d]+),*(full)?\]/", $content, $matches)) {
63
+ foreach($matches[1] as $key => $category_id) {
64
+ $categories[$key]['id'] = $category_id;
65
+ //$categories[$key]['display'] = $matches[2][$key];
66
+ $original_string = $matches[0][$key];
67
+ $query = array('category_id' => $category_id);
68
+
69
+ $content = str_replace($original_string, wpsc_display_products_page($query), $content);
70
+
71
+ }
72
+
73
+
74
+ return $content;
75
+
76
+ //echo("<pre>".print_r($categories,true)."</pre>");
77
+ $siteurl = get_option('siteurl');
78
+ if(get_option('permalink_structure') != '') {
79
+ $seperator ="?";
80
+ } else {
81
+ $seperator ="&amp;";
82
+ }
83
+
84
+ foreach((array)$activated_widgets as $widget_container) {
85
+ if(is_array($widget_container) && array_search(__('Product Donations', 'wpsc'), $widget_container)) {
86
+ $no_donations_sql = "AND `".WPSC_TABLE_PRODUCT_LIST."`.`donation` != '1'";
87
+ break;
88
+ }
89
+ }
90
+ foreach((array)$categories as $category) {
91
+ $full_view = null;
92
+ if($category['display'] == 'full') {
93
+ $sql = "SELECT DISTINCT `".WPSC_TABLE_PRODUCT_LIST."`.*, `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."`.`category_id`,`".WPSC_TABLE_PRODUCT_ORDER."`.`order`, IF(ISNULL(`".WPSC_TABLE_PRODUCT_ORDER."`.`order`), 0, 1) AS `order_state` FROM `".WPSC_TABLE_PRODUCT_LIST."` LEFT JOIN `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."` ON `".WPSC_TABLE_PRODUCT_LIST."`.`id` = `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."`.`product_id` LEFT JOIN `".WPSC_TABLE_PRODUCT_ORDER."` ON ( ( `".WPSC_TABLE_PRODUCT_LIST."`.`id` = `".WPSC_TABLE_PRODUCT_ORDER."`.`product_id` ) AND ( `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."`.`category_id` = `".WPSC_TABLE_PRODUCT_ORDER."`.`category_id` ) ) WHERE `".WPSC_TABLE_PRODUCT_LIST."`.`active` = '1' AND `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."`.`category_id` IN ('".$category['id']."') $no_donations_sql ORDER BY `order_state` DESC,`".WPSC_TABLE_PRODUCT_ORDER."`.`order` ASC";
94
+
95
+ $product_list = $wpdb->get_results($sql,ARRAY_A);
96
+ // sorry about the global variable, but it was the best way I could think of to avoid people having to upgrade the gold cart
97
+ $GLOBALS['wpsc_category_id'] = $category['id'];
98
+ if(function_exists('product_display_list') && (get_option('product_view') == 'list')) {
99
+ $output .= product_display_list($product_list, $group_type, $group_sql, $search_sql);
100
+ } else if(function_exists('product_display_grid') && (get_option('product_view') == 'grid')) {
101
+ $output .= product_display_grid($product_list, $group_type, $group_sql, $search_sql);
102
+ } else {
103
+ $output .= product_display_default($product_list, $group_type, $group_sql, $search_sql);
104
+ }
105
+
106
+ } else {
107
+ $sql = "SELECT DISTINCT `".WPSC_TABLE_PRODUCT_LIST."`.*, `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."`.`category_id`,`".WPSC_TABLE_PRODUCT_ORDER."`.`order`, IF(ISNULL(`".WPSC_TABLE_PRODUCT_ORDER."`.`order`), 0, 1) AS `order_state` FROM `".WPSC_TABLE_PRODUCT_LIST."` LEFT JOIN `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."` ON `".WPSC_TABLE_PRODUCT_LIST."`.`id` = `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."`.`product_id` LEFT JOIN `".WPSC_TABLE_PRODUCT_ORDER."` ON ( ( `".WPSC_TABLE_PRODUCT_LIST."`.`id` = `".WPSC_TABLE_PRODUCT_ORDER."`.`product_id` ) AND ( `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."`.`category_id` = `".WPSC_TABLE_PRODUCT_ORDER."`.`category_id` ) ) WHERE `".WPSC_TABLE_PRODUCT_LIST."`.`active` = '1' AND `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."`.`category_id` IN ('".$category['id']."') $no_donations_sql ORDER BY `order_state` DESC,`".WPSC_TABLE_PRODUCT_ORDER."`.`order` ASC";
108
+
109
+ $product_list = $wpdb->get_results($sql,ARRAY_A);
110
+ $output = "<div id='products_page_container' class='wrap wpsc_container'>\n\r";
111
+ $output .= "<div id='homepage_products'>\n\r";
112
+ if ($full_view != null){
113
+ $output .= "<table class='productdisplay'>";
114
+ }
115
+ foreach((array)$product_list as $product) {
116
+ if(function_exists('wpsc_theme_html')) {
117
+ $wpsc_theme = wpsc_theme_html($product);
118
+ }
119
+ if ($full_view == null) {
120
+ $output .= "<div class='category_view_product'>\n\r";
121
+ } else {
122
+ /* product image is here */
123
+ $output .= "<tr>";
124
+ $output .= "<td class='imagecol'>";
125
+ }
126
+ $output .="<a href='".WPSC_IMAGE_URL.$product['image']."' class='thickbox preview_link' rel='".str_replace(" ", "_",$product['name'])."'>";
127
+ if($product['image'] != '') {
128
+ $output .= "<img class='product_image' src='".WPSC_THUMBNAIL_URL.$product['image']."' title='".$product['name']."' alt='".$product['name']."' />\n\r";
129
+ }
130
+ $output .= "</a>";
131
+ if ($full_view != null) {
132
+ $output .= "</td><td class='textcol'>";
133
+ } else {
134
+ $output .= "<div class='product_details'>";
135
+ }
136
+ if (get_option('hide_name_link')!=1) {
137
+ if(($product['special']==1) && ($variations_output[1] === null)) {
138
+ $output .= "<a href='".wpsc_product_url($product['id'])."' class='wpsc_product_title' >$special<strong class='special'>Special / Sale Price - </strong><strong>" . stripslashes($product['name']) . "</strong></a>";
139
+ } else {
140
+ $output .= "<a href='".wpsc_product_url($product['id'])."' class='wpsc_product_title' >$special<strong>" . stripslashes($product['name']) . "</strong></a>";
141
+ }
142
+ } else {
143
+ if(($product['special']==1) && ($variations_output[1] === null)) {
144
+ $output .= "<a class='wpsc_product_title' >$special<strong class='special'>Special / Sale Price - </strong><strong>" . stripslashes($product['name']) . "</strong></a>";
145
+ } else {
146
+ $output .= "<a class='wpsc_product_title' >$special<strong>" . stripslashes($product['name']) . "</strong></a>";
147
+ }
148
+ }
149
+ if ($full_view !=null) {
150
+ if($product['description'] != '') {
151
+ $output .= "<p class='wpsc_description'>".nl2br(stripslashes($product['description'])) . "</p>";
152
+ }
153
+
154
+ if($product['additional_description'] != '') {
155
+ $output .= "<a href='#' class='additional_description_link' onclick='return show_additional_description(\"additionaldescription".$product['id']."\",\"link_icon".$product['id']."\");'>";
156
+ $output .= "<img id='link_icon".$product['id']."' class='additional_description_button' src='".WPSC_URL."/images/icon_window_expand.gif' title='".$product['name']."' alt='".$product['name']."' />";
157
+ $output .= __('More Details', 'wpsc')."</a>";
158
+
159
+ $output .= "<span class='additional_description' id='additionaldescription".$product['id']."'><br />";
160
+ $output .= nl2br(stripslashes($product['additional_description'])) . "";
161
+ $output .= "</span><br />";
162
+ }
163
+ }
164
+ /*
165
+ adding to cart stuff
166
+ */
167
+ $output .= "<form id='product_".$product['id']."' name='product_".$product['id']."' method='post' action='".get_option('product_list_url').$seperator."category=".$_GET['category']."' onsubmit='submitform(this);return false;' >";
168
+ $output .= "<input type='hidden' name='prodid' value='".$product['id']."' />";
169
+ $output .= "<input type='hidden' name='item' value='".$product['id']."' />";
170
+
171
+ $variations_procesor = new nzshpcrt_variations;
172
+
173
+ $variations_output = $variations_procesor->display_product_variations($product['id'],false, false, true);
174
+ $output .= $variations_output[0];
175
+ if($variations_output[1] !== null) {
176
+ $product['price'] = $variations_output[1];
177
+ }
178
+
179
+ if(($product['special']==1) && ($variations_output[1] === null)) {
180
+ $output .= "<span class='oldprice'>".nzshpcrt_currency_display($product['price'], $product['notax']) . "</span><br />";
181
+ $output .= nzshpcrt_currency_display(($product['price'] - $product['special_price']), $product['notax'],false,$product['id']) . "<br />";
182
+ } else {
183
+ $output .= "<span id='product_price_".$product['id']."'>" . nzshpcrt_currency_display($product['price'], $product['notax']) . "</span><br />";
184
+ }
185
+ if(((get_option('hide_addtocart_button') !='1') || (get_option('payment_gateway') !='google'))) {
186
+ if(isset($wpsc_theme) && is_array($wpsc_theme) && ($wpsc_theme['html'] !='')) {
187
+ $output .= $wpsc_theme['html'];
188
+ } else {
189
+ $output .= "<input type='submit' id='product_".$product['id']."_submit_button' class='wpsc_buy_button' name='Buy' value='".__('Add To Cart', 'wpsc')."' />";
190
+ }
191
+ }
192
+ $output .= "</form>";
193
+ if (get_option('addtocart_or_buynow')=='1') {
194
+ if (get_option('payment_gateway')=='google') {
195
+ $output .= google_buynow($product['id']);
196
+ }
197
+ }
198
+
199
+
200
+ if ($full_view != null) {
201
+ if(get_option('product_ratings') == 1) {
202
+ $output .= "<div class='product_footer'>";
203
+
204
+ $output .= "<div class='product_average_vote'>";
205
+ $output .= "<strong>".__('Avg. Customer Rating', 'wpsc').":</strong>";
206
+ $output .= nzshpcrt_product_rating($product['id']);
207
+ $output .= "</div>";
208
+
209
+ $output .= "<div class='product_user_vote'>";
210
+ $vote_output = nzshpcrt_product_vote($product['id'],"onmouseover='hide_save_indicator(\"saved_".$product['id']."_text\");'");
211
+ if($vote_output[1] == 'voted') {
212
+ $output .= "<strong><span id='rating_".$product['id']."_text'>".__('Your Rating', 'wpsc').":</span>";
213
+ $output .= "<span class='rating_saved' id='saved_".$product['id']."_text'> ".__('Saved', 'wpsc')."</span>";
214
+ $output .= "</strong>";
215
+ } else if($vote_output[1] == 'voting') {
216
+ $output .= "<strong><span id='rating_".$product['id']."_text'>".__('Rate This item', 'wpsc').":</span>";
217
+ $output .= "<span class='rating_saved' id='saved_".$product['id']."_text'> ".__('Saved', 'wpsc')."</span>";
218
+ $output .= "</strong>";
219
+ }
220
+ $output .= $vote_output[0];
221
+ $output .= "</div>";
222
+ $output .= "</div>";
223
+ }
224
+
225
+ $output .="</td>";
226
+ $output .="</tr>";
227
+ } else {
228
+ $output .= "</div>\n\r";
229
+ $output .= "</div>";
230
+ }
231
+ }
232
+ if ($full_view != null) {
233
+ $output .= "</table>";
234
+ }
235
+ $output .= "</div>\n\r";
236
+ $output .= "<br style='clear: left;'>\n\r";
237
+ $output .= "</div>\n\r";
238
+ }
239
+ $content = str_replace($category['original_string'], $output, $content);
240
+ }
241
+ }
242
+ return $content;
243
+ }
244
  ?>
image_processing.php CHANGED
@@ -99,6 +99,8 @@ global $wpdb;
99
 
100
  // Final thumbnail cropped from the center out.
101
  //ImageCopyResampled( $dst_img, $temp_img, 0, 0, $w1, $h1, $width, $height, $width, $height );
 
 
102
  ImageCopy( $dst_img, $temp_img, $w1, $h1, 0, 0, $temp_w, $temp_h );
103
  //mail('thomas.howard@gmail.com','lolwut',"ImageCopy( $dst_img, $temp_img, $w1, $h1, 0, 0, $temp_w, $temp_h );");
104
 
99
 
100
  // Final thumbnail cropped from the center out.
101
  //ImageCopyResampled( $dst_img, $temp_img, 0, 0, $w1, $h1, $width, $height, $width, $height );
102
+ if(!isset($h1))
103
+ $h1 = 0;
104
  ImageCopy( $dst_img, $temp_img, $w1, $h1, 0, 0, $temp_w, $temp_h );
105
  //mail('thomas.howard@gmail.com','lolwut',"ImageCopy( $dst_img, $temp_img, $w1, $h1, 0, 0, $temp_w, $temp_h );");
106
 
insertcate.php CHANGED
@@ -11,7 +11,7 @@ $tinyURI = get_option('siteurl').$tinyURI;
11
 
12
  $a = substr($filedir, strpos($filedir,'/wp-content/plugins/'));
13
  $plugindir = substr($a , 0, strpos($a,'/js') );
14
- $pluginURL = get_settings('siteurl') . $plugindir;
15
  ?>
16
  <html xmlns="http://www.w3.org/1999/xhtml">
17
  <head>
11
 
12
  $a = substr($filedir, strpos($filedir,'/wp-content/plugins/'));
13
  $plugindir = substr($a , 0, strpos($a,'/js') );
14
+ $pluginURL = get_option('siteurl') . $plugindir;
15
  ?>
16
  <html xmlns="http://www.w3.org/1999/xhtml">
17
  <head>
languages/wpsc-pt_PT.mo ADDED
Binary file
languages/wpsc-pt_PT.po ADDED
@@ -0,0 +1,4014 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Wordpress Shopping Cart - 3.7.6.1\n"
4
+ "Report-Msgid-Bugs-To: http://wordpress.org/tag/wp-e-commerce\n"
5
+ "POT-Creation-Date: 2010-06-08 02:28+0000\n"
6
+ "PO-Revision-Date: \n"
7
+ "Last-Translator: Manuel Inácio <info@minacio.com>\n"
8
+ "Language-Team: Manuel Inácio <info@minacio.com>\n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Poedit-KeywordsList: __;_e\n"
13
+ "X-Poedit-Basepath: C:\\www\\www\\wpecommerce\\wp-content\\plugins\n"
14
+ "X-Poedit-Language: Portuguese\n"
15
+ "X-Poedit-Country: PORTUGAL\n"
16
+ "X-Poedit-SearchPath-0: wp-e-commerce\n"
17
+
18
+ #: admin-form-functions.php:10
19
+ msgid "You are editing the &quot;[categorisation]&quot; Category"
20
+ msgstr "Está a editar a categoria &quot;[categorisation]&quot;"
21
+
22
+ #: admin-form-functions.php:11
23
+ #: wpsc-admin/display-groups.page.php:759
24
+ msgid "+ Add new category to the &quot;[categorisation]&quot; Group"
25
+ msgstr "+ Adicione uma nova categoria ao grupo &quot;[categorisation]&quot;"
26
+
27
+ #: admin-form-functions.php:25
28
+ #: admin-form-functions.php:279
29
+ #: admin-form-functions.php:867
30
+ #: display-ecommerce-subs.php:9
31
+ #: js/tinymce3/window.php:105
32
+ #: user-log.php:200
33
+ #: user-log.php:359
34
+ #: wpsc-admin/display-groups.page.php:698
35
+ #: wpsc-admin/display-groups.page.php:774
36
+ #: wpsc-admin/display-upgrades.page.php:88
37
+ #: wpsc-admin/display-variations.page.php:13
38
+ #: wpsc-admin/display-variations.page.php:156
39
+ #: wpsc-admin/includes/display-items-functions.php:792
40
+ #: wpsc-admin/includes/display-items-functions.php:804
41
+ #: wpsc-admin/includes/settings-pages/presentation.php:457
42
+ msgid "Name"
43
+ msgstr "Nome"
44
+
45
+ #: admin-form-functions.php:34
46
+ #: js/tinymce3/window.php:109
47
+ #: wpsc-admin/display-groups.page.php:782
48
+ #: wpsc-admin/includes/display-items-functions.php:807
49
+ msgid "Description"
50
+ msgstr "Descrição"
51
+
52
+ #: admin-form-functions.php:44
53
+ msgid "Category Parent"
54
+ msgstr "Categoria principal"
55
+
56
+ #: admin-form-functions.php:85
57
+ msgid "Category&nbsp;Image"
58
+ msgstr "Categoria&nbsp;Imagem"
59
+
60
+ #: admin-form-functions.php:101
61
+ #: admin-form-functions.php:110
62
+ #: admin-form-functions.php:198
63
+ #: wpsc-admin/display-groups.page.php:812
64
+ #: wpsc-admin/display-groups.page.php:865
65
+ #: wpsc-admin/includes/display-items-functions.php:675
66
+ #: wpsc-admin/includes/settings-pages/presentation.php:864
67
+ #: wpsc-admin/includes/settings-pages/presentation.php:875
68
+ #: wpsc-admin/includes/settings-pages/presentation.php:884
69
+ #: wpsc-admin/includes/settings-pages/presentation.php:945
70
+ msgid "Height"
71
+ msgstr "Altura"
72
+
73
+ #: admin-form-functions.php:101
74
+ #: admin-form-functions.php:110
75
+ #: admin-form-functions.php:199
76
+ #: wpsc-admin/display-groups.page.php:812
77
+ #: wpsc-admin/display-groups.page.php:866
78
+ #: wpsc-admin/includes/display-items-functions.php:687
79
+ #: wpsc-admin/includes/settings-pages/presentation.php:865
80
+ #: wpsc-admin/includes/settings-pages/presentation.php:875
81
+ #: wpsc-admin/includes/settings-pages/presentation.php:884
82
+ #: wpsc-admin/includes/settings-pages/presentation.php:946
83
+ msgid "Width"
84
+ msgstr "Largura"
85
+
86
+ #: admin-form-functions.php:102
87
+ #: admin-form-functions.php:111
88
+ #: wpsc-admin/display-groups.page.php:813
89
+ msgid "You can upload thumbnail images for each group. To display Group details in your shop you must configure these settings under <a href=\"admin.php?page=wpsc-settings&tab=presentation\">Presentation Settings</a>."
90
+ msgstr "Pode fazer upload de imagens miniatura para cada grupo. Para mostrar os detalhes do Grupo na sua loja, deverá configurar essas definições nas <a href=\"admin.php?page=wpsc-settings&tab=presentation\">Definições de Apresentação</a>."
91
+
92
+ #: admin-form-functions.php:119
93
+ msgid "Delete Image"
94
+ msgstr "Eliminar imagem"
95
+
96
+ #: admin-form-functions.php:133
97
+ #: wpsc-admin/display-groups.page.php:16
98
+ #: wpsc-admin/includes/settings-pages/general.php:83
99
+ msgid "Target Markets"
100
+ msgstr "Mercados alvo"
101
+
102
+ #: admin-form-functions.php:138
103
+ #: wpsc-admin/display-groups.page.php:22
104
+ #: wpsc-admin/includes/settings-pages/general.php:89
105
+ msgid ""
106
+ "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.\r\n"
107
+ "\t\t\t"
108
+ msgstr ""
109
+ "A funcionalidade de Mercados Alvo foi desactivada porque tem a extensão Suhosin PHP instalada neste servidor. Se precisa utilizar a funcionalidade de Mercados Alvo, deverá desactivar a extensão Suhosin PHP. Se não o conseguir fazer, deverá contactar o seu fornecedor de alojamento.\n"
110
+ "\t\t\t"
111
+
112
+ #: admin-form-functions.php:164
113
+ #: wpsc-admin/display-groups.page.php:822
114
+ #: wpsc-admin/includes/settings-pages/presentation.php:57
115
+ msgid "Presentation Settings"
116
+ msgstr "Definições de apresentação"
117
+
118
+ #: admin-form-functions.php:165
119
+ #: wpsc-admin/display-groups.page.php:823
120
+ msgid "To over-ride the presentation settings for this group you can enter in your prefered settings here"
121
+ msgstr "Para se sobrepor às definições de apresentação deste grupo, pode introduzir aqui as definições da sua preferência"
122
+
123
+ #: admin-form-functions.php:171
124
+ #: wpsc-admin/display-groups.page.php:831
125
+ #: wpsc-admin/includes/settings-pages/presentation.php:288
126
+ msgid "Catalog View"
127
+ msgstr "Vissualização de catálogo"
128
+
129
+ #: admin-form-functions.php:175
130
+ #: wpsc-includes/form-display.functions.php:6
131
+ msgid "Please select"
132
+ msgstr "Por favor seleccione"
133
+
134
+ #: admin-form-functions.php:176
135
+ #: wpsc-admin/display-groups.page.php:835
136
+ #: wpsc-admin/includes/settings-pages/presentation.php:346
137
+ msgid "Default View"
138
+ msgstr "Visualização padrão"
139
+
140
+ #: admin-form-functions.php:178
141
+ #: admin-form-functions.php:180
142
+ #: wpsc-admin/display-groups.page.php:839
143
+ #: wpsc-admin/display-groups.page.php:843
144
+ #: wpsc-admin/includes/settings-pages/presentation.php:350
145
+ #: wpsc-admin/includes/settings-pages/presentation.php:354
146
+ msgid "List View"
147
+ msgstr "Visualização de lista"
148
+
149
+ #: admin-form-functions.php:183
150
+ #: admin-form-functions.php:185
151
+ #: wpsc-admin/display-groups.page.php:849
152
+ #: wpsc-admin/display-groups.page.php:853
153
+ #: wpsc-admin/includes/settings-pages/presentation.php:361
154
+ #: wpsc-admin/includes/settings-pages/presentation.php:365
155
+ msgid "Grid View"
156
+ msgstr "Vista em grelha"
157
+
158
+ #: admin-form-functions.php:195
159
+ #: wpsc-admin/display-groups.page.php:863
160
+ msgid "Thumbnail&nbsp;Size"
161
+ msgstr "Tamanhol&nbsp;da&nbsp;miniatura"
162
+
163
+ #: admin-form-functions.php:208
164
+ #: wpsc-admin/display-groups.page.php:872
165
+ #: wpsc-admin/display-sales-logs.php:317
166
+ #: wpsc-admin/display-sales-logs.php:318
167
+ msgid "Checkout Settings"
168
+ msgstr "Definições de checkout"
169
+
170
+ #: admin-form-functions.php:217
171
+ #: wpsc-admin/display-groups.page.php:878
172
+ msgid "This category requires additional checkout form fields"
173
+ msgstr "Esta categoria requer campos adicionais no formulário de checkout"
174
+
175
+ #: admin-form-functions.php:222
176
+ msgid "None"
177
+ msgstr "Nenhum"
178
+
179
+ #: admin-form-functions.php:247
180
+ #: wpsc-admin/display-groups.page.php:906
181
+ msgid "Products in this category use the billing address to calculate shipping"
182
+ msgstr "Os produtos nesta categoria utilizam o endereço de facturação para calcular os portes"
183
+
184
+ #: admin-form-functions.php:250
185
+ #: display-coupons.php:502
186
+ #: display-coupons.php:526
187
+ #: merchants/chronopay.php:427
188
+ #: merchants/paypal_multiple.php:478
189
+ #: merchants/paypal_multiple.php:486
190
+ #: merchants/paypal_multiple.php:502
191
+ #: wpsc-admin/display-groups.page.php:908
192
+ #: wpsc-admin/includes/display-items-functions.php:823
193
+ #: wpsc-admin/includes/settings-pages/admin.php:38
194
+ #: wpsc-admin/includes/settings-pages/admin.php:64
195
+ #: wpsc-admin/includes/settings-pages/checkout.php:71
196
+ #: wpsc-admin/includes/settings-pages/checkout.php:95
197
+ #: wpsc-admin/includes/settings-pages/checkout.php:118
198
+ #: wpsc-admin/includes/settings-pages/checkout.php:143
199
+ #: wpsc-admin/includes/settings-pages/general.php:72
200
+ #: wpsc-admin/includes/settings-pages/general.php:197
201
+ #: wpsc-admin/includes/settings-pages/presentation.php:108
202
+ #: wpsc-admin/includes/settings-pages/presentation.php:139
203
+ #: wpsc-admin/includes/settings-pages/presentation.php:163
204
+ #: wpsc-admin/includes/settings-pages/presentation.php:187
205
+ #: wpsc-admin/includes/settings-pages/presentation.php:210
206
+ #: wpsc-admin/includes/settings-pages/presentation.php:232
207
+ #: wpsc-admin/includes/settings-pages/presentation.php:483
208
+ #: wpsc-admin/includes/settings-pages/presentation.php:534
209
+ #: wpsc-admin/includes/settings-pages/presentation.php:575
210
+ #: wpsc-admin/includes/settings-pages/presentation.php:611
211
+ #: wpsc-admin/includes/settings-pages/presentation.php:716
212
+ #: wpsc-admin/includes/settings-pages/presentation.php:740
213
+ #: wpsc-admin/includes/settings-pages/presentation.php:771
214
+ #: wpsc-admin/includes/settings-pages/presentation.php:796
215
+ #: wpsc-admin/includes/settings-pages/presentation.php:823
216
+ #: wpsc-admin/includes/settings-pages/presentation.php:849
217
+ #: wpsc-admin/includes/settings-pages/presentation.php:909
218
+ #: wpsc-admin/includes/settings-pages/presentation.php:935
219
+ #: wpsc-admin/includes/settings-pages/presentation.php:979
220
+ #: wpsc-admin/includes/settings-pages/presentation.php:1026
221
+ #: wpsc-admin/includes/settings-pages/shipping.php:87
222
+ #: wpsc-admin/includes/settings-pages/shipping.php:122
223
+ #: wpsc-admin/includes/settings-pages/shipping.php:152
224
+ msgid "Yes"
225
+ msgstr "Sim"
226
+
227
+ #: admin-form-functions.php:251
228
+ #: display-coupons.php:503
229
+ #: display-coupons.php:527
230
+ #: merchants/chronopay.php:428
231
+ #: merchants/paypal_multiple.php:479
232
+ #: merchants/paypal_multiple.php:487
233
+ #: merchants/paypal_multiple.php:503
234
+ #: wpsc-admin/display-groups.page.php:909
235
+ #: wpsc-admin/includes/display-items-functions.php:825
236
+ #: wpsc-admin/includes/settings-pages/admin.php:39
237
+ #: wpsc-admin/includes/settings-pages/admin.php:65
238
+ #: wpsc-admin/includes/settings-pages/checkout.php:72
239
+ #: wpsc-admin/includes/settings-pages/checkout.php:97
240
+ #: wpsc-admin/includes/settings-pages/checkout.php:120
241
+ #: wpsc-admin/includes/settings-pages/checkout.php:145
242
+ #: wpsc-admin/includes/settings-pages/general.php:74
243
+ #: wpsc-admin/includes/settings-pages/general.php:200
244
+ #: wpsc-admin/includes/settings-pages/presentation.php:109
245
+ #: wpsc-admin/includes/settings-pages/presentation.php:140
246
+ #: wpsc-admin/includes/settings-pages/presentation.php:164
247
+ #: wpsc-admin/includes/settings-pages/presentation.php:188
248
+ #: wpsc-admin/includes/settings-pages/presentation.php:212
249
+ #: wpsc-admin/includes/settings-pages/presentation.php:234
250
+ #: wpsc-admin/includes/settings-pages/presentation.php:484
251
+ #: wpsc-admin/includes/settings-pages/presentation.php:535
252
+ #: wpsc-admin/includes/settings-pages/presentation.php:576
253
+ #: wpsc-admin/includes/settings-pages/presentation.php:612
254
+ #: wpsc-admin/includes/settings-pages/presentation.php:717
255
+ #: wpsc-admin/includes/settings-pages/presentation.php:741
256
+ #: wpsc-admin/includes/settings-pages/presentation.php:772
257
+ #: wpsc-admin/includes/settings-pages/presentation.php:797
258
+ #: wpsc-admin/includes/settings-pages/presentation.php:824
259
+ #: wpsc-admin/includes/settings-pages/presentation.php:850
260
+ #: wpsc-admin/includes/settings-pages/presentation.php:910
261
+ #: wpsc-admin/includes/settings-pages/presentation.php:936
262
+ #: wpsc-admin/includes/settings-pages/presentation.php:980
263
+ #: wpsc-admin/includes/settings-pages/presentation.php:1027
264
+ #: wpsc-admin/includes/settings-pages/shipping.php:88
265
+ #: wpsc-admin/includes/settings-pages/shipping.php:123
266
+ #: wpsc-admin/includes/settings-pages/shipping.php:153
267
+ msgid "No"
268
+ msgstr "Não"
269
+
270
+ #: admin-form-functions.php:261
271
+ msgid "Update Category"
272
+ msgstr "Actualizar categoria"
273
+
274
+ #: admin-form-functions.php:262
275
+ #: admin-form-functions.php:300
276
+ #: admin-form-functions.php:319
277
+ #: shipping/tablerate.php:44
278
+ #: shipping/weightrate.php:35
279
+ #: wpsc-admin/admin.php:347
280
+ #: wpsc-admin/ajax-and-init.php:1897
281
+ #: wpsc-admin/display-groups.page.php:669
282
+ #: wpsc-admin/display-items.page.php:276
283
+ #: wpsc-admin/display-items.page.php:400
284
+ #: wpsc-admin/display-sales-logs.php:425
285
+ #: wpsc-admin/display-sales-logs.php:550
286
+ #: wpsc-admin/display-variations.page.php:178
287
+ #: wpsc-admin/display-variations.page.php:191
288
+ #: wpsc-admin/display-variations.page.php:213
289
+ #: wpsc-admin/includes/display-items-functions.php:351
290
+ #: wpsc-admin/includes/display-items-functions.php:797
291
+ #: wpsc-admin/includes/settings-pages/checkout.php:248
292
+ msgid "Delete"
293
+ msgstr "Eliminar"
294
+
295
+ #: admin-form-functions.php:288
296
+ #: wpsc-admin/display-variations.page.php:164
297
+ msgid "Variation Values"
298
+ msgstr "Valores da variável"
299
+
300
+ #: admin-form-functions.php:307
301
+ #: wpsc-admin/admin.php:236
302
+ #: wpsc-admin/display-variations.page.php:218
303
+ #: wpsc-admin/includes/settings-pages/checkout.php:175
304
+ msgid "Add"
305
+ msgstr "Adicionar"
306
+
307
+ #: admin-form-functions.php:318
308
+ #: display-coupons.php:389
309
+ #: display-coupons.php:450
310
+ #: wpsc-admin/display-groups.page.php:106
311
+ #: wpsc-admin/display-groups.page.php:706
312
+ #: wpsc-admin/display-groups.page.php:719
313
+ #: wpsc-admin/display-variations.page.php:14
314
+ #: wpsc-admin/display-variations.page.php:111
315
+ #: wpsc-includes/variations.class.php:343
316
+ #: wpsc-includes/wpsc_query.php:226
317
+ msgid "Edit"
318
+ msgstr "Editar"
319
+
320
+ #: admin-form-functions.php:339
321
+ #: display-coupons.php:174
322
+ #: display-coupons.php:365
323
+ #: wpsc-admin/display-sales-logs.php:247
324
+ msgid "Coupon Code"
325
+ msgstr "Código do cupão"
326
+
327
+ #: admin-form-functions.php:340
328
+ #: display-coupons.php:177
329
+ #: display-coupons.php:369
330
+ #: themes/default/shopping_cart_page.php:190
331
+ #: themes/iShop/shopping_cart_page.php:163
332
+ #: themes/marketplace/shopping_cart_page.php:161
333
+ #: transaction_result_functions.php:207
334
+ #: transaction_result_functions.php:215
335
+ #: wpsc-admin/ajax-and-init.php:1141
336
+ #: wpsc-admin/ajax-and-init.php:1147
337
+ #: wpsc-admin/display-sales-logs.php:250
338
+ msgid "Discount"
339
+ msgstr "Desconto"
340
+
341
+ #: admin-form-functions.php:341
342
+ #: display-coupons.php:180
343
+ #: display-coupons.php:373
344
+ msgid "Start"
345
+ msgstr "Início"
346
+
347
+ #: admin-form-functions.php:342
348
+ #: display-coupons.php:183
349
+ #: display-coupons.php:377
350
+ msgid "Expiry"
351
+ msgstr "Final"
352
+
353
+ #: admin-form-functions.php:343
354
+ #: display-coupons.php:186
355
+ msgid "Use Once"
356
+ msgstr "Utilização única"
357
+
358
+ #: admin-form-functions.php:344
359
+ #: display-coupons.php:189
360
+ #: display-coupons.php:381
361
+ msgid "Active"
362
+ msgstr "Activo"
363
+
364
+ #: admin-form-functions.php:345
365
+ #: display-coupons.php:193
366
+ #: display-coupons.php:287
367
+ #: display-coupons.php:385
368
+ msgid "Apply On All Products"
369
+ msgstr "Aplicável a todos os produtos"
370
+
371
+ #: admin-form-functions.php:554
372
+ msgid "Update Coupon"
373
+ msgstr "Actualizar cupão"
374
+
375
+ #: admin-form-functions.php:555
376
+ msgid "Delete Coupon"
377
+ msgstr "Eliminar cupão"
378
+
379
+ #: admin-form-functions.php:566
380
+ #: wpsc-admin/admin.php:137
381
+ msgid "Settings"
382
+ msgstr "Definições"
383
+
384
+ #: admin-form-functions.php:570
385
+ #: wpsc-admin/display-sales-logs.php:316
386
+ msgid "Shop Settings"
387
+ msgstr "Definições da Loja"
388
+
389
+ #: admin-form-functions.php:571
390
+ msgid "Money and Payment"
391
+ msgstr "Dinheiro e pagamentos"
392
+
393
+ #: admin-form-functions.php:572
394
+ msgid "Checkout Page Settings"
395
+ msgstr "Definições da página de checkout"
396
+
397
+ #: admin-form-functions.php:590
398
+ #: admin-form-functions.php:591
399
+ msgid "product"
400
+ msgstr "produto"
401
+
402
+ #: admin-form-functions.php:590
403
+ #: admin-form-functions.php:591
404
+ msgid "products"
405
+ msgstr "produtos"
406
+
407
+ #: admin-form-functions.php:595
408
+ #: admin-form-functions.php:596
409
+ msgid "group"
410
+ msgstr "grupo"
411
+
412
+ #: admin-form-functions.php:595
413
+ #: admin-form-functions.php:596
414
+ msgid "groups"
415
+ msgstr "grupos"
416
+
417
+ #: admin-form-functions.php:600
418
+ #: admin-form-functions.php:601
419
+ msgid "sale"
420
+ msgstr "venda"
421
+
422
+ #: admin-form-functions.php:600
423
+ #: admin-form-functions.php:601
424
+ msgid "sales"
425
+ msgstr "vendas"
426
+
427
+ #: admin-form-functions.php:607
428
+ msgid "variation"
429
+ msgstr "variável"
430
+
431
+ #: admin-form-functions.php:607
432
+ msgid "variations"
433
+ msgstr "variáveis"
434
+
435
+ #: admin-form-functions.php:611
436
+ #: admin-form-functions.php:612
437
+ #: admin-form-functions.php:615
438
+ msgid "transaction"
439
+ msgstr "transação"
440
+
441
+ #: admin-form-functions.php:611
442
+ #: admin-form-functions.php:612
443
+ #: admin-form-functions.php:615
444
+ msgid "transactions"
445
+ msgstr "transações"
446
+
447
+ #: admin-form-functions.php:624
448
+ msgid "Current Month"
449
+ msgstr "Mês actual"
450
+
451
+ #: admin-form-functions.php:629
452
+ msgid "At a Glance"
453
+ msgstr "Vista geral"
454
+
455
+ #: admin-form-functions.php:659
456
+ msgid "Pending"
457
+ msgstr "Pendente"
458
+
459
+ #: admin-form-functions.php:674
460
+ msgid "Closed"
461
+ msgstr "Fechado"
462
+
463
+ #: admin-form-functions.php:682
464
+ #: admin-form-functions.php:690
465
+ #: wpsc-admin/includes/display-items-functions.php:350
466
+ msgid "Add New Product"
467
+ msgstr "Adicionar um novo produto"
468
+
469
+ #: admin-form-functions.php:682
470
+ msgid "Here you can add products, groups or variations"
471
+ msgstr "Aqui pode adicionar produtos, grupos ou variáveis"
472
+
473
+ #: admin-form-functions.php:691
474
+ msgid "Right Now"
475
+ msgstr "Agora"
476
+
477
+ #: admin-form-functions.php:696
478
+ msgid "You have <a href=\"admin.php?page=wpsc-edit-products\">:productcount:</a>, contained within <a href=\"admin.php?page=wpsc-edit-groups\">:groupcount:</a>. This month you made :salecount: and generated a total of :monthtotal: and your total sales ever is :overaltotal:. You have :pendingcount: awaiting approval."
479
+ msgstr "Tem <a href=\"admin.php?page=wpsc-edit-products\">:productcount:</a>, em <a href=\"admin.php?page=wpsc-edit-groups\">:groupcount:</a>. Neste mês realizou :salecount:, gerou um total de :monthtotal: e o total global das suas vendas é de :overaltotal:. Tem :pendingcount: a aguardar aprovação."
480
+
481
+ #: admin-form-functions.php:698
482
+ msgid "You are using the :theme: style. This is WP e-Commerce :versionnumber:."
483
+ msgstr "Está a utilizar o tema :theme:. Esta é a versão :versionnumber: do WP e-Commerce."
484
+
485
+ #: admin-form-functions.php:729
486
+ msgid "Packing Slip"
487
+ msgstr "Nota de Embalagem"
488
+
489
+ #: admin-form-functions.php:730
490
+ msgid "Order"
491
+ msgstr "Encomenda"
492
+
493
+ #: admin-form-functions.php:865
494
+ #: themes/default/list_view.php:137
495
+ #: themes/default/products_page.php:197
496
+ #: themes/default/shopping_cart_page.php:15
497
+ #: themes/default/single_product.php:131
498
+ #: themes/iShop/list_view.php:138
499
+ #: themes/iShop/products_page.php:196
500
+ #: themes/iShop/shopping_cart_page.php:14
501
+ #: themes/iShop/single_product.php:134
502
+ #: themes/marketplace/list_view.php:139
503
+ #: themes/marketplace/products_page.php:199
504
+ #: themes/marketplace/shopping_cart_page.php:14
505
+ #: themes/marketplace/single_product.php:136
506
+ #: user-log.php:204
507
+ #: wpsc-includes/display.functions.php:47
508
+ msgid "Quantity"
509
+ msgstr "Quantidade"
510
+
511
+ #: admin-form-functions.php:870
512
+ #: js/tinymce3/window.php:113
513
+ #: themes/default/cart_widget.php:25
514
+ #: themes/default/products_page.php:214
515
+ #: themes/default/products_page.php:216
516
+ #: themes/default/shopping_cart_page.php:19
517
+ #: themes/default/single_product.php:148
518
+ #: themes/default/single_product.php:150
519
+ #: themes/iShop/cart_widget.php:25
520
+ #: themes/iShop/products_page.php:212
521
+ #: themes/iShop/products_page.php:214
522
+ #: themes/iShop/shopping_cart_page.php:18
523
+ #: themes/iShop/single_product.php:151
524
+ #: themes/iShop/single_product.php:153
525
+ #: themes/marketplace/cart_widget.php:25
526
+ #: themes/marketplace/products_page.php:216
527
+ #: themes/marketplace/products_page.php:218
528
+ #: themes/marketplace/shopping_cart_page.php:18
529
+ #: themes/marketplace/single_product.php:153
530
+ #: themes/marketplace/single_product.php:155
531
+ #: user-log.php:60
532
+ #: user-log.php:208
533
+ #: wpsc-admin/includes/display-items-functions.php:189
534
+ #: wpsc-admin/includes/display-items-functions.php:242
535
+ #: wpsc-admin/includes/settings-pages/presentation.php:458
536
+ #: wpsc-includes/variations.class.php:218
537
+ msgid "Price"
538
+ msgstr "Preço"
539
+
540
+ #: admin-form-functions.php:872
541
+ #: themes/default/cart_widget.php:40
542
+ #: themes/default/shopping_cart_page.php:17
543
+ #: themes/iShop/cart_widget.php:40
544
+ #: themes/iShop/shopping_cart_page.php:16
545
+ #: themes/marketplace/cart_widget.php:40
546
+ #: themes/marketplace/shopping_cart_page.php:16
547
+ #: transaction_result_functions.php:176
548
+ #: transaction_result_functions.php:178
549
+ #: wpsc-admin/ajax-and-init.php:1120
550
+ #: wpsc-admin/ajax-and-init.php:1122
551
+ #: wpsc-admin/display-options-settings.page.php:102
552
+ #: wpsc-admin/display-sales-logs.php:256
553
+ msgid "Shipping"
554
+ msgstr "Envio"
555
+
556
+ #: admin-form-functions.php:980
557
+ msgid "This users cart was empty"
558
+ msgstr "O carrinho de compras deste utilizador encontrava-se vazio"
559
+
560
+ #: display-coupons.php:29
561
+ msgid "Thanks, the coupon has been added."
562
+ msgstr "Obrigado, o cupão foi adicionado"
563
+
564
+ #: display-coupons.php:155
565
+ msgid "Coupons"
566
+ msgstr "Cupões"
567
+
568
+ #: display-coupons.php:160
569
+ msgid "Create Coupon"
570
+ msgstr "Criar cupão"
571
+
572
+ #: display-coupons.php:351
573
+ msgid "Add New Condition"
574
+ msgstr "Adicionar nova variável"
575
+
576
+ #: display-coupons.php:466
577
+ msgid "<strong>Note:</strong> Due to a current limitation of PayPal, if your user makes a purchase and uses a coupon, we can not send a list of items through to paypal for processing. Rather, we must send the total amount of the purchase, so that within PayPal the user who purchases a product will see your shop name and the total amount of their purchase."
578
+ msgstr "<strong>Devido a uma limitação actual do PayPal, se o utilizador fizer uma compra e utilizar um cupão, não podemos enviar uma lista dos artigos para o PayPal, para processamento. Temos antes que enviar o valor total da compra, para que no PayPal, o utilizador que comprou um produto, veja o nome da loja e o montante total da compra."
579
+
580
+ #: display-coupons.php:478
581
+ msgid "Marketing Settings"
582
+ msgstr "Definições de Marketing"
583
+
584
+ #: display-coupons.php:485
585
+ msgid "Display Cross Sales"
586
+ msgstr "Mostrar vendas cruzadas"
587
+
588
+ #: display-coupons.php:509
589
+ msgid "Show Share This (Social Bookmarks)"
590
+ msgstr "Mostrar \"Share this\" (Social Bookmarks)"
591
+
592
+ #: display-coupons.php:532
593
+ msgid "Display How Customer Found Us Survey"
594
+ msgstr "Mostrar o inquérito \"Como o cliente nos encontrou\""
595
+
596
+ #: display-coupons.php:549
597
+ #: wpsc-admin/display-groups.page.php:642
598
+ #: wpsc-admin/display-groups.page.php:667
599
+ msgid "Submit"
600
+ msgstr "Submeter"
601
+
602
+ #: display-coupons.php:555
603
+ msgid "RSS Address"
604
+ msgstr "Endereço RSS"
605
+
606
+ #: display-coupons.php:559
607
+ msgid "<strong>Note:</strong> Not only can people use this RSS to keep update with your product list but you can also use this link to promote your products in your facebook profile. <br />Just add the <a href=\"http://apps.facebook.com/getshopped\">getshopped! facebook application</a> to your facebook profile and follow the instructions."
608
+ msgstr "<strong>Nota: Os seus clientes podem utilizar o Feed RSS para se manter actualizados sobre os seus produtos. Poderá também utilizar esta ligação para promover os seus produtos no seu perfil do Facebook. <br /> Basta adicionar a aplicação <a href=\"http://apps.facebook.com/getshopped\">Facebook getshopped!</a> ao seu perfil do Facebook e seguir as instruções."
609
+
610
+ #: display-coupons.php:573
611
+ msgid "Google Merchant Centre / Google Product Search"
612
+ msgstr ""
613
+
614
+ #: display-ecommerce-subs.php:9
615
+ msgid "User ID"
616
+ msgstr "ID de utilizador"
617
+
618
+ #: display-ecommerce-subs.php:9
619
+ #: edit-profile.php:39
620
+ #: user-log.php:362
621
+ #: wpsc-admin/admin.php:349
622
+ #: wpsc-includes/install_and_update.functions.php:656
623
+ msgid "Email"
624
+ msgstr "Email"
625
+
626
+ #: display-ecommerce-subs.php:9
627
+ msgid "Registered Date"
628
+ msgstr "Data de registo"
629
+
630
+ #: display-ecommerce-subs.php:9
631
+ msgid "Suspend"
632
+ msgstr "Suspender"
633
+
634
+ #: display-ecommerce-subs.php:9
635
+ msgid "Activate"
636
+ msgstr "Activar"
637
+
638
+ #: edit-profile.php:31
639
+ #: wpsc-includes/install_and_update.functions.php:650
640
+ #: wpsc-includes/install_and_update.functions.php:658
641
+ msgid "First Name"
642
+ msgstr "Primeiro nome"
643
+
644
+ #: edit-profile.php:32
645
+ msgid "Please enter a valid name"
646
+ msgstr "Por favor insira um nome válido"
647
+
648
+ #: edit-profile.php:35
649
+ #: wpsc-includes/install_and_update.functions.php:651
650
+ #: wpsc-includes/install_and_update.functions.php:659
651
+ msgid "Last Name"
652
+ msgstr "Último nome"
653
+
654
+ #: edit-profile.php:36
655
+ msgid "Please enter a valid surname"
656
+ msgstr "Por favor insira um apelido válido"
657
+
658
+ #: edit-profile.php:40
659
+ msgid "Please enter a valid email address"
660
+ msgstr "Por favor introduza um endereço de email válido"
661
+
662
+ #: edit-profile.php:43
663
+ msgid "Address 1"
664
+ msgstr "Morada (linha 1)"
665
+
666
+ #: edit-profile.php:44
667
+ msgid "Address 2"
668
+ msgstr "Morada (linha 2)"
669
+
670
+ #: edit-profile.php:45
671
+ msgid "Please enter a valid address"
672
+ msgstr "Por favor insira uma morada válida"
673
+
674
+ #: edit-profile.php:48
675
+ #: wpsc-includes/install_and_update.functions.php:653
676
+ #: wpsc-includes/install_and_update.functions.php:661
677
+ msgid "City"
678
+ msgstr "Localidade"
679
+
680
+ #: edit-profile.php:49
681
+ msgid "Please enter your town or city."
682
+ msgstr "Por favor insira a sua localidade"
683
+
684
+ #: edit-profile.php:52
685
+ #: user-log.php:361
686
+ #: wpsc-includes/install_and_update.functions.php:669
687
+ msgid "Phone"
688
+ msgstr "Telefone"
689
+
690
+ #: edit-profile.php:53
691
+ msgid "Please enter a valid phone number"
692
+ msgstr "Por favor insira um número de telefone válido"
693
+
694
+ #: edit-profile.php:56
695
+ #: wpsc-admin/admin.php:350
696
+ #: wpsc-includes/install_and_update.functions.php:654
697
+ #: wpsc-includes/install_and_update.functions.php:663
698
+ msgid "Country"
699
+ msgstr "País"
700
+
701
+ #: edit-profile.php:57
702
+ msgid "Please select your country from the list."
703
+ msgstr "Por favor selecione o seu país na lista"
704
+
705
+ #: edit-profile.php:61
706
+ #: wpsc-includes/checkout.class.php:536
707
+ #: wpsc-includes/checkout.class.php:550
708
+ #: wpsc-includes/checkout.class.php:561
709
+ #: wpsc-includes/checkout.class.php:569
710
+ #: wpsc-includes/checkout.class.php:580
711
+ #: wpsc-includes/checkout.class.php:679
712
+ msgid "Please enter a valid"
713
+ msgstr "Por favor insira um valor válido no seguinte campo:"
714
+
715
+ #: edit-profile.php:84
716
+ msgid "Thanks, your changes have been saved."
717
+ msgstr "Obrigado, as suas alterações foram guardadas."
718
+
719
+ #: edit-profile.php:188
720
+ msgid "Save Profile"
721
+ msgstr "Guardar perfil"
722
+
723
+ #: editor.php:49
724
+ msgid "placeholder for:"
725
+ msgstr "espaço reservado para"
726
+
727
+ #: editor.php:144
728
+ msgid "Your forms:"
729
+ msgstr "Os seus formulários:"
730
+
731
+ #: editor.php:146
732
+ #: insertcate.php:87
733
+ #: js/tinymce3/window.php:144
734
+ msgid "Insert"
735
+ msgstr "Inserir"
736
+
737
+ #: editor.php:147
738
+ #: insertcate.php:90
739
+ #: js/tinymce3/window.php:140
740
+ msgid "Cancel"
741
+ msgstr "Cancelar"
742
+
743
+ #: google_shipping_country.php:7
744
+ msgid "Google Shipping Country"
745
+ msgstr "País de expedição do Google"
746
+
747
+ #: google_shipping_country.php:43
748
+ #: tax_and_shipping.php:86
749
+ #: wpsc-admin/includes/settings-pages/checkout.php:268
750
+ msgid "Save Changes"
751
+ msgstr "Guardar alterações"
752
+
753
+ #: homepage_products_functions.php:85
754
+ #: widgets/donations_widget.php:6
755
+ #: widgets/donations_widget.php:77
756
+ #: widgets/donations_widget.php:78
757
+ msgid "Product Donations"
758
+ msgstr "Doações de produtos"
759
+
760
+ #: homepage_products_functions.php:157
761
+ #: themes/default/products_page.php:126
762
+ #: themes/iShop/products_page.php:127
763
+ #: themes/marketplace/products_page.php:129
764
+ msgid "More Details"
765
+ msgstr "Mais detalhes"
766
+
767
+ #: homepage_products_functions.php:189
768
+ #: themes/default/grid_view.php:142
769
+ #: themes/default/list_view.php:154
770
+ #: themes/default/products_page.php:234
771
+ #: themes/default/single_product.php:180
772
+ #: themes/iShop/grid_view.php:144
773
+ #: themes/iShop/list_view.php:157
774
+ #: themes/iShop/products_page.php:232
775
+ #: themes/iShop/single_product.php:181
776
+ #: themes/marketplace/grid_view.php:145
777
+ #: themes/marketplace/list_view.php:156
778
+ #: themes/marketplace/products_page.php:236
779
+ #: themes/marketplace/single_product.php:183
780
+ #: widgets/donations_widget.php:48
781
+ #: widgets/specials_widget.php:69
782
+ #: wpsc-admin/includes/settings-pages/presentation.php:85
783
+ #: wpsc-includes/display.functions.php:326
784
+ msgid "Add To Cart"
785
+ msgstr "Adicionar ao carrinho"
786
+
787
+ #: homepage_products_functions.php:205
788
+ #: wpsc-includes/wpsc_query.php:875
789
+ msgid "Avg. Customer Rating"
790
+ msgstr "Média de avaliações dos clientes"
791
+
792
+ #: homepage_products_functions.php:212
793
+ #: wpsc-includes/wpsc_query.php:882
794
+ msgid "Your Rating"
795
+ msgstr "A sua avaliação"
796
+
797
+ #: homepage_products_functions.php:213
798
+ #: homepage_products_functions.php:217
799
+ #: wpsc-includes/wpsc_query.php:883
800
+ msgid "Saved"
801
+ msgstr "Guardado"
802
+
803
+ #: homepage_products_functions.php:216
804
+ msgid "Rate This item"
805
+ msgstr "Avalie este artigo"
806
+
807
+ #: insertcate.php:67
808
+ msgid "Pick a Category"
809
+ msgstr "Escolha uma categoria"
810
+
811
+ #: insertcate.php:74
812
+ msgid "Your Categories:"
813
+ msgstr "As suas categorias"
814
+
815
+ #: js/tinymce3/window.php:36
816
+ #: js/tinymce3/window.php:118
817
+ msgid "Category"
818
+ msgstr "Categoria"
819
+
820
+ #: js/tinymce3/window.php:37
821
+ #: wpsc-admin/display-upgrades.page.php:47
822
+ msgid "Product Slider"
823
+ msgstr "Product Slider"
824
+
825
+ #: js/tinymce3/window.php:38
826
+ #: wpsc-admin/includes/display-items-functions.php:137
827
+ #: wpsc-admin/includes/display-items-functions.php:139
828
+ msgid "Add Product"
829
+ msgstr "Adicionar produto"
830
+
831
+ #: js/tinymce3/window.php:48
832
+ #: js/tinymce3/window.php:76
833
+ msgid "Select Category"
834
+ msgstr "Selecionar categoria"
835
+
836
+ #: js/tinymce3/window.php:51
837
+ #: js/tinymce3/window.php:78
838
+ #: js/tinymce3/window.php:122
839
+ msgid "No Category"
840
+ msgstr "Sem categoria"
841
+
842
+ #: js/tinymce3/window.php:65
843
+ msgid "Number of items per Page"
844
+ msgstr "Número de artigos por página"
845
+
846
+ #: js/tinymce3/window.php:91
847
+ msgid "Number of visible items"
848
+ msgstr "Número de artigos visíveis"
849
+
850
+ #: merchants/chronopay.php:440
851
+ #: merchants/paypal_multiple.php:562
852
+ #: wpsc-admin/includes/settings-pages/admin.php:227
853
+ #: wpsc-admin/includes/settings-pages/gateway.php:92
854
+ #: wpsc-admin/includes/settings-pages/gateway.php:172
855
+ #: wpsc-admin/includes/settings-pages/general.php:207
856
+ #: wpsc-admin/includes/settings-pages/presentation.php:1060
857
+ #: wpsc-admin/includes/settings-pages/shipping.php:276
858
+ #: wpsc-admin/includes/settings-pages/shipping.php:298
859
+ msgid "Update &raquo;"
860
+ msgstr "Actualizar &raquo;"
861
+
862
+ #: merchants/paypal-standard.merchant.php:137
863
+ msgid "Your Subscription"
864
+ msgstr "A sua subscrição"
865
+
866
+ #: merchants/paypal_certified.php:621
867
+ #: merchants/paypal_multiple.php:527
868
+ msgid "Currency Converter"
869
+ msgstr "Conversor de divisas"
870
+
871
+ #: merchants/paypal_certified.php:624
872
+ msgid "If your website uses a currency not accepted by Paypal, select an accepted currency using the drop down menu bellow. Buyers on your site will still pay in your local currency however we will send the order through to Paypal using currency you choose below."
873
+ msgstr "Se o seu website utiliza uma moeda não aceite pelo Paypal, selecione uma moeda utilizando o menu abaixo. Os compradores no seu website continuarão a pagar na sua moeda local, no entanto a ordem de pagamento será enviada ao Paypal utilizando a moeda que escolher aqui."
874
+
875
+ #: merchants/paypal_multiple.php:530
876
+ #, php-format
877
+ msgid "Your website uses <strong>%s</strong>. This currency is not supported by PayPal, please select a currency using the drop down menu below. Buyers on your site will still pay in your local currency however we will send the order through to Paypal using the currency you choose below."
878
+ msgstr "O seu site utiliza <strong>% s </ strong>. Esta moeda não é suportada pelo PayPal. Por favor, escolha uma moeda utilizando o menu abaixo. Os compradores do site pagarão na moeda local, no entanto, o pedido será enviado através do Paypal utilizando a moeda que escolher aqui."
879
+
880
+ #: merchants/paypal_pro.php:276
881
+ msgid "There is a problem with your PayPal account configuration, please contact PayPal for further information."
882
+ msgstr "Existe um problema com a configuração da sua conta do PayPal. Por favor contacte o PayPal para mais informações."
883
+
884
+ #: merchants/paypal_pro.php:281
885
+ msgid "Sorry your transaction did not go through to Paypal successfully, please try again."
886
+ msgstr "Desculpe mas a sua transação não foi processada pelo Paypal com sucesso. Por favor tente de novo."
887
+
888
+ #: merchants/paypal_pro.php:370
889
+ msgid "API Username:"
890
+ msgstr ""
891
+
892
+ #: merchants/paypal_pro.php:378
893
+ msgid "API Password:"
894
+ msgstr ""
895
+
896
+ #: merchants/paypal_pro.php:386
897
+ msgid "API Signature:"
898
+ msgstr ""
899
+
900
+ #: merchants/paypal_pro.php:394
901
+ msgid "Test Mode Enabled:"
902
+ msgstr "Modo de teste activado"
903
+
904
+ #: merchants/testmode.php:30
905
+ msgid "Enter the payment instructions that you wish to display to your customers when they make a purchase"
906
+ msgstr "Insira as instruções de pagamento que deseja mostrar aos clientes quando efectuarem uma compra"
907
+
908
+ #: merchants/testmode.php:32
909
+ msgid "For example, this is where you the Shop Owner might enter your bank account details or address so that your customer can make their manual payment."
910
+ msgstr "Por exemplo, é aqui que o proprietário da loja poderá inserir os detalhes da conta bancária ou endereço para que o cliente possa efectuar o pagamento manual."
911
+
912
+ #: share-this.php:435
913
+ msgid "E-mail this, post to del.icio.us, etc."
914
+ msgstr "Enviar por email, publicar no del.icio.us, etc."
915
+
916
+ #: share-this.php:488
917
+ msgid "Close"
918
+ msgstr "Fechar"
919
+
920
+ #: share-this.php:490
921
+ #: share-this.php:842
922
+ msgid "Social Web"
923
+ msgstr "Web Social"
924
+
925
+ #: share-this.php:491
926
+ #: share-this.php:867
927
+ #: themes/default/shopping_cart_page.php:242
928
+ #: themes/iShop/shopping_cart_page.php:213
929
+ #: themes/marketplace/shopping_cart_page.php:211
930
+ msgid "E-mail"
931
+ msgstr "Email"
932
+
933
+ #: share-this.php:508
934
+ #: share-this.php:871
935
+ msgid "E-mail It"
936
+ msgstr "Enviar por email"
937
+
938
+ #: share-this.php:511
939
+ #: share-this.php:874
940
+ msgid "To Address:"
941
+ msgstr "Destinatário:"
942
+
943
+ #: share-this.php:515
944
+ #: share-this.php:878
945
+ msgid "Your Name:"
946
+ msgstr "O seu nome:"
947
+
948
+ #: share-this.php:519
949
+ #: share-this.php:882
950
+ msgid "Your Address:"
951
+ msgstr "A sua morada:"
952
+
953
+ #: share-this.php:523
954
+ #: share-this.php:886
955
+ msgid "Send It"
956
+ msgstr "Enviar"
957
+
958
+ #: share-this.php:605
959
+ msgid "Click your <strong>back button</strong> and make sure those e-mail addresses are valid then try again."
960
+ msgstr "Clique no <strong>botão retroceder</strong> e certifique-se de que os endereços de email sºao valido e tente de novo."
961
+
962
+ #: share-this.php:615
963
+ msgid "Check out this product on "
964
+ msgstr "Veja este produto em "
965
+
966
+ #: share-this.php:620
967
+ #: share-this.php:640
968
+ msgid "Greetings--"
969
+ msgstr "Saudações,"
970
+
971
+ #: share-this.php:621
972
+ #: share-this.php:641
973
+ msgid " thinks this will be of interest to you:"
974
+ msgstr "achou que este artigo lhe poderia interessar:"
975
+
976
+ #: share-this.php:634
977
+ #: share-this.php:644
978
+ msgid "Enjoy."
979
+ msgstr "Aproveite."
980
+
981
+ #: share-this.php:702
982
+ msgid "Share This : "
983
+ msgstr "Partilhe:"
984
+
985
+ #: share-this.php:838
986
+ #, php-format
987
+ msgid "<strong>What is this?</strong> From this page you can use the <em>Social Web</em> links to save %s to a social bookmarking site, or the <em>E-mail</em> form to send a link via e-mail."
988
+ msgstr "<strong>O que é isto?</strong> A partir desta página poderá utilizar as ligações <em>Social Web</em> para guardar %s em vários sites, ou o formulário de <em>Email</em> para enviar esta ligação por email."
989
+
990
+ #: share-this.php:909
991
+ msgid "Posted in: "
992
+ msgstr "Publicado em:"
993
+
994
+ #: share-this.php:912
995
+ msgid "Return to:"
996
+ msgstr "Regressar a:"
997
+
998
+ #: shipping/australiapost.php:47
999
+ msgid "Australia Post"
1000
+ msgstr ""
1001
+
1002
+ #: shipping/australiapost.php:54
1003
+ msgid "Standard Parcel Post"
1004
+ msgstr ""
1005
+
1006
+ #: shipping/australiapost.php:55
1007
+ msgid "Express Post"
1008
+ msgstr ""
1009
+
1010
+ #: shipping/australiapost.php:56
1011
+ msgid "Air Mail"
1012
+ msgstr ""
1013
+
1014
+ #: shipping/australiapost.php:57
1015
+ msgid "Sea Mail"
1016
+ msgstr ""
1017
+
1018
+ #: shipping/australiapost.php:58
1019
+ msgid "Economy Air Parcel Post"
1020
+ msgstr ""
1021
+
1022
+ #: shipping/australiapost.php:59
1023
+ msgid "Express Post International"
1024
+ msgstr ""
1025
+
1026
+ #: shipping/australiapost.php:95
1027
+ msgid "This shipping module only works if the base country in settings, region is set to Australia."
1028
+ msgstr "Este módulo de expedição apenas funciona se o seu país base, nas definições, estiver definido como Austrália."
1029
+
1030
+ #: shipping/australiapost.php:100
1031
+ msgid "You must set your base postcode above before this shipping module will work."
1032
+ msgstr "Deverá definir acima o seu código postal base para que este módulo de expedição funcione."
1033
+
1034
+ #: shipping/australiapost.php:103
1035
+ msgid "Select the Australia Post services that you want to offer during checkout:"
1036
+ msgstr "Seleccione o serviço de Correios da Austrália que pretende oferecer durante o checkout:"
1037
+
1038
+ #: shipping/australiapost.php:110
1039
+ msgid "Notes:"
1040
+ msgstr "Notas:"
1041
+
1042
+ #: shipping/australiapost.php:111
1043
+ msgid "1. The actual services quoted to the customer during checkout will depend on the destination country. Not all methods are available to all destinations."
1044
+ msgstr "1. Os serviços orçamentos aos clientes durante o checkout vão depender do país de destino. Nem todos os métodos estão disponíveis para todos os destinos."
1045
+
1046
+ #: shipping/australiapost.php:112
1047
+ msgid "2. Each product must have a valid weight configured. When editing a product, use the weight field.)."
1048
+ msgstr "2. Cada produto deverá configurado um peso válido. Ao editar um produto, utilize o campo peso."
1049
+
1050
+ #: shipping/australiapost.php:113
1051
+ msgid "3. To ensure accurate quotes, each product must valid dimensions configured. When editing a product, use the height, width and length fields."
1052
+ msgstr "3. Para assegurar orçamentos correctos, cada produto deverá ter configuradas dimensões válidas. Ao editar um produto, utilize os campos altura, largura e comprimento."
1053
+
1054
+ #: shipping/australiapost.php:114
1055
+ msgid "4. The combined dimensions are estimated by calculating the volume of each item, and then calculating the cubed root of the overall order volume which becomes width, length and height."
1056
+ msgstr "4. As dimensões combinadas são estimadas pelo cálculo do volume de cada artigo, depois pelo cálculo da raiz quadrada do volume total da encomenda e finalmente convertendo em largura, comprimento e altura."
1057
+
1058
+ #: shipping/australiapost.php:115
1059
+ msgid "5. If no product volumes are defined, then default package dimensions of 100mm x 100mm x 100mm will be used."
1060
+ msgstr "5. Se não forem definidos volumes de produtos, serão utilizadas dimensões padrão da embalagem de 100mm x 100mm x 100mm."
1061
+
1062
+ #: shipping/australiapost.php:257
1063
+ #, php-format
1064
+ msgid "%1$s (estimated delivery time: %2$d business day)"
1065
+ msgid_plural "%1$s (estimated delivery time: %2$d business days)"
1066
+ msgstr[0] "%1$s (tempo de entrega estimado: %2$d dia útil)"
1067
+ msgstr[1] "%1$s (tempo de entrega estimado: %2$d dias úteis)"
1068
+
1069
+ #: shipping/flatrate.php:31
1070
+ msgid "If you do not wish to ship to a particular region, leave the field blank. To offer free shipping to a region, enter 0."
1071
+ msgstr "Se não desejar expedir para uma determinada região, deixe o campo em branco. Se pretender oferecer a expedição para uma região, insira 0."
1072
+
1073
+ #: shipping/tablerate.php:30
1074
+ #: themes/default/shopping_cart_page.php:202
1075
+ #: themes/iShop/shopping_cart_page.php:175
1076
+ #: themes/marketplace/shopping_cart_page.php:173
1077
+ msgid "Total Price"
1078
+ msgstr "Preço total"
1079
+
1080
+ #: shipping/tablerate.php:30
1081
+ #: shipping/weightrate.php:30
1082
+ msgid "Shipping Price"
1083
+ msgstr "Preço de envio"
1084
+
1085
+ #: shipping/tablerate.php:37
1086
+ #: wpsc-admin/admin.php:366
1087
+ msgid "If price is "
1088
+ msgstr "Se o preço for"
1089
+
1090
+ #: shipping/tablerate.php:39
1091
+ #: shipping/weightrate.php:35
1092
+ #: wpsc-admin/admin.php:365
1093
+ msgid " and above"
1094
+ msgstr " ou superior"
1095
+
1096
+ #: shipping/ups.php:76
1097
+ msgid "UPS Letter"
1098
+ msgstr "UPS Letter"
1099
+
1100
+ #: shipping/ups.php:77
1101
+ msgid "Your Packaging"
1102
+ msgstr "A sua embalagem"
1103
+
1104
+ #: shipping/ups.php:78
1105
+ msgid "UPS Tube"
1106
+ msgstr "UPS Tube"
1107
+
1108
+ #: shipping/ups.php:79
1109
+ msgid "UPS Pak"
1110
+ msgstr "UPS Pak"
1111
+
1112
+ #: shipping/ups.php:80
1113
+ msgid "UPS Express Box"
1114
+ msgstr "UPS Express Box"
1115
+
1116
+ #: shipping/ups.php:81
1117
+ msgid "UPS Express Box - Small"
1118
+ msgstr "UPS Express Box - Small"
1119
+
1120
+ #: shipping/ups.php:82
1121
+ msgid "UPS Express Box - Medium"
1122
+ msgstr "UPS Express Box - Medium"
1123
+
1124
+ #: shipping/ups.php:83
1125
+ msgid "UPS Express Box - Large"
1126
+ msgstr "UPS Express Box - Large"
1127
+
1128
+ #: shipping/ups.php:86
1129
+ msgid "Destination Type"
1130
+ msgstr "Tipo de destino"
1131
+
1132
+ #: shipping/ups.php:97
1133
+ msgid "Residential Address"
1134
+ msgstr "Endereço particular"
1135
+
1136
+ #: shipping/ups.php:98
1137
+ msgid "Commercial Address"
1138
+ msgstr "Endereço comercial"
1139
+
1140
+ #: shipping/ups.php:104
1141
+ msgid "Packaging"
1142
+ msgstr "Embalagem"
1143
+
1144
+ #: shipping/ups.php:124
1145
+ msgid "Use Testing Environment"
1146
+ msgstr "Utilizar ambiente de testes"
1147
+
1148
+ #: shipping/ups.php:133
1149
+ msgid "UPS Preferred Services"
1150
+ msgstr ""
1151
+
1152
+ #: shipping/ups.php:154
1153
+ msgid "All services used if no services selected"
1154
+ msgstr "Todos os serviços serão utilizados se nenhum for seleccionado"
1155
+
1156
+ #: shipping/ups.php:158
1157
+ msgid "UPS Username"
1158
+ msgstr "UPS Username"
1159
+
1160
+ #: shipping/ups.php:164
1161
+ msgid "UPS Password"
1162
+ msgstr "UPS Password"
1163
+
1164
+ #: shipping/ups.php:170
1165
+ msgid "UPS XML API Key"
1166
+ msgstr "UPS XML API Key"
1167
+
1168
+ #: shipping/ups.php:174
1169
+ msgid "Don't have an API login/ID ?"
1170
+ msgstr "Não tem "
1171
+
1172
+ #: shipping/ups.php:175
1173
+ msgid "Click Here"
1174
+ msgstr "Clique aqui"
1175
+
1176
+ #: shipping/usps.php:37
1177
+ msgid "USPS ID"
1178
+ msgstr "USPS ID"
1179
+
1180
+ #: shipping/usps.php:45
1181
+ msgid "USPS Password"
1182
+ msgstr "USPS Password"
1183
+
1184
+ #: shipping/usps.php:53
1185
+ msgid "Use Test Server:"
1186
+ msgstr "Utilizar servidor de testes:"
1187
+
1188
+ #: shipping/weightrate.php:30
1189
+ msgid "Total weight <br />(<abbr alt=\"You must enter the weight here in pounds, regardless of what you used on your products\" title=\"You must enter the weight here in pounds, regardless of what you used on your products\">in Pounds</abbr>)"
1190
+ msgstr "Peso total <br />(<abbr alt=\"Deverá inserir aqui o peso total em libras independentemente da unidade utilizada nos seus produtos\" title=\"Deverá inserir aqui o peso total em libras independentemente da unidade utilizada nos seus produtos\">em Libras (Pounds)</abbr>)"
1191
+
1192
+ #: shipping/weightrate.php:35
1193
+ #: wpsc-admin/admin.php:367
1194
+ msgid "If weight is "
1195
+ msgstr "Se o peso for"
1196
+
1197
+ #: shopping_cart_functions.php:36
1198
+ #: shopping_cart_functions.php:44
1199
+ #: shopping_cart_functions.php:54
1200
+ #: widgets/shopping_cart_widget.php:27
1201
+ msgid "Shopping Cart"
1202
+ msgstr "Carrinho de compras"
1203
+
1204
+ #: tagging_functions.php:79
1205
+ #, php-format
1206
+ msgid "%d topics"
1207
+ msgstr "%d tópicos"
1208
+
1209
+ #: tax_and_shipping.php:34
1210
+ msgid "GST/Tax Rate"
1211
+ msgstr "Taxa de IVA"
1212
+
1213
+ #: themes/default/cart_widget.php:15
1214
+ #: themes/iShop/cart_widget.php:15
1215
+ #: themes/marketplace/cart_widget.php:15
1216
+ msgid "Number of items"
1217
+ msgstr "Número de artigos"
1218
+
1219
+ #: themes/default/cart_widget.php:23
1220
+ #: themes/default/shopping_cart_page.php:14
1221
+ #: themes/iShop/cart_widget.php:23
1222
+ #: themes/iShop/shopping_cart_page.php:13
1223
+ #: themes/marketplace/cart_widget.php:23
1224
+ #: themes/marketplace/shopping_cart_page.php:13
1225
+ msgid "Product"
1226
+ msgstr "Produto"
1227
+
1228
+ #: themes/default/cart_widget.php:24
1229
+ #: themes/iShop/cart_widget.php:24
1230
+ #: themes/marketplace/cart_widget.php:24
1231
+ msgid "Qty"
1232
+ msgstr "Qt."
1233
+
1234
+ #: themes/default/cart_widget.php:59
1235
+ #: themes/iShop/cart_widget.php:60
1236
+ #: themes/marketplace/cart_widget.php:59
1237
+ msgid "Postage &amp; Tax "
1238
+ msgstr "Portes e impostos"
1239
+
1240
+ #: themes/default/cart_widget.php:63
1241
+ #: themes/iShop/cart_widget.php:64
1242
+ #: themes/marketplace/cart_widget.php:63
1243
+ #: transaction_result_functions.php:211
1244
+ #: transaction_result_functions.php:218
1245
+ #: user-log.php:220
1246
+ #: wpsc-admin/ajax-and-init.php:1144
1247
+ #: wpsc-admin/ajax-and-init.php:1150
1248
+ #: wpsc-admin/display-sales-logs.php:261
1249
+ msgid "Total"
1250
+ msgstr "Total"
1251
+
1252
+ #: themes/default/cart_widget.php:72
1253
+ #: themes/iShop/cart_widget.php:73
1254
+ #: themes/marketplace/cart_widget.php:72
1255
+ msgid "Empty your cart"
1256
+ msgstr "Esvaziar carrinho"
1257
+
1258
+ #: themes/default/cart_widget.php:76
1259
+ #: themes/iShop/cart_widget.php:77
1260
+ #: themes/marketplace/cart_widget.php:76
1261
+ #: wpsc-includes/display.functions.php:153
1262
+ msgid "Go to Checkout"
1263
+ msgstr "Continuar para checkout"
1264
+
1265
+ #: themes/default/cart_widget.php:78
1266
+ #: themes/iShop/cart_widget.php:79
1267
+ #: themes/marketplace/cart_widget.php:78
1268
+ msgid "Your shopping cart is empty"
1269
+ msgstr "O seu carrinho está vazio"
1270
+
1271
+ #: themes/default/cart_widget.php:80
1272
+ #: themes/iShop/cart_widget.php:81
1273
+ #: themes/marketplace/cart_widget.php:80
1274
+ msgid "Visit the shop"
1275
+ msgstr "Visitar a loja"
1276
+
1277
+ #: themes/default/functions.php:15
1278
+ #: themes/iShop/functions.php:15
1279
+ #: themes/marketplace/functions.php:15
1280
+ #: wpsc-admin/includes/settings-pages/presentation.php:989
1281
+ msgid "Page Number position"
1282
+ msgstr "Posição do número da página"
1283
+
1284
+ #: themes/default/grid_view.php:144
1285
+ #: themes/default/list_view.php:162
1286
+ #: themes/default/products_page.php:242
1287
+ #: themes/default/single_product.php:189
1288
+ #: themes/iShop/grid_view.php:146
1289
+ #: themes/iShop/list_view.php:167
1290
+ #: themes/iShop/products_page.php:240
1291
+ #: themes/iShop/single_product.php:190
1292
+ #: themes/marketplace/grid_view.php:147
1293
+ #: themes/marketplace/list_view.php:163
1294
+ #: themes/marketplace/products_page.php:245
1295
+ #: themes/marketplace/single_product.php:192
1296
+ #: widgets/specials_widget.php:66
1297
+ msgid "This product has sold out."
1298
+ msgstr "Este produto está esgotado."
1299
+
1300
+ #: themes/default/grid_view.php:168
1301
+ #: themes/default/list_view.php:184
1302
+ #: themes/default/products_page.php:266
1303
+ #: themes/iShop/grid_view.php:170
1304
+ #: themes/iShop/list_view.php:189
1305
+ #: themes/iShop/products_page.php:265
1306
+ #: themes/marketplace/grid_view.php:171
1307
+ #: themes/marketplace/list_view.php:185
1308
+ #: themes/marketplace/products_page.php:270
1309
+ msgid "There are no products in this group."
1310
+ msgstr "Não existem produtos neste grupo."
1311
+
1312
+ #: themes/default/list_view.php:152
1313
+ #: themes/default/products_page.php:232
1314
+ #: themes/default/single_product.php:178
1315
+ #: themes/iShop/list_view.php:155
1316
+ #: themes/iShop/products_page.php:230
1317
+ #: themes/iShop/single_product.php:179
1318
+ #: themes/marketplace/list_view.php:154
1319
+ #: themes/marketplace/products_page.php:234
1320
+ #: themes/marketplace/single_product.php:181
1321
+ #: wpsc-admin/includes/settings-pages/presentation.php:87
1322
+ #: wpsc-includes/display.functions.php:242
1323
+ msgid "Buy Now"
1324
+ msgstr "Compre agora"
1325
+
1326
+ #: themes/default/list_view.php:158
1327
+ #: themes/default/products_page.php:238
1328
+ #: themes/default/single_product.php:185
1329
+ #: themes/iShop/list_view.php:163
1330
+ #: themes/iShop/products_page.php:236
1331
+ #: themes/iShop/single_product.php:186
1332
+ #: themes/marketplace/list_view.php:159
1333
+ #: themes/marketplace/products_page.php:241
1334
+ #: themes/marketplace/single_product.php:188
1335
+ msgid "Updating cart..."
1336
+ msgstr "A actualizar o carrinho..."
1337
+
1338
+ #: themes/default/products_page.php:207
1339
+ #: themes/default/single_product.php:141
1340
+ #: themes/iShop/products_page.php:205
1341
+ #: themes/iShop/single_product.php:144
1342
+ #: themes/marketplace/products_page.php:209
1343
+ #: themes/marketplace/single_product.php:146
1344
+ #: widgets/donations_widget.php:47
1345
+ msgid "Donation"
1346
+ msgstr "Doação"
1347
+
1348
+ #: themes/default/products_page.php:218
1349
+ #: themes/default/single_product.php:157
1350
+ #: themes/iShop/products_page.php:216
1351
+ #: themes/iShop/single_product.php:158
1352
+ #: themes/marketplace/products_page.php:220
1353
+ #: themes/marketplace/single_product.php:160
1354
+ #: user-log.php:216
1355
+ msgid "P&amp;P"
1356
+ msgstr "Portes"
1357
+
1358
+ #: themes/default/shopping_cart_page.php:10
1359
+ #: themes/iShop/shopping_cart_page.php:9
1360
+ #: themes/marketplace/shopping_cart_page.php:9
1361
+ msgid "Please review your order"
1362
+ msgstr "Por favor confirme a sua encomenda"
1363
+
1364
+ #: themes/default/shopping_cart_page.php:37
1365
+ #: themes/default/shopping_cart_page.php:66
1366
+ #: themes/iShop/shopping_cart_page.php:35
1367
+ #: themes/iShop/shopping_cart_page.php:66
1368
+ #: themes/marketplace/shopping_cart_page.php:35
1369
+ #: themes/marketplace/shopping_cart_page.php:65
1370
+ msgid "Update"
1371
+ msgstr "Actualizar"
1372
+
1373
+ #: themes/default/shopping_cart_page.php:50
1374
+ #: themes/iShop/shopping_cart_page.php:49
1375
+ #: themes/marketplace/shopping_cart_page.php:48
1376
+ msgid "Remove"
1377
+ msgstr "Remover"
1378
+
1379
+ #: themes/default/shopping_cart_page.php:59
1380
+ #: themes/iShop/shopping_cart_page.php:59
1381
+ #: themes/marketplace/shopping_cart_page.php:58
1382
+ msgid "Coupon is not valid."
1383
+ msgstr "O cupão não é válido."
1384
+
1385
+ #: themes/default/shopping_cart_page.php:62
1386
+ #: themes/iShop/shopping_cart_page.php:62
1387
+ #: themes/marketplace/shopping_cart_page.php:61
1388
+ msgid "Enter your coupon number"
1389
+ msgstr "Insira o número do seu cupão"
1390
+
1391
+ #: themes/default/shopping_cart_page.php:92
1392
+ #: themes/iShop/shopping_cart_page.php:91
1393
+ #: themes/marketplace/shopping_cart_page.php:90
1394
+ msgid "Calculate Shipping Price"
1395
+ msgstr "Calcular preço de envio"
1396
+
1397
+ #: themes/default/shopping_cart_page.php:96
1398
+ #: themes/iShop/shopping_cart_page.php:95
1399
+ #: themes/marketplace/shopping_cart_page.php:94
1400
+ msgid "Please choose a country below to calculate your shipping costs"
1401
+ msgstr "Por favor seleccione um país para calcular os custos de envio"
1402
+
1403
+ #: themes/default/shopping_cart_page.php:105
1404
+ msgid "Please provide a Zipcode and click Calculate in order to continue."
1405
+ msgstr "Por favor seleccione um código postal e clique em Calcular para continuar."
1406
+
1407
+ #: themes/default/shopping_cart_page.php:112
1408
+ #: themes/iShop/shopping_cart_page.php:139
1409
+ #: themes/marketplace/shopping_cart_page.php:138
1410
+ msgid "Sorry, online ordering is unavailable to this destination and/or weight. Please double check your destination details."
1411
+ msgstr "Pedimos desculpa mas as encomendas online não se enocntram disponíveis para este destino e/ou peso. Por favor confirme novamente os seus detalhes de destino."
1412
+
1413
+ #: themes/default/shopping_cart_page.php:130
1414
+ #: themes/iShop/shopping_cart_page.php:115
1415
+ #: themes/marketplace/shopping_cart_page.php:114
1416
+ #: wpsc-includes/ajax.functions.php:405
1417
+ msgid "- Choose a Shipping Rate"
1418
+ msgstr "- Escolha uma taxa de envio"
1419
+
1420
+ #: themes/default/shopping_cart_page.php:179
1421
+ #: transaction_result_functions.php:210
1422
+ #: transaction_result_functions.php:217
1423
+ #: user-log.php:317
1424
+ #: wpsc-admin/ajax-and-init.php:1143
1425
+ #: wpsc-admin/ajax-and-init.php:1149
1426
+ msgid "Total Shipping"
1427
+ msgstr "Total de portes"
1428
+
1429
+ #: themes/default/shopping_cart_page.php:225
1430
+ #: themes/iShop/shopping_cart_page.php:196
1431
+ #: themes/marketplace/shopping_cart_page.php:194
1432
+ msgid "Not yet a member?"
1433
+ msgstr "Ainda não é membro?"
1434
+
1435
+ #: themes/default/shopping_cart_page.php:226
1436
+ #: themes/iShop/shopping_cart_page.php:197
1437
+ #: themes/marketplace/shopping_cart_page.php:195
1438
+ msgid "In order to buy from us, you'll need an account. Joining is free and easy. All you need is a username, password and valid email address."
1439
+ msgstr "Para poder adquirir os nossos produtos, necessita de uma conta. Criar uma é grátis e simples. Só precisa de um nome de utilizador, password e endereço de email válido."
1440
+
1441
+ #: themes/default/shopping_cart_page.php:240
1442
+ #: themes/iShop/shopping_cart_page.php:211
1443
+ #: themes/marketplace/shopping_cart_page.php:209
1444
+ msgid "Username"
1445
+ msgstr "Nome de utilizador"
1446
+
1447
+ #: themes/default/shopping_cart_page.php:241
1448
+ #: themes/iShop/shopping_cart_page.php:212
1449
+ #: themes/marketplace/shopping_cart_page.php:210
1450
+ msgid "Password"
1451
+ msgstr "Password"
1452
+
1453
+ #: themes/default/shopping_cart_page.php:246
1454
+ #: themes/iShop/shopping_cart_page.php:217
1455
+ #: themes/marketplace/shopping_cart_page.php:215
1456
+ msgid "Please enter your contact details:"
1457
+ msgstr "Por favor indique os seus detalhes de contacto:"
1458
+
1459
+ #: themes/default/shopping_cart_page.php:248
1460
+ #: themes/iShop/shopping_cart_page.php:219
1461
+ #: themes/marketplace/shopping_cart_page.php:217
1462
+ msgid "Fields marked with an asterisk must be filled in."
1463
+ msgstr "Os campos marcados com asterisco são de preenchimento obrigatório."
1464
+
1465
+ #: themes/default/shopping_cart_page.php:323
1466
+ #: themes/iShop/shopping_cart_page.php:294
1467
+ #: themes/marketplace/shopping_cart_page.php:292
1468
+ msgid "Select a payment gateway"
1469
+ msgstr "Seleccione um gateway de pagamento"
1470
+
1471
+ #: themes/default/shopping_cart_page.php:357
1472
+ #: themes/iShop/shopping_cart_page.php:328
1473
+ #: themes/marketplace/shopping_cart_page.php:326
1474
+ msgid "I agree to The "
1475
+ msgstr "Eu concordo e aceito os "
1476
+
1477
+ #: themes/default/shopping_cart_page.php:358
1478
+ #: themes/iShop/shopping_cart_page.php:329
1479
+ #: themes/marketplace/shopping_cart_page.php:327
1480
+ #: wpsc-admin/includes/settings-pages/admin.php:107
1481
+ msgid "Terms and Conditions"
1482
+ msgstr "Termos e Condições de Utilização"
1483
+
1484
+ #: themes/default/shopping_cart_page.php:370
1485
+ #: themes/iShop/shopping_cart_page.php:341
1486
+ #: themes/marketplace/shopping_cart_page.php:339
1487
+ msgid "Make Purchase"
1488
+ msgstr "Efectuar compra"
1489
+
1490
+ #: themes/default/shopping_cart_page.php:384
1491
+ #: themes/iShop/shopping_cart_page.php:355
1492
+ #: themes/marketplace/shopping_cart_page.php:353
1493
+ #: transaction_result_functions.php:375
1494
+ msgid "Oops, there is nothing in your cart."
1495
+ msgstr "Ups, o seu carrinho está vazio! "
1496
+
1497
+ #: themes/default/shopping_cart_page.php:384
1498
+ #: themes/iShop/shopping_cart_page.php:355
1499
+ #: themes/marketplace/shopping_cart_page.php:353
1500
+ #: transaction_result_functions.php:375
1501
+ msgid "Please visit our shop"
1502
+ msgstr "Por favor visite a nossa loja"
1503
+
1504
+ #: themes/default/single_product.php:96
1505
+ #: themes/iShop/single_product.php:99
1506
+ #: themes/marketplace/single_product.php:101
1507
+ msgid "Personalize your product"
1508
+ msgstr "Personalize o seu produto"
1509
+
1510
+ #: themes/default/single_product.php:97
1511
+ #: themes/iShop/single_product.php:100
1512
+ #: themes/marketplace/single_product.php:102
1513
+ msgid "Complete this form to include a personalized message with your purchase."
1514
+ msgstr "Complete este formulário para incluir uma mensagem pessoal com a sua compra."
1515
+
1516
+ #: themes/default/single_product.php:104
1517
+ #: themes/iShop/single_product.php:107
1518
+ #: themes/marketplace/single_product.php:109
1519
+ msgid "Upload a File"
1520
+ msgstr "Upload de ficheiro"
1521
+
1522
+ #: themes/default/single_product.php:105
1523
+ #: themes/iShop/single_product.php:108
1524
+ #: themes/marketplace/single_product.php:110
1525
+ msgid "Select a file from your computer to include with this purchase. "
1526
+ msgstr "Seleccione um ficheiro do seu computador para incluir nesta compra."
1527
+
1528
+ #: transaction_result_functions.php:35
1529
+ msgid "We&#39;re Sorry, your order has not been accepted, the most likely reason is that you have insufficient funds."
1530
+ msgstr "Lamentamos informar que a sua encomenda não foi aceite. A razão mais comum para esta situação é que não tem saldo suficiente."
1531
+
1532
+ #: transaction_result_functions.php:37
1533
+ msgid "New pending order"
1534
+ msgstr "Nova encomenda pendente"
1535
+
1536
+ #: transaction_result_functions.php:37
1537
+ msgid "There is a new order awaiting processing:"
1538
+ msgstr "Há uma encomenda a aguardar processamento"
1539
+
1540
+ #: transaction_result_functions.php:41
1541
+ #: transaction_result_functions.php:257
1542
+ #: wpsc-admin/ajax-and-init.php:1184
1543
+ msgid "Thank you, your purchase is pending, you will be sent an email once the order clears."
1544
+ msgstr "Obrigado, a sua encomenda encontra-se pendente. Enviaremos um email logo que seja processada."
1545
+
1546
+ #: transaction_result_functions.php:220
1547
+ #: transaction_result_functions.php:221
1548
+ #: wpsc-admin/ajax-and-init.php:1152
1549
+ #: wpsc-admin/ajax-and-init.php:1153
1550
+ msgid "Your Transaction ID"
1551
+ msgstr "O seu ID de transação"
1552
+
1553
+ #: transaction_result_functions.php:222
1554
+ #: wpsc-admin/ajax-and-init.php:1154
1555
+ msgid "Transaction ID"
1556
+ msgstr "ID da transação"
1557
+
1558
+ #: transaction_result_functions.php:258
1559
+ #: wpsc-admin/ajax-and-init.php:1185
1560
+ msgid "Order Pending: Payment Required"
1561
+ msgstr "Encomenda pendente: Pagamento necessário"
1562
+
1563
+ #: transaction_result_functions.php:260
1564
+ #: wpsc-admin/ajax-and-init.php:1188
1565
+ #: wpsc-admin/includes/settings-pages/admin.php:128
1566
+ msgid "Purchase Receipt"
1567
+ msgstr "Recibo da compra"
1568
+
1569
+ #: transaction_result_functions.php:265
1570
+ #: user-log.php:336
1571
+ msgid "Customer Details"
1572
+ msgstr "Detalhes do cliente"
1573
+
1574
+ #: transaction_result_functions.php:351
1575
+ msgid "Purchase Report"
1576
+ msgstr "Relatório de compra"
1577
+
1578
+ #: transaction_result_functions.php:367
1579
+ msgid "The Transaction was successful"
1580
+ msgstr "A transação foi efectuada com sucesso"
1581
+
1582
+ #: transaction_results.php:40
1583
+ #: transaction_results.php:49
1584
+ msgid "Sorry your transaction was not accepted.<br /><a href="
1585
+ msgstr "Pedimos desculpa mas a sua transação não foi aceite.<br /><a href="
1586
+
1587
+ #: updates/updating_tasks.php:53
1588
+ #, fuzzy
1589
+ msgid ""
1590
+ "Your purchase from %shop_name% has just been dispatched. It should arrive soon. To keep track of your products status a tracking id has been attached. \\r\\n"
1591
+ " your tracking id is: %trackid%"
1592
+ msgstr ""
1593
+ "A sua encomenda no website %shop_name% acabou de ser processada e deverá chegar em breve. O código de rastreamento da sua encomenda permite-lhe seguir o respectivo estado. \\\n"
1594
+ " O código da sua encomenda é: %trackid%'"
1595
+
1596
+ #: updates/updating_tasks.php:56
1597
+ msgid "Your Order from %shop_name% has been dispatched"
1598
+ msgstr "A sua encomenda efectuada em %shop_name% foi processada."
1599
+
1600
+ #: updates/updating_tasks.php:653
1601
+ #: updates/updating_tasks.php:660
1602
+ #: wpsc-includes/install_and_update.functions.php:163
1603
+ msgid "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.You ordered these items:%product_list%%total_shipping%%total_price%"
1604
+ msgstr "Obrigado por comprar em %shop_name%! A sua encomenda será processada e os produtos enviados brevemente. Se adquiriu produtos em formato digital, poderá fazer os respectivos downloads a partir dos links disponibilizados nesta página. Sempre que aplicável, todos os produtos incluem impostos, portes e embalagem. Encomendou os seguintes artigos:%product_list%%total_shipping%%total_price%"
1605
+
1606
+ #: updates/updating_tasks.php:654
1607
+ #: updates/updating_tasks.php:667
1608
+ #: wpsc-includes/install_and_update.functions.php:164
1609
+ msgid "%product_list%%total_shipping%%total_price%"
1610
+ msgstr "%product_list%%total_shipping%%total_price%"
1611
+
1612
+ #: user-downloads.php:41
1613
+ msgid "File Names"
1614
+ msgstr "Nomes de ficheiro"
1615
+
1616
+ #: user-downloads.php:42
1617
+ msgid "Downloads Left"
1618
+ msgstr "Downloads restantes"
1619
+
1620
+ #: user-downloads.php:43
1621
+ #: user-log.php:56
1622
+ msgid "Date"
1623
+ msgstr "Data"
1624
+
1625
+ #: user-downloads.php:69
1626
+ msgid "You have not purchased any downloadable products yet."
1627
+ msgstr "Ainda não aqdquiriu produtos digitais para download."
1628
+
1629
+ #: user-log.php:52
1630
+ msgid "Status"
1631
+ msgstr "Estado"
1632
+
1633
+ #: user-log.php:65
1634
+ #: user-log.php:383
1635
+ msgid "Payment Method"
1636
+ msgstr "Método de pagamento"
1637
+
1638
+ #: user-log.php:94
1639
+ msgid "Details"
1640
+ msgstr "Detalhes"
1641
+
1642
+ #: user-log.php:147
1643
+ msgid "Order Status"
1644
+ msgstr "Estado da encomenda"
1645
+
1646
+ #: user-log.php:169
1647
+ #: wpsc-admin/display-sales-logs.php:188
1648
+ #: wpsc-admin/includes/display-items-functions.php:651
1649
+ msgid "Shipping Details"
1650
+ msgstr "Detalhes de envio"
1651
+
1652
+ #: user-log.php:188
1653
+ msgid "Order Details"
1654
+ msgstr "Detalhes da encomenda"
1655
+
1656
+ #: user-log.php:212
1657
+ msgid "GST"
1658
+ msgstr "IVA"
1659
+
1660
+ #: user-log.php:318
1661
+ msgid "Final Total"
1662
+ msgstr "Total final"
1663
+
1664
+ #: user-log.php:360
1665
+ #: wpsc-includes/install_and_update.functions.php:652
1666
+ #: wpsc-includes/install_and_update.functions.php:660
1667
+ msgid "Address"
1668
+ msgstr "Morada"
1669
+
1670
+ #: user-log.php:384
1671
+ msgid "Purchase No."
1672
+ msgstr "Compra n.º"
1673
+
1674
+ #: user-log.php:387
1675
+ msgid "Transaction Id"
1676
+ msgstr "ID da transação"
1677
+
1678
+ #: user-log.php:401
1679
+ msgid "No transactions for this month."
1680
+ msgstr "Não existem transações neste mês."
1681
+
1682
+ #: user-log.php:412
1683
+ msgid "There have not been any purchases yet."
1684
+ msgstr "Ainda não foram efectuadas compras."
1685
+
1686
+ #: user-log.php:427
1687
+ msgid "You must be logged in to use this page. Please use the form below to login to your account."
1688
+ msgstr "Deverá estar ligado para utilizar esta página. Por favor utilize o formulário abaixo para fazer login na sua conta."
1689
+
1690
+ #: widgets/admin_menu_widget.php:8
1691
+ #: widgets/admin_menu_widget.php:22
1692
+ msgid "Admin Menu"
1693
+ msgstr "Menu de administração"
1694
+
1695
+ #: widgets/category_widget.27.php:19
1696
+ #: wpsc-admin/admin.php:104
1697
+ #: wpsc-admin/display-groups.page.php:565
1698
+ #: wpsc-admin/includes/display-items-functions.php:404
1699
+ #: wpsc-includes/category.functions.php:361
1700
+ msgid "Categories"
1701
+ msgstr "Categorias"
1702
+
1703
+ #: widgets/category_widget.27.php:134
1704
+ #: widgets/category_widget.28.php:69
1705
+ #: widgets/donations_widget.php:71
1706
+ #: widgets/latest_product_widget.php:74
1707
+ #: widgets/price_range_widget.php:71
1708
+ #: widgets/product_tag_widget.php:30
1709
+ #: widgets/shopping_cart_widget.php:78
1710
+ #: widgets/specials_widget.php:103
1711
+ msgid "Title:"
1712
+ msgstr "Título:"
1713
+
1714
+ #: widgets/category_widget.27.php:159
1715
+ #: widgets/category_widget.28.php:80
1716
+ msgid "Display the :category: Group"
1717
+ msgstr "Mostra o grupo :category:"
1718
+
1719
+ #: widgets/category_widget.27.php:168
1720
+ #: widgets/category_widget.28.php:88
1721
+ msgid "Display the Group thumbnails in the sidebar"
1722
+ msgstr "Mostra os thumbnails do Grupo na barra lateral"
1723
+
1724
+ #: widgets/category_widget.27.php:179
1725
+ #: widgets/category_widget.28.php:11
1726
+ msgid "Product Grouping Widget"
1727
+ msgstr "Widget de grupos de produtos"
1728
+
1729
+ #: widgets/category_widget.27.php:181
1730
+ #: widgets/category_widget.28.php:12
1731
+ #: widgets/category_widget.28.php:19
1732
+ msgid "Product Categories"
1733
+ msgstr "Categorias de produtos"
1734
+
1735
+ #: widgets/latest_product_widget.php:7
1736
+ #: widgets/latest_product_widget.php:88
1737
+ #: widgets/latest_product_widget.php:89
1738
+ msgid "Latest Products"
1739
+ msgstr "Últimos produtos"
1740
+
1741
+ #: widgets/latest_product_widget.php:75
1742
+ msgid "Number of products to show:"
1743
+ msgstr "Número de produtos a mostrar:"
1744
+
1745
+ #: widgets/price_range_widget.php:6
1746
+ #: widgets/price_range_widget.php:77
1747
+ #: widgets/price_range_widget.php:78
1748
+ msgid "Price Range"
1749
+ msgstr "Gama de preços"
1750
+
1751
+ #: widgets/price_range_widget.php:54
1752
+ msgid "Show All"
1753
+ msgstr "Mostrar todos"
1754
+
1755
+ #: widgets/product_tag_widget.php:9
1756
+ #: widgets/product_tag_widget.php:38
1757
+ #: widgets/product_tag_widget.php:39
1758
+ #: wpsc-admin/includes/display-items-functions.php:428
1759
+ #: wpsc-admin/includes/display-items-functions.php:430
1760
+ msgid "Product Tags"
1761
+ msgstr "Tags de produtos"
1762
+
1763
+ #: widgets/shopping_cart_widget.php:43
1764
+ #: widgets/shopping_cart_widget.php:48
1765
+ msgid "Loading..."
1766
+ msgstr "A carregar..."
1767
+
1768
+ #: widgets/shopping_cart_widget.php:79
1769
+ msgid "Hide Cart When Empty:"
1770
+ msgstr "Ocultar o carrinho quando vazio:"
1771
+
1772
+ #: widgets/specials_widget.php:10
1773
+ #: widgets/specials_widget.php:112
1774
+ #: widgets/specials_widget.php:113
1775
+ msgid "Product Specials"
1776
+ msgstr "Produtos em promoção"
1777
+
1778
+ #: widgets/specials_widget.php:106
1779
+ msgid "Show Description:"
1780
+ msgstr "Mostrar descrição:"
1781
+
1782
+ #: wp-shopping-cart.php:150
1783
+ msgid "Note: if this is blank, the image will not be resized"
1784
+ msgstr "Nota: Se este campo estiver em branco, a imagem não será redimensionada"
1785
+
1786
+ #: wp-shopping-cart.php:151
1787
+ #: wpsc-includes/install_and_update.functions.php:68
1788
+ msgid "Order Received"
1789
+ msgstr "Encomenda recebida"
1790
+
1791
+ #: wp-shopping-cart.php:153
1792
+ #: wpsc-includes/install_and_update.functions.php:71
1793
+ msgid "Closed Order"
1794
+ msgstr "Encomenda encerrada"
1795
+
1796
+ #: wp-shopping-cart.php:526
1797
+ msgid "Please Note"
1798
+ msgstr "Por favor note"
1799
+
1800
+ #: wp-shopping-cart.php:527
1801
+ #, php-format
1802
+ msgid "Before upgrading you should check the <a %s>upgrade information</a> and changelog as you may need to make updates to your template files."
1803
+ msgstr "Antes de fazer upgrade deverá verificar a <a %s>informação de upgrade</a> e registo de alterações uma vez que poderão ser necessárias alterações aos ficheiros do seu template."
1804
+
1805
+ #: wpsc-admin/admin.php:77
1806
+ #: wpsc-admin/admin.php:80
1807
+ #: wpsc-admin/admin.php:82
1808
+ #: wpsc-admin/admin.php:87
1809
+ #: wpsc-admin/admin.php:90
1810
+ msgid "Store"
1811
+ msgstr "Loja"
1812
+
1813
+ #: wpsc-admin/admin.php:95
1814
+ #: wpsc-admin/admin.php:449
1815
+ #: wpsc-admin/admin.php:479
1816
+ #: wpsc-admin/display-sales-logs.php:32
1817
+ #: wpsc-admin/includes/purchlogs_upgrade.php:73
1818
+ msgid "Sales"
1819
+ msgstr "Vendas"
1820
+
1821
+ #: wpsc-admin/admin.php:100
1822
+ msgid "Products"
1823
+ msgstr "Produtos"
1824
+
1825
+ #: wpsc-admin/admin.php:108
1826
+ msgid "Variations"
1827
+ msgstr "Variáveis"
1828
+
1829
+ #: wpsc-admin/admin.php:131
1830
+ #: wpsc-admin/admin.php:133
1831
+ msgid "Marketing"
1832
+ msgstr "Marketing"
1833
+
1834
+ #: wpsc-admin/admin.php:140
1835
+ #: wpsc-admin/display-upgrades.page.php:61
1836
+ msgid "Upgrades"
1837
+ msgstr "Upgrades"
1838
+
1839
+ #: wpsc-admin/admin.php:144
1840
+ msgid "- Debug"
1841
+ msgstr "- Debug"
1842
+
1843
+ #: wpsc-admin/admin.php:181
1844
+ msgid "Product Tracking Email"
1845
+ msgstr "Email de rastreamento de produto"
1846
+
1847
+ #: wpsc-admin/admin.php:182
1848
+ msgid ""
1849
+ "Track & Trace means you may track the progress of your parcel with our online parcel tracker, just login to our website and enter the following Tracking ID to view the status of your order.\n"
1850
+ "\n"
1851
+ "Tracking ID: %trackid%\n"
1852
+ msgstr ""
1853
+ "A função de Rastreamento & Localização permite-lhe acompanhar online o progresso da sua encomenda. Apenas tem que fazer login no nosso website e inserir o seguinte ID de Rastreamento.\n"
1854
+ "\n"
1855
+ "ID de Rastreamento: %trackid%\n"
1856
+
1857
+ #: wpsc-admin/admin.php:235
1858
+ msgid "Tags used on this post:"
1859
+ msgstr "Tags utilizadas neste artigo:"
1860
+
1861
+ #: wpsc-admin/admin.php:237
1862
+ msgid "Add new tag"
1863
+ msgstr "Adicionar nova tag"
1864
+
1865
+ #: wpsc-admin/admin.php:238
1866
+ #: wpsc-admin/includes/display-items-functions.php:432
1867
+ msgid "Separate tags with commas"
1868
+ msgstr "Separe as tags com vírgulas"
1869
+
1870
+ #: wpsc-admin/admin.php:348
1871
+ msgid "Text"
1872
+ msgstr "Texto"
1873
+
1874
+ #: wpsc-admin/admin.php:351
1875
+ msgid "Textarea"
1876
+ msgstr "Caixa de texto"
1877
+
1878
+ #: wpsc-admin/admin.php:352
1879
+ msgid "Heading"
1880
+ msgstr "Cabeçalho"
1881
+
1882
+ #: wpsc-admin/admin.php:353
1883
+ msgid "Coupon"
1884
+ msgstr "Cupão"
1885
+
1886
+ #: wpsc-admin/admin.php:358
1887
+ #: wpsc-admin/includes/display-items-functions.php:1079
1888
+ msgid "Label"
1889
+ msgstr "Rótulo"
1890
+
1891
+ #: wpsc-admin/admin.php:359
1892
+ #: wpsc-admin/includes/display-items-functions.php:1083
1893
+ msgid "Label Description"
1894
+ msgstr "Descrição do rótulo"
1895
+
1896
+ #: wpsc-admin/admin.php:360
1897
+ #: wpsc-admin/includes/display-items-functions.php:1091
1898
+ msgid "Item Number"
1899
+ msgstr "Número do artigo"
1900
+
1901
+ #: wpsc-admin/admin.php:361
1902
+ #: wpsc-admin/includes/display-items-functions.php:1087
1903
+ msgid "Life Number"
1904
+ msgstr ""
1905
+
1906
+ #: wpsc-admin/admin.php:362
1907
+ #: wpsc-admin/includes/display-items-functions.php:1095
1908
+ msgid "Product Code"
1909
+ msgstr "Código do produto"
1910
+
1911
+ #: wpsc-admin/admin.php:363
1912
+ #: wpsc-admin/includes/display-items-functions.php:1099
1913
+ msgid "PDF"
1914
+ msgstr "PDF"
1915
+
1916
+ #: wpsc-admin/admin.php:436
1917
+ #: wpsc-admin/display-sales-logs.php:359
1918
+ msgid "Last 30 Days"
1919
+ msgstr "Últimos 30 dias"
1920
+
1921
+ #: wpsc-admin/admin.php:455
1922
+ #: wpsc-admin/admin.php:485
1923
+ msgid "Orders"
1924
+ msgstr "Encomendas"
1925
+
1926
+ #: wpsc-admin/admin.php:465
1927
+ #: wpsc-admin/admin.php:497
1928
+ msgid "Avg Orders"
1929
+ msgstr "Média de encomendas"
1930
+
1931
+ #: wpsc-admin/admin.php:475
1932
+ #: wpsc-admin/display-sales-logs.php:372
1933
+ msgid "Life Time"
1934
+ msgstr "Desde sempre"
1935
+
1936
+ #: wpsc-admin/admin.php:518
1937
+ #: wpsc-admin/admin.php:746
1938
+ msgid "e-Commerce"
1939
+ msgstr "e-Commerce"
1940
+
1941
+ #: wpsc-admin/admin.php:535
1942
+ msgid "E-Commerce"
1943
+ msgstr "E-Commerce"
1944
+
1945
+ #: wpsc-admin/admin.php:652
1946
+ msgid "Sales by Quarter"
1947
+ msgstr "Vendas por trimestre"
1948
+
1949
+ #: wpsc-admin/admin.php:738
1950
+ msgid "Sales by"
1951
+ msgstr "Vendas por"
1952
+
1953
+ #: wpsc-admin/admin.php:781
1954
+ msgid "Your \"products page\" is not currently set to display any products. You need to select a product grouping to display by default. <br /> This is set in the Shop Settings page."
1955
+ msgstr "A sua página de produtos não está actualmente configurada para mostrar qualquer produto. Deverá seleccionar um grupo de produtos para mostra por defeito. <br /> Esta configuração é definida na página de Definições da Loja."
1956
+
1957
+ #: wpsc-admin/ajax-and-init.php:766
1958
+ #: wpsc-admin/display-variations.page.php:145
1959
+ msgid "Edit Variation Set"
1960
+ msgstr "Editar conjunto de variáveis"
1961
+
1962
+ #: wpsc-admin/ajax-and-init.php:985
1963
+ msgid "Your Order"
1964
+ msgstr "A sua encomenda"
1965
+
1966
+ #: wpsc-admin/ajax-and-init.php:1106
1967
+ #: wpsc-admin/ajax-and-init.php:1107
1968
+ #: wpsc-admin/includes/display-items-functions.php:1035
1969
+ msgid "Click to download"
1970
+ msgstr "Clique para fazer download"
1971
+
1972
+ #: wpsc-admin/ajax-and-init.php:1232
1973
+ msgid "The administrator has unlocked your file"
1974
+ msgstr "O administrador desbloqueou o seu ficheiro"
1975
+
1976
+ #: wpsc-admin/ajax-and-init.php:1232
1977
+ msgid "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."
1978
+ msgstr ""
1979
+ "Caro cliente,\n"
1980
+ "Temos o prazer de comunicar que a sua encomenda foi actualizada e os seus downloads estão agora activos.\n"
1981
+ "Por favor efectue os seus downloads através dos seguintes links:\n"
1982
+ "\n"
1983
+ "[download_links]\n"
1984
+ "\n"
1985
+ "Obrigado pela preferência."
1986
+
1987
+ #: wpsc-admin/display-groups.page.php:41
1988
+ msgid "Select the markets you are selling this category to."
1989
+ msgstr "Seleccione os mercados onde pretende vender esta categoria de produtos"
1990
+
1991
+ #: wpsc-admin/display-groups.page.php:236
1992
+ msgid "The item has been added"
1993
+ msgstr "O artigo foi adicionado"
1994
+
1995
+ #: wpsc-admin/display-groups.page.php:238
1996
+ #: wpsc-admin/display-groups.page.php:244
1997
+ msgid "The item has not been added"
1998
+ msgstr "O artigo não foi adicionado"
1999
+
2000
+ #: wpsc-admin/display-groups.page.php:469
2001
+ msgid "The product group has been edited."
2002
+ msgstr "O grupo de produtos foi editado."
2003
+
2004
+ #: wpsc-admin/display-groups.page.php:474
2005
+ msgid "The group has been added."
2006
+ msgstr "O grupo foi adicionado."
2007
+
2008
+ #: wpsc-admin/display-groups.page.php:486
2009
+ msgid "The group has been edited."
2010
+ msgstr "O grupo foi editado."
2011
+
2012
+ #: wpsc-admin/display-groups.page.php:542
2013
+ msgid "Are you sure you want to delete this category? If the category has any subcategories, they will be deleted too."
2014
+ msgstr "Tem a certeza que prentende eliminar esta categoria? Se a categoria contiver subcategorias, estas serão também eliminadas."
2015
+
2016
+ #: wpsc-admin/display-groups.page.php:550
2017
+ msgid "Are you sure you want to delete this product group? All categories it contains will be deleted too."
2018
+ msgstr "Tem a certeza que prentende eliminar este grupo de produtos? Todas as categorias do grupo serão também eliminadas."
2019
+
2020
+ #: wpsc-admin/display-groups.page.php:573
2021
+ msgid "Categorizing your products into groups help your customers find them. For instance if you sell hats and trousers you might want to setup a Group called clothes and add hats and trousers to that group."
2022
+ msgstr "Classificar os seus produtos em grupos ajuda os seus clientes a encontrá-los. Por exemplo, se vende chapéus e calças, poderá definir um grupo chamado Roupas e adicionar chapéus e calças a esse grupo."
2023
+
2024
+ #: wpsc-admin/display-groups.page.php:588
2025
+ msgid "Select a Group to Manage"
2026
+ msgstr "Seleccione um grupo para gerir"
2027
+
2028
+ #: wpsc-admin/display-groups.page.php:606
2029
+ msgid "or"
2030
+ msgstr "ou"
2031
+
2032
+ #: wpsc-admin/display-groups.page.php:608
2033
+ #: wpsc-admin/display-groups.page.php:625
2034
+ msgid "Add New Group"
2035
+ msgstr "Adicione um novo grupo"
2036
+
2037
+ #: wpsc-admin/display-groups.page.php:649
2038
+ msgid "Edit Group"
2039
+ msgstr "Editar grupo"
2040
+
2041
+ #: wpsc-admin/display-groups.page.php:684
2042
+ msgid "&quot;[categorisation]&quot; Group"
2043
+ msgstr "Grupo &quot;[categorisation]&quot;"
2044
+
2045
+ #: wpsc-admin/display-groups.page.php:694
2046
+ msgid "Image"
2047
+ msgstr "Imagem"
2048
+
2049
+ #: wpsc-admin/display-groups.page.php:717
2050
+ msgid "You are editing the &quot;[categorisation]&quot; Group"
2051
+ msgstr "Está a editar o grupo &quot;[categorisation]&quot;"
2052
+
2053
+ #: wpsc-admin/display-groups.page.php:738
2054
+ #: wpsc-admin/display-groups.page.php:742
2055
+ msgid "You are editing an item in the &quot;[categorisation]&quot; Group"
2056
+ msgstr "Está a editar um artigo no grupo &quot;[categorisation]&quot; "
2057
+
2058
+ #: wpsc-admin/display-groups.page.php:741
2059
+ msgid "Edit Details"
2060
+ msgstr "Editar detalhes"
2061
+
2062
+ #: wpsc-admin/display-groups.page.php:757
2063
+ #: wpsc-admin/display-groups.page.php:920
2064
+ msgid "Add Category"
2065
+ msgstr "Adicionar categoria"
2066
+
2067
+ #: wpsc-admin/display-groups.page.php:760
2068
+ msgid "Adding a new category here will make it available when you add or edit a product."
2069
+ msgstr "Ao adicionar uma categoria aqui, ficará disponível quando adicionar ou editar um produto."
2070
+
2071
+ #: wpsc-admin/display-groups.page.php:766
2072
+ #: wpsc-admin/display-groups.page.php:769
2073
+ msgid "You are adding a new item to the &quot;[categorisation]&quot; Group"
2074
+ msgstr "Está a adicionar um artigo ao grupo &quot;[categorisation]&quot; "
2075
+
2076
+ #: wpsc-admin/display-groups.page.php:791
2077
+ msgid "Group Parent"
2078
+ msgstr "Grupo \"pai\""
2079
+
2080
+ #: wpsc-admin/display-groups.page.php:799
2081
+ msgid "Group&nbsp;Image"
2082
+ msgstr "Imagem&nbsp;so&nbsp;Grupo"
2083
+
2084
+ #: wpsc-admin/display-items.page.php:29
2085
+ msgid "Display Products"
2086
+ msgstr "Mostrar produtos"
2087
+
2088
+ #: wpsc-admin/display-items.page.php:49
2089
+ #: wpsc-admin/display-items.page.php:54
2090
+ #, fuzzy, php-format
2091
+ msgid "%s product updated."
2092
+ msgid_plural "%s products updated."
2093
+ msgstr[0] "Produto actualizado."
2094
+ msgstr[1] "Produto actualizado."
2095
+
2096
+ #: wpsc-admin/display-items.page.php:63
2097
+ #, fuzzy, php-format
2098
+ msgid "Product deleted."
2099
+ msgid_plural "%s products deleted."
2100
+ msgstr[0] "Produto actualizado."
2101
+ msgstr[1] "Produto actualizado."
2102
+
2103
+ #: wpsc-admin/display-items.page.php:68
2104
+ #, fuzzy, php-format
2105
+ msgid "Product duplicated."
2106
+ msgid_plural "%s products duplicated."
2107
+ msgstr[0] "Produto actualizado."
2108
+ msgstr[1] "Produto actualizado."
2109
+
2110
+ #: wpsc-admin/display-items.page.php:74
2111
+ #: wpsc-admin/display-variations.page.php:49
2112
+ msgid "Product updated."
2113
+ msgstr "Produto actualizado."
2114
+
2115
+ #: wpsc-admin/display-items.page.php:114
2116
+ msgid "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."
2117
+ msgstr "As seguintes pastas não são graváveis: :directory: Não lhe será possível fazer upload de qualquer ficheiro ou imagem para aqui. Será necessário alterar as permissões destas pastas, para as tornar acessíveis."
2118
+
2119
+ #: wpsc-admin/display-items.page.php:147
2120
+ msgid ""
2121
+ "You are about to delete the selected products.\n"
2122
+ " 'Cancel' to stop, 'OK' to delete."
2123
+ msgstr ""
2124
+ "Está prestes a eliminar os produtos seleccionados '%s'\n"
2125
+ "Escolha 'Cancelar' para parar ou 'OK' para eliminar."
2126
+
2127
+ #: wpsc-admin/display-items.page.php:231
2128
+ msgid "&laquo;"
2129
+ msgstr "&laquo;"
2130
+
2131
+ #: wpsc-admin/display-items.page.php:232
2132
+ msgid "&raquo;"
2133
+ msgstr "&raquo;"
2134
+
2135
+ #: wpsc-admin/display-items.page.php:270
2136
+ msgid "Search"
2137
+ msgstr "Pesquisar"
2138
+
2139
+ #: wpsc-admin/display-items.page.php:275
2140
+ #: wpsc-admin/display-sales-logs.php:419
2141
+ msgid "Bulk Actions"
2142
+ msgstr "Acções em massa"
2143
+
2144
+ #: wpsc-admin/display-items.page.php:277
2145
+ #: wpsc-admin/display-items.page.php:425
2146
+ #: wpsc-admin/includes/display-items-functions.php:823
2147
+ msgid "Publish"
2148
+ msgstr "Publicar"
2149
+
2150
+ #: wpsc-admin/display-items.page.php:278
2151
+ #: wpsc-admin/display-items.page.php:365
2152
+ msgid "Draft"
2153
+ msgstr "Rascunho"
2154
+
2155
+ #: wpsc-admin/display-items.page.php:282
2156
+ #: wpsc-admin/display-sales-logs.php:428
2157
+ msgid "Apply"
2158
+ msgstr "Aplicar"
2159
+
2160
+ #: wpsc-admin/display-items.page.php:318
2161
+ msgid "No Name"
2162
+ msgstr "Sem nome"
2163
+
2164
+ #: wpsc-admin/display-items.page.php:396
2165
+ #: wpsc-admin/includes/display-items-functions.php:351
2166
+ msgid "Delete this product"
2167
+ msgstr "Eliminar este produto"
2168
+
2169
+ #: wpsc-admin/display-items.page.php:398
2170
+ #: wpsc-admin/includes/display-items-functions.php:351
2171
+ #, php-format
2172
+ msgid ""
2173
+ "You are about to delete this product '%s'\n"
2174
+ " 'Cancel' to stop, 'OK' to delete."
2175
+ msgstr ""
2176
+ "Está prestes a eliminar este produto '%s'\n"
2177
+ "Escolha 'Cancelar' para parar ou 'OK' para eliminar."
2178
+
2179
+ #: wpsc-admin/display-items.page.php:423
2180
+ msgid "Unpublish"
2181
+ msgstr "Despublicar"
2182
+
2183
+ #: wpsc-admin/display-items.page.php:452
2184
+ msgid "You have no products added."
2185
+ msgstr "Não produtos adicionados."
2186
+
2187
+ #: wpsc-admin/display-items.page.php:469
2188
+ msgid "View All Categories"
2189
+ msgstr "Ver todas as categorias"
2190
+
2191
+ #: wpsc-admin/display-options-settings.page.php:18
2192
+ msgid "It looks like your wp-e-commerce theme files are out of date, this can cause potential problems with some gateways and the appearances of the front end of your shop. <br /><strong>We recommend you download the latest version of wp-e-commerce unzip it, and copy the new themes folder into your 'uploads/wpsc/themes' folder on your site. Or port your changes across.</strong>"
2193
+ msgstr "Aparentemente os ficheiros do seu tema do wp-e-commerce estão desactualizados, o que poderá provocar problemas com alguns gateways e na aparência do front end da sua loja. <br /><strong>Recomendamos que faça download da última versão do wp-e-commerce, descompacte-a e copie a nova pasta 'themes' para a pasta do seu site 'uploads/wpsc/themes'. </strong>"
2194
+
2195
+ #: wpsc-admin/display-options-settings.page.php:44
2196
+ msgid "Thanks, your thumbnail images have been resized."
2197
+ msgstr "Obrigado, os thumbnails das imagens foram redimensionados."
2198
+
2199
+ #: wpsc-admin/display-options-settings.page.php:99
2200
+ msgid "General"
2201
+ msgstr "Geral"
2202
+
2203
+ #: wpsc-admin/display-options-settings.page.php:100
2204
+ msgid "Presentation"
2205
+ msgstr "Apresentação"
2206
+
2207
+ #: wpsc-admin/display-options-settings.page.php:101
2208
+ msgid "Admin"
2209
+ msgstr "Admin"
2210
+
2211
+ #: wpsc-admin/display-options-settings.page.php:103
2212
+ msgid "Payment Options"
2213
+ msgstr "Opções de pagamento"
2214
+
2215
+ #: wpsc-admin/display-options-settings.page.php:104
2216
+ msgid "Import"
2217
+ msgstr "Importar"
2218
+
2219
+ #: wpsc-admin/display-options-settings.page.php:105
2220
+ #: wpsc-includes/install_and_update.functions.php:213
2221
+ msgid "Checkout"
2222
+ msgstr "Checkout"
2223
+
2224
+ #: wpsc-admin/display-options-settings.page.php:176
2225
+ msgid "To configure a shipping module select one on the left."
2226
+ msgstr "Para configurar um módulo de envio, seleccione um da listagem à esquerda."
2227
+
2228
+ #: wpsc-admin/display-options-settings.page.php:186
2229
+ #, php-format
2230
+ msgid " Setting Options Updated. "
2231
+ msgid_plural " %s Settings Options Updated. "
2232
+ msgstr[0] "%s opção de definição actualizada."
2233
+ msgstr[1] "%s opções de definições actualizadas."
2234
+
2235
+ #: wpsc-admin/display-options-settings.page.php:191
2236
+ #, php-format
2237
+ msgid "%s Setting Option deleted. "
2238
+ msgid_plural "%s Setting Option deleted. "
2239
+ msgstr[0] "%s opção de definição eliminada."
2240
+ msgstr[1] "%s opções de definições eliminadas."
2241
+
2242
+ #: wpsc-admin/display-options-settings.page.php:195
2243
+ #, fuzzy
2244
+ msgid " Shipping Option Updated."
2245
+ msgid_plural " Shipping Option Updated."
2246
+ msgstr[0] "Opções de envio"
2247
+ msgstr[1] "Opções de envio"
2248
+
2249
+ #: wpsc-admin/display-options-settings.page.php:199
2250
+ #, php-format
2251
+ msgid "%s Checkout Field Added."
2252
+ msgid_plural "%s Checkout Fields Added."
2253
+ msgstr[0] " %s campo de checkout adicionado."
2254
+ msgstr[1] " %s campos de chekout adicionados."
2255
+
2256
+ #: wpsc-admin/display-sales-logs.php:65
2257
+ #, fuzzy, php-format
2258
+ msgid "%s Purchase Log updated."
2259
+ msgid_plural "%s Purchase Logs updated."
2260
+ msgstr[0] "Data de relatório de compra:"
2261
+ msgstr[1] "Data de relatório de compra:"
2262
+
2263
+ #: wpsc-admin/display-sales-logs.php:73
2264
+ #, php-format
2265
+ msgid "%s product not updated, somebody is editing it."
2266
+ msgid_plural "%s products not updated, somebody is editing them."
2267
+ msgstr[0] "%s produto não actualizado, alguém o está a editar."
2268
+ msgstr[1] "%s produtos não actualizados, alguém os está a editar."
2269
+
2270
+ #: wpsc-admin/display-sales-logs.php:78
2271
+ #, fuzzy, php-format
2272
+ msgid "%s Purchase Log deleted."
2273
+ msgid_plural "%s Purchase Logs deleted."
2274
+ msgstr[0] "Data de relatório de compra:"
2275
+ msgstr[1] "Data de relatório de compra:"
2276
+
2277
+ #: wpsc-admin/display-sales-logs.php:88
2278
+ msgid "When upgrading the Wp-E-Commerce Plugin from 3.6.* to 3.7 it is required that you associate your checkout form fields with the new Purchase Logs system. To do so please "
2279
+ msgstr "Ao fazer upgrade do Wp-E-Commerce Plugin de 2.6.* para 3.7 é necessário é associar os campos do seu formulário de checkout ao novo sistema de Registo de Compra. Para o fazer, por favor"
2280
+
2281
+ #: wpsc-admin/display-sales-logs.php:114
2282
+ msgid "GetShopped News"
2283
+ msgstr "Notícias GetShopped"
2284
+
2285
+ #: wpsc-admin/display-sales-logs.php:151
2286
+ #, fuzzy
2287
+ msgid "Downloads for this log have been released."
2288
+ msgid_plural "Downloads for this log have been released."
2289
+ msgstr[0] "Obrigado, os thumbnails das imagens foram redimensionados."
2290
+ msgstr[1] "Obrigado, os thumbnails das imagens foram redimensionados."
2291
+
2292
+ #: wpsc-admin/display-sales-logs.php:155
2293
+ msgid "Receipt has been resent "
2294
+ msgid_plural "Receipt has been resent "
2295
+ msgstr[0] "O recibo foi reenviado "
2296
+ msgstr[1] "Os recebidos foram reenviados "
2297
+
2298
+ #: wpsc-admin/display-sales-logs.php:196
2299
+ #: wpsc-admin/includes/settings-pages/shipping.php:46
2300
+ msgid "Shipping Options"
2301
+ msgstr "Opções de envio"
2302
+
2303
+ #: wpsc-admin/display-sales-logs.php:199
2304
+ msgid "Shipping Method:"
2305
+ msgstr "Método de envio:"
2306
+
2307
+ #: wpsc-admin/display-sales-logs.php:200
2308
+ msgid "Shipping Option:"
2309
+ msgstr "Opção de envio:"
2310
+
2311
+ #: wpsc-admin/display-sales-logs.php:202
2312
+ msgid "Tracking ID:"
2313
+ msgstr "ID de acompanhamento:"
2314
+
2315
+ #: wpsc-admin/display-sales-logs.php:203
2316
+ msgid "Shipping Status:"
2317
+ msgstr "Estado do envio:"
2318
+
2319
+ #: wpsc-admin/display-sales-logs.php:204
2320
+ msgid "Track History:"
2321
+ msgstr "Historial de acompanhamento:"
2322
+
2323
+ #: wpsc-admin/display-sales-logs.php:210
2324
+ msgid "Billing Details"
2325
+ msgstr "Detalhes de facturação:"
2326
+
2327
+ #: wpsc-admin/display-sales-logs.php:211
2328
+ msgid "Purchase Log Date:"
2329
+ msgstr "Data de relatório de compra:"
2330
+
2331
+ #: wpsc-admin/display-sales-logs.php:212
2332
+ msgid "Purchase Number:"
2333
+ msgstr "N.º da compra"
2334
+
2335
+ #: wpsc-admin/display-sales-logs.php:213
2336
+ msgid "Buyers Name:"
2337
+ msgstr "Nome do cliente:"
2338
+
2339
+ #: wpsc-admin/display-sales-logs.php:214
2340
+ msgid "Address:"
2341
+ msgstr "Morada:"
2342
+
2343
+ #: wpsc-admin/display-sales-logs.php:216
2344
+ msgid "Phone:"
2345
+ msgstr "Telefone:"
2346
+
2347
+ #: wpsc-admin/display-sales-logs.php:217
2348
+ msgid "Email:"
2349
+ msgstr "Email:"
2350
+
2351
+ #: wpsc-admin/display-sales-logs.php:218
2352
+ msgid "Payment Method:"
2353
+ msgstr "Método de pagamento:"
2354
+
2355
+ #: wpsc-admin/display-sales-logs.php:220
2356
+ msgid "How User Found Us:"
2357
+ msgstr "como chegou até nós:"
2358
+
2359
+ #: wpsc-admin/display-sales-logs.php:226
2360
+ msgid "Items Ordered"
2361
+ msgstr "Artigos encomendados:"
2362
+
2363
+ #: wpsc-admin/display-sales-logs.php:268
2364
+ msgid "Order Status:"
2365
+ msgstr "Estado da encomenda:"
2366
+
2367
+ #: wpsc-admin/display-sales-logs.php:288
2368
+ msgid "Actions"
2369
+ msgstr "Acções"
2370
+
2371
+ #: wpsc-admin/display-sales-logs.php:293
2372
+ msgid "View Packing Slip"
2373
+ msgstr "Ver Nota de Embalagem"
2374
+
2375
+ #: wpsc-admin/display-sales-logs.php:295
2376
+ msgid "Resend Receipt to Buyer"
2377
+ msgstr "Reenviar recibo para o cliente"
2378
+
2379
+ #: wpsc-admin/display-sales-logs.php:297
2380
+ #: wpsc-admin/display-sales-logs.php:550
2381
+ msgid "Delete this log"
2382
+ msgstr "Eliminar este registo"
2383
+
2384
+ #: wpsc-admin/display-sales-logs.php:297
2385
+ #: wpsc-admin/display-sales-logs.php:550
2386
+ #, php-format
2387
+ msgid ""
2388
+ "You are about to delete this log '%s'\n"
2389
+ " 'Cancel' to stop, 'OK' to delete."
2390
+ msgstr ""
2391
+ "está prestes a eliminar este registo '%s'\n"
2392
+ "Escolha 'Cancelar' para parar ou 'OK' para eliminar."
2393
+
2394
+ #: wpsc-admin/display-sales-logs.php:297
2395
+ msgid "Remove this record"
2396
+ msgstr "Eliminar este registo"
2397
+
2398
+ #: wpsc-admin/display-sales-logs.php:299
2399
+ msgid "Go Back"
2400
+ msgstr "Voltar atrás"
2401
+
2402
+ #: wpsc-admin/display-sales-logs.php:314
2403
+ msgid "e-Commerce Admin Menu"
2404
+ msgstr "Menu de administração do e-Commerce"
2405
+
2406
+ #: wpsc-admin/display-sales-logs.php:333
2407
+ msgid "WP e-Commerce News"
2408
+ msgstr "Notícias WP e-Commerce"
2409
+
2410
+ #: wpsc-admin/display-sales-logs.php:355
2411
+ msgid "Order Summary"
2412
+ msgstr "Resumo da encomenda"
2413
+
2414
+ #: wpsc-admin/display-sales-logs.php:367
2415
+ msgid "(accepted payments)"
2416
+ msgstr "(pagamentos aceites)"
2417
+
2418
+ #: wpsc-admin/display-sales-logs.php:382
2419
+ msgid "Subscribe to your orders"
2420
+ msgstr "Subscreva as suas encomendas"
2421
+
2422
+ #: wpsc-admin/display-sales-logs.php:384
2423
+ msgid "Subscribe to an RSS feed"
2424
+ msgstr "Subscreva um Feed RSS"
2425
+
2426
+ #: wpsc-admin/display-sales-logs.php:384
2427
+ msgid "of your orders"
2428
+ msgstr "das suas encomendas"
2429
+
2430
+ #: wpsc-admin/display-sales-logs.php:387
2431
+ msgid "Plugin News"
2432
+ msgstr "Notícias do plugin"
2433
+
2434
+ #: wpsc-admin/display-sales-logs.php:389
2435
+ msgid "The <a href=\"http://instinct.co.nz/blogshop/products-page/\" target=\"_blank\">WP DropShop Module</a> is the latest and most cutting edge shopping cart available online. Coupled with Grid View then your site will be the talk of street! <br/><br/>The <a href=\"http://instinct.co.nz/blogshop/products-page/\" target=\"_blank\">GridView Module</a> is a visual module built to enhance the way your product page looks.<br/><br/><a href=\"http://www.instinct.co.nz/wp-campaign-monitor/100\">WP Campaign Monitor</a> is an email newsletter tool built just for WP users who want to send campaigns, track the results and manage their subscribers. The latest version integrates with e-commerce lite meaning that you will be able to send buyers email newsletters and much more. "
2436
+ msgstr "<a href=\"http://instinct.co.nz/blogshop/products-page/\" target=\"_blank\">WP DropShop Module</a>é o mais recente e avançado carrinho de compras disponível online. Juntamente com o Grid View, o seu website será falado por todos! <br/><br/><a href=\"http://instinct.co.nz/blogshop/products-page/\" target=\"_blank\">GridView Module</a> é um módulo visual, construído para melhorar a aparência da sua página de produtos.<br/><br/><a href=\"http://www.instinct.co.nz/wp-campaign-monitor/100\">WP Campaign Monitor</a> é uma ferramenta de envio de newsletters por email, construída especificamente para utilizadores do Wordpress, que pretendam enviar campanhas, acompanhar os resultados e gerir os subscritores. A última versão integra-se com o e-Commerce lite, o que significa que será capaz de enviar newsletters por email para os seus clientes e muito mais... "
2437
+
2438
+ #: wpsc-admin/display-sales-logs.php:390
2439
+ msgid "This shop is powered by "
2440
+ msgstr "Loja powered by "
2441
+
2442
+ #: wpsc-admin/display-sales-logs.php:399
2443
+ msgid "Upgrade to Gold"
2444
+ msgstr "Upgrade para Gold"
2445
+
2446
+ #: wpsc-admin/display-sales-logs.php:399
2447
+ msgid " and unleash more functionality into your shop."
2448
+ msgstr " e acrescente mais funcionalidades à sua loja."
2449
+
2450
+ #: wpsc-admin/display-sales-logs.php:430
2451
+ msgid "View:"
2452
+ msgstr "Ver: "
2453
+
2454
+ #: wpsc-admin/display-sales-logs.php:468
2455
+ msgid "Filter"
2456
+ msgstr "Filtro"
2457
+
2458
+ #: wpsc-admin/display-sales-logs.php:471
2459
+ msgid "Oops there are no purchase logs for your selection, please try again."
2460
+ msgstr "Ups, não existem registos de compra para a sua selecção, por favor tente novamente."
2461
+
2462
+ #: wpsc-admin/display-sales-logs.php:491
2463
+ msgid "Total:"
2464
+ msgstr "Total: "
2465
+
2466
+ #: wpsc-admin/display-sales-logs.php:503
2467
+ msgid "Download CSV"
2468
+ msgstr "Download em ficheiro CSV"
2469
+
2470
+ #: wpsc-admin/display-sales-logs.php:512
2471
+ msgid ""
2472
+ "You are about to delete the selected purchase logs.\n"
2473
+ " 'Cancel' to stop, 'OK' to delete."
2474
+ msgstr ""
2475
+ "Está prestes a eliminar os registos de compra seleccionados.\n"
2476
+ "Escolha 'Cancelar' para parar ou 'OK' para eliminar."
2477
+
2478
+ #: wpsc-admin/display-sales-logs.php:578
2479
+ msgid "Search Logs"
2480
+ msgstr "Pesquisar registos"
2481
+
2482
+ #: wpsc-admin/display-upgrades.page.php:12
2483
+ msgid "WP e-Commerce Upgrades"
2484
+ msgstr "Upgrades do WP e-Commerce"
2485
+
2486
+ #: wpsc-admin/display-upgrades.page.php:13
2487
+ msgid "Add more functionality to your e-Commerce site. Prices may be subject to change."
2488
+ msgstr "Adicione mais funcionalidade ao seu site de comércio electrónico. Os preços estão sujeitos a alteração."
2489
+
2490
+ #: wpsc-admin/display-upgrades.page.php:19
2491
+ msgid "Pure Gold"
2492
+ msgstr ""
2493
+
2494
+ #: wpsc-admin/display-upgrades.page.php:26
2495
+ #: wpsc-admin/includes/settings-pages/presentation.php:671
2496
+ #: wpsc-admin/includes/settings-pages/presentation.php:675
2497
+ msgid "DropShop"
2498
+ msgstr ""
2499
+
2500
+ #: wpsc-admin/display-upgrades.page.php:33
2501
+ msgid "MP3 Player"
2502
+ msgstr ""
2503
+
2504
+ #: wpsc-admin/display-upgrades.page.php:40
2505
+ msgid "Members Only Module"
2506
+ msgstr "Members Only Module"
2507
+
2508
+ #: wpsc-admin/display-upgrades.page.php:54
2509
+ msgid "NextGen Gallery Buy Now Buttons"
2510
+ msgstr "NextGen Gallery Buy Now Buttons"
2511
+
2512
+ #: wpsc-admin/display-upgrades.page.php:78
2513
+ #: wpsc-admin/display-upgrades.page.php:86
2514
+ msgid "API Key Reset"
2515
+ msgstr "Repor API Key"
2516
+
2517
+ #: wpsc-admin/display-upgrades.page.php:81
2518
+ msgid "Enter your API name and key to release it from an old site that you no longer use."
2519
+ msgstr "Insira o seu nome da API para a libertar de um site antigo que já não utilize."
2520
+
2521
+ #: wpsc-admin/display-upgrades.page.php:92
2522
+ msgid "API Key"
2523
+ msgstr "API Key"
2524
+
2525
+ #: wpsc-admin/display-upgrades.page.php:97
2526
+ msgid "Reset API Key"
2527
+ msgstr "Reset API Key"
2528
+
2529
+ #: wpsc-admin/display-upgrades.page.php:106
2530
+ msgid "Upgrade Instructions"
2531
+ msgstr "Instruções de upgrade"
2532
+
2533
+ #: wpsc-admin/display-upgrades.page.php:108
2534
+ #, php-format
2535
+ msgid "Copy the gold_cart_files directory into the %s folder."
2536
+ msgstr "Copiar a pasta gord_cart_files para a pasta %s."
2537
+
2538
+ #: wpsc-admin/display-upgrades.page.php:111
2539
+ msgid "This folder should be automatically created when the e-commerce plugin is activated, but if it is not, you will have to create it yourself."
2540
+ msgstr "Esta pasta deveria ser automaticamente criada quando o plugin ecommerce é activado, mas se não está activada deverá criá-la você mesmo."
2541
+
2542
+ #: wpsc-admin/display-upgrades.page.php:114
2543
+ msgid "Now a new panel should appear in the Upgrades page where you must enter your API Username and API Key. "
2544
+ msgstr "Agora deverá aparecer um novo painel na página de Upgrades onde deverá inserir o seu API Username e API Key."
2545
+
2546
+ #: wpsc-admin/display-upgrades.page.php:118
2547
+ msgid "For more information visit our documentation page."
2548
+ msgstr "Para mais informação visita a nossa página de documentação."
2549
+
2550
+ #: wpsc-admin/display-upgrades.page.php:162
2551
+ msgid "Your API key has been Reset"
2552
+ msgstr "A sua API key foi reposta"
2553
+
2554
+ #: wpsc-admin/display-variations.page.php:21
2555
+ msgid "Are you sure you want to delete this product?"
2556
+ msgstr "De certeza que pretende eliminar este produto?"
2557
+
2558
+ #: wpsc-admin/display-variations.page.php:37
2559
+ #: wpsc-admin/includes/settings-pages/presentation.php:392
2560
+ msgid "Display Variations"
2561
+ msgstr "Mostrar variáveis"
2562
+
2563
+ #: wpsc-admin/display-variations.page.php:39
2564
+ msgid "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..."
2565
+ msgstr "Uma variável pode ser qualquer opção de um produto. ie: Tamanho, Cor, etc. <br />Por exemplo: se está a vender t-shirts, poderá definir uma variável chamada tamanho com os valores S, M, L, XL..."
2566
+
2567
+ #: wpsc-admin/display-variations.page.php:149
2568
+ #: wpsc-admin/includes/display-items-functions.php:613
2569
+ msgid "Add Variation Set"
2570
+ msgstr "Adicionar conjunto de variáveis"
2571
+
2572
+ #: wpsc-admin/display-variations.page.php:199
2573
+ msgid "Add Value"
2574
+ msgstr "Adicionar valor"
2575
+
2576
+ #: wpsc-admin/display-variations.page.php:212
2577
+ msgid "Update Variations"
2578
+ msgstr "Actualizar variáveis"
2579
+
2580
+ #: wpsc-admin/includes/display-items-functions.php:137
2581
+ msgid "Edit Product"
2582
+ msgstr "Editar o produto"
2583
+
2584
+ #: wpsc-admin/includes/display-items-functions.php:148
2585
+ msgid "Product Name"
2586
+ msgstr "Nome do produto"
2587
+
2588
+ #: wpsc-admin/includes/display-items-functions.php:157
2589
+ msgid "Display Product Shortcode"
2590
+ msgstr "Mostrar abreviatura do produto"
2591
+
2592
+ #: wpsc-admin/includes/display-items-functions.php:158
2593
+ msgid "Buy Now Shortcode"
2594
+ msgstr "Abreviatura de Compre Já"
2595
+
2596
+ #: wpsc-admin/includes/display-items-functions.php:159
2597
+ msgid "Add to Cart Shortcode"
2598
+ msgstr "Abreviatura de Adicionar ao Carrinho de Compras"
2599
+
2600
+ #: wpsc-admin/includes/display-items-functions.php:165
2601
+ msgid "Display Product Template Tag"
2602
+ msgstr "Mostrar tag de modelo de produto"
2603
+
2604
+ #: wpsc-admin/includes/display-items-functions.php:166
2605
+ msgid "Buy Now PHP"
2606
+ msgstr "Compre Agora PHP"
2607
+
2608
+ #: wpsc-admin/includes/display-items-functions.php:167
2609
+ msgid "Add to Cart PHP"
2610
+ msgstr "Adicionar ao Carrinho PHP"
2611
+
2612
+ #: wpsc-admin/includes/display-items-functions.php:168
2613
+ msgid "Display Product SKU"
2614
+ msgstr "Mostrar SKU do produto"
2615
+
2616
+ #: wpsc-admin/includes/display-items-functions.php:185
2617
+ msgid "Stock Keeping Unit"
2618
+ msgstr "SKU"
2619
+
2620
+ #: wpsc-admin/includes/display-items-functions.php:193
2621
+ msgid "Sale Price :"
2622
+ msgstr "Preço de venda:"
2623
+
2624
+ #: wpsc-admin/includes/display-items-functions.php:216
2625
+ msgid "New Currency"
2626
+ msgstr "Nova moeda"
2627
+
2628
+ #: wpsc-admin/includes/display-items-functions.php:220
2629
+ #: wpsc-admin/includes/display-items-functions.php:259
2630
+ #: wpsc-admin/includes/settings-pages/general.php:119
2631
+ #: wpsc-includes/install_and_update.functions.php:114
2632
+ msgid "Currency type"
2633
+ msgstr "Tipo de moeda"
2634
+
2635
+ #: wpsc-admin/includes/display-items-functions.php:244
2636
+ #: wpsc-admin/includes/display-items-functions.php:283
2637
+ msgid "Delete Currency"
2638
+ msgstr "Eliminar moeda"
2639
+
2640
+ #: wpsc-admin/includes/display-items-functions.php:301
2641
+ msgid "Additional Description"
2642
+ msgstr "Descrição adicional"
2643
+
2644
+ #: wpsc-admin/includes/display-items-functions.php:350
2645
+ msgid "Update Product"
2646
+ msgstr "Actualizar o produto"
2647
+
2648
+ #: wpsc-admin/includes/display-items-functions.php:374
2649
+ msgid "Categories and Tags"
2650
+ msgstr "Categorias e tags"
2651
+
2652
+ #: wpsc-admin/includes/display-items-functions.php:413
2653
+ msgid "Select &quot;[categorisation]&quot;"
2654
+ msgstr "Seleccione &quot;[categorisation]&quot;"
2655
+
2656
+ #: wpsc-admin/includes/display-items-functions.php:469
2657
+ msgid "Price and Stock Control"
2658
+ msgstr "Controlo de preço e stock"
2659
+
2660
+ #: wpsc-admin/includes/display-items-functions.php:479
2661
+ #, php-format
2662
+ msgid "Do not include tax (tax is set in <a href=\"%s\"/wp-admin/admin.php?page=wpsc-settings\">shop config</a>)"
2663
+ msgstr "Não incluir impostos (o imposto é definido nas <a href=\"%s\"/wp-admin/admin.php?page=wpsc-settings\">Definições gerais</a>)"
2664
+
2665
+ #: wpsc-admin/includes/display-items-functions.php:486
2666
+ msgid "This is a donation, checking this box populates the donations widget."
2667
+ msgstr "Esta é uma doação, marcar esta caixa preenche o widget de doações"
2668
+
2669
+ #: wpsc-admin/includes/display-items-functions.php:493
2670
+ msgid "Table Rate Price"
2671
+ msgstr "Tabela de preços"
2672
+
2673
+ #: wpsc-admin/includes/display-items-functions.php:498
2674
+ msgid "Quantity In Cart"
2675
+ msgstr "Quantidade no carrinho"
2676
+
2677
+ #: wpsc-admin/includes/display-items-functions.php:499
2678
+ msgid "Discounted Price"
2679
+ msgstr "Preço com desconto"
2680
+
2681
+ #: wpsc-admin/includes/display-items-functions.php:534
2682
+ msgid "Custom Tax Rate"
2683
+ msgstr "Taxa de imposto personalizada"
2684
+
2685
+ #: wpsc-admin/includes/display-items-functions.php:548
2686
+ msgid "I have a limited number of this item in stock. If the stock runs out, this product will not be available on the shop unless you untick this box or add more stock."
2687
+ msgstr "Eu tenho um número limitado deste artigo em stock. Se o stock esgotar, este produto não estará disponível na loja a menos que desmarque esta opção ou adicione mais stock."
2688
+
2689
+ #: wpsc-admin/includes/display-items-functions.php:563
2690
+ #: wpsc-admin/includes/display-items-functions.php:577
2691
+ #: wpsc-admin/includes/display-items-functions.php:584
2692
+ msgid "If this product runs out of stock set status to Unpublished & email site owner"
2693
+ msgstr "Se o stock deste produto esgotar, definir o estado para não publicado e enviar um email ao administrador do website"
2694
+
2695
+ #: wpsc-admin/includes/display-items-functions.php:576
2696
+ #: wpsc-admin/includes/display-items-functions.php:583
2697
+ msgid "Stock Qty"
2698
+ msgstr "Quant. Stock"
2699
+
2700
+ #: wpsc-admin/includes/display-items-functions.php:610
2701
+ msgid "Variation Control"
2702
+ msgstr "Controlo de variáveis"
2703
+
2704
+ #: wpsc-admin/includes/display-items-functions.php:614
2705
+ msgid "+ Add New Variations"
2706
+ msgstr "+ Adicionar novas variáveis"
2707
+
2708
+ #: wpsc-admin/includes/display-items-functions.php:660
2709
+ msgid "Weight"
2710
+ msgstr "Peso"
2711
+
2712
+ #: wpsc-admin/includes/display-items-functions.php:700
2713
+ msgid "Length"
2714
+ msgstr "Comprimento"
2715
+
2716
+ #: wpsc-admin/includes/display-items-functions.php:724
2717
+ msgid "Flat Rate Settings"
2718
+ msgstr "Definições de taxa fixa"
2719
+
2720
+ #: wpsc-admin/includes/display-items-functions.php:729
2721
+ msgid "Local Shipping Fee"
2722
+ msgstr "Taxa de expedição local"
2723
+
2724
+ #: wpsc-admin/includes/display-items-functions.php:738
2725
+ msgid "International Shipping Fee"
2726
+ msgstr "Taxa de expedição internacional"
2727
+
2728
+ #: wpsc-admin/includes/display-items-functions.php:747
2729
+ msgid "Disregard Shipping for this product"
2730
+ msgstr "Não considerar expedição para este produto"
2731
+
2732
+ #: wpsc-admin/includes/display-items-functions.php:776
2733
+ msgid "Advanced Options"
2734
+ msgstr "Opções avançadas"
2735
+
2736
+ #: wpsc-admin/includes/display-items-functions.php:784
2737
+ msgid "Custom Meta"
2738
+ msgstr "Metainformação personalizada"
2739
+
2740
+ #: wpsc-admin/includes/display-items-functions.php:785
2741
+ msgid "Add Custom Meta"
2742
+ msgstr "Adicionar Metainformação personalizada"
2743
+
2744
+ #: wpsc-admin/includes/display-items-functions.php:795
2745
+ msgid "Value"
2746
+ msgstr "Valor"
2747
+
2748
+ #: wpsc-admin/includes/display-items-functions.php:812
2749
+ msgid "Merchant Notes"
2750
+ msgstr "Valor"
2751
+
2752
+ #: wpsc-admin/includes/display-items-functions.php:815
2753
+ msgid "These notes are only available here."
2754
+ msgstr "Estas observações apenas estão disponíveis aqui."
2755
+
2756
+ #: wpsc-admin/includes/display-items-functions.php:834
2757
+ msgid "Personalisation Options"
2758
+ msgstr "Opções de personalização"
2759
+
2760
+ #: wpsc-admin/includes/display-items-functions.php:837
2761
+ msgid "Users can personalize this product by leaving a message on single product page"
2762
+ msgstr "Os clientes podem personalizar este produto ao deixar um mensagem na página individual do produto"
2763
+
2764
+ #: wpsc-admin/includes/display-items-functions.php:846
2765
+ msgid "Users can upload images on single product page to purchase logs."
2766
+ msgstr "Os clientes podem fazer upload de imagens para os registos de compra na página individual do produto"
2767
+
2768
+ #: wpsc-admin/includes/display-items-functions.php:857
2769
+ msgid "Prohibited"
2770
+ msgstr "Proibido"
2771
+
2772
+ #: wpsc-admin/includes/display-items-functions.php:871
2773
+ msgid "Off Site Product Link"
2774
+ msgstr "Link de produto em site externo"
2775
+
2776
+ #: wpsc-admin/includes/display-items-functions.php:872
2777
+ msgid "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 over rides the buy now and add to cart links and takes you to the site linked here."
2778
+ msgstr "Se este produto está à venda noutro site, insira o link aqui. Por exemplo, se seu produto é um ficheiro MP3 para venda no iTunes, poderia colocar o link aqui. Esta opção sobrepõe-se ao \"comprar agora\" e \"adicionar ao carrinho\" e leva-o para o site vinculado aqui."
2779
+
2780
+ #: wpsc-admin/includes/display-items-functions.php:873
2781
+ msgid "External Link"
2782
+ msgstr "Link externo"
2783
+
2784
+ #: wpsc-admin/includes/display-items-functions.php:881
2785
+ msgid "Enable IntenseDebate Comments"
2786
+ msgstr "Activar IntenseDebate Comments"
2787
+
2788
+ #: wpsc-admin/includes/display-items-functions.php:887
2789
+ msgid "Allow users to comment on this product."
2790
+ msgstr "Permitir os utilizadores comentarem este produto."
2791
+
2792
+ #: wpsc-admin/includes/display-items-functions.php:914
2793
+ msgid "Product Images"
2794
+ msgstr "Imagens do produto"
2795
+
2796
+ #: wpsc-admin/includes/display-items-functions.php:922
2797
+ msgid "Select Files"
2798
+ msgstr "Seleccione ficheiros"
2799
+
2800
+ #: wpsc-admin/includes/display-items-functions.php:976
2801
+ msgid "You are using the Flash uploader. Problems? Try the <a class=\"wpsc_upload_switcher\" onclick='wpsc_upload_switcher(\"browser\")'>Browser uploader</a> instead."
2802
+ msgstr "Está a utilizar o carregamento de ficheiro por Flash. Problemas? Em alternativa experimente o <a class=\"wpsc_upload_switcher\" onclick='wpsc_upload_switcher(\"browser\")'>carregamento pelo Browser</a>."
2803
+
2804
+ #: wpsc-admin/includes/display-items-functions.php:980
2805
+ msgid "To upload multiple product thumbnails you must <a href=\"http://www.instinct.co.nz/shop/\">install the premium upgrade</a>"
2806
+ msgstr "Para fazer upload de vários thumbnails de produtos de uma só vez, deverá <a href=\"http://www.instinct.co.nz/shop/\">instalar o upgrade premium </a>"
2807
+
2808
+ #: wpsc-admin/includes/display-items-functions.php:989
2809
+ msgid "Select an image to upload:"
2810
+ msgstr "Seleccione uma imagem para fazer upload:"
2811
+
2812
+ #: wpsc-admin/includes/display-items-functions.php:999
2813
+ msgid "You are using the Browser uploader. Problems? Try the <a class=\"wpsc_upload_switcher\" onclick='wpsc_upload_switcher(\"flash\")'>Flash uploader</a> instead."
2814
+ msgstr "Está a utilizar o carregamento de ficheiro pelo Browser. Problemas? Em alternativa experimente o <a class=\"wpsc_upload_switcher\" onclick='wpsc_upload_switcher(\"flash\")'>carregamento por Flash</a>."
2815
+
2816
+ #: wpsc-admin/includes/display-items-functions.php:1003
2817
+ msgid "Manage your thumbnails"
2818
+ msgstr "Gerir os seus thumbnails"
2819
+
2820
+ #: wpsc-admin/includes/display-items-functions.php:1025
2821
+ msgid "Product Download"
2822
+ msgstr "Download de produtos"
2823
+
2824
+ #: wpsc-admin/includes/display-items-functions.php:1028
2825
+ msgid "Upload File"
2826
+ msgstr "Upload de ficheiro"
2827
+
2828
+ #: wpsc-admin/includes/display-items-functions.php:1029
2829
+ msgid "Max Upload Size"
2830
+ msgstr "Tamanho máximo de upload"
2831
+
2832
+ #: wpsc-admin/includes/display-items-functions.php:1033
2833
+ msgid "Preview File"
2834
+ msgstr "Pré-visualizar o ficheiro"
2835
+
2836
+ #: wpsc-admin/includes/display-items-functions.php:1043
2837
+ msgid "Select an MP3 file to upload as a preview"
2838
+ msgstr "Seleccione um ficheiro MP# para fazer upload como pré-visualização"
2839
+
2840
+ #: wpsc-admin/includes/display-items-functions.php:1064
2841
+ msgid "Label Control"
2842
+ msgstr "Controlo de rótulo"
2843
+
2844
+ #: wpsc-admin/includes/display-items-functions.php:1070
2845
+ #: wpsc-admin/includes/display-items-functions.php:1071
2846
+ msgid "Add Label"
2847
+ msgstr "Adicionar rótulo"
2848
+
2849
+ #: wpsc-admin/includes/display-items-functions.php:1128
2850
+ #: wpsc-admin/includes/display-items-functions.php:1155
2851
+ msgid "Preview"
2852
+ msgstr "Pré-visualizar"
2853
+
2854
+ #: wpsc-admin/includes/display-items-functions.php:1199
2855
+ #: wpsc-admin/includes/settings-pages/presentation.php:856
2856
+ msgid "Thumbnail Settings"
2857
+ msgstr "Definições de thumbnails"
2858
+
2859
+ #: wpsc-admin/includes/display-items-functions.php:1207
2860
+ msgid "use default size"
2861
+ msgstr "utilizar tamanho padrão"
2862
+
2863
+ #: wpsc-admin/includes/display-items-functions.php:1207
2864
+ msgid "This is set on the Settings Page"
2865
+ msgstr "Isto é definido na página de Definições"
2866
+
2867
+ #: wpsc-admin/includes/display-items-functions.php:1213
2868
+ msgid "do not resize thumbnail image"
2869
+ msgstr "não derimensionar a thumbnail de imagem"
2870
+
2871
+ #: wpsc-admin/includes/display-items-functions.php:1217
2872
+ msgid "use specific size"
2873
+ msgstr "utilizar tamanho específico"
2874
+
2875
+ #: wpsc-admin/includes/display-items-functions.php:1219
2876
+ msgid "px width"
2877
+ msgstr "px de largura"
2878
+
2879
+ #: wpsc-admin/includes/display-items-functions.php:1220
2880
+ msgid "px height"
2881
+ msgstr "px de altura"
2882
+
2883
+ #: wpsc-admin/includes/display-items-functions.php:1225
2884
+ msgid "use separate thumbnail"
2885
+ msgstr "utilize thumbnails separados"
2886
+
2887
+ #: wpsc-admin/includes/display-items-functions.php:1333
2888
+ #: wpsc-admin/includes/display-items-functions.php:1338
2889
+ msgid "HTML"
2890
+ msgstr "HTML"
2891
+
2892
+ #: wpsc-admin/includes/display-items-functions.php:1334
2893
+ #: wpsc-admin/includes/display-items-functions.php:1339
2894
+ msgid "Visual"
2895
+ msgstr ""
2896
+
2897
+ #: wpsc-admin/includes/product-functions.php:41
2898
+ #, php-format
2899
+ msgid "Please refrain from uploading images larger than <strong>%d x %d</strong> pixels"
2900
+ msgstr "Por favor não faça upload de imagens maiores que <strong>%d x %d</strong> pixels"
2901
+
2902
+ #: wpsc-admin/includes/product-functions.php:52
2903
+ #: wpsc-includes/category.functions.php:220
2904
+ msgid "N/A"
2905
+ msgstr "N/D"
2906
+
2907
+ #: wpsc-admin/includes/product-functions.php:77
2908
+ msgid "<strong>ERROR</strong>: Please enter a Product name.<br />"
2909
+ msgstr "<strong>ERRO</strong>: Por favor introduza um nome de produto.<br />"
2910
+
2911
+ #: wpsc-admin/includes/product-functions.php:80
2912
+ msgid "<strong>ERROR</strong>: Please enter a Product Category.<br />"
2913
+ msgstr "<strong>ERRO</strong>: Por favor insira uma categoria de produto.<br />"
2914
+
2915
+ #: wpsc-admin/includes/product-functions.php:192
2916
+ msgid "Could not update product in the database"
2917
+ msgstr "Não foi possível actualizar o produto na base de dados"
2918
+
2919
+ #: wpsc-admin/includes/product-functions.php:200
2920
+ msgid "Could not insert product into the database"
2921
+ msgstr "Não foi possível inserir o produto na base de dados"
2922
+
2923
+ #: wpsc-admin/includes/purchlogs_upgrade.php:67
2924
+ msgid "Check Out Form Fields updated."
2925
+ msgid_plural "Check Out Form Fields updated."
2926
+ msgstr[0] "O campo de formulário de checkout actualizado."
2927
+ msgstr[1] "Os campos de formulário de checkout foram actualizados."
2928
+
2929
+ #: wpsc-admin/includes/purchlogs_upgrade.php:74
2930
+ msgid "Upgrading to WP e-Commerce 3.7 and later requires you to run this fix once.The following Boxes corresponds to the form fields in your current checkout page. All you have to do is select from the drop-down menu box what each of the following fields represent. Sorry for any inconvenience caused, but we're sure you'll agree that the new purchase logs are worth this minor hassle. "
2931
+ msgstr "Actualizar para o WP e-Commerce 3.7 e posterior requer que isto seja executado uma vez. As seguintes caixas correspondem aos campos de formulário na sua página de checkout actual. Tudo que você precisa fazer é seleccionar na caixa de menu drop-down o que cada um dos seguintes campos representam. Pedimos desculpa pelo incómodo causado mas temos a certeza que concorda que os novos registos de compra justificam este incómodo menor."
2932
+
2933
+ #: wpsc-admin/includes/settings-pages/admin.php:7
2934
+ msgid "Admin Settings"
2935
+ msgstr "Definições de administrador"
2936
+
2937
+ #: wpsc-admin/includes/settings-pages/admin.php:13
2938
+ msgid "Max downloads per file"
2939
+ msgstr "Número de downloads por ficheiro"
2940
+
2941
+ #: wpsc-admin/includes/settings-pages/admin.php:35
2942
+ msgid "Lock downloads to IP address"
2943
+ msgstr "Bloquear downloads para o endereço IP"
2944
+
2945
+ #: wpsc-admin/includes/settings-pages/admin.php:61
2946
+ msgid "Check MIME types on file uploads"
2947
+ msgstr "Verificar MIME types ao fazer upload de ficheiros"
2948
+
2949
+ #: wpsc-admin/includes/settings-pages/admin.php:68
2950
+ msgid "Warning: Disabling this exposes your site to greater possibility of malicious files being uploaded, we reccomend installing the Fileinfo extention for PHP rather than disabling this."
2951
+ msgstr "ATENÇÃO: Desactivar esta opção expõe o seu site a uma maior possibilidade de upload de arquivos maliciosos. Recomendamos a instalação da extensão Fileinfo para PHP ao invés de desactivar esta opção."
2952
+
2953
+ #: wpsc-admin/includes/settings-pages/admin.php:76
2954
+ msgid "Purchase Log Email"
2955
+ msgstr "Email de relatório de compra"
2956
+
2957
+ #: wpsc-admin/includes/settings-pages/admin.php:80
2958
+ msgid "i.e. this is the address where your purchase reports are sent."
2959
+ msgstr "i.e. este é o endereço de email para onde são enviados os relatórios de compras."
2960
+
2961
+ #: wpsc-admin/includes/settings-pages/admin.php:86
2962
+ msgid "Purchase Receipt - Reply Address"
2963
+ msgstr "Recibo de compra - Endereço de resposta"
2964
+
2965
+ #: wpsc-admin/includes/settings-pages/admin.php:90
2966
+ msgid "i.e. this is the reply address contained in the purchase receipt sent to the buyer."
2967
+ msgstr "i.e. este é o endereço de email de resposta incluído no recibo de compra, enviado para o cliente."
2968
+
2969
+ #: wpsc-admin/includes/settings-pages/admin.php:96
2970
+ msgid "Purchase Receipt - Reply Name"
2971
+ msgstr "Recibo de compra - Nome de resposta"
2972
+
2973
+ #: wpsc-admin/includes/settings-pages/admin.php:100
2974
+ msgid "i.e. this is the \"from name\" buyers will see in their purchase receipt. "
2975
+ msgstr "i.e. este será o nome \"Enviado por\" que os clientes verão no seu recibo de compra."
2976
+
2977
+ #: wpsc-admin/includes/settings-pages/admin.php:115
2978
+ msgid "Custom Messages"
2979
+ msgstr "Mensagens personalizadas"
2980
+
2981
+ #: wpsc-admin/includes/settings-pages/admin.php:118
2982
+ msgid "Tags can be used"
2983
+ msgstr "Podem ser utilizadas tags "
2984
+
2985
+ #: wpsc-admin/includes/settings-pages/admin.php:139
2986
+ msgid "Admin Report"
2987
+ msgstr "Relatório de administrador"
2988
+
2989
+ #: wpsc-admin/includes/settings-pages/admin.php:144
2990
+ msgid "Track and Trace settings"
2991
+ msgstr "Definições de Rastreamento e Localização"
2992
+
2993
+ #: wpsc-admin/includes/settings-pages/admin.php:154
2994
+ msgid "Tracking Email Subject"
2995
+ msgstr "Assunto do email de rastreamento"
2996
+
2997
+ #: wpsc-admin/includes/settings-pages/admin.php:158
2998
+ msgid "Tracking Email Message"
2999
+ msgstr "Mensagem do email de rastreamento"
3000
+
3001
+ #: wpsc-admin/includes/settings-pages/admin.php:162
3002
+ msgid "URL Settings"
3003
+ msgstr "Definições de URL"
3004
+
3005
+ #: wpsc-admin/includes/settings-pages/admin.php:167
3006
+ #: wpsc-includes/install_and_update.functions.php:95
3007
+ msgid "The location of the product list"
3008
+ msgstr "A localização da lista de produtos"
3009
+
3010
+ #: wpsc-admin/includes/settings-pages/admin.php:175
3011
+ #: wpsc-includes/install_and_update.functions.php:96
3012
+ msgid "The location of the shopping cart"
3013
+ msgstr "A localização do carrinho de compras"
3014
+
3015
+ #: wpsc-admin/includes/settings-pages/admin.php:193
3016
+ msgid "Transaction Details URL"
3017
+ msgstr "URL de Detalhes da Transacção"
3018
+
3019
+ #: wpsc-admin/includes/settings-pages/admin.php:204
3020
+ msgid "User Account URL"
3021
+ msgstr "URL da Conta de Utilizador"
3022
+
3023
+ #: wpsc-admin/includes/settings-pages/admin.php:215
3024
+ msgid "Update Page URLs"
3025
+ msgstr "Actualizar URL de página"
3026
+
3027
+ #: wpsc-admin/includes/settings-pages/admin.php:216
3028
+ msgid "Fix Product Group Permalinks"
3029
+ msgstr "Corrigir permalinks do grupo de produtos"
3030
+
3031
+ #: wpsc-admin/includes/settings-pages/checkout.php:42
3032
+ msgid "Checkout Options"
3033
+ msgstr "Opções de checkout"
3034
+
3035
+ #: wpsc-admin/includes/settings-pages/checkout.php:55
3036
+ msgid "Users must register before checking out"
3037
+ msgstr "Os utilizadores deverão registar-se antes de efectuar o checkout"
3038
+
3039
+ #: wpsc-admin/includes/settings-pages/checkout.php:75
3040
+ msgid "If yes then you must also turn on the wordpress option \"Any one can register\""
3041
+ msgstr "Se sim, deverá igualmente activar a opção do Wordpress \"Qualquer pessoa se pode registar\""
3042
+
3043
+ #: wpsc-admin/includes/settings-pages/checkout.php:92
3044
+ msgid "Lock Tax to Billing Country"
3045
+ msgstr "Associar imposto ao país de facturação"
3046
+
3047
+ #: wpsc-admin/includes/settings-pages/checkout.php:115
3048
+ msgid " Disregard Billing State for Tax Calculations"
3049
+ msgstr "Não considerar o estado de facturação para cálculo do imposto"
3050
+
3051
+ #: wpsc-admin/includes/settings-pages/checkout.php:140
3052
+ msgid "Enable Shipping Same as Billing Option: "
3053
+ msgstr "Activar a opção de dados de envio iguais aos dados pessoais"
3054
+
3055
+ #: wpsc-admin/includes/settings-pages/checkout.php:153
3056
+ msgid "Here you can customise the forms to be displayed in your checkout page. The checkout page is where you collect important user information that will show up in your purchase logs i.e. the buyers address, and name..."
3057
+ msgstr "Aqui poderá personalizar os formulários que serão mostrados na página de checkout. É na página de checkout que poderá recolher informações importantes dos seus clientes, que serão apresentadas nos relatórios de compras, como o nome do cliente, a morada, etc..."
3058
+
3059
+ #: wpsc-admin/includes/settings-pages/checkout.php:170
3060
+ msgid "+ Add New Form Set"
3061
+ msgstr "+ Adicione um novo conjunto de formulário"
3062
+
3063
+ #: wpsc-admin/includes/settings-pages/checkout.php:174
3064
+ msgid "Add new Form Set"
3065
+ msgstr "Adicione um novo conjunto de formulário"
3066
+
3067
+ #: wpsc-admin/includes/settings-pages/checkout.php:251
3068
+ msgid "This will be the Email address that the Purchase Reciept is sent to."
3069
+ msgstr "Este é o endereço de email para onde será enviado o Recibo da Encomenda."
3070
+
3071
+ #: wpsc-admin/includes/settings-pages/checkout.php:269
3072
+ msgid "Add New Form Field"
3073
+ msgstr "Adicione um novo campo de formulário"
3074
+
3075
+ #: wpsc-admin/includes/settings-pages/gateway.php:31
3076
+ msgid "Please Select A Payment Gateway"
3077
+ msgstr "Por favor seleccione um Gateway de Pagamento"
3078
+
3079
+ #: wpsc-admin/includes/settings-pages/gateway.php:55
3080
+ msgid "Gateway Options"
3081
+ msgstr "Opções de Gateway"
3082
+
3083
+ #: wpsc-admin/includes/settings-pages/gateway.php:64
3084
+ #: wpsc-admin/includes/settings-pages/general.php:7
3085
+ #: wpsc-admin/includes/settings-pages/shipping.php:52
3086
+ #: wpsc-admin/includes/settings-pages/shipping.php:58
3087
+ msgid "General Settings"
3088
+ msgstr "Definições gerais"
3089
+
3090
+ #: wpsc-admin/includes/settings-pages/gateway.php:68
3091
+ msgid "Payment Gateways"
3092
+ msgstr "Gateways de pagamento"
3093
+
3094
+ #: wpsc-admin/includes/settings-pages/gateway.php:72
3095
+ msgid "Activate the payment gateways that you want to make available to your customers by selecting them below."
3096
+ msgstr "Active os gateways de pagamento que pretende disponibilizar aos seus clientes, selecionando-os de seguida:"
3097
+
3098
+ #: wpsc-admin/includes/settings-pages/gateway.php:98
3099
+ msgid "We Recommend"
3100
+ msgstr "Recomendamos"
3101
+
3102
+ #: wpsc-admin/includes/settings-pages/gateway.php:107
3103
+ #: wpsc-admin/includes/settings-pages/gateway.php:114
3104
+ msgid " Select a Payment Gateway below to configure it."
3105
+ msgstr " Seleccione um Gateway de Pagamento para o configurar."
3106
+
3107
+ #: wpsc-admin/includes/settings-pages/gateway.php:122
3108
+ msgid "Payment Gateway"
3109
+ msgstr "Gateway de pagamento"
3110
+
3111
+ #: wpsc-admin/includes/settings-pages/gateway.php:134
3112
+ msgid "Display Name"
3113
+ msgstr "Nome a mostrar"
3114
+
3115
+ #: wpsc-admin/includes/settings-pages/gateway.php:162
3116
+ msgid "The text that people see when making a purchase"
3117
+ msgstr "O texto que os clientes vêem quando efectuam uma compra"
3118
+
3119
+ #: wpsc-admin/includes/settings-pages/general.php:13
3120
+ msgid "Base Country/Region"
3121
+ msgstr "País base"
3122
+
3123
+ #: wpsc-admin/includes/settings-pages/general.php:39
3124
+ msgid "Select your primary business location."
3125
+ msgstr "Seleccione a localização principal do seu negócio."
3126
+
3127
+ #: wpsc-admin/includes/settings-pages/general.php:43
3128
+ msgid "Tax Settings"
3129
+ msgstr "Definições de impostos"
3130
+
3131
+ #: wpsc-admin/includes/settings-pages/general.php:60
3132
+ msgid "Tax Included in prices"
3133
+ msgstr "Imposto incluído nos preços"
3134
+
3135
+ #: wpsc-admin/includes/settings-pages/general.php:116
3136
+ msgid "Currency Settings"
3137
+ msgstr "Definições de moedas"
3138
+
3139
+ #: wpsc-admin/includes/settings-pages/general.php:143
3140
+ #: wpsc-includes/install_and_update.functions.php:115
3141
+ msgid "Currency sign location"
3142
+ msgstr "Localização do símbolo da moeda"
3143
+
3144
+ #: wpsc-admin/includes/settings-pages/general.php:194
3145
+ msgid "Hide Decimals on Products Pages"
3146
+ msgstr "Ocultar casas decimais nas páginas de produtos"
3147
+
3148
+ #: wpsc-admin/includes/settings-pages/import.php:7
3149
+ msgid "Import Products CSV"
3150
+ msgstr "Importar produtos de ficheiro CSV"
3151
+
3152
+ #: wpsc-admin/includes/settings-pages/import.php:8
3153
+ msgid "<p>You can import your products from a comma delimited text file.</p><p>An example of a cvs import file would look like this: </p><p>Description, Additional Description, Product Name, Price, SKU, weight, weight unit, stock quantity, is limited quantity</p>"
3154
+ msgstr "<p>Poderá importar os seus produtos de um ficheiro de texto CSV.</p><p>Um exemplo de um ficheiro CSV de importação terá o seguinte aspecto: </p><p>Descrição, Descrição adicional, Nome do produto, Preço, SKU, peso, unidade de peso, stock, limite de quantidade</p>"
3155
+
3156
+ #: wpsc-admin/includes/settings-pages/presentation.php:14
3157
+ msgid "Show All Products"
3158
+ msgstr "Mostrar todos os produtos"
3159
+
3160
+ #: wpsc-admin/includes/settings-pages/presentation.php:21
3161
+ msgid "Show Category List"
3162
+ msgstr "Mostrar lista de categorias"
3163
+
3164
+ #: wpsc-admin/includes/settings-pages/presentation.php:28
3165
+ msgid "Show All Products + Category List"
3166
+ msgstr "Mostrar todos os produtos + Lista de categorias"
3167
+
3168
+ #: wpsc-admin/includes/settings-pages/presentation.php:63
3169
+ msgid "Button Settings"
3170
+ msgstr "Definições de botão"
3171
+
3172
+ #: wpsc-admin/includes/settings-pages/presentation.php:67
3173
+ msgid "Button Type"
3174
+ msgstr "Tipo de botão"
3175
+
3176
+ #: wpsc-admin/includes/settings-pages/presentation.php:92
3177
+ msgid "Hide \"Add to cart\" button"
3178
+ msgstr "Ocultar o botão \"Adicionar ao carrinho\""
3179
+
3180
+ #: wpsc-admin/includes/settings-pages/presentation.php:117
3181
+ msgid "Product Settings"
3182
+ msgstr "Definições de produto"
3183
+
3184
+ #: wpsc-admin/includes/settings-pages/presentation.php:122
3185
+ #: wpsc-includes/install_and_update.functions.php:162
3186
+ msgid "Show Product Ratings"
3187
+ msgstr "Mostrar avaliações de produtos"
3188
+
3189
+ #: wpsc-admin/includes/settings-pages/presentation.php:146
3190
+ msgid "Display Fancy Purchase Notifications"
3191
+ msgstr "Mostrar notificações de compra imaginativas"
3192
+
3193
+ #: wpsc-admin/includes/settings-pages/presentation.php:170
3194
+ msgid "Show Postage and Packaging"
3195
+ msgstr "Mostrar Portes e Embalagem"
3196
+
3197
+ #: wpsc-admin/includes/settings-pages/presentation.php:193
3198
+ msgid "Disable link in Title"
3199
+ msgstr "Desabilitar o link no título"
3200
+
3201
+ #: wpsc-admin/includes/settings-pages/presentation.php:217
3202
+ msgid "Add quantity field to each product description"
3203
+ msgstr "Adicionar campo de quantidade à descrição de cada produto "
3204
+
3205
+ #: wpsc-admin/includes/settings-pages/presentation.php:242
3206
+ msgid "Theme Customisation"
3207
+ msgstr "Personalização de temas"
3208
+
3209
+ #: wpsc-admin/includes/settings-pages/presentation.php:247
3210
+ msgid "Thanks, the themes have been copied."
3211
+ msgstr "Obrigado, os temas foram copiados."
3212
+
3213
+ #: wpsc-admin/includes/settings-pages/presentation.php:256
3214
+ msgid "Theming your stores appearance is easy."
3215
+ msgstr "Personalizar o tema da sua loja é fácil."
3216
+
3217
+ #: wpsc-admin/includes/settings-pages/presentation.php:258
3218
+ msgid "You just need to edit the appropriate files in the following location."
3219
+ msgstr "Apenas precisa editar os ficheiros apropriados na seguinte localização."
3220
+
3221
+ #: wpsc-admin/includes/settings-pages/presentation.php:259
3222
+ #: wpsc-admin/includes/settings-pages/presentation.php:271
3223
+ msgid "Path:"
3224
+ msgstr "Caminho:"
3225
+
3226
+ #: wpsc-admin/includes/settings-pages/presentation.php:261
3227
+ msgid "To create a new theme:"
3228
+ msgstr "Para criar um novo tema:"
3229
+
3230
+ #: wpsc-admin/includes/settings-pages/presentation.php:263
3231
+ msgid "Copy the default directory and rename it 'newTheme'"
3232
+ msgstr "Copie a pasta default e renomeie-a para 'novoTema'"
3233
+
3234
+ #: wpsc-admin/includes/settings-pages/presentation.php:264
3235
+ msgid "Rename the default.css file inside the 'newTheme' directory to 'newTheme.css'"
3236
+ msgstr "Renomeie o ficheiro default.css dentro da pasta 'novoTema' para 'novoTema.css'"
3237
+
3238
+ #: wpsc-admin/includes/settings-pages/presentation.php:269
3239
+ msgid "The permissions on your themes directory are incorrect."
3240
+ msgstr "As permissões da sua pasta de temas no seu servidor estão incorrectas."
3241
+
3242
+ #: wpsc-admin/includes/settings-pages/presentation.php:270
3243
+ msgid "Please set the permissions to 775 on the following directory."
3244
+ msgstr "Por favor defina as permissões para 755 na seguinte pasta."
3245
+
3246
+ #: wpsc-admin/includes/settings-pages/presentation.php:275
3247
+ msgid "Your theme files have not been moved. Until your theme files have been moved, we have disabled automatic upgrades."
3248
+ msgstr "Os ficheiros do seu tema não foram movidos. Os upgrades automáticos estão desactivados até que os ficheiros do seu tema sejam movidos."
3249
+
3250
+ #: wpsc-admin/includes/settings-pages/presentation.php:276
3251
+ #, php-format
3252
+ msgid "Click here to <a href='%s'>Move your files</a> to a safe place"
3253
+ msgstr "Clique aqui para <a href='%s'>mover os seus ficheiros</a> para um local seguro"
3254
+
3255
+ #: wpsc-admin/includes/settings-pages/presentation.php:280
3256
+ msgid "Read Tutorials"
3257
+ msgstr "Ler tutoriais"
3258
+
3259
+ #: wpsc-admin/includes/settings-pages/presentation.php:285
3260
+ msgid "Product Page Settings"
3261
+ msgstr "Definições da página de produto"
3262
+
3263
+ #: wpsc-admin/includes/settings-pages/presentation.php:372
3264
+ msgid "Purchase unavailable options"
3265
+ msgstr "Opções de compra indisponíveis"
3266
+
3267
+ #: wpsc-admin/includes/settings-pages/presentation.php:377
3268
+ msgid "Show quantity form in list view"
3269
+ msgstr "Mostrar quantidade na visualização de lista"
3270
+
3271
+ #: wpsc-admin/includes/settings-pages/presentation.php:382
3272
+ msgid "Products Per Row"
3273
+ msgstr "Produtos por linha"
3274
+
3275
+ #: wpsc-admin/includes/settings-pages/presentation.php:387
3276
+ msgid "Show images only"
3277
+ msgstr "Mostrar apenas imagens"
3278
+
3279
+ #: wpsc-admin/includes/settings-pages/presentation.php:397
3280
+ msgid "Display Description"
3281
+ msgstr "Mostrar descrição"
3282
+
3283
+ #: wpsc-admin/includes/settings-pages/presentation.php:402
3284
+ msgid "Display \"Add To Cart\" Button"
3285
+ msgstr "Mostrar o botão \"Adicione ao carrinho\" "
3286
+
3287
+ #: wpsc-admin/includes/settings-pages/presentation.php:406
3288
+ msgid "Display \"More Details\" Button"
3289
+ msgstr "Mostrar o botão \"Mais detalhes\""
3290
+
3291
+ #: wpsc-admin/includes/settings-pages/presentation.php:416
3292
+ msgid "Theme"
3293
+ msgstr "Tema"
3294
+
3295
+ #: wpsc-admin/includes/settings-pages/presentation.php:425
3296
+ msgid "Product page displays"
3297
+ msgstr "Apresentação da página de produtos"
3298
+
3299
+ #: wpsc-admin/includes/settings-pages/presentation.php:453
3300
+ #, fuzzy
3301
+ msgid "Sort Products By"
3302
+ msgstr "Ordenar produtos por"
3303
+
3304
+ #: wpsc-admin/includes/settings-pages/presentation.php:459
3305
+ msgid "Drag &amp; Drop"
3306
+ msgstr "Arrastar &amp; Largar"
3307
+
3308
+ #: wpsc-admin/includes/settings-pages/presentation.php:460
3309
+ msgid "Time Uploaded"
3310
+ msgstr "Data de Upload"
3311
+
3312
+ #: wpsc-admin/includes/settings-pages/presentation.php:462
3313
+ msgid "If you have used the drag-drop interface on the edit-products page to order your products then you must use the Drag &amp; Drop option."
3314
+ msgstr "Se utilizou a interface arrastar-largar na página de edição de produtos para encomendar os seus produtos, então deverá utilizar a opção Arrastar &amp; Largar. "
3315
+
3316
+ #: wpsc-admin/includes/settings-pages/presentation.php:466
3317
+ msgid "Show Breadcrumbs"
3318
+ msgstr "Mostrar Breadcrumbs"
3319
+
3320
+ #: wpsc-admin/includes/settings-pages/presentation.php:492
3321
+ msgid "Product Groups/Products Display"
3322
+ msgstr "Grupos de produtos/Apresentação de produtos"
3323
+
3324
+ #: wpsc-admin/includes/settings-pages/presentation.php:510
3325
+ msgid "Product Groups Only (All products displayed)"
3326
+ msgstr "Apenas grupos de produtos (todos os produtos apresentados)"
3327
+
3328
+ #: wpsc-admin/includes/settings-pages/presentation.php:511
3329
+ msgid "Sliding Product Groups (1 product per page)"
3330
+ msgstr "Grupos de produtos corridos (um produto por página)"
3331
+
3332
+ #: wpsc-admin/includes/settings-pages/presentation.php:518
3333
+ msgid "Show Subcategory Products in Parent Category"
3334
+ msgstr "Mostrar produtos das subcategorias na categoria principal"
3335
+
3336
+ #: wpsc-admin/includes/settings-pages/presentation.php:544
3337
+ msgid "Show Search"
3338
+ msgstr "Mostrar pesquisa"
3339
+
3340
+ #: wpsc-admin/includes/settings-pages/presentation.php:581
3341
+ msgid "Show Advanced Search"
3342
+ msgstr "Mostrar pesquisa avançada"
3343
+
3344
+ #: wpsc-admin/includes/settings-pages/presentation.php:584
3345
+ msgid "Use Live Search"
3346
+ msgstr "Utilizar Live Search"
3347
+
3348
+ #: wpsc-admin/includes/settings-pages/presentation.php:595
3349
+ msgid "Replace Page Title With Product/Category Name"
3350
+ msgstr "Subtituir o título da página pelo nome da categoria ou produto"
3351
+
3352
+ #: wpsc-admin/includes/settings-pages/presentation.php:617
3353
+ msgid "Shopping Cart Settings"
3354
+ msgstr "Definições do carrinho de compras"
3355
+
3356
+ #: wpsc-admin/includes/settings-pages/presentation.php:620
3357
+ #: wpsc-includes/install_and_update.functions.php:101
3358
+ #: wpsc-includes/install_and_update.functions.php:103
3359
+ #: wpsc-includes/install_and_update.functions.php:107
3360
+ #: wpsc-includes/install_and_update.functions.php:109
3361
+ msgid "Cart Location"
3362
+ msgstr "Localização do carrinho"
3363
+
3364
+ #: wpsc-admin/includes/settings-pages/presentation.php:649
3365
+ #: wpsc-admin/includes/settings-pages/presentation.php:653
3366
+ msgid "Sidebar"
3367
+ msgstr "Barra lateral"
3368
+
3369
+ #: wpsc-admin/includes/settings-pages/presentation.php:657
3370
+ msgid "Page"
3371
+ msgstr "Página"
3372
+
3373
+ #: wpsc-admin/includes/settings-pages/presentation.php:661
3374
+ #: wpsc-admin/includes/settings-pages/presentation.php:665
3375
+ msgid "Widget"
3376
+ msgstr "Widget"
3377
+
3378
+ #: wpsc-admin/includes/settings-pages/presentation.php:665
3379
+ #: wpsc-admin/includes/settings-pages/presentation.php:675
3380
+ msgid "You need to enable the widgets plugin to use this"
3381
+ msgstr "É necessário activar o plugin de widgets para utilizar isto"
3382
+
3383
+ #: wpsc-admin/includes/settings-pages/presentation.php:675
3384
+ msgid "You need to install the Gold and DropShop extentions to use this"
3385
+ msgstr "Precisa instalar a extensão Gold and DropShop para utilizar isto"
3386
+
3387
+ #: wpsc-admin/includes/settings-pages/presentation.php:679
3388
+ msgid "Manual"
3389
+ msgstr "Manual"
3390
+
3391
+ #: wpsc-admin/includes/settings-pages/presentation.php:682
3392
+ msgid "Show Dropshop on every page"
3393
+ msgstr "Mostrar DropShop em todas as páginas"
3394
+
3395
+ #: wpsc-admin/includes/settings-pages/presentation.php:683
3396
+ msgid "Show Dropshop only on product page"
3397
+ msgstr "Mostrar DropShop apenas na página de produto"
3398
+
3399
+ #: wpsc-admin/includes/settings-pages/presentation.php:686
3400
+ msgid "Use light Dropshop style"
3401
+ msgstr "Utilizar Dropshop estilo claro"
3402
+
3403
+ #: wpsc-admin/includes/settings-pages/presentation.php:687
3404
+ msgid "Use dark Dropshop style"
3405
+ msgstr "Utilizar Dropshop estilo escuro"
3406
+
3407
+ #: wpsc-admin/includes/settings-pages/presentation.php:688
3408
+ msgid "Crafty"
3409
+ msgstr "Crafty"
3410
+
3411
+ #: wpsc-admin/includes/settings-pages/presentation.php:698
3412
+ msgid "Use Sliding Cart"
3413
+ msgstr "Utilizar Carrinho de Compras em carrocel"
3414
+
3415
+ #: wpsc-admin/includes/settings-pages/presentation.php:723
3416
+ msgid "Display \"+ Postage & Tax\""
3417
+ msgstr "Mostrar \"+ Portes e Taxas\""
3418
+
3419
+ #: wpsc-admin/includes/settings-pages/presentation.php:749
3420
+ msgid "Product Group Settings"
3421
+ msgstr "Definições de grupo de produtos"
3422
+
3423
+ #: wpsc-admin/includes/settings-pages/presentation.php:753
3424
+ msgid "Show Product Group Description"
3425
+ msgstr "Mostrar descrição de grupo de produtos"
3426
+
3427
+ #: wpsc-admin/includes/settings-pages/presentation.php:778
3428
+ msgid "Show Product Group Thumbnails"
3429
+ msgstr "Mostrar thumbnails de grupo de produtos"
3430
+
3431
+ #: wpsc-admin/includes/settings-pages/presentation.php:805
3432
+ msgid "Show Product Count per Product Group"
3433
+ msgstr "Mostrar contagem de produtos por grupo de produtos"
3434
+
3435
+ #: wpsc-admin/includes/settings-pages/presentation.php:831
3436
+ msgid "Use Category Grid View"
3437
+ msgstr "Utilizar visualização de categorias em grelha"
3438
+
3439
+ #: wpsc-admin/includes/settings-pages/presentation.php:862
3440
+ msgid "Default Product Thumbnail Size"
3441
+ msgstr "Tamanho por defeito da thumbnail de produto"
3442
+
3443
+ #: wpsc-admin/includes/settings-pages/presentation.php:866
3444
+ msgid "Resize Existing Thumbnails"
3445
+ msgstr "Redimensionar thumbnails existentes"
3446
+
3447
+ #: wpsc-admin/includes/settings-pages/presentation.php:872
3448
+ msgid "Default Product Group Thumbnail Size"
3449
+ msgstr "Tamanho por defeito da thumbnail de grupo de produtos"
3450
+
3451
+ #: wpsc-admin/includes/settings-pages/presentation.php:881
3452
+ msgid "Single Product Image Size"
3453
+ msgstr "Tamanho da imagem individual do produto"
3454
+
3455
+ #: wpsc-admin/includes/settings-pages/presentation.php:892
3456
+ #: wpsc-includes/install_and_update.functions.php:87
3457
+ msgid "Show Thumbnails"
3458
+ msgstr "Mostrar thumbnails"
3459
+
3460
+ #: wpsc-admin/includes/settings-pages/presentation.php:918
3461
+ msgid "Show Thumbnail Gallery"
3462
+ msgstr "Mostrar galeria de thumbnails"
3463
+
3464
+ #: wpsc-admin/includes/settings-pages/presentation.php:942
3465
+ msgid "Gallery Thumbnail Image Size"
3466
+ msgstr "Tamanho da imagem de thumbnail da galeria"
3467
+
3468
+ #: wpsc-admin/includes/settings-pages/presentation.php:956
3469
+ msgid "Pagination settings"
3470
+ msgstr "Definições de paginação"
3471
+
3472
+ #: wpsc-admin/includes/settings-pages/presentation.php:960
3473
+ msgid "Use Pagination"
3474
+ msgstr "Utilizar paginação"
3475
+
3476
+ #: wpsc-admin/includes/settings-pages/presentation.php:982
3477
+ msgid "number of products to show per page"
3478
+ msgstr "número de produtos a mostrar por página"
3479
+
3480
+ #: wpsc-admin/includes/settings-pages/presentation.php:992
3481
+ msgid "Top"
3482
+ msgstr "Topo"
3483
+
3484
+ #: wpsc-admin/includes/settings-pages/presentation.php:993
3485
+ msgid "Bottom"
3486
+ msgstr "Rodapé"
3487
+
3488
+ #: wpsc-admin/includes/settings-pages/presentation.php:994
3489
+ msgid "Both"
3490
+ msgstr "Ambos"
3491
+
3492
+ #: wpsc-admin/includes/settings-pages/presentation.php:1001
3493
+ msgid "Comment Settings"
3494
+ msgstr "Definições de comentários"
3495
+
3496
+ #: wpsc-admin/includes/settings-pages/presentation.php:1005
3497
+ msgid "Use IntenseDebate Comments"
3498
+ msgstr "Utilizar IntenseDebate Comments"
3499
+
3500
+ #: wpsc-admin/includes/settings-pages/presentation.php:1029
3501
+ msgid "IntenseDebate Account ID"
3502
+ msgstr "ID de conta (Account ID) IntenseDebate"
3503
+
3504
+ #: wpsc-admin/includes/settings-pages/presentation.php:1031
3505
+ msgid "Help on finding the Account ID"
3506
+ msgstr "Ajuda para encontrar o sei ID de conta (Account ID)"
3507
+
3508
+ #: wpsc-admin/includes/settings-pages/presentation.php:1040
3509
+ msgid "By Default Display Comments on"
3510
+ msgstr "Por defeito, mostrar comentários em"
3511
+
3512
+ #: wpsc-admin/includes/settings-pages/shipping.php:67
3513
+ msgid "Use Shipping"
3514
+ msgstr "Utilizar expedição"
3515
+
3516
+ #: wpsc-admin/includes/settings-pages/shipping.php:89
3517
+ msgid "If you are only selling digital downloads, you should select no to disable the shipping on your site."
3518
+ msgstr "Se vende apenas produtos digitais para download, deverá seleccionar não para desactivar a opção de envio no seu site."
3519
+
3520
+ #: wpsc-admin/includes/settings-pages/shipping.php:94
3521
+ msgid "Base Zipcode/Postcode:"
3522
+ msgstr "Código postal base:"
3523
+
3524
+ #: wpsc-admin/includes/settings-pages/shipping.php:97
3525
+ msgid "If you are based in America then you need to set your own Zipcode for UPS and USPS to work. This should be the Zipcode for your Base of Operations."
3526
+ msgstr "Se estiver a operar a partir dos Estados Unidos da América, necessita configurar o seu próprio código postal para trabalhar com a UPS ou USPS. Este deverá ser o código postal da sua base operacional."
3527
+
3528
+ #: wpsc-admin/includes/settings-pages/shipping.php:119
3529
+ msgid "ShipWire Settings"
3530
+ msgstr "Definições ShipWire"
3531
+
3532
+ #: wpsc-admin/includes/settings-pages/shipping.php:130
3533
+ msgid "ShipWire Email"
3534
+ msgstr "Email ShipWire"
3535
+
3536
+ #: wpsc-admin/includes/settings-pages/shipping.php:131
3537
+ msgid "ShipWire Password"
3538
+ msgstr "Password ShipWire"
3539
+
3540
+ #: wpsc-admin/includes/settings-pages/shipping.php:139
3541
+ msgid "Enable Free Shipping Discount"
3542
+ msgstr "Activar desconto de envio gratuito:"
3543
+
3544
+ #: wpsc-admin/includes/settings-pages/shipping.php:184
3545
+ #: wpsc-admin/includes/settings-pages/shipping.php:189
3546
+ msgid "Shipping Modules"
3547
+ msgstr "Módulos de envio"
3548
+
3549
+ #: wpsc-admin/includes/settings-pages/shipping.php:195
3550
+ msgid "To enable shipping in WP e-Commerce you must select which shipping methods you want to enable on your site"
3551
+ msgstr "Para permitir expedição no WP e-Commerce deverá seleccionar os meios de expedição que pretende disponibilizar no seu website"
3552
+
3553
+ #: wpsc-admin/includes/settings-pages/shipping.php:196
3554
+ msgid "<br /><strong>UPS has been deactivated because you are running PHP4, please upgrade to PHP5 to enable UPS.</strong>"
3555
+ msgstr "<br /><strong>A UPS foi desactivada porque você está a correr o PHP4. Por favor faça o upgrade para PHP5 para permitir a UPS.</strong>"
3556
+
3557
+ #: wpsc-admin/includes/settings-pages/shipping.php:200
3558
+ msgid "Internal Shipping Calculators"
3559
+ msgstr "Calculadoras internas de fretes de expedição"
3560
+
3561
+ #: wpsc-admin/includes/settings-pages/shipping.php:233
3562
+ msgid "External Shipping Calculators"
3563
+ msgstr "Calculadoras externas de fretes de expedição"
3564
+
3565
+ #: wpsc-admin/includes/settings-pages/shipping.php:236
3566
+ msgid "The following shipping modules all need cURL which is not installed on this server, you may need to contact your web hosting provider to get it set up. "
3567
+ msgstr "Os seguintes módulos de expedição necessitam do cURL, que não está instalado neste servidor. Para o configurar, poderá ser necessário entrar em contacto com o seu fornecedor de alojamento web."
3568
+
3569
+ #: wpsc-includes/ajax.functions.php:104
3570
+ msgid "You just added \"[product_name]\" to your cart."
3571
+ msgstr "Adicionou o artigo \"[product_name]\" ao seu carrinho de compras."
3572
+
3573
+ #: wpsc-includes/ajax.functions.php:107
3574
+ msgid "Sorry, but you cannot add zero items to your cart"
3575
+ msgstr "Pedimos desculpa mas não pode adicionar zero artigos ao seu carrinho de compras"
3576
+
3577
+ #: wpsc-includes/ajax.functions.php:109
3578
+ msgid "Sorry, but there are only [number] of this item in stock."
3579
+ msgstr "Pedimos desculpa mas apenas temos [number] unidades deste artigo em stock."
3580
+
3581
+ #: wpsc-includes/ajax.functions.php:111
3582
+ msgid "Sorry, but the item \"[product_name]\" is out of stock."
3583
+ msgstr "Pedimos desculpa mas o artigo \"[product_name]\" encontra-se esgotado."
3584
+
3585
+ #: wpsc-includes/ajax.functions.php:593
3586
+ msgid "You must select a shipping method, otherwise we cannot process your order."
3587
+ msgstr "Tem que escolher um método de envio, caso contrário não podemos processar a sua encomenda."
3588
+
3589
+ #: wpsc-includes/ajax.functions.php:598
3590
+ msgid "Please agree to the terms and conditions, otherwise we cannot process your order."
3591
+ msgstr "Por favor aceite os Termos e Condições de Utilização, caso contrário não podemos processar a sua encomenda."
3592
+
3593
+ #: wpsc-includes/ajax.functions.php:618
3594
+ #, php-format
3595
+ msgid "Oops the product : %s cannot be shipped to %s. To continue with your transaction please remove this product from the list above."
3596
+ msgstr "Ups, o produto %s não pode ser enviado para %s. Para continuar com a sua transacção, por favor remova este produto da lista."
3597
+
3598
+ #: wpsc-includes/ajax.functions.php:641
3599
+ msgid "Please enter a Zipcode and click calculate to proceed"
3600
+ msgstr "Por favor insira um código postal e clique em Calcular para continuar"
3601
+
3602
+ #: wpsc-includes/ajax.functions.php:980
3603
+ #: wpsc-includes/ajax.functions.php:1039
3604
+ msgid "This download is no longer valid, Please contact the site administrator for more information."
3605
+ msgstr "Este download já não é válido. Por favor contacte o administrador do site para mais informações."
3606
+
3607
+ #: wpsc-includes/category.functions.php:361
3608
+ msgid "Brands"
3609
+ msgstr "Marcas"
3610
+
3611
+ #: wpsc-includes/checkout.class.php:45
3612
+ #, php-format
3613
+ msgid "Tax Included (%s%%)"
3614
+ msgstr "Imposto incluído (%s%%)"
3615
+
3616
+ #: wpsc-includes/checkout.class.php:47
3617
+ msgid "Tax Included"
3618
+ msgstr "Imposto incluído"
3619
+
3620
+ #: wpsc-includes/checkout.class.php:50
3621
+ msgid "Tax"
3622
+ msgstr "Imposto"
3623
+
3624
+ #: wpsc-includes/display.functions.php:90
3625
+ msgid "People who bought this item also bought"
3626
+ msgstr "Clientes que compraram este artigo compraram também"
3627
+
3628
+ #: wpsc-includes/display.functions.php:138
3629
+ msgid "Updating"
3630
+ msgstr "A actualizar"
3631
+
3632
+ #: wpsc-includes/display.functions.php:154
3633
+ msgid "Continue Shopping"
3634
+ msgstr "Continue a comprar"
3635
+
3636
+ #: wpsc-includes/display.functions.php:255
3637
+ msgid "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."
3638
+ msgstr "Está a utilizar o grupo de produtos de exemplo como o seu grupo de produtos padrão e este não tem artigos. Deverá definir outro grupo como grupo padrão, através da página de Definições de Loja."
3639
+
3640
+ #: wpsc-includes/display.functions.php:257
3641
+ msgid "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."
3642
+ msgstr "Este grupo está definido como o grupo de produtos padrão. Deve adicionar-lhe alguns artigos ou alterar o seu grupo de produtos padrão para um que contenha artigos."
3643
+
3644
+ #: wpsc-includes/form-display.functions.php:65
3645
+ msgid "Select Parent"
3646
+ msgstr "Seleccione o pai"
3647
+
3648
+ #: wpsc-includes/form-display.functions.php:137
3649
+ msgid "Choose a downloadable file for this product:"
3650
+ msgstr "Seleccione um ficheiro para download para este produto:"
3651
+
3652
+ #: wpsc-includes/form-display.functions.php:181
3653
+ msgid "Choose a downloadable file for this variation"
3654
+ msgstr "Seleccione um ficheiro para download para esta variável"
3655
+
3656
+ #: wpsc-includes/form-display.functions.php:187
3657
+ msgid "No Product"
3658
+ msgstr "Sem produtos"
3659
+
3660
+ #: wpsc-includes/install_and_update.functions.php:60
3661
+ msgid "Example category"
3662
+ msgstr "Categoria exemplo"
3663
+
3664
+ #: wpsc-includes/install_and_update.functions.php:60
3665
+ #: wpsc-includes/install_and_update.functions.php:61
3666
+ msgid "Example details"
3667
+ msgstr "Detalhes exemplo"
3668
+
3669
+ #: wpsc-includes/install_and_update.functions.php:61
3670
+ msgid "Example Brand"
3671
+ msgstr "Marca exemplo"
3672
+
3673
+ #: wpsc-includes/install_and_update.functions.php:69
3674
+ msgid "Accepted Payment"
3675
+ msgstr "Pagamento aceite"
3676
+
3677
+ #: wpsc-includes/install_and_update.functions.php:70
3678
+ msgid "Job Dispatched"
3679
+ msgstr "Encomenda expedida"
3680
+
3681
+ #: wpsc-includes/install_and_update.functions.php:89
3682
+ msgid "product image width"
3683
+ msgstr "largura da imagem do produto"
3684
+
3685
+ #: wpsc-includes/install_and_update.functions.php:90
3686
+ msgid "product image height"
3687
+ msgstr "altura da imagem do produto"
3688
+
3689
+ #: wpsc-includes/install_and_update.functions.php:92
3690
+ msgid "product group image width"
3691
+ msgstr "largura da imagem do grupo de produtos"
3692
+
3693
+ #: wpsc-includes/install_and_update.functions.php:93
3694
+ msgid "product group image height"
3695
+ msgstr "altura da imagem do grupo de produtos"
3696
+
3697
+ #: wpsc-includes/install_and_update.functions.php:97
3698
+ msgid "The location of the checkout page"
3699
+ msgstr "A localização da página de checkout"
3700
+
3701
+ #: wpsc-includes/install_and_update.functions.php:98
3702
+ msgid "The location of the transaction detail page"
3703
+ msgstr "A localização da página de detalhes da transação"
3704
+
3705
+ #: wpsc-includes/install_and_update.functions.php:99
3706
+ msgid "The payment gateway to use"
3707
+ msgstr "A gateway de pagamento a utilizar"
3708
+
3709
+ #: wpsc-includes/install_and_update.functions.php:117
3710
+ msgid "the GST rate"
3711
+ msgstr "a taxa de IVA"
3712
+
3713
+ #: wpsc-includes/install_and_update.functions.php:119
3714
+ msgid "the download limit"
3715
+ msgstr "o limite de downloads"
3716
+
3717
+ #: wpsc-includes/install_and_update.functions.php:121
3718
+ msgid "Display or hide postage and packaging"
3719
+ msgstr "Mostrar ou ocultar portes e embalagem"
3720
+
3721
+ #: wpsc-includes/install_and_update.functions.php:123
3722
+ msgid "Display or hide specials on the sidebar"
3723
+ msgstr "Mostrar ou ocultar promoções na barra lateral"
3724
+
3725
+ #: wpsc-includes/install_and_update.functions.php:126
3726
+ msgid "Default postage and packaging"
3727
+ msgstr "Portes e embalagem padrão"
3728
+
3729
+ #: wpsc-includes/install_and_update.functions.php:128
3730
+ msgid "Email address that purchase log is sent to"
3731
+ msgstr "Endereço de email para onde é enviado o relatório da compra"
3732
+
3733
+ #: wpsc-includes/install_and_update.functions.php:129
3734
+ msgid "Email address that purchase reports are sent from"
3735
+ msgstr "Endereço de email para onde são enviados os relatórios de compras"
3736
+
3737
+ #: wpsc-includes/install_and_update.functions.php:130
3738
+ msgid "Checkout terms and conditions"
3739
+ msgstr "Termos e condições de utilização para checkout"
3740
+
3741
+ #: wpsc-includes/install_and_update.functions.php:132
3742
+ msgid "Google Merchant Key"
3743
+ msgstr "Google Merchant Key"
3744
+
3745
+ #: wpsc-includes/install_and_update.functions.php:133
3746
+ msgid "Google Merchant ID"
3747
+ msgstr "Google Merchant ID"
3748
+
3749
+ #: wpsc-includes/install_and_update.functions.php:135
3750
+ msgid "Default Brand"
3751
+ msgstr "Marca padrão"
3752
+
3753
+ #: wpsc-includes/install_and_update.functions.php:136
3754
+ msgid "Select what product group you want to display on the products page"
3755
+ msgstr "Seleccione o grupo de produtos a mostrar na página de produtos"
3756
+
3757
+ #: wpsc-includes/install_and_update.functions.php:149
3758
+ #: wpsc-includes/install_and_update.functions.php:155
3759
+ msgid "paypal business"
3760
+ msgstr "paypal business"
3761
+
3762
+ #: wpsc-includes/install_and_update.functions.php:150
3763
+ #: wpsc-includes/install_and_update.functions.php:151
3764
+ #: wpsc-includes/install_and_update.functions.php:158
3765
+ msgid "paypal url"
3766
+ msgstr "paypal url"
3767
+
3768
+ #: wpsc-includes/install_and_update.functions.php:207
3769
+ msgid "Products Page"
3770
+ msgstr "Página de produtos"
3771
+
3772
+ #: wpsc-includes/install_and_update.functions.php:225
3773
+ msgid "Transaction Results"
3774
+ msgstr "Resultados da transação"
3775
+
3776
+ #: wpsc-includes/install_and_update.functions.php:231
3777
+ msgid "Your Account"
3778
+ msgstr "A sua conta"
3779
+
3780
+ #: wpsc-includes/install_and_update.functions.php:649
3781
+ msgid "1. Your billing/contact details"
3782
+ msgstr "1. Os seus detalhes de facturação/contacto"
3783
+
3784
+ #: wpsc-includes/install_and_update.functions.php:655
3785
+ #: wpsc-includes/install_and_update.functions.php:664
3786
+ msgid "Postal Code"
3787
+ msgstr "Código postal"
3788
+
3789
+ #: wpsc-includes/install_and_update.functions.php:657
3790
+ msgid "2. Shipping details"
3791
+ msgstr "2. Detalhes de envio"
3792
+
3793
+ #: wpsc-includes/install_and_update.functions.php:662
3794
+ msgid "State"
3795
+ msgstr "Estado"
3796
+
3797
+ #: wpsc-includes/misc.functions.php:46
3798
+ msgid "<strong>ERROR</strong>: Please enter a username."
3799
+ msgstr "<strong>ERRO</strong>: Por favor introduza um nome de utilizador."
3800
+
3801
+ #: wpsc-includes/misc.functions.php:48
3802
+ msgid "<strong>ERROR</strong>: This username is invalid. Please enter a valid username."
3803
+ msgstr "<strong>ERRO</strong>: O nome de utilizador é inválido. Por favor introduza um nome de utilizador válido."
3804
+
3805
+ #: wpsc-includes/misc.functions.php:51
3806
+ msgid "<strong>ERROR</strong>: This username is already registered, please choose another one."
3807
+ msgstr "<strong>ERRO</strong>: Este nome de utilizador já existe, por favor escolha outro."
3808
+
3809
+ #: wpsc-includes/misc.functions.php:56
3810
+ msgid "<strong>ERROR</strong>: Please type your e-mail address."
3811
+ msgstr "<strong>ERRO</strong>: Por favor introduza o seu endereço de email."
3812
+
3813
+ #: wpsc-includes/misc.functions.php:58
3814
+ msgid "<strong>ERROR</strong>: The email address isn&#8217;t correct."
3815
+ msgstr "<strong>ERRO</strong>: O endereço de email não é correcto."
3816
+
3817
+ #: wpsc-includes/misc.functions.php:61
3818
+ msgid "<strong>ERROR</strong>: This email is already registered, please choose another one."
3819
+ msgstr "<strong>ERRO</strong>: Este endereço de email já está registado, por favor escolha outro."
3820
+
3821
+ #: wpsc-includes/misc.functions.php:69
3822
+ #, php-format
3823
+ msgid "<strong>ERROR</strong>: Couldn&#8217;t register you... please contact the <a href=\"mailto:%s\">webmaster</a> !"
3824
+ msgstr "<strong>ERRO</strong>: Não foi possível efectuar o seu registo... por favor contacte o <a href=\"mailto:%s\">webmaster</a> !"
3825
+
3826
+ #: wpsc-includes/processing.functions.php:30
3827
+ #: wpsc-includes/processing.functions.php:36
3828
+ #: wpsc-includes/processing.functions.php:46
3829
+ msgid " is out of stock"
3830
+ msgstr "está esgotado"
3831
+
3832
+ #: wpsc-includes/processing.functions.php:30
3833
+ #: wpsc-includes/processing.functions.php:36
3834
+ #: wpsc-includes/processing.functions.php:46
3835
+ msgid "Remaining stock of "
3836
+ msgstr "Stock restante de "
3837
+
3838
+ #: wpsc-includes/processing.functions.php:30
3839
+ msgid " and its variations is 0. Product was unpublished."
3840
+ msgstr "e as suas variações é 0. O produto foi despublicado."
3841
+
3842
+ #: wpsc-includes/processing.functions.php:36
3843
+ msgid " is 0. Product variation was set to invisible."
3844
+ msgstr "é 0. A variável do produto está definida com invisível."
3845
+
3846
+ #: wpsc-includes/processing.functions.php:46
3847
+ msgid " is 0. Product was unpublished."
3848
+ msgstr "é 0. O produto foi despublicado."
3849
+
3850
+ #: wpsc-includes/processing.functions.php:916
3851
+ msgid "This product has no available stock"
3852
+ msgstr "Este produto não tem stock disponível"
3853
+
3854
+ #: wpsc-includes/processing.functions.php:964
3855
+ msgid "One or more of your shipping modules does not support products without a weight set. Please either disable shipping for this product or give it a weight"
3856
+ msgstr "Pelo menos um dos seus módulo de expedição não suporta produtos que não tenham um peso definido. Por favor desactive a opção de expedição para este produto ou atribua-lhe um peso"
3857
+
3858
+ #: wpsc-includes/purchaselogs.class.php:596
3859
+ #, php-format
3860
+ msgid "Release downloads locked to this IP address %s"
3861
+ msgstr "Desbloquear downloads bloqueados para este endereço IP %s"
3862
+
3863
+ #: wpsc-includes/purchaselogs.class.php:816
3864
+ msgid "Thanks, the purchase log record has been deleted"
3865
+ msgstr "Obrigado, o registo de compra foi eliminado"
3866
+
3867
+ #: wpsc-includes/rss_template.php:7
3868
+ msgid "WP e-Commerce"
3869
+ msgstr "WP e-Commerce"
3870
+
3871
+ #: wpsc-includes/upgrades.php:122
3872
+ msgid "Visit upgrade homepage"
3873
+ msgstr "Visitar a página inicial de upgrades"
3874
+
3875
+ #: wpsc-includes/upgrades.php:127
3876
+ msgid "Visit author homepage"
3877
+ msgstr "Visitar a página do autor"
3878
+
3879
+ #: wpsc-includes/upgrades.php:131
3880
+ #, php-format
3881
+ msgid "By %s"
3882
+ msgstr "Por %s"
3883
+
3884
+ #: wpsc-includes/variations.class.php:216
3885
+ msgid "Variation"
3886
+ msgstr "Variável"
3887
+
3888
+ #: wpsc-includes/variations.class.php:217
3889
+ msgid "Stock"
3890
+ msgstr "Stock"
3891
+
3892
+ #: wpsc-includes/variations.class.php:220
3893
+ msgid "More"
3894
+ msgstr "Mais"
3895
+
3896
+ #: wpsc-includes/variations.class.php:352
3897
+ msgid "Weight Settings"
3898
+ msgstr "Definições de peso"
3899
+
3900
+ #: wpsc-includes/wpsc_query.php:939
3901
+ msgid "Save"
3902
+ msgstr "Guardar"
3903
+
3904
+ #~ msgid "Google Base"
3905
+ #~ msgstr "Google Base"
3906
+
3907
+ #~ msgid ""
3908
+ #~ "Your site has been granted access to google base.<br /> All future "
3909
+ #~ "products will be submitted to google base.<br />"
3910
+ #~ msgstr ""
3911
+ #~ "O seu website tem acesso ao Google Base.<br /> Todos os produtos futuros "
3912
+ #~ "serão submetidos ao Google Base.<br />"
3913
+
3914
+ #~ msgid "Click here to remove access"
3915
+ #~ msgstr "Clique aqui para retirar o acesso"
3916
+
3917
+ #~ msgid "Grant Access"
3918
+ #~ msgstr "Conceder acesso"
3919
+
3920
+ #~ msgid ""
3921
+ #~ "Powered by <a href=\"http://alexking.org/projects/wordpress\">Share This</"
3922
+ #~ "a>"
3923
+ #~ msgstr ""
3924
+ #~ "Powered by <a href=\"http://alexking.org/projects/wordpress\">Share This</"
3925
+ #~ "a>"
3926
+
3927
+ #~ msgid "Delivery State"
3928
+ #~ msgstr "Estado da entrega"
3929
+
3930
+ #~ msgid "Date requested"
3931
+ #~ msgstr "Data solicitada"
3932
+
3933
+ #~ msgid "Comment"
3934
+ #~ msgstr "Comentário"
3935
+
3936
+ #~ msgid ""
3937
+ #~ "<strong>ERROR</strong>: This email address is already registered, please "
3938
+ #~ "supply another."
3939
+ #~ msgstr ""
3940
+ #~ "<strong>ERRO</strong>: Este endereço de email já se encontra registado, "
3941
+ #~ "por favor tente com outro."
3942
+
3943
+ #~ msgid "Registration Complete"
3944
+ #~ msgstr "Registo concluído"
3945
+
3946
+ #~ msgid "Username: %s"
3947
+ #~ msgstr "Nome de utilizador: %s"
3948
+
3949
+ #~ msgid "Password: %s"
3950
+ #~ msgstr "Password: %s"
3951
+
3952
+ #~ msgid "emailed to you"
3953
+ #~ msgstr "enviado por email para si"
3954
+
3955
+ #~ msgid "E-mail: %s"
3956
+ #~ msgstr "Email: %s"
3957
+
3958
+ #~ msgid "Register"
3959
+ #~ msgstr "Registar"
3960
+
3961
+ #~ msgid "Click stars to rate"
3962
+ #~ msgstr "Clique nas estrelas para avaliar"
3963
+
3964
+ #~ msgid "No Votes"
3965
+ #~ msgstr "Sem Votos"
3966
+
3967
+ #~ msgid "1 Vote"
3968
+ #~ msgstr "1 Voto"
3969
+
3970
+ #~ msgid "person has given this image"
3971
+ #~ msgstr "pessoa deu a esta imagem"
3972
+
3973
+ #~ msgid "people have given this image"
3974
+ #~ msgstr "pessoas deram a esta imagem"
3975
+
3976
+ #~ msgid "stars."
3977
+ #~ msgstr "estrelas."
3978
+
3979
+ #~ msgid "Delivery Address"
3980
+ #~ msgstr "Endereço de entrega"
3981
+
3982
+ #~ msgid "Delivery City"
3983
+ #~ msgstr "Localidade de entrega"
3984
+
3985
+ #~ msgid "Delivery Country"
3986
+ #~ msgstr "País de entrega"
3987
+
3988
+ #~ msgid ""
3989
+ #~ "There was an error contacting the payment gateway, please try again later."
3990
+ #~ msgstr ""
3991
+ #~ "Lamentamos mas ocorreu um erro ao contactar a gateway de pagamento, por "
3992
+ #~ "favor tente de novo mais tarde."
3993
+
3994
+ #~ msgid ""
3995
+ #~ "Because your order is over 150lbs, the SIte Owner will contact you "
3996
+ #~ "directly about shipping rates."
3997
+ #~ msgstr ""
3998
+ #~ "Uma vez que a sua encomenda excede xxx, o adminsitrador do site irá "
3999
+ #~ "contactá-lo directamente, acerca das taxas de envio."
4000
+
4001
+ #~ msgid "About This Page"
4002
+ #~ msgstr "Acerca desta página"
4003
+
4004
+ #~ msgid "Add Group"
4005
+ #~ msgstr "Adicionar grupo"
4006
+
4007
+ #~ msgid "Language"
4008
+ #~ msgstr "Idioma"
4009
+
4010
+ #~ msgid "Show list of product groups"
4011
+ #~ msgstr "Mostrar lista de grupos de produtos"
4012
+
4013
+ #~ msgid "Select Theme"
4014
+ #~ msgstr "Selecionne o tema"
merchants/chronopay.php CHANGED
@@ -200,7 +200,7 @@ function nzshpcrt_chronopay_callback()
200
  global $wpdb;
201
  // needs to execute on page start
202
  // look at page 36
203
- if($_GET['chronopay_callback'] == 'true' && $_POST['cs2'] == 'chronopay')
204
  {
205
  // This is a call from chronopay. validate that it is from a chronopay server in the and process.
206
  // validate cs3 variable to see if it makes sense for security
@@ -283,7 +283,7 @@ function nzshpcrt_chronopay_callback()
283
  function nzshpcrt_chronopay_results()
284
  {
285
  // Function used to translate the ChronoPay returned cs1=sessionid POST variable into the recognised GET variable for the transaction results page.
286
- if($_POST['cs1'] !='' && $_GET['sessionid'] == '')
287
  {
288
  $_GET['sessionid'] = $_POST['cs1'];
289
  }
200
  global $wpdb;
201
  // needs to execute on page start
202
  // look at page 36
203
+ if(isset($_GET['chronopay_callback']) && ($_GET['chronopay_callback'] == 'true') && ($_POST['cs2'] == 'chronopay'))
204
  {
205
  // This is a call from chronopay. validate that it is from a chronopay server in the and process.
206
  // validate cs3 variable to see if it makes sense for security
283
  function nzshpcrt_chronopay_results()
284
  {
285
  // Function used to translate the ChronoPay returned cs1=sessionid POST variable into the recognised GET variable for the transaction results page.
286
+ if(isset($_POST['cs1']) && ($_POST['cs1'] !='') && ($_GET['sessionid'] == ''))
287
  {
288
  $_GET['sessionid'] = $_POST['cs1'];
289
  }
merchants/paypal-pro.merchant.php CHANGED
@@ -396,7 +396,8 @@ function form_paypal_pro(){
396
  return $output;
397
  }
398
 
399
-
 
400
  if(in_array('wpsc_merchant_paypal_pro',(array)get_option('custom_gateway_options'))) {
401
  $curryear = date('Y');
402
 
396
  return $output;
397
  }
398
 
399
+ $years = '';
400
+ $months = '';
401
  if(in_array('wpsc_merchant_paypal_pro',(array)get_option('custom_gateway_options'))) {
402
  $curryear = date('Y');
403
 
merchants/paypal_certified.php CHANGED
@@ -125,9 +125,13 @@ function paypal_certified_currencyconverter(){
125
  function processingfunctions()
126
  {
127
  global $wpdb, $wpsc_cart;
128
- $sessionid = $_SESSION['paypalexpresssessionid'];
129
 
130
- if($_REQUEST['act']=='error'){
 
 
 
 
 
131
  session_start();
132
  $resArray=$_SESSION['reshash'];
133
  $_SESSION['paypalExpressMessage']= '
@@ -207,7 +211,7 @@ $_SESSION['paypalExpressMessage']= '
207
  </center>
208
  </table>";
209
 
210
- }else if($_REQUEST['act']=='do'){
211
  session_start();
212
 
213
  /* Gather the information to make the final call to
@@ -763,6 +767,7 @@ $output .= "
763
  */
764
  //$SandboxFlag = true;
765
  //exit(get_option('paypal_certified_server_type'));
 
766
  if (get_option('paypal_certified_server_type') == 'sandbox'){
767
  $SandboxFlag=true;
768
  } elseif(get_option('paypal_certified_server_type') == 'production') {
125
  function processingfunctions()
126
  {
127
  global $wpdb, $wpsc_cart;
 
128
 
129
+ $sessionid = '';
130
+ if (isset($_SESSION['paypalexpresssessionid'])) {
131
+ $sessionid = $_SESSION['paypalexpresssessionid'];
132
+ }
133
+
134
+ if(isset($_REQUEST['act']) && ($_REQUEST['act']=='error')){
135
  session_start();
136
  $resArray=$_SESSION['reshash'];
137
  $_SESSION['paypalExpressMessage']= '
211
  </center>
212
  </table>";
213
 
214
+ }else if(isset($_REQUEST['act']) && ($_REQUEST['act']=='do')){
215
  session_start();
216
 
217
  /* Gather the information to make the final call to
767
  */
768
  //$SandboxFlag = true;
769
  //exit(get_option('paypal_certified_server_type'));
770
+ $SandboxFlag = '';
771
  if (get_option('paypal_certified_server_type') == 'sandbox'){
772
  $SandboxFlag=true;
773
  } elseif(get_option('paypal_certified_server_type') == 'production') {
share-this.php CHANGED
@@ -477,6 +477,8 @@ function wpsc_akst_share_form() {
477
 
478
  if (isset($current_user)) {
479
  $user = get_currentuserinfo();
 
 
480
  $name = $current_user->user_nicename;
481
  $email = $current_user->user_email;
482
  }
@@ -526,8 +528,9 @@ function wpsc_akst_share_form() {
526
  </li>
527
  </ul>
528
  <input type="hidden" name="wpsc_akst_action" value="send_mail" />
529
- <input type="hidden" name="wpsc_akst_post_id" id="wpsc_akst_post_id" value="<?php print($id); ?>" />
530
  <?php
 
531
  if($wp_query->query_vars['product_url_name'] != '') {
532
  $product_id = $wpdb->get_var("SELECT `product_id` FROM `".WPSC_TABLE_PRODUCTMETA."` WHERE `meta_key` IN ( 'url_name' ) AND `meta_value` IN ( '".$wp_query->query_vars['product_url_name']."' ) ORDER BY `product_id` DESC LIMIT 1");
533
  } else if(is_numeric($_GET['product_id'])){
477
 
478
  if (isset($current_user)) {
479
  $user = get_currentuserinfo();
480
+ if (!isset($current_user->user_nicename)) $current_user->user_nicename = '';
481
+ if (!isset($current_user->user_email)) $current_user->user_email = '';
482
  $name = $current_user->user_nicename;
483
  $email = $current_user->user_email;
484
  }
528
  </li>
529
  </ul>
530
  <input type="hidden" name="wpsc_akst_action" value="send_mail" />
531
+ <input type="hidden" name="wpsc_akst_post_id" id="wpsc_akst_post_id" value="<?php if (isset($id)) print($id); ?>" />
532
  <?php
533
+ if (!isset($wp_query->query_vars['product_url_name'])) $wp_query->query_vars['product_url_name'] = '';
534
  if($wp_query->query_vars['product_url_name'] != '') {
535
  $product_id = $wpdb->get_var("SELECT `product_id` FROM `".WPSC_TABLE_PRODUCTMETA."` WHERE `meta_key` IN ( 'url_name' ) AND `meta_value` IN ( '".$wp_query->query_vars['product_url_name']."' ) ORDER BY `product_id` DESC LIMIT 1");
536
  } else if(is_numeric($_GET['product_id'])){
shipping/flatrate.php CHANGED
@@ -57,6 +57,8 @@ class flatrate {
57
  }
58
 
59
  function submit_form() {
 
 
60
  if($_POST['shipping'] != null) {
61
  $shipping = (array)get_option('flat_rates');
62
  $submitted_shipping = (array)$_POST['shipping'];
57
  }
58
 
59
  function submit_form() {
60
+ if (!isset($_POST['shipping'])) $_POST['shipping'] = null;
61
+
62
  if($_POST['shipping'] != null) {
63
  $shipping = (array)get_option('flat_rates');
64
  $submitted_shipping = (array)$_POST['shipping'];
shipping/tablerate.php CHANGED
@@ -54,6 +54,8 @@ class tablerate {
54
  }
55
 
56
  function submit_form() {
 
 
57
  $layers = (array)$_POST['layer'];
58
  $shippings = (array)$_POST['shipping'];
59
  if ($shippings != '') {
@@ -66,6 +68,7 @@ class tablerate {
66
  }
67
  }
68
  }
 
69
  if ($_POST['checkpage'] == 'table') {
70
  update_option('table_rate_layers',$new_layer);
71
  }
54
  }
55
 
56
  function submit_form() {
57
+ if (!isset($_POST['layer'])) $_POST['layer'] = '';
58
+
59
  $layers = (array)$_POST['layer'];
60
  $shippings = (array)$_POST['shipping'];
61
  if ($shippings != '') {
68
  }
69
  }
70
  }
71
+ if (!isset($_POST['checkpage'])) $_POST['checkpage'] = '';
72
  if ($_POST['checkpage'] == 'table') {
73
  update_option('table_rate_layers',$new_layer);
74
  }
shipping/ups.php CHANGED
@@ -240,8 +240,10 @@ class ups {
240
  /* This function is called when the user hit "submit" in the
241
  * UPS settings area under Shipping to update the setttings.
242
  */
 
243
  $wpsc_ups_services = $_POST['wpsc_ups_services'];
244
  update_option('wpsc_ups_services',$wpsc_ups_services);
 
245
  if ($_POST['wpsc_ups_settings'] != '') {
246
  $temp = $_POST['wpsc_ups_settings'];
247
  // base64_encode the information so it isnt stored as plaintext.
240
  /* This function is called when the user hit "submit" in the
241
  * UPS settings area under Shipping to update the setttings.
242
  */
243
+ if (!isset($_POST['wpsc_ups_services'])) $_POST['wpsc_ups_services'] = '';
244
  $wpsc_ups_services = $_POST['wpsc_ups_services'];
245
  update_option('wpsc_ups_services',$wpsc_ups_services);
246
+ if (!isset($_POST['wpsc_ups_settings'])) $_POST['wpsc_ups_settings'] = '';
247
  if ($_POST['wpsc_ups_settings'] != '') {
248
  $temp = $_POST['wpsc_ups_settings'];
249
  // base64_encode the information so it isnt stored as plaintext.
shipping/usps.php CHANGED
@@ -50,6 +50,9 @@ class usps {
50
  }
51
 
52
  function submit_form() {
 
 
 
53
  if ($_POST['uspsid'] != '') {
54
  update_option('uspsid', $_POST['uspsid']);
55
  }
50
  }
51
 
52
  function submit_form() {
53
+ if (!isset($_POST['uspsid'])) $_POST['uspsid'] = '';
54
+ if (!isset($_POST['uspspw'])) $_POST['uspspw'] = '';
55
+
56
  if ($_POST['uspsid'] != '') {
57
  update_option('uspsid', $_POST['uspsid']);
58
  }
shipping/weightrate.php CHANGED
@@ -42,6 +42,8 @@ class weightrate {
42
  }
43
 
44
  function submit_form() {
 
 
45
  $layers = (array)$_POST['weight_layer'];
46
  $shippings = (array)$_POST['weight_shipping'];
47
  if ($shippings != ''){
42
  }
43
 
44
  function submit_form() {
45
+ if (!isset($_POST['weight_layer'])) $_POST['weight_layer'] = '';
46
+ if (!isset($_POST['weight_shipping'])) $_POST['weight_shipping'] = '';
47
  $layers = (array)$_POST['weight_layer'];
48
  $shippings = (array)$_POST['weight_shipping'];
49
  if ($shippings != ''){
shopping_cart_functions.php CHANGED
@@ -29,13 +29,17 @@ function wpsc_shopping_cart($input = null, $override_state = null) {
29
  echo "</div></div>";
30
  }
31
  } else if(($state == 3) || ($state == 4)) {
32
- $cart = $_SESSION['nzshpcrt_cart'];
 
 
33
  if($state == 4) {
34
  #echo $input;
35
  echo "<div id='widgetshoppingcart'>";
36
  echo "<h3>".__('Shopping Cart')."$fancy_collapser</h3>";
37
  echo " <div id='shoppingcartcontents'>";
38
- echo wpsc_shopping_basket_internals($cart,false,true);
 
 
39
  echo " </div>";
40
  echo "</div>";
41
  $dont_add_input = true;
@@ -69,14 +73,14 @@ function nzshpcrt_shopping_basket($input = null, $override_state = null) {
69
  function wpsc_shopping_basket_internals($cart,$quantity_limit = false, $no_title=false) {
70
  global $wpdb, $wpsc_theme_path;
71
  $display_state = "";
72
- if((($_SESSION['slider_state'] == 0) || (wpsc_cart_item_count() < 1)) && (get_option('show_sliding_cart') == 1)) {
73
  $display_state = "style='display: none;'";
74
  }
75
  echo " <div id='sliding_cart' class='shopping-cart-wrapper' $display_state>";
76
  $cur_wpsc_theme_folder = apply_filters('wpsc_theme_folder',$wpsc_theme_path.WPSC_THEME_DIR);
77
  include_once($cur_wpsc_theme_folder."/cart_widget.php");
78
  echo " </div>";
79
- return $output;
80
  }
81
 
82
  function wpsc_country_region_list($form_id = null, $ajax = false , $selected_country = null, $selected_region = null, $supplied_form_id = null, $checkoutfields = false) {
29
  echo "</div></div>";
30
  }
31
  } else if(($state == 3) || ($state == 4)) {
32
+ if (isset($_SESSION['nzshpcrt_cart'])) {
33
+ $cart = $_SESSION['nzshpcrt_cart'];
34
+ }
35
  if($state == 4) {
36
  #echo $input;
37
  echo "<div id='widgetshoppingcart'>";
38
  echo "<h3>".__('Shopping Cart')."$fancy_collapser</h3>";
39
  echo " <div id='shoppingcartcontents'>";
40
+ if (isset($cart)) {
41
+ echo wpsc_shopping_basket_internals($cart,false,true);
42
+ }
43
  echo " </div>";
44
  echo "</div>";
45
  $dont_add_input = true;
73
  function wpsc_shopping_basket_internals($cart,$quantity_limit = false, $no_title=false) {
74
  global $wpdb, $wpsc_theme_path;
75
  $display_state = "";
76
+ if((( (isset($_SESSION['slider_state']) && $_SESSION['slider_state'] == 0) )|| (wpsc_cart_item_count() < 1)) && (get_option('show_sliding_cart') == 1)) {
77
  $display_state = "style='display: none;'";
78
  }
79
  echo " <div id='sliding_cart' class='shopping-cart-wrapper' $display_state>";
80
  $cur_wpsc_theme_folder = apply_filters('wpsc_theme_folder',$wpsc_theme_path.WPSC_THEME_DIR);
81
  include_once($cur_wpsc_theme_folder."/cart_widget.php");
82
  echo " </div>";
83
+ // return $output;
84
  }
85
 
86
  function wpsc_country_region_list($form_id = null, $ajax = false , $selected_country = null, $selected_region = null, $supplied_form_id = null, $checkoutfields = false) {
tagging_functions.php CHANGED
@@ -74,9 +74,9 @@ function wp_generate_product_tag_cloud( $tags, $args = '' ) {
74
 
75
  foreach ( $counts as $tag => $count ) {
76
  $tag_id = $tag_ids[$tag];
77
- $tag_link = clean_url($tag_links[$tag]);
78
- $tag = str_replace(' ', '&nbsp;', wp_specialchars( $tag ));
79
- $a[] = "<a href='$tag_link' class='tag-link-$tag_id' title='" . attribute_escape( sprintf( __('%d topics'), $count ) ) . "'$rel style='font-size: " .
80
  ( $smallest + ( ( $count - $min_count ) * $font_step ) )
81
  . "$unit;'>$tag</a>";
82
  }
74
 
75
  foreach ( $counts as $tag => $count ) {
76
  $tag_id = $tag_ids[$tag];
77
+ $tag_link = esc_url($tag_links[$tag]);
78
+ $tag = str_replace(' ', '&nbsp;', esc_html( $tag ));
79
+ $a[] = "<a href='$tag_link' class='tag-link-$tag_id' title='" . esc_attr( sprintf( __('%d topics'), $count ) ) . "'$rel style='font-size: " .
80
  ( $smallest + ( ( $count - $min_count ) * $font_step ) )
81
  . "$unit;'>$tag</a>";
82
  }
themes/default.old/shopping_cart_page.php CHANGED
@@ -230,7 +230,7 @@ if(wpsc_cart_item_count() > 0) :
230
  <fieldset class='wpsc_registration_form'>
231
  <label><?php _e('Username'); ?>:</label><input type="text" name="log" id="log" value="" size="20"/>
232
  <label><?php _e('Password'); ?>:</label><input type="password" name="pwd" id="pwd" value="" size="20" />
233
- <label><?php _e('E-mail'); ?>:</label><input type="text" name="user_email" id="user_email" value="<?php echo attribute_escape(stripslashes($user_email)); ?>" size="20" />
234
  </fieldset>
235
  <?php endif; ?>
236
 
230
  <fieldset class='wpsc_registration_form'>
231
  <label><?php _e('Username'); ?>:</label><input type="text" name="log" id="log" value="" size="20"/>
232
  <label><?php _e('Password'); ?>:</label><input type="password" name="pwd" id="pwd" value="" size="20" />
233
+ <label><?php _e('E-mail'); ?>:</label><input type="text" name="user_email" id="user_email" value="<?php echo esc_attr(stripslashes($user_email)); ?>" size="20" />
234
  </fieldset>
235
  <?php endif; ?>
236
 
themes/default/checkout.php CHANGED
@@ -256,7 +256,7 @@ get_header(); ?>
256
  <fieldset class='wpsc_registration_form'>
257
  <label><?php _e('Username'); ?>:</label><input type="text" name="log" id="log" value="" size="20"/>
258
  <label><?php _e('Password'); ?>:</label><input type="password" name="pwd" id="pwd" value="" size="20" />
259
- <label><?php _e('E-mail'); ?>:</label><input type="text" name="user_email" id="user_email" value="<?php echo attribute_escape(stripslashes($user_email)); ?>" size="20" />
260
  </fieldset>
261
  <?php endif; ?>
262
 
256
  <fieldset class='wpsc_registration_form'>
257
  <label><?php _e('Username'); ?>:</label><input type="text" name="log" id="log" value="" size="20"/>
258
  <label><?php _e('Password'); ?>:</label><input type="password" name="pwd" id="pwd" value="" size="20" />
259
+ <label><?php _e('E-mail'); ?>:</label><input type="text" name="user_email" id="user_email" value="<?php echo esc_attr(stripslashes($user_email)); ?>" size="20" />
260
  </fieldset>
261
  <?php endif; ?>
262
 
themes/default/shopping_cart_page.php CHANGED
@@ -9,370 +9,429 @@ if(wpsc_cart_item_count() > 0) :
9
  ?>
10
  <p><?php echo __('Please review your order', 'wpsc'); ?></p>
11
  <table class="productcart">
12
- <tr class="firstrow">
13
- <td class='firstcol'></td>
14
- <td><?php echo __('Product', 'wpsc'); ?>:</td>
15
- <td><?php echo __('Quantity', 'wpsc'); ?>:</td>
16
- <td><?php echo __('Price', 'wpsc'); ?>:</td>
17
- <td><?php echo __('Shipping', 'wpsc'); ?>:</td>
18
- <td></td>
19
- </tr>
20
- <?php while (wpsc_have_cart_items()) : wpsc_the_cart_item(); ?>
21
-
22
- <?php //this displays the confirm your order html ?>
23
-
24
- <tr class="product_row">
25
- <td class="firstcol"><img src='<?php echo wpsc_cart_item_image(48,48); ?>' alt='<?php echo wpsc_cart_item_name(); ?>' title='<?php echo wpsc_cart_item_name(); ?>' /></td>
26
- <td class="firstcol">
27
- <a href='<?php echo wpsc_cart_item_url();?>'><?php echo wpsc_cart_item_name(); ?></a>
28
- </td>
29
- <td>
30
- <form action="<?php echo get_option('shopping_cart_url'); ?>" method="post" class="adjustform">
31
- <input type="text" name="quantity" size="2" value="<?php echo wpsc_cart_item_quantity(); ?>" />
32
- <input type="hidden" name="key" value="<?php echo wpsc_the_cart_item_key(); ?>" />
33
- <input type="hidden" name="wpsc_update_quantity" value="true" />
34
- <input type="submit" value="<?php echo __('Update', 'wpsc'); ?>" name="submit" />
35
- </form>
36
- </td>
37
- <td><span class="pricedisplay"><?php echo wpsc_cart_item_price(); ?></span></td>
38
- <td><span class="pricedisplay" id='shipping_<?php echo wpsc_the_cart_item_key(); ?>'><?php echo wpsc_cart_item_shipping(); ?></span></td>
39
- <td>
40
- <form action="<?php echo get_option('shopping_cart_url'); ?>" method="post" class="adjustform">
41
- <input type="hidden" name="quantity" value="0" />
42
- <input type="hidden" name="key" value="<?php echo wpsc_the_cart_item_key(); ?>" />
43
- <input type="hidden" name="wpsc_update_quantity" value="true" />
44
- <button class='remove_button' type="submit"><span><?php echo __('Remove', 'wpsc'); ?></span></button>
45
- </form>
46
- </td>
47
- </tr>
48
- <?php endwhile; ?>
49
- <?php //this HTML displays coupons if there are any active coupons to use ?>
50
- <?php if(wpsc_uses_coupons()): ?>
51
-
52
- <?php if(wpsc_coupons_error()): ?>
53
- <tr><td><?php echo __('Coupon is not valid.', 'wpsc'); ?></td></tr>
54
- <?php endif; ?>
55
- <tr>
56
- <td colspan="2"><?php _e('Enter your coupon number'); ?> :</td>
57
- <td colspan="3" align='left'>
58
- <form method='post' action="<?php echo get_option('shopping_cart_url'); ?>">
59
- <input type='text' name='coupon_num' id='coupon_num' value='<?php echo $wpsc_cart->coupons_name; ?>' />
60
- <input type='submit' value='<?php echo __('Update', 'wpsc') ?>' />
61
- </form>
62
- </td>
63
- </tr>
64
- <?php endif; ?>
65
- </table>
66
- <?php //this HTML dispalys the calculate your order HTML ?>
67
-
68
- <?php if(isset($_SESSION['nocamsg']) && isset($_GET['noca']) && $_GET['noca'] == 'confirm'): ?>
69
- <p class='validation-error'><?php echo $_SESSION['nocamsg']; ?></p>
70
- <?php endif; ?>
71
- <?php if($_SESSION['categoryAndShippingCountryConflict'] != '') : ?>
72
- <p class='validation-error'><?php echo $_SESSION['categoryAndShippingCountryConflict']; ?></p>
73
- <?php
74
- endif;
75
-
76
- if($_SESSION['WpscGatewayErrorMessage'] != '') :
77
- ?>
78
- <p class='validation-error'><?php echo $_SESSION['WpscGatewayErrorMessage']; ?></p>
79
- <?php
80
- endif;
81
- ?>
82
- <?php do_action('wpsc_before_shipping_of_shopping_cart'); ?>
83
- <div id='wpsc_shopping_cart_container'>
84
- <?php if(wpsc_uses_shipping()) : ?>
85
- <h2><?php echo __('Calculate Shipping Price', 'wpsc'); ?></h2>
86
- <table class="productcart">
87
- <tr>
88
- <td colspan='5'>
89
- <?php echo __('Please choose a country below to calculate your shipping costs', 'wpsc'); ?>
90
- </td>
91
- </tr>
92
-
93
- <?php if (!wpsc_have_shipping_quote()) : // No valid shipping quotes ?>
94
- <?php if (($_SESSION['wpsc_zipcode'] == '') || ($_SESSION['wpsc_zipcode'] == 'Your Zipcode')) : // No valid shipping quotes ?>
95
- <?php if ($_SESSION['wpsc_update_location'] == true) :?>
96
- <tr>
97
- <td colspan='5' class='shipping_error' >
98
- <?php echo __('Please provide a Zipcode and click Calculate in order to continue.', 'wpsc'); ?>
99
- </td>
100
- </tr>
101
- <?php endif; ?>
102
- <?php else: ?>
103
- <tr>
104
- <td colspan='5' class='shipping_error' >
105
- <?php echo __('Sorry, online ordering is unavailable to this destination and/or weight. Please double check your destination details.', 'wpsc'); ?>
106
- </td>
107
- </tr>
108
- <?php endif; ?>
109
- <?php endif; ?>
110
- <tr>
111
- <td colspan='5'>
112
- <form name='change_country' id='change_country' action='' method='post'>
113
- <?php echo wpsc_shipping_country_list();?>
114
- <input type='hidden' name='wpsc_update_location' value='true' />
115
- <input type='submit' name='wpsc_submit_zipcode' value='Calculate' />
116
- </form>
117
- </td>
118
- </tr>
119
-
120
- <?php if (wpsc_have_morethanone_shipping_quote()) :?>
121
- <?php while (wpsc_have_shipping_methods()) : wpsc_the_shipping_method(); ?>
122
- <?php if (!wpsc_have_shipping_quotes()) { continue; } // Don't display shipping method if it doesn't have at least one quote ?>
123
- <tr><td class='shipping_header' colspan='5'><?php echo wpsc_shipping_method_name().__('- Choose a Shipping Rate', 'wpsc'); ?> </td></tr>
124
- <?php while (wpsc_have_shipping_quotes()) : wpsc_the_shipping_quote(); ?>
125
- <tr>
126
- <td colspan='3'>
127
- <label for='<?php echo wpsc_shipping_quote_html_id(); ?>'><?php echo wpsc_shipping_quote_name(); ?></label>
128
- </td>
129
- <td style='text-align:center;'>
130
- <label for='<?php echo wpsc_shipping_quote_html_id(); ?>'><?php echo wpsc_shipping_quote_value(); ?></label>
131
- </td>
132
- <td style='text-align:center;'>
133
- <?php if(wpsc_have_morethanone_shipping_methods_and_quotes()): ?>
134
- <input type='radio' id='<?php echo wpsc_shipping_quote_html_id(); ?>' <?php echo wpsc_shipping_quote_selected_state(); ?> onclick='switchmethod("<?php echo wpsc_shipping_quote_name(); ?>", "<?php echo wpsc_shipping_method_internal_name(); ?>")' value='<?php echo wpsc_shipping_quote_value(true); ?>' name='shipping_method' />
135
- <?php else: ?>
136
- <input <?php echo wpsc_shipping_quote_selected_state(); ?> disabled='disabled' type='radio' id='<?php echo wpsc_shipping_quote_html_id(); ?>' value='<?php echo wpsc_shipping_quote_value(true); ?>' name='shipping_method' />
137
- <?php wpsc_update_shipping_single_method(); ?>
138
- <?php endif; ?>
139
- </td>
140
- </tr>
141
- <?php endwhile; ?>
142
- <?php endwhile; ?>
143
- <?php endif; ?>
144
-
145
- <?php wpsc_update_shipping_multiple_methods(); ?>
146
-
147
-
148
- <?php if (!wpsc_have_shipping_quote()) : // No valid shipping quotes ?>
149
- </table>
150
- </div>
151
- <?php return; ?>
152
- <?php endif; ?>
153
- </table>
154
- <?php endif; ?>
155
-
156
- <table class="productcart">
157
- <?php if(wpsc_cart_tax(false) > 0) : ?>
158
- <tr class="total_price total_tax">
159
- <td colspan="3">
160
- <?php echo wpsc_display_tax_label(true); ?>
161
-
162
- </td>
163
- <td colspan="2">
164
- <span id="checkout_tax" class="pricedisplay checkout-tax"><?php echo wpsc_cart_tax(); ?></span>
165
- </td>
166
- </tr>
167
- <?php endif; ?>
168
-
169
- <?php if(wpsc_uses_shipping()) : ?>
170
- <tr class="total_price total_shipping">
171
- <td colspan="3">
172
- <?php echo __('Total Shipping', 'wpsc'); ?>
173
- </td>
174
- <td colspan="2">
175
- <span id="checkout_shipping" class="pricedisplay checkout-shipping"><?php echo wpsc_cart_shipping(); ?></span>
176
- </td>
177
- </tr>
178
- <?php endif; ?>
179
-
180
- <?php if(wpsc_uses_coupons() && (wpsc_coupon_amount(false) > 0)): ?>
181
- <tr class="total_price">
182
- <td colspan="3">
183
- <?php echo __('Discount', 'wpsc'); ?>
184
- </td>
185
- <td colspan="2">
186
- <span id="coupons_amount" class="pricedisplay"><?php echo wpsc_coupon_amount(); ?></span>
187
- </td>
188
- </tr>
189
- <?php endif ?>
190
-
191
-
192
-
193
- <tr class='total_price'>
194
- <td colspan='3'>
195
- <?php echo __('Total Price', 'wpsc'); ?>
196
- </td>
197
- <td colspan='2'>
198
- <span id='checkout_total' class="pricedisplay checkout-total"><?php echo wpsc_cart_total(); ?></span>
199
- </td>
200
- </tr>
201
-
202
-
203
- </table>
204
-
205
- <?php do_action('wpsc_before_form_of_shopping_cart'); ?>
206
-
207
- <form class='wpsc_checkout_forms' action='' method='post' enctype="multipart/form-data">
208
-
209
- <?php
210
- /**
211
- * Both the registration forms and the checkout details forms must be in the same form element as they are submitted together, you cannot have two form elements submit together without the use of JavaScript.
212
- */
213
- ?>
214
-
215
- <?php if(!is_user_logged_in() && get_option('users_can_register') && get_option('require_register')) : ?>
216
- <h2><?php _e('Not yet a member?');?></h2>
217
- <p><?php _e('In order to buy from us, you\'ll need an account. Joining is free and easy. All you need is a username, password and valid email address.');?></p>
218
- <?php if(count($_SESSION['wpsc_checkout_user_error_messages']) > 0) : ?>
219
- <div class="login_error">
220
- <?php
221
- foreach($_SESSION['wpsc_checkout_user_error_messages'] as $user_error ) {
222
- echo $user_error."<br />\n";
223
- }
224
- $_SESSION['wpsc_checkout_user_error_messages'] = array();
225
- ?>
226
- </div>
227
- <?php endif; ?>
228
-
229
-
230
- <fieldset class='wpsc_registration_form'>
231
- <label><?php _e('Username'); ?>:</label><input type="text" name="log" id="log" value="" size="20"/>
232
- <label><?php _e('Password'); ?>:</label><input type="password" name="pwd" id="pwd" value="" size="20" />
233
- <label><?php _e('E-mail'); ?>:</label><input type="text" name="user_email" id="user_email" value="<?php echo attribute_escape(stripslashes($user_email)); ?>" size="20" />
234
- </fieldset>
235
- <?php endif; ?>
236
-
237
- <h2><?php echo __('Please enter your contact details:', 'wpsc'); ?></h2>
238
- <?php/* echo __('Note, Once you press submit, you will need to have your Credit card handy.', 'wpsc'); <br /> */?>
239
- <?php echo __('Fields marked with an asterisk must be filled in.', 'wpsc'); ?>
240
- <?php
241
- if(count($_SESSION['wpsc_checkout_misc_error_messages']) > 0) {
242
- echo "<div class='login_error'>\n\r";
243
- foreach((array)$_SESSION['wpsc_checkout_misc_error_messages'] as $user_error ) {
244
- echo $user_error."<br />\n";
245
- }
246
- echo "</div>\n\r";
247
- }
248
- $_SESSION['wpsc_checkout_misc_error_messages'] =array();
249
- ?>
250
- <table class='wpsc_checkout_table'>
251
- <?php while (wpsc_have_checkout_items()) : wpsc_the_checkout_item(); ?>
252
- <?php if(wpsc_is_shipping_details()) : ?>
253
- <tr>
254
- <td colspan ='2'>
255
- <br />
256
- <input type='checkbox' value='true' name='shippingSameBilling' id='shippingSameBilling' />
257
- <label for='shippingSameBilling'>Shipping Address same as Billing Address?</label>
258
-
259
- </td>
260
- </tr>
261
- <?php endif; ?>
262
-
263
- <?php if(wpsc_checkout_form_is_header() == true) : ?>
264
- <tr <?php echo wpsc_the_checkout_item_error_class();?>>
265
- <td <?php if(wpsc_is_shipping_details()) echo "class='wpsc_shipping_forms'"; ?> colspan='2'>
266
- <h4>
267
- <?php echo wpsc_checkout_form_name();?>
268
- </h4>
269
- </td>
270
- </tr>
271
- <?php else: ?>
272
- <?php if((!wpsc_uses_shipping()) && $wpsc_checkout->checkout_item->unique_name == 'shippingstate'): ?>
273
- <?php else : ?>
274
- <tr <?php echo wpsc_the_checkout_item_error_class();?>>
275
- <td>
276
- <label for='<?php echo wpsc_checkout_form_element_id(); ?>'>
277
- <?php echo wpsc_checkout_form_name();?>:
278
- </label>
279
- </td>
280
- <td>
281
- <?php echo wpsc_checkout_form_field();?>
282
-
283
- <?php if(wpsc_the_checkout_item_error() != ''): ?>
284
- <p class='validation-error'><?php echo wpsc_the_checkout_item_error(); ?></p>
285
-
286
- <?php endif; ?>
287
- </td>
288
- </tr>
289
- <?php endif; ?>
290
-
291
- <?php endif; ?>
292
-
293
- <?php endwhile; ?>
294
-
295
- <?php if (get_option('display_find_us') == '1') : ?>
296
- <tr>
297
- <td>How did you find us:</td>
298
- <td>
299
- <select name='how_find_us'>
300
- <option value='Word of Mouth'>Word of mouth</option>
301
- <option value='Advertisement'>Advertising</option>
302
- <option value='Internet'>Internet</option>
303
- <option value='Customer'>Existing Customer</option>
304
- </select>
305
- </td>
306
- </tr>
307
- <?php endif; ?>
308
- <tr>
309
- <td colspan='2'>
310
-
311
- <?php //this HTML displays activated payment gateways?>
312
-
313
- <?php if(wpsc_gateway_count() > 1): // if we have more than one gateway enabled, offer the user a choice ?>
314
- <h3><?php echo __('Select a payment gateway', 'wpsc');?></h3>
315
- <?php while (wpsc_have_gateways()) : wpsc_the_gateway(); ?>
316
- <div class="custom_gateway">
317
- <?php if(wpsc_gateway_internal_name() == 'noca'){ ?>
318
- <label><input type="radio" id='noca_gateway' value="<?php echo wpsc_gateway_internal_name();?>" <?php echo wpsc_gateway_is_checked(); ?> name="custom_gateway" class="custom_gateway"/><?php echo wpsc_gateway_name();?></label>
319
- <?php }else{ ?>
320
- <label><input type="radio" value="<?php echo wpsc_gateway_internal_name();?>" <?php echo wpsc_gateway_is_checked(); ?> name="custom_gateway" class="custom_gateway"/><?php echo wpsc_gateway_name();?></label>
321
- <?php } ?>
322
-
323
-
324
- <?php if(wpsc_gateway_form_fields()): ?>
325
- <table class='<?php echo wpsc_gateway_form_field_style();?>'>
326
- <?php echo wpsc_gateway_form_fields();?>
327
- </table>
328
- <?php endif; ?>
329
- </div>
330
- <?php endwhile; ?>
331
- <?php else: // otherwise, there is no choice, stick in a hidden form ?>
332
- <?php while (wpsc_have_gateways()) : wpsc_the_gateway(); ?>
333
- <input name='custom_gateway' value='<?php echo wpsc_gateway_internal_name();?>' type='hidden' />
334
-
335
- <?php if(wpsc_gateway_form_fields()): ?>
336
- <table>
337
- <?php echo wpsc_gateway_form_fields();?>
338
- </table>
339
- <?php endif; ?>
340
- <?php endwhile; ?>
341
- <?php endif; ?>
342
-
343
- </td>
344
- </tr>
345
- <?php if(get_option('terms_and_conditions') != '') : ?>
346
- <tr>
347
- <td colspan='2'>
348
- <input type='checkbox' value='yes' name='agree' /> <?php echo __('I agree to The ', 'wpsc');?><a class='thickbox' target='_blank' href='<?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
349
  echo get_option('siteurl')."?termsandconds=true&amp;width=360&amp;height=400'"; ?>' class='termsandconds'><?php echo __('Terms and Conditions', 'wpsc');?></a>
350
- </td>
351
- </tr>
352
- <?php endif; ?>
353
- <tr>
354
- <td colspan='2'>
355
- <?php if(get_option('terms_and_conditions') == '') : ?>
356
- <input type='hidden' value='yes' name='agree' />
357
- <?php endif; ?>
358
- <?php //exit('<pre>'.print_r($wpsc_gateway->wpsc_gateways[0]['name'], true).'</pre>');
359
- if(count($wpsc_gateway->wpsc_gateways) == 1 && $wpsc_gateway->wpsc_gateways[0]['name'] == 'Noca'){}else{?>
360
- <input type='hidden' value='submit_checkout' name='wpsc_action' />
361
- <input type='submit' value='<?php echo __('Make Purchase', 'wpsc');?>' name='submit' class='make_purchase' />
362
- <?php }/* else: ?>
363
-
364
- <br /><strong><?php echo __('Please login or signup above to make your purchase', 'wpsc');?></strong><br />
365
- <?php echo __('If you have just registered, please check your email and login before you make your purchase', 'wpsc');?>
366
- </td>
367
- <?php endif; */?>
368
- </td>
369
- </tr>
370
- </table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
371
  </form>
372
  </div>
 
 
373
  <?php
374
  else:
375
- echo __('Oops, there is nothing in your cart.', 'wpsc') . "<a href=".get_option("product_list_url").">" . __('Please visit our shop', 'wpsc') . "</a>";
376
  endif;
377
  do_action('wpsc_bottom_of_shopping_cart');
378
- ?>
9
  ?>
10
  <p><?php echo __('Please review your order', 'wpsc'); ?></p>
11
  <table class="productcart">
12
+ <tr class="firstrow">
13
+ <td class='firstcol'></td>
14
+ <td><?php echo __('Product', 'wpsc'); ?>:</td>
15
+ <td><?php echo __('Quantity', 'wpsc'); ?>:</td>
16
+ <?php if(wpsc_uses_shipping()): ?>
17
+ <!-- <td><?php //echo __('Shipping', 'wpsc'); ?>:</td> -->
18
+ <?php endif; ?>
19
+ <td><?php echo __('Price', 'wpsc'); ?>:</td>
20
+
21
+ <td></td>
22
+ </tr>
23
+ <?php while (wpsc_have_cart_items()) : wpsc_the_cart_item(); ?>
24
+
25
+ <?php //this displays the confirm your order html ?>
26
+
27
+ <tr class="product_row product_row_<?php echo wpsc_the_cart_item_key(); ?>">
28
+ <td class="firstcol wpsc_product_image wpsc_product_image_<?php echo wpsc_the_cart_item_key(); ?>"><img src='<?php echo wpsc_cart_item_image(48,48); ?>' alt='<?php echo wpsc_cart_item_name(); ?>' title='<?php echo wpsc_cart_item_name(); ?>' /></td>
29
+ <td class="firstcol wpsc_product_name wpsc_product_name_<?php echo wpsc_the_cart_item_key(); ?>">
30
+ <a href='<?php echo wpsc_cart_item_url();?>'><?php echo wpsc_cart_item_name(); ?></a>
31
+ </td>
32
+ <td class='wpsc_product_quantity wpsc_product_quantity_<?php echo wpsc_the_cart_item_key(); ?>'>
33
+ <form action="<?php echo get_option('shopping_cart_url'); ?>" method="post" class="adjustform">
34
+ <input type="text" name="quantity" size="2" value="<?php echo wpsc_cart_item_quantity(); ?>" />
35
+ <input type="hidden" name="key" value="<?php echo wpsc_the_cart_item_key(); ?>" />
36
+ <input type="hidden" name="wpsc_update_quantity" value="true" />
37
+ <input type="submit" value="<?php echo __('Update', 'wpsc'); ?>" name="submit" />
38
+ </form>
39
+ </td>
40
+ <?php if(wpsc_uses_shipping()): ?>
41
+
42
+ <?php endif; ?>
43
+ <td class='wpsc_product_price wpsc_product_price_<?php echo wpsc_the_cart_item_key(); ?>'><span class="pricedisplay"><?php echo wpsc_cart_item_price(); ?></span></td>
44
+
45
+ <td class='wpsc_product_remove wpsc_product_remove_<?php echo wpsc_the_cart_item_key(); ?>'>
46
+ <form action="<?php echo get_option('shopping_cart_url'); ?>" method="post" class="adjustform">
47
+ <input type="hidden" name="quantity" value="0" />
48
+ <input type="hidden" name="key" value="<?php echo wpsc_the_cart_item_key(); ?>" />
49
+ <input type="hidden" name="wpsc_update_quantity" value="true" />
50
+ <button class='remove_button' type="submit"><span><?php echo __('Remove', 'wpsc'); ?></span></button>
51
+ </form>
52
+ </td>
53
+ </tr>
54
+ <?php endwhile; ?>
55
+ <?php //this HTML displays coupons if there are any active coupons to use ?>
56
+
57
+ <?php //echo "<pre>"; print_r($wpsc_cart); echo "</pre>"; echo "total cart weight: ".wpsc_cart_weight_total();
58
+
59
+ if(wpsc_uses_coupons()): ?>
60
+
61
+ <?php if(wpsc_coupons_error()): ?>
62
+ <tr class='wpsc_coupon_error_row'><td><?php echo __('Coupon is not valid.', 'wpsc'); ?></td></tr>
63
+ <?php endif; ?>
64
+ <tr class='wpsc_coupon_row'>
65
+ <td colspan="2"><?php _e('Enter your coupon number'); ?> :</td>
66
+ <td colspan="3" align='left'>
67
+ <form method='post' action="<?php echo get_option('shopping_cart_url'); ?>">
68
+ <input type='text' name='coupon_num' id='coupon_num' value='<?php echo $wpsc_cart->coupons_name; ?>' />
69
+ <input type='submit' value='<?php echo __('Update', 'wpsc') ?>' />
70
+ </form>
71
+ </td>
72
+ </tr>
73
+ <?php endif; ?>
74
+ </table>
75
+ <p class='wpsc_cost_before'><?php _e('Cost before shipping = ','wpsc'); ?> <?php echo wpsc_cart_total_widget(false,false,false);?></p>
76
+ <?php //this HTML dispalys the calculate your order HTML ?>
77
+
78
+ <?php if(isset($_SESSION['nocamsg']) && isset($_GET['noca']) && $_GET['noca'] == 'confirm'): ?>
79
+ <p class='validation-error'><?php echo $_SESSION['nocamsg']; ?></p>
80
+ <?php endif; ?>
81
+ <?php if($_SESSION['categoryAndShippingCountryConflict'] != '') : ?>
82
+ <p class='validation-error'><?php echo $_SESSION['categoryAndShippingCountryConflict']; ?></p>
83
+ <?php
84
+ endif;
85
+
86
+ if($_SESSION['WpscGatewayErrorMessage'] != '') :
87
+ ?>
88
+ <p class='validation-error'><?php echo $_SESSION['WpscGatewayErrorMessage']; ?></p>
89
+ <?php
90
+ endif;
91
+ ?>
92
+ <?php do_action('wpsc_before_shipping_of_shopping_cart'); ?>
93
+ <div id='wpsc_shopping_cart_container'>
94
+ <?php if(wpsc_uses_shipping()) : ?>
95
+ <h2><?php echo __('Calculate Shipping Price', 'wpsc'); ?></h2>
96
+ <table class="productcart">
97
+ <tr class='wpsc_shipping_info'>
98
+ <td colspan='5'>
99
+ <?php echo __('Please choose a country below to calculate your shipping costs', 'wpsc'); ?>
100
+ </td>
101
+ </tr>
102
+
103
+ <?php if (!wpsc_have_shipping_quote()) : // No valid shipping quotes ?>
104
+ <?php if (($_SESSION['wpsc_zipcode'] == '') || ($_SESSION['wpsc_zipcode'] == 'Your Zipcode')) : // No valid shipping quotes ?>
105
+ <?php if ($_SESSION['wpsc_update_location'] == true) :?>
106
+ <tr class='wpsc_update_location'>
107
+ <td colspan='5' class='shipping_error' >
108
+ <?php echo __('Please provide a Zipcode and click Calculate in order to continue.', 'wpsc'); ?>
109
+ </td>
110
+ </tr>
111
+ <?php endif; ?>
112
+ <?php else: ?>
113
+ <tr class='wpsc_update_location_error'>
114
+ <td colspan='5' class='shipping_error' >
115
+ <?php echo __('Sorry, online ordering is unavailable to this destination and/or weight. Please double check your destination details.', 'wpsc'); ?>
116
+ </td>
117
+ </tr>
118
+ <?php endif; ?>
119
+ <?php endif; ?>
120
+ <tr class='wpsc_change_country'>
121
+ <td colspan='5'>
122
+ <form name='change_country' id='change_country' action='' method='post'>
123
+ <?php echo wpsc_shipping_country_list();?>
124
+ <input type='hidden' name='wpsc_update_location' value='true' />
125
+ <input type='submit' name='wpsc_submit_zipcode' value='Calculate' />
126
+ </form>
127
+ </td>
128
+ </tr>
129
+
130
+ <?php if (wpsc_have_morethanone_shipping_quote()) :?>
131
+ <?php while (wpsc_have_shipping_methods()) : wpsc_the_shipping_method(); ?>
132
+ <?php if (!wpsc_have_shipping_quotes()) { continue; } // Don't display shipping method if it doesn't have at least one quote ?>
133
+ <tr class='wpsc_shipping_header'><td class='shipping_header' colspan='5'><?php echo wpsc_shipping_method_name().__('- Choose a Shipping Rate', 'wpsc'); ?> </td></tr>
134
+ <?php while (wpsc_have_shipping_quotes()) : wpsc_the_shipping_quote(); ?>
135
+ <tr class='<?php echo wpsc_shipping_quote_html_id(); ?>'>
136
+ <td class='wpsc_shipping_quote_name wpsc_shipping_quote_name_<?php echo wpsc_shipping_quote_html_id(); ?>' colspan='3'>
137
+ <label for='<?php echo wpsc_shipping_quote_html_id(); ?>'><?php echo wpsc_shipping_quote_name(); ?></label>
138
+ </td>
139
+ <td class='wpsc_shipping_quote_price wpsc_shipping_quote_price_<?php echo wpsc_shipping_quote_html_id(); ?>' style='text-align:center;'>
140
+ <label for='<?php echo wpsc_shipping_quote_html_id(); ?>'><?php echo wpsc_shipping_quote_value(); ?></label>
141
+ </td>
142
+ <td class='wpsc_shipping_quote_radio wpsc_shipping_quote_radio_<?php echo wpsc_shipping_quote_html_id(); ?>' style='text-align:center;'>
143
+ <?php if(wpsc_have_morethanone_shipping_methods_and_quotes()): ?>
144
+ <input type='radio' id='<?php echo wpsc_shipping_quote_html_id(); ?>' <?php echo wpsc_shipping_quote_selected_state(); ?> onclick='switchmethod("<?php echo wpsc_shipping_quote_name(); ?>", "<?php echo wpsc_shipping_method_internal_name(); ?>")' value='<?php echo wpsc_shipping_quote_value(true); ?>' name='shipping_method' />
145
+ <?php else: ?>
146
+ <input <?php echo wpsc_shipping_quote_selected_state(); ?> disabled='disabled' type='radio' id='<?php echo wpsc_shipping_quote_html_id(); ?>' value='<?php echo wpsc_shipping_quote_value(true); ?>' name='shipping_method' />
147
+ <?php wpsc_update_shipping_single_method(); ?>
148
+ <?php endif; ?>
149
+ </td>
150
+ </tr>
151
+ <?php endwhile; ?>
152
+ <?php endwhile; ?>
153
+ <?php endif; ?>
154
+
155
+ <?php wpsc_update_shipping_multiple_methods(); ?>
156
+
157
+
158
+ <?php if (!wpsc_have_shipping_quote()) : // No valid shipping quotes ?>
159
+ </table>
160
+ </div>
161
+ <?php return; ?>
162
+ <?php endif; ?>
163
+ </table>
164
+ <?php endif; ?>
165
+
166
+ <table class="productcart">
167
+ <tr class="total_price total_tax" <?php if(wpsc_cart_tax(false) < 0) {echo 'style="display:none;"';} ?>>
168
+ <td colspan="3">
169
+ <?php echo wpsc_display_tax_label(true); ?>
170
+
171
+ </td>
172
+ <td colspan="2">
173
+ <span id="checkout_tax" class="pricedisplay checkout-tax"><?php echo wpsc_cart_tax(); ?></span>
174
+ </td>
175
+ </tr>
176
+ </table>
177
+ <?php do_action('wpsc_before_form_of_shopping_cart'); ?>
178
+
179
+ <form class='wpsc_checkout_forms' action='' method='post' enctype="multipart/form-data">
180
+
181
+ <?php
182
+ /**
183
+ * Both the registration forms and the checkout details forms must be in the same form element as they are submitted together, you cannot have two form elements submit together without the use of JavaScript.
184
+ */
185
+ ?>
186
+
187
+ <?php if(!is_user_logged_in() && get_option('users_can_register') && get_option('require_register')) :
188
+ global $current_user;
189
+ get_currentuserinfo(); ?>
190
+ <h2><?php _e('Not yet a member?');?></h2>
191
+ <p><?php _e('In order to buy from us, you\'ll need an account. Joining is free and easy. All you need is a username, password and valid email address.');?></p>
192
+ <?php if(count($_SESSION['wpsc_checkout_user_error_messages']) > 0) : ?>
193
+ <div class="login_error">
194
+ <?php
195
+ foreach($_SESSION['wpsc_checkout_user_error_messages'] as $user_error ) {
196
+ echo $user_error."<br />\n";
197
+ }
198
+ $_SESSION['wpsc_checkout_user_error_messages'] = array();
199
+ ?>
200
+ </div>
201
+ <?php endif; ?>
202
+
203
+
204
+ <fieldset class='wpsc_registration_form'>
205
+ <label><?php _e('Username'); ?>:</label><input type="text" name="log" id="log" value="" size="20"/>
206
+ <label><?php _e('Password'); ?>:</label><input type="password" name="pwd" id="pwd" value="" size="20" />
207
+ <label><?php _e('E-mail'); ?>:</label><input type="text" name="user_email" id="user_email" value="<?php echo attribute_escape(stripslashes($user_email)); ?>" size="20" />
208
+ </fieldset>
209
+ <?php endif; ?>
210
+
211
+ <!--
212
+ <h2><?php //exit('<pre>'.print_r($_SESSION,true).'</pre>');//echo __('Please enter your contact details:', 'wpsc'); ?></h2>
213
+ <?php/* echo __('Note, Once you press submit, you will need to have your Credit card handy.', 'wpsc'); <br /> */?>
214
+ <p><?php //echo __('Fields marked with an asterisk must be filled in.', 'wpsc'); ?></p>
215
+ -->
216
+ <?php
217
+ if(count($_SESSION['wpsc_checkout_misc_error_messages']) > 0) {
218
+ echo "<div class='login_error'>\n\r";
219
+ foreach((array)$_SESSION['wpsc_checkout_misc_error_messages'] as $user_error ) {
220
+ echo $user_error."<br />\n";
221
+ }
222
+ echo "</div>\n\r";
223
+ }
224
+ $_SESSION['wpsc_checkout_misc_error_messages'] =array();
225
+ // wpsc_has_correct_region($_SESSION['wpsc_delivery_country'],$_SESSION['wpsc_delivery_region']);
226
+ ?>
227
+ <table class='wpsc_checkout_table table-1'>
228
+ <?php while (wpsc_have_checkout_items()) : wpsc_the_checkout_item(); ?>
229
+ <?php if(wpsc_checkout_form_is_header() == true) : $i++;?>
230
+ <?php if($i > 1):?>
231
+ </table>
232
+ <table class='wpsc_checkout_table table-<?php echo $i; ?>'>
233
+ <?php endif; ?>
234
+ <tr <?php echo wpsc_the_checkout_item_error_class();?>>
235
+ <td <?php if(wpsc_is_shipping_details()){ echo "class='wpsc_shipping_forms'";}else{echo "class='wpsc_billing_forms'";} ?> colspan='2'>
236
+ <h4><?php echo wpsc_checkout_form_name();?></h4>
237
+ </td>
238
+ </tr>
239
+ <?php if(!wpsc_is_shipping_details() && $i <= 1){?>
240
+ <tr class='same_as_shipping_row'>
241
+ <td colspan ='2'>
242
+ <input type='checkbox' value='true' name='billing_same_as_shipping' id='billing_same_as_shipping' />
243
+ <label for='billing_same_as_shipping'><?php _e('Same as shipping address?','wpsc'); ?></label>
244
+ </td>
245
+ </tr>
246
+ <?php } ?>
247
+ <?php else: ?>
248
+ <?php if((!wpsc_uses_shipping()) && $wpsc_checkout->checkout_item->unique_name == 'shippingstate'): ?>
249
+
250
+ <?php elseif(wpsc_checkout_form_element_id() =='wpsc_checkout_form_8'): ?>
251
+ <div class='wpsc_email_address'>
252
+ <p class='<?php echo wpsc_checkout_form_element_id(); ?>'>
253
+ <label class='wpsc_email_address' for='<?php echo wpsc_checkout_form_element_id(); ?>'>
254
+ <?php echo wpsc_checkout_form_name();?>
255
+
256
+ </label>
257
+ </span>
258
+ <p>
259
+ <?php echo wpsc_checkout_form_field();?>
260
+
261
+ <?php if(wpsc_the_checkout_item_error() != ''): ?>
262
+ <p class='validation-error'><?php echo wpsc_the_checkout_item_error(); ?></span>
263
+
264
+ <?php endif; ?>
265
+ </p>
266
+ </div>
267
+ <?php else : ?>
268
+ <tr <?php echo wpsc_the_checkout_item_error_class();?>>
269
+ <?php // to get rid of shipping state label
270
+ if (wpsc_checkout_form_name() == 'State: '){ ?>
271
+ <td class='shippingstate' colspan='2'>
272
+ <?php if($wpsc_checkout->checkout_item->unique_name != 'shippingstate' || (wpsc_has_regions($_SESSION['wpsc_delivery_country']))){
273
+ echo wpsc_checkout_form_field();
274
+ }else{
275
+ // exit('<pre>'.print_r($_SESSION,true).'</pre>');
276
+ echo '&nbsp;';
277
+ }
278
+ ?>
279
+
280
+ <?php if(wpsc_the_checkout_item_error() != ''): ?>
281
+ <p class='validation-error'><?php echo wpsc_the_checkout_item_error(); ?></p>
282
+
283
+ <?php endif; ?>
284
+ </td>
285
+ <?php }else{?>
286
+ <td class='<?php echo wpsc_checkout_form_element_id(); ?>'>
287
+ <label for='<?php echo wpsc_checkout_form_element_id(); ?>'>
288
+ <?php echo wpsc_checkout_form_name();?>
289
+
290
+ </label>
291
+ </td>
292
+ <td>
293
+ <?php echo wpsc_checkout_form_field();?>
294
+
295
+ <?php if(wpsc_the_checkout_item_error() != ''): ?>
296
+ <p class='validation-error'><?php echo wpsc_the_checkout_item_error(); ?></p>
297
+
298
+ <?php endif; ?>
299
+ </td>
300
+ <?php
301
+ } ?>
302
+ </tr>
303
+ <?php endif; ?>
304
+
305
+ <?php endif; ?>
306
+
307
+ <?php endwhile; ?>
308
+
309
+ <?php if (get_option('display_find_us') == '1') : ?>
310
+ <tr>
311
+ <td>How did you find us:</td>
312
+ <td>
313
+ <select name='how_find_us'>
314
+ <option value='Word of Mouth'>Word of mouth</option>
315
+ <option value='Advertisement'>Advertising</option>
316
+ <option value='Internet'>Internet</option>
317
+ <option value='Customer'>Existing Customer</option>
318
+ </select>
319
+ </td>
320
+ </tr>
321
+ <?php endif; ?>
322
+ <tr>
323
+ <td colspan='2' class='wpsc_gateway_container'>
324
+
325
+ <?php //this HTML displays activated payment gateways?>
326
+
327
+ <?php if(wpsc_gateway_count() > 1): // if we have more than one gateway enabled, offer the user a choice ?>
328
+ <h3><?php echo __('Select a payment gateway', 'wpsc');?></h3>
329
+ <?php while (wpsc_have_gateways()) : wpsc_the_gateway(); ?>
330
+ <div class="custom_gateway">
331
+ <?php if(wpsc_gateway_internal_name() == 'noca'){ ?>
332
+ <label><input type="radio" id='noca_gateway' value="<?php echo wpsc_gateway_internal_name();?>" <?php echo wpsc_gateway_is_checked(); ?> name="custom_gateway" class="custom_gateway"/><?php echo wpsc_gateway_name();?></label>
333
+ <?php }else{ ?>
334
+ <label><input type="radio" value="<?php echo wpsc_gateway_internal_name();?>" <?php echo wpsc_gateway_is_checked(); ?> name="custom_gateway" class="custom_gateway"/><?php echo wpsc_gateway_name();?></label>
335
+ <?php } ?>
336
+
337
+
338
+ <?php if(wpsc_gateway_form_fields()): ?>
339
+ <table class='<?php echo wpsc_gateway_form_field_style();?>'>
340
+ <?php echo wpsc_gateway_form_fields();?>
341
+ </table>
342
+ <?php endif; ?>
343
+ </div>
344
+ <?php endwhile; ?>
345
+ <?php else: // otherwise, there is no choice, stick in a hidden form ?>
346
+ <?php while (wpsc_have_gateways()) : wpsc_the_gateway(); ?>
347
+ <input name='custom_gateway' value='<?php echo wpsc_gateway_internal_name();?>' type='hidden' />
348
+
349
+ <?php if(wpsc_gateway_form_fields()): ?>
350
+ <table>
351
+ <?php echo wpsc_gateway_form_fields();?>
352
+ </table>
353
+ <?php endif; ?>
354
+ <?php endwhile; ?>
355
+ <?php endif; ?>
356
+
357
+ </td>
358
+ </tr>
359
+
360
+ <?php if(get_option('terms_and_conditions') != '') : ?>
361
+ <tr>
362
+ <td colspan='2'>
363
+ <input type='checkbox' value='yes' name='agree' /> <?php echo __('I agree to The ', 'wpsc');?><a class='thickbox' target='_blank' href='<?php
364
  echo get_option('siteurl')."?termsandconds=true&amp;width=360&amp;height=400'"; ?>' class='termsandconds'><?php echo __('Terms and Conditions', 'wpsc');?></a>
365
+ </td>
366
+ </tr>
367
+ <?php endif; ?>
368
+ </table>
369
+
370
+ <table class='wpsc_checkout_table table-4'>
371
+ <tr>
372
+ <td class='wpsc_total_price_and_shipping'colspan='2'>
373
+ <h4><?php echo __('Total Price with Shipping','wpsc'); ?></h4>
374
+ </td>
375
+ </tr>
376
+ <?php if(wpsc_uses_shipping()) : ?>
377
+ <tr class="total_price total_shipping">
378
+ <td class='wpsc_totals'>
379
+ <?php echo __('Total Shipping', 'wpsc'); ?>
380
+ </td>
381
+ <td class='wpsc_totals'>
382
+ <span id="checkout_shipping" class="pricedisplay checkout-shipping"><?php echo wpsc_cart_shipping(); ?></span>
383
+ </td>
384
+ </tr>
385
+ <?php endif; ?>
386
+
387
+ <?php if(wpsc_uses_coupons() && (wpsc_coupon_amount(false) > 0)): ?>
388
+ <tr class="total_price">
389
+ <td class='wpsc_totals'>
390
+ <?php echo __('Discount', 'wpsc'); ?>
391
+ </td>
392
+ <td class='wpsc_totals'>
393
+ <span id="coupons_amount" class="pricedisplay"><?php echo wpsc_coupon_amount(); ?></span>
394
+ </td>
395
+ </tr>
396
+ <?php endif ?>
397
+
398
+
399
+
400
+ <tr class='total_price'>
401
+ <td class='wpsc_totals'>
402
+ <?php echo __('Total Price', 'wpsc'); ?>
403
+ </td>
404
+ <td class='wpsc_totals'>
405
+ <span id='checkout_total' class="pricedisplay checkout-total"><?php echo wpsc_cart_total(); ?></span>
406
+ </td>
407
+ </tr>
408
+ </table>
409
+
410
+ <!-- div for make purchase button -->
411
+ <div class='wpsc_make_purchase'>
412
+ <span>
413
+ <?php if(get_option('terms_and_conditions') == '') : ?>
414
+ <input type='hidden' value='yes' name='agree' />
415
+ <?php endif; ?>
416
+ <?php //exit('<pre>'.print_r($wpsc_gateway->wpsc_gateways[0]['name'], true).'</pre>');
417
+ if(count($wpsc_gateway->wpsc_gateways) == 1 && $wpsc_gateway->wpsc_gateways[0]['name'] == 'Noca'){}else{?>
418
+ <input type='hidden' value='submit_checkout' name='wpsc_action' />
419
+ <input type='submit' value='<?php echo __('Make Purchase', 'wpsc');?>' name='submit' class='make_purchase wpsc_buy_button' />
420
+ <?php }/* else: ?>
421
+
422
+ <br /><strong><?php echo __('Please login or signup above to make your purchase', 'wpsc');?></strong><br />
423
+ <?php echo __('If you have just registered, please check your email and login before you make your purchase', 'wpsc');?>
424
+ </td>
425
+ <?php endif; */?>
426
+ </span>
427
+ </div>
428
  </form>
429
  </div>
430
+
431
+ <div class='clear'></div>
432
  <?php
433
  else:
434
+ echo __('Oops, there is nothing in your cart.', 'wpsc') . "<a href=".get_option("product_list_url").">" . __('Please visit our shop', 'wpsc') . "</a>";
435
  endif;
436
  do_action('wpsc_bottom_of_shopping_cart');
437
+ ?>
themes/default/single_product.php CHANGED
@@ -1,225 +1,225 @@
1
- <?php
2
- global $wpsc_query, $wpdb, $wpsc_custom_meta;
3
- $image_width = get_option('single_view_image_width');
4
- $image_height = get_option('single_view_image_height');
5
- ?>
6
- <div id='products_page_container' class="wrap wpsc_container">
7
-
8
- <?php if(wpsc_has_breadcrumbs()) :?>
9
- <div class='breadcrumb'>
10
- <a href='<?php echo get_option('product_list_url'); ?>'><?php echo get_option('blogname'); ?></a> &raquo;
11
- <?php while (wpsc_have_breadcrumbs()) : wpsc_the_breadcrumb(); ?>
12
- <?php if(wpsc_breadcrumb_url()) :?>
13
- <a href='<?php echo wpsc_breadcrumb_url(); ?>'><?php echo wpsc_breadcrumb_name(); ?></a> &raquo;
14
- <?php else: ?>
15
- <?php echo wpsc_breadcrumb_name(); ?>
16
- <?php endif; ?>
17
- <?php endwhile; ?>
18
- </div>
19
- <?php endif; ?>
20
-
21
- <?php do_action('wpsc_top_of_products_page'); // Plugin hook for adding things to the top of the products page, like the live search ?>
22
-
23
- <div class="productdisplay">
24
- <?php /** start the product loop here, this is single products view, so there should be only one */?>
25
- <?php while (wpsc_have_products()) : wpsc_the_product(); ?>
26
- <div class="single_product_display product_view_<?php echo wpsc_the_product_id(); ?>">
27
- <div class="textcol">
28
- <div class="imagecol">
29
- <?php if(wpsc_the_product_thumbnail()) :?>
30
- <a rel="<?php echo str_replace(array(" ", '"',"'", '&quot;','&#039;'), array("_", "", "", "",''), wpsc_the_product_title()); ?>" class="thickbox preview_link" href="<?php echo wpsc_the_product_image(); ?>">
31
- <img class="product_image" id="product_image_<?php echo wpsc_the_product_id(); ?>" alt="<?php echo wpsc_the_product_title(); ?>" title="<?php echo wpsc_the_product_title(); ?>" src="<?php echo wpsc_the_product_image($image_width, $image_height); ?>" />
32
- </a>
33
- <?php else: ?>
34
- <div class="item_no_image">
35
- <a href="<?php echo wpsc_the_product_permalink(); ?>">
36
- <span>No Image Available</span>
37
- </a>
38
- </div>
39
- <?php endif; ?>
40
- </div>
41
-
42
-
43
- <div class="producttext">
44
- <h2 class="prodtitles"><span><?php echo wpsc_the_product_title(); ?></span><?php echo wpsc_edit_the_product_link(); ?></h2>
45
- <?php
46
- do_action('wpsc_product_before_description', wpsc_the_product_id(), $wpsc_query->product);
47
- ?>
48
- <div class="wpsc_description"><?php echo wpsc_the_product_description(); ?></div>
49
-
50
- <?php
51
- do_action('wpsc_product_addons', wpsc_the_product_id());
52
- ?>
53
- <?php if(wpsc_the_product_additional_description()) : ?>
54
- <div class="single_additional_description">
55
- <?php
56
- $value = '';
57
- $the_addl_desc = wpsc_the_product_additional_description();
58
- if( is_serialized($the_addl_desc) ) {
59
- $addl_descriptions = @unserialize($the_addl_desc);
60
- } else {
61
- $addl_descriptions = array('addl_desc', $the_addl_desc);
62
- }
63
-
64
- if( isset($addl_descriptions['addl_desc']) ) {
65
- $value = $addl_descriptions['addl_desc'];
66
- }
67
-
68
- if( function_exists('wpsc_addl_desc_show') ) {
69
- echo wpsc_addl_desc_show( $addl_descriptions );
70
- } else {
71
- echo stripslashes( wpautop($the_addl_desc, $br=1));
72
- }
73
- ?>
74
- </div>
75
- <?php endif; ?>
76
-
77
- <?php do_action('wpsc_product_addon_after_descr', wpsc_the_product_id()); ?>
78
-
79
- <?php /** the custom meta HTML and loop */ ?>
80
- <?php
81
-
82
- ?>
83
- <div class="custom_meta">
84
- <?php while (wpsc_have_custom_meta()) : wpsc_the_custom_meta(); ?>
85
- <strong><?php echo wpsc_custom_meta_name(); ?>: </strong><?php echo wpsc_custom_meta_value(); ?><br />
86
- <?php endwhile; ?>
87
- </div>
88
- <?php /** the custom meta HTML and loop ends here */?>
89
-
90
- <form class='product_form' enctype="multipart/form-data" action="<?php echo wpsc_this_page_url(); ?>" method="post" name="1" id="product_<?php echo wpsc_the_product_id(); ?>">
91
- <?php if(wpsc_product_has_personal_text()) : ?>
92
- <div class='custom_text'>
93
- <h4><?php echo __('Personalize your product', 'wpsc'); ?></h4>
94
- <?php echo __('Complete this form to include a personalized message with your purchase.', 'wpsc'); ?><br />
95
- <input type='text' name='custom_text' value='' />
96
- </div>
97
- <?php endif; ?>
98
-
99
- <?php if(wpsc_product_has_supplied_file()) : ?>
100
- <div class='custom_file'>
101
- <h4><?php echo __('Upload a File', 'wpsc'); ?></h4>
102
- <?php echo __('Select a file from your computer to include with this purchase. ', 'wpsc'); ?><br />
103
- <input type='file' name='custom_file' value='' />
104
- </div>
105
- <?php endif; ?>
106
-
107
-
108
- <?php /** the variation group HTML and loop */?>
109
- <div class="wpsc_variation_forms">
110
- <?php while (wpsc_have_variation_groups()) : wpsc_the_variation_group(); ?>
111
- <p>
112
- <label for="<?php echo wpsc_vargrp_form_id(); ?>"><?php echo wpsc_the_vargrp_name(); ?>:</label>
113
- <?php /** the variation HTML and loop */?>
114
- <select class='wpsc_select_variation' name="variation[<?php echo wpsc_vargrp_id(); ?>]" id="<?php echo wpsc_vargrp_form_id(); ?>">
115
- <?php while (wpsc_have_variations()) : wpsc_the_variation(); ?>
116
- <option value="<?php echo wpsc_the_variation_id(); ?>" <?php echo wpsc_the_variation_out_of_stock(); ?>><?php echo wpsc_the_variation_name(); ?></option>
117
- <?php endwhile; ?>
118
- </select>
119
- </p>
120
- <?php endwhile; ?>
121
- </div>
122
- <?php /** the variation group HTML and loop ends here */?>
123
-
124
-
125
- <!-- THIS IS THE QUANTITY OPTION MUST BE ENABLED FROM ADMIN SETTINGS -->
126
- <?php if(wpsc_has_multi_adding()): ?>
127
- <label class='wpsc_quantity_update' for='wpsc_quantity_update'><?php echo __('Quantity', 'wpsc'); ?>:</label>
128
-
129
- <input type="text" id='wpsc_quantity_update' name="wpsc_quantity_update" size="2" value="1"/>
130
- <input type="hidden" name="key" value="<?php echo wpsc_the_cart_item_key(); ?>"/>
131
- <input type="hidden" name="wpsc_update_quantity" value="true"/>
132
- <?php endif ;?>
133
-
134
- <div class="wpsc_product_price">
135
- <?php if(wpsc_product_is_donation()) : ?>
136
- <label for='donation_price_<?php echo wpsc_the_product_id(); ?>'><?php echo __('Donation', 'wpsc'); ?>:</label>
137
- <input type='text' id='donation_price_<?php echo wpsc_the_product_id(); ?>' name='donation_price' value='<?php echo $wpsc_query->product['price']; ?>' size='6' />
138
- <br />
139
-
140
-
141
- <?php else : ?>
142
- <?php if(wpsc_product_on_special()) : ?>
143
-
144
- <span class='oldprice'><span id="old_product_price_<?php echo wpsc_the_product_id(); ?>" class="pricedisplay"><?php echo wpsc_product_normal_price(); ?></span><?php echo __('Price', 'wpsc'); ?>:</span><br />
145
- <?php endif; ?>
146
- <span id="product_price_<?php echo wpsc_the_product_id(); ?>" class="pricedisplay"><?php echo wpsc_the_product_price(); ?></span><?php echo __('Price', 'wpsc'); ?>: <br/>
147
- <!-- multi currency code -->
148
- <?php if(wpsc_product_has_multicurrency()) : ?>
149
- <?php echo wpsc_display_product_multicurrency(); ?>
150
- <?php endif; ?>
151
- <!-- end multi currency code -->
152
- <?php if(get_option('display_pnp') == 1) : ?>
153
- <span class="pricedisplay"><?php echo wpsc_product_postage_and_packaging(); ?></span><?php echo __('P&amp;P', 'wpsc'); ?>: <br />
154
- <?php endif; ?>
155
- <?php endif; ?>
156
- </div>
157
- <?php if(function_exists('wpsc_akst_share_link') && (get_option('wpsc_share_this') == 1)) {
158
- echo wpsc_akst_share_link('return');
159
- } ?>
160
-
161
- <input type="hidden" value="add_to_cart" name="wpsc_ajax_action"/>
162
- <input type="hidden" value="<?php echo wpsc_the_product_id(); ?>" name="product_id"/>
163
-
164
- <?php if(wpsc_product_is_customisable()) : ?>
165
- <input type="hidden" value="true" name="is_customisable"/>
166
- <?php endif; ?>
167
-
168
-
169
- <!-- END OF QUANTITY OPTION -->
170
- <?php if((get_option('hide_addtocart_button') == 0) && (get_option('addtocart_or_buynow') !='1')) : ?>
171
- <?php if(wpsc_product_has_stock()) : ?>
172
- <?php if(wpsc_product_external_link(wpsc_the_product_id()) != '') : ?>
173
- <?php $action = wpsc_product_external_link(wpsc_the_product_id()); ?>
174
- <input class="wpsc_buy_button" type='button' value='<?php echo __('Buy Now', 'wpsc'); ?>' onclick='gotoexternallink("<?php echo $action; ?>")'>
175
- <?php else: ?>
176
- <input type="submit" value="<?php echo __('Add To Cart', 'wpsc'); ?>" name="Buy" class="wpsc_buy_button" id="product_<?php echo wpsc_the_product_id(); ?>_submit_button"/>
177
- <?php endif; ?>
178
-
179
- <div class='wpsc_loading_animation'>
180
- <img title="Loading" alt="Loading" src="<?php echo WPSC_URL ;?>/images/indicator.gif" class="loadingimage" />
181
- <?php echo __('Updating cart...', 'wpsc'); ?>
182
- </div>
183
-
184
- <?php else : ?>
185
- <p class='soldout'><?php echo __('This product has sold out.', 'wpsc'); ?></p>
186
- <?php endif ; ?>
187
- <?php endif ; ?>
188
- </form>
189
-
190
- <?php if((get_option('hide_addtocart_button') == 0) && (get_option('addtocart_or_buynow')=='1')) : ?>
191
- <?php echo wpsc_buy_now_button(wpsc_the_product_id()); ?>
192
- <?php endif ; ?>
193
-
194
- <?php echo wpsc_product_rater(); ?>
195
-
196
-
197
- <?php
198
- if(function_exists('gold_shpcrt_display_gallery')) :
199
- echo gold_shpcrt_display_gallery(wpsc_the_product_id());
200
- endif;
201
-
202
- echo wpsc_also_bought(wpsc_the_product_id());
203
- ?>
204
- </div>
205
-
206
- <form onsubmit="submitform(this);return false;" action="<?php echo wpsc_this_page_url(); ?>" method="post" name="product_<?php echo wpsc_the_product_id(); ?>" id="product_extra_<?php echo wpsc_the_product_id(); ?>">
207
- <input type="hidden" value="<?php echo wpsc_the_product_id(); ?>" name="prodid"/>
208
- <input type="hidden" value="<?php echo wpsc_the_product_id(); ?>" name="item"/>
209
- </form>
210
- </div>
211
- </div>
212
- </div>
213
-
214
- <?php echo wpsc_product_comments(); ?>
215
- <?php endwhile; ?>
216
- <?php /** end the product loop here */?>
217
-
218
- <?php
219
- if(function_exists('fancy_notifications')) {
220
- echo fancy_notifications();
221
- }
222
- ?>
223
-
224
-
225
  </div>
1
+ <?php
2
+ global $wpsc_query, $wpdb, $wpsc_custom_meta;
3
+ $image_width = get_option('single_view_image_width');
4
+ $image_height = get_option('single_view_image_height');
5
+ ?>
6
+ <div id='products_page_container' class="wrap wpsc_container">
7
+
8
+ <?php if(wpsc_has_breadcrumbs()) :?>
9
+ <div class='breadcrumb'>
10
+ <a href='<?php echo get_option('product_list_url'); ?>'><?php echo get_option('blogname'); ?></a> &raquo;
11
+ <?php while (wpsc_have_breadcrumbs()) : wpsc_the_breadcrumb(); ?>
12
+ <?php if(wpsc_breadcrumb_url()) :?>
13
+ <a href='<?php echo wpsc_breadcrumb_url(); ?>'><?php echo wpsc_breadcrumb_name(); ?></a> &raquo;
14
+ <?php else: ?>
15
+ <?php echo wpsc_breadcrumb_name(); ?>
16
+ <?php endif; ?>
17
+ <?php endwhile; ?>
18
+ </div>
19
+ <?php endif; ?>
20
+
21
+ <?php do_action('wpsc_top_of_products_page'); // Plugin hook for adding things to the top of the products page, like the live search ?>
22
+
23
+ <div class="productdisplay">
24
+ <?php /** start the product loop here, this is single products view, so there should be only one */?>
25
+ <?php while (wpsc_have_products()) : wpsc_the_product(); ?>
26
+ <div class="single_product_display product_view_<?php echo wpsc_the_product_id(); ?>">
27
+ <div class="textcol">
28
+ <div class="imagecol">
29
+ <?php if(wpsc_the_product_thumbnail()) :?>
30
+ <a rel="<?php echo str_replace(array(" ", '"',"'", '&quot;','&#039;'), array("_", "", "", "",''), wpsc_the_product_title()); ?>" class="thickbox preview_link" href="<?php echo wpsc_the_product_image(); ?>">
31
+ <img class="product_image" id="product_image_<?php echo wpsc_the_product_id(); ?>" alt="<?php echo wpsc_the_product_title(); ?>" title="<?php echo wpsc_the_product_title(); ?>" src="<?php echo wpsc_the_product_image($image_width, $image_height); ?>" />
32
+ </a>
33
+ <?php else: ?>
34
+ <div class="item_no_image">
35
+ <a href="<?php echo wpsc_the_product_permalink(); ?>">
36
+ <span>No Image Available</span>
37
+ </a>
38
+ </div>
39
+ <?php endif; ?>
40
+ </div>
41
+
42
+
43
+ <div class="producttext">
44
+ <h2 class="prodtitles"><span><?php echo wpsc_the_product_title(); ?></span><?php echo wpsc_edit_the_product_link(); ?></h2>
45
+ <?php
46
+ do_action('wpsc_product_before_description', wpsc_the_product_id(), $wpsc_query->product);
47
+ ?>
48
+ <div class="wpsc_description"><?php echo wpsc_the_product_description(); ?></div>
49
+
50
+ <?php
51
+ do_action('wpsc_product_addons', wpsc_the_product_id());
52
+ ?>
53
+ <?php if(wpsc_the_product_additional_description()) : ?>
54
+ <div class="single_additional_description">
55
+ <?php
56
+ $value = '';
57
+ $the_addl_desc = wpsc_the_product_additional_description();
58
+ if( is_serialized($the_addl_desc) ) {
59
+ $addl_descriptions = @unserialize($the_addl_desc);
60
+ } else {
61
+ $addl_descriptions = array('addl_desc', $the_addl_desc);
62
+ }
63
+
64
+ if( isset($addl_descriptions['addl_desc']) ) {
65
+ $value = $addl_descriptions['addl_desc'];
66
+ }
67
+
68
+ if( function_exists('wpsc_addl_desc_show') ) {
69
+ echo wpsc_addl_desc_show( $addl_descriptions );
70
+ } else {
71
+ echo stripslashes( wpautop($the_addl_desc, $br=1));
72
+ }
73
+ ?>
74
+ </div>
75
+ <?php endif; ?>
76
+
77
+ <?php do_action('wpsc_product_addon_after_descr', wpsc_the_product_id()); ?>
78
+
79
+ <?php /** the custom meta HTML and loop */ ?>
80
+ <?php
81
+
82
+ ?>
83
+ <div class="custom_meta">
84
+ <?php while (wpsc_have_custom_meta()) : wpsc_the_custom_meta(); ?>
85
+ <strong><?php echo wpsc_custom_meta_name(); ?>: </strong><?php echo wpsc_custom_meta_value(); ?><br />
86
+ <?php endwhile; ?>
87
+ </div>
88
+ <?php /** the custom meta HTML and loop ends here */?>
89
+
90
+ <form class='product_form' enctype="multipart/form-data" action="<?php echo wpsc_this_page_url(); ?>" method="post" name="1" id="product_<?php echo wpsc_the_product_id(); ?>">
91
+ <?php if(wpsc_product_has_personal_text()) : ?>
92
+ <div class='custom_text'>
93
+ <h4><?php echo __('Personalize your product', 'wpsc'); ?></h4>
94
+ <?php echo __('Complete this form to include a personalized message with your purchase.', 'wpsc'); ?><br />
95
+ <input type='text' name='custom_text' value='' />
96
+ </div>
97
+ <?php endif; ?>
98
+
99
+ <?php if(wpsc_product_has_supplied_file()) : ?>
100
+ <div class='custom_file'>
101
+ <h4><?php echo __('Upload a File', 'wpsc'); ?></h4>
102
+ <?php echo __('Select a file from your computer to include with this purchase. ', 'wpsc'); ?><br />
103
+ <input type='file' name='custom_file' value='' />
104
+ </div>
105
+ <?php endif; ?>
106
+
107
+
108
+ <?php /** the variation group HTML and loop */?>
109
+ <div class="wpsc_variation_forms">
110
+ <?php while (wpsc_have_variation_groups()) : wpsc_the_variation_group(); ?>
111
+ <p>
112
+ <label for="<?php echo wpsc_vargrp_form_id(); ?>"><?php echo wpsc_the_vargrp_name(); ?>:</label>
113
+ <?php /** the variation HTML and loop */?>
114
+ <select class='wpsc_select_variation' name="variation[<?php echo wpsc_vargrp_id(); ?>]" id="<?php echo wpsc_vargrp_form_id(); ?>">
115
+ <?php while (wpsc_have_variations()) : wpsc_the_variation(); ?>
116
+ <option value="<?php echo wpsc_the_variation_id(); ?>" <?php echo wpsc_the_variation_out_of_stock(); ?>><?php echo wpsc_the_variation_name(); ?></option>
117
+ <?php endwhile; ?>
118
+ </select>
119
+ </p>
120
+ <?php endwhile; ?>
121
+ </div>
122
+ <?php /** the variation group HTML and loop ends here */?>
123
+
124
+
125
+ <!-- THIS IS THE QUANTITY OPTION MUST BE ENABLED FROM ADMIN SETTINGS -->
126
+ <?php if(wpsc_has_multi_adding()): ?>
127
+ <label class='wpsc_quantity_update' for='wpsc_quantity_update'><?php echo __('Quantity', 'wpsc'); ?>:</label>
128
+
129
+ <input type="text" id='wpsc_quantity_update' name="wpsc_quantity_update" size="2" value="1"/>
130
+ <input type="hidden" name="key" value="<?php echo wpsc_the_cart_item_key(); ?>"/>
131
+ <input type="hidden" name="wpsc_update_quantity" value="true"/>
132
+ <?php endif ;?>
133
+
134
+ <div class="wpsc_product_price">
135
+ <?php if(wpsc_product_is_donation()) : ?>
136
+ <label for='donation_price_<?php echo wpsc_the_product_id(); ?>'><?php echo __('Donation', 'wpsc'); ?>:</label>
137
+ <input type='text' id='donation_price_<?php echo wpsc_the_product_id(); ?>' name='donation_price' value='<?php echo $wpsc_query->product['price']; ?>' size='6' />
138
+ <br />
139
+
140
+
141
+ <?php else : ?>
142
+ <?php if(wpsc_product_on_special()) : ?>
143
+
144
+ <span class='oldprice'><span id="old_product_price_<?php echo wpsc_the_product_id(); ?>" class="pricedisplay"><?php echo wpsc_product_normal_price(); ?></span><?php echo __('Price', 'wpsc'); ?>:</span><br />
145
+ <?php endif; ?>
146
+ <span id="product_price_<?php echo wpsc_the_product_id(); ?>" class="pricedisplay"><?php echo wpsc_the_product_price(); ?></span><?php echo __('Price', 'wpsc'); ?>: <br/>
147
+ <!-- multi currency code -->
148
+ <?php if(wpsc_product_has_multicurrency()) : ?>
149
+ <?php echo wpsc_display_product_multicurrency(); ?>
150
+ <?php endif; ?>
151
+ <!-- end multi currency code -->
152
+ <?php if(get_option('display_pnp') == 1) : ?>
153
+ <span class="pricedisplay"><?php echo wpsc_product_postage_and_packaging(); ?></span><?php echo __('P&amp;P', 'wpsc'); ?>: <br />
154
+ <?php endif; ?>
155
+ <?php endif; ?>
156
+ </div>
157
+ <?php if(function_exists('wpsc_akst_share_link') && (get_option('wpsc_share_this') == 1)) {
158
+ echo wpsc_akst_share_link('return');
159
+ } ?>
160
+
161
+ <input type="hidden" value="add_to_cart" name="wpsc_ajax_action"/>
162
+ <input type="hidden" value="<?php echo wpsc_the_product_id(); ?>" name="product_id"/>
163
+
164
+ <?php if(wpsc_product_is_customisable()) : ?>
165
+ <input type="hidden" value="true" name="is_customisable"/>
166
+ <?php endif; ?>
167
+
168
+
169
+ <!-- END OF QUANTITY OPTION -->
170
+ <?php if((get_option('hide_addtocart_button') == 0) && (get_option('addtocart_or_buynow') !='1')) : ?>
171
+ <?php if(wpsc_product_has_stock()) : ?>
172
+ <?php if(wpsc_product_external_link(wpsc_the_product_id()) != '') : ?>
173
+ <?php $action = wpsc_product_external_link(wpsc_the_product_id()); ?>
174
+ <input class="wpsc_buy_button" type='button' value='<?php echo __('Buy Now', 'wpsc'); ?>' onclick='gotoexternallink("<?php echo $action; ?>")'>
175
+ <?php else: ?>
176
+ <input type="submit" value="<?php echo __('Add To Cart', 'wpsc'); ?>" name="Buy" class="wpsc_buy_button" id="product_<?php echo wpsc_the_product_id(); ?>_submit_button"/>
177
+ <?php endif; ?>
178
+
179
+ <div class='wpsc_loading_animation'>
180
+ <img title="Loading" alt="Loading" src="<?php echo WPSC_URL ;?>/images/indicator.gif" class="loadingimage" />
181
+ <?php echo __('Updating cart...', 'wpsc'); ?>
182
+ </div>
183
+
184
+ <?php else : ?>
185
+ <p class='soldout'><?php echo __('This product has sold out.', 'wpsc'); ?></p>
186
+ <?php endif ; ?>
187
+ <?php endif ; ?>
188
+ </form>
189
+
190
+ <?php if((get_option('hide_addtocart_button') == 0) && (get_option('addtocart_or_buynow')=='1')) : ?>
191
+ <?php echo wpsc_buy_now_button(wpsc_the_product_id()); ?>
192
+ <?php endif ; ?>
193
+
194
+ <?php echo wpsc_product_rater(); ?>
195
+
196
+
197
+ <?php
198
+ if(function_exists('gold_shpcrt_display_gallery')) :
199
+ echo gold_shpcrt_display_gallery(wpsc_the_product_id());
200
+ endif;
201
+
202
+ echo wpsc_also_bought(wpsc_the_product_id());
203
+ ?>
204
+ </div>
205
+
206
+ <form onsubmit="submitform(this);return false;" action="<?php echo wpsc_this_page_url(); ?>" method="post" name="product_<?php echo wpsc_the_product_id(); ?>" id="product_extra_<?php echo wpsc_the_product_id(); ?>">
207
+ <input type="hidden" value="<?php echo wpsc_the_product_id(); ?>" name="prodid"/>
208
+ <input type="hidden" value="<?php echo wpsc_the_product_id(); ?>" name="item"/>
209
+ </form>
210
+ </div>
211
+ </div>
212
+ </div>
213
+
214
+ <?php echo wpsc_product_comments(); ?>
215
+ <?php endwhile; ?>
216
+ <?php /** end the product loop here */?>
217
+
218
+ <?php
219
+ if(function_exists('fancy_notifications')) {
220
+ echo fancy_notifications();
221
+ }
222
+ ?>
223
+
224
+
225
  </div>
themes/iShop/shopping_cart_page.php CHANGED
@@ -204,7 +204,7 @@ if(wpsc_cart_item_count() > 0) :
204
  <fieldset class='wpsc_registration_form'>
205
  <label><?php _e('Username'); ?>:</label><input type="text" name="log" id="log" value="" size="20"/>
206
  <label><?php _e('Password'); ?>:</label><input type="password" name="pwd" id="pwd" value="" size="20" />
207
- <label><?php _e('E-mail'); ?>:</label><input type="text" name="user_email" id="user_email" value="<?php echo attribute_escape(stripslashes($user_email)); ?>" size="20" />
208
  </fieldset>
209
  <?php endif; ?>
210
 
204
  <fieldset class='wpsc_registration_form'>
205
  <label><?php _e('Username'); ?>:</label><input type="text" name="log" id="log" value="" size="20"/>
206
  <label><?php _e('Password'); ?>:</label><input type="password" name="pwd" id="pwd" value="" size="20" />
207
+ <label><?php _e('E-mail'); ?>:</label><input type="text" name="user_email" id="user_email" value="<?php echo esc_attr(stripslashes($user_email)); ?>" size="20" />
208
  </fieldset>
209
  <?php endif; ?>
210
 
themes/marketplace/shopping_cart_page.php CHANGED
@@ -203,7 +203,7 @@ if(wpsc_cart_item_count() > 0) :
203
  <fieldset class='wpsc_registration_form'>
204
  <label><?php _e('Username'); ?>:</label><input type="text" name="log" id="log" value="" size="20"/>
205
  <label><?php _e('Password'); ?>:</label><input type="password" name="pwd" id="pwd" value="" size="20" />
206
- <label><?php _e('E-mail'); ?>:</label><input type="text" name="user_email" id="user_email" value="<?php echo attribute_escape(stripslashes($user_email)); ?>" size="20" />
207
  </fieldset>
208
  <?php endif; ?>
209
 
203
  <fieldset class='wpsc_registration_form'>
204
  <label><?php _e('Username'); ?>:</label><input type="text" name="log" id="log" value="" size="20"/>
205
  <label><?php _e('Password'); ?>:</label><input type="password" name="pwd" id="pwd" value="" size="20" />
206
+ <label><?php _e('E-mail'); ?>:</label><input type="text" name="user_email" id="user_email" value="<?php echo esc_attr(stripslashes($user_email)); ?>" size="20" />
207
  </fieldset>
208
  <?php endif; ?>
209
 
themes/single-wpsc-product.php CHANGED
@@ -179,15 +179,26 @@ get_header();
179
  <input type="hidden" value="true" name="is_customisable"/>
180
  <?php endif; ?>
181
 
182
- <!-- END OF QUANTITY OPTION -->
183
- <?php if((get_option('hide_addtocart_button') == 0) && (get_option('addtocart_or_buynow') !='1')) : ?>
184
- <?php if(wpsc_product_has_stock()) : ?>
 
 
 
185
  <?php if(wpsc_product_external_link(wpsc_the_product_id()) != '') : ?>
186
- <?php $action = wpsc_product_external_link(wpsc_the_product_id()); ?>
187
- <input class="wpsc_buy_button" type='button' value='<?php echo __('Buy Now', 'wpsc'); ?>' onclick='gotoexternallink("<?php echo $action; ?>")'>
188
- <?php else: ?>
189
- <input type="submit" value="<?php echo __('Add To Cart', 'wpsc'); ?>" name="Buy" class="wpsc_buy_button" id="product_<?php echo wpsc_the_product_id(); ?>_submit_button"/>
190
- <?php endif; ?>
 
 
 
 
 
 
 
 
191
 
192
  <div class='wpsc_loading_animation'>
193
  <img title="Loading" alt="Loading" src="<?php echo WPSC_URL ;?>/images/indicator.gif" class="loadingimage" />
@@ -197,10 +208,9 @@ get_header();
197
  if(function_exists('fancy_notifications')) {
198
  echo fancy_notifications();
199
  }
200
- ?>
201
  <?php else : ?>
202
  <p class='soldout'><?php echo __('This product has sold out.', 'wpsc'); ?></p>
203
- <?php endif ; ?>
204
  <?php endif ; ?>
205
  </form>
206
 
179
  <input type="hidden" value="true" name="is_customisable"/>
180
  <?php endif; ?>
181
 
182
+
183
+
184
+ <?php if( wpsc_product_has_stock() ) :
185
+ // Checks if has stock
186
+ ?>
187
+
188
  <?php if(wpsc_product_external_link(wpsc_the_product_id()) != '') : ?>
189
+ <?php $action = 'onclick=\'gotoexternallink("'.wpsc_product_external_link(wpsc_the_product_id()).'")\'';
190
+ else:
191
+ $action = '';
192
+ endif;
193
+ ?>
194
+ <!-- END OF QUANTITY OPTION -->
195
+ <?php if((get_option('hide_addtocart_button') == 0) && (get_option('addtocart_or_buynow') !='1')) :
196
+ //Add to Cart button
197
+ ?>
198
+ <input class="wpsc_buy_button" type='submit' id="product_<?php echo wpsc_the_product_id(); ?>_submit_button" value='<?php echo __('Add to Cart', 'wpsc'); ?>' <?php echo $action; ?>>
199
+ <?php else: ?>
200
+ <input type="submit" value="<?php echo __('Buy Now:', 'wpsc'); ?>" name="Buy" class="wpsc_buy_button" id="product_<?php echo wpsc_the_product_id(); ?>_submit_button" <?php echo $action; ?> />
201
+ <?php endif; ?>
202
 
203
  <div class='wpsc_loading_animation'>
204
  <img title="Loading" alt="Loading" src="<?php echo WPSC_URL ;?>/images/indicator.gif" class="loadingimage" />
208
  if(function_exists('fancy_notifications')) {
209
  echo fancy_notifications();
210
  }
211
+ ?>
212
  <?php else : ?>
213
  <p class='soldout'><?php echo __('This product has sold out.', 'wpsc'); ?></p>
 
214
  <?php endif ; ?>
215
  </form>
216
 
widgets/admin_menu_widget.php CHANGED
@@ -18,8 +18,8 @@ function widget_admin_menu($args){
18
  function widget_admin_menu_control() { return null; }
19
 
20
  function widget_admin_menu_init() {
21
- if(function_exists('register_sidebar_widget')) {
22
- register_sidebar_widget(__('Admin Menu', 'wpsc'), 'widget_admin_menu');
23
  #register_widget_control('Admin Menu', 'widget_admin_menu', 300, 90);
24
  }
25
  return;
18
  function widget_admin_menu_control() { return null; }
19
 
20
  function widget_admin_menu_init() {
21
+ if(function_exists('wp_register_sidebar_widget')) {
22
+ wp_register_sidebar_widget('widget_admin_menu', __('Admin Menu', 'wpsc'), 'widget_admin_menu');
23
  #register_widget_control('Admin Menu', 'widget_admin_menu', 300, 90);
24
  }
25
  return;
widgets/category_widget.27.php CHANGED
@@ -90,7 +90,7 @@ function widget_wpsc_categorisation_control( $widget_args = 1 ) {
90
  if ((!isset($widget_wpsc_categorisation_instance['title']) && isset($options[$widget_number])) || ($options[$widget_number]['check'] == 1)) {// user clicked cancel or no changes made
91
  continue;
92
  }
93
- $options[$widget_number]['title'] = wp_specialchars($widget_wpsc_categorisation_instance['title']);
94
  $categorisation_groups = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_CATEGORISATION_GROUPS."` WHERE `active` IN ('1')", ARRAY_A);
95
 
96
 
@@ -122,7 +122,7 @@ function widget_wpsc_categorisation_control( $widget_args = 1 ) {
122
  $something = '';
123
  $number = '%i%';
124
  } else {
125
- $title = attribute_escape($options[$number]['title']);
126
  }
127
 
128
 
90
  if ((!isset($widget_wpsc_categorisation_instance['title']) && isset($options[$widget_number])) || ($options[$widget_number]['check'] == 1)) {// user clicked cancel or no changes made
91
  continue;
92
  }
93
+ $options[$widget_number]['title'] = esc_html($widget_wpsc_categorisation_instance['title']);
94
  $categorisation_groups = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_CATEGORISATION_GROUPS."` WHERE `active` IN ('1')", ARRAY_A);
95
 
96
 
122
  $something = '';
123
  $number = '%i%';
124
  } else {
125
+ $title = esc_attr($options[$number]['title']);
126
  }
127
 
128
 
widgets/donations_widget.php CHANGED
@@ -120,9 +120,9 @@ function widget_donations_control() {
120
  * Displays the products
121
  */
122
  function widget_donations_init() {
123
- if(function_exists('register_sidebar_widget')) {
124
- register_sidebar_widget(__('Product Donations', 'wpsc'), 'widget_donations');
125
- register_widget_control(__('Product Donations', 'wpsc'), 'widget_donations_control');
126
  }
127
  return;
128
  }
120
  * Displays the products
121
  */
122
  function widget_donations_init() {
123
+ if(function_exists('wp_register_sidebar_widget')) {
124
+ wp_register_sidebar_widget('widget_donations', __('Product Donations', 'wpsc'), 'widget_donations');
125
+ wp_register_widget_control('widget_donations', __('Product Donations', 'wpsc'), 'widget_donations_control');
126
  }
127
  return;
128
  }
widgets/latest_product_widget.php CHANGED
@@ -116,9 +116,9 @@ function widget_latest_products_control() {
116
  * Displays the products
117
  */
118
  function widget_latest_products_init() {
119
- if(function_exists('register_sidebar_widget')) {
120
- register_sidebar_widget(__('Latest Products', 'wpsc'), 'widget_latest_products');
121
- register_widget_control(__('Latest Products', 'wpsc'), 'widget_latest_products_control');
122
  }
123
  return;
124
  }
116
  * Displays the products
117
  */
118
  function widget_latest_products_init() {
119
+ if(function_exists('wp_register_sidebar_widget')) {
120
+ wp_register_sidebar_widget('widget_latest_products', __('Latest Products', 'wpsc'), 'widget_latest_products');
121
+ wp_register_widget_control('widget_latest_products', __('Latest Products', 'wpsc'), 'widget_latest_products_control');
122
  }
123
  return;
124
  }
widgets/price_range_widget.php CHANGED
@@ -73,9 +73,9 @@ function widget_price_range_control() {
73
  }
74
 
75
  function widget_price_range_init() {
76
- if(function_exists('register_sidebar_widget')) {
77
- register_sidebar_widget(__('Price Range', 'wpsc'), 'widget_price_range');
78
- register_widget_control(__('Price Range', 'wpsc'), 'widget_price_range_control');
79
  }
80
  return;
81
  }
73
  }
74
 
75
  function widget_price_range_init() {
76
+ if(function_exists('wp_register_sidebar_widget')) {
77
+ wp_register_sidebar_widget('widget_price_range', __('Price Range', 'wpsc'), 'widget_price_range');
78
+ wp_register_widget_control('widget_price_range', __('Price Range', 'wpsc'), 'widget_price_range_control');
79
  }
80
  return;
81
  }
widgets/product_tag_widget.php CHANGED
@@ -32,11 +32,11 @@ function widget_product_tag_control() {
32
  }
33
 
34
  function widget_product_tag_init() {
35
- if(function_exists('register_sidebar_widget')) {
36
  //$widget_ops = array('classname' => 'widget_pages', 'description' => __( "Your blog's WordPress Pages") );
37
  //wp_register_sidebar_widget('pages', __('Pages'), 'wp_widget_pages', $widget_ops);
38
- register_sidebar_widget(__('Product Tags', 'wpsc'), 'widget_product_tag');
39
- register_widget_control(__('Product Tags', 'wpsc'), 'widget_product_tag_control');
40
  }
41
  return;
42
  }
32
  }
33
 
34
  function widget_product_tag_init() {
35
+ if(function_exists('wp_register_sidebar_widget')) {
36
  //$widget_ops = array('classname' => 'widget_pages', 'description' => __( "Your blog's WordPress Pages") );
37
  //wp_register_sidebar_widget('pages', __('Pages'), 'wp_widget_pages', $widget_ops);
38
+ wp_register_sidebar_widget('widget_product_tag', __('Product Tags', 'wpsc'), 'widget_product_tag');
39
+ wp_register_widget_control('widget_product_tag', __('Product Tags', 'wpsc'), 'widget_product_tag_control');
40
  }
41
  return;
42
  }
widgets/shopping_cart_widget.php CHANGED
@@ -70,16 +70,16 @@ function widget_wp_shopping_cart_control() {
70
  }
71
 
72
  function widget_wp_shopping_cart_init() {
73
- if(function_exists('register_sidebar_widget')) {
74
  $widget_ops['description'] = "Your most used tags in cloud format";
75
- register_sidebar_widget('Shopping Cart', 'widget_wp_shopping_cart', $widget_ops);
76
- register_widget_control('Shopping Cart', 'widget_wp_shopping_cart_control');
77
  $GLOBALS['wpsc_cart_widget'] = true;
78
  if(get_option('cart_location') == 1) {
79
  update_option('cart_location', 4);
80
  remove_action('wp_list_pages','nzshpcrt_shopping_basket');
81
  }
82
- #register_widget_control('Shopping Cart', 'widget_wp_shopping_cart_control', 300, 90);
83
  }
84
  return;
85
  }
70
  }
71
 
72
  function widget_wp_shopping_cart_init() {
73
+ if(function_exists('wp_register_sidebar_widget')) {
74
  $widget_ops['description'] = "Your most used tags in cloud format";
75
+ wp_register_sidebar_widget('widget_wp_shopping_cart', 'Shopping Cart', 'widget_wp_shopping_cart', $widget_ops);
76
+ wp_register_widget_control('widget_wp_shopping_cart', 'Shopping Cart', 'widget_wp_shopping_cart_control');
77
  $GLOBALS['wpsc_cart_widget'] = true;
78
  if(get_option('cart_location') == 1) {
79
  update_option('cart_location', 4);
80
  remove_action('wp_list_pages','nzshpcrt_shopping_basket');
81
  }
82
+ #wp_register_widget_control('Shopping Cart', 'widget_wp_shopping_cart_control', 300, 90);
83
  }
84
  return;
85
  }
widgets/specials_widget.php CHANGED
@@ -133,9 +133,9 @@ function widget_specials_control() {
133
  * Displays the products
134
  */
135
  function widget_specials_init() {
136
- if(function_exists('register_sidebar_widget')) {
137
- register_sidebar_widget(__('Product Specials', 'wpsc'), 'widget_specials');
138
- register_widget_control(__('Product Specials', 'wpsc'), 'widget_specials_control');
139
  }
140
  return;
141
  }
133
  * Displays the products
134
  */
135
  function widget_specials_init() {
136
+ if(function_exists('wp_register_sidebar_widget')) {
137
+ wp_register_sidebar_widget('widget_specials', __('Product Specials', 'wpsc'), 'widget_specials');
138
+ wp_register_widget_control('widget_specials', __('Product Specials', 'wpsc'), 'widget_specials_control');
139
  }
140
  return;
141
  }
wp-shopping-cart.php CHANGED
@@ -33,8 +33,6 @@ define('IS_WP27', version_compare($version_processing[0], '2.7', '>='));
33
  define('IS_WP29', version_compare($version_processing[0], '2.9', '>='));
34
  define('IS_WP30', version_compare($version_processing[0], '3.0', '>='));
35
 
36
-
37
-
38
  // // we need to know where we are, rather than assuming where we are
39
 
40
  //Define the path to the plugin folder
@@ -153,8 +151,12 @@ require_once(WPSC_FILE_PATH."/wpsc-includes/form-display.functions.php");
153
  require_once(WPSC_FILE_PATH."/wpsc-includes/merchant.class.php");
154
  require_once(WPSC_FILE_PATH."/wpsc-includes/meta.functions.php");
155
  require_once(WPSC_FILE_PATH."/wpsc-includes/productfeed.php");
 
 
 
 
156
  //exit(print_r($v1,true));
157
- if($v1[0] >= 2.8){
158
  require_once(WPSC_FILE_PATH."/wpsc-includes/upgrades.php");
159
  }
160
 
@@ -174,7 +176,9 @@ $wpsc_currency_data = array();
174
  $wpsc_title_data = array();
175
  $GLOBALS['nzshpcrt_imagesize_info'] = __('Note: if this is blank, the image will not be resized', 'wpsc');
176
  $nzshpcrt_log_states[0]['name'] = __('Order Received', 'wpsc');
177
- $nzshpcrt_log_states[1]['name'] = TXT_WPSC_PROCESSING;
 
 
178
  $nzshpcrt_log_states[2]['name'] = __('Closed Order', 'wpsc');
179
 
180
 
@@ -206,7 +210,7 @@ include_once(WPSC_FILE_PATH.'/image_processing.php');
206
 
207
 
208
  // if we are in the admin section, include the admin code
209
- if(WP_ADMIN == true) {
210
  require_once(WPSC_FILE_PATH."/wpsc-admin/admin.php");
211
  }
212
 
@@ -234,8 +238,16 @@ if(IS_WPMU == 1) {
234
 
235
  $wp_upload_dir_data = wp_upload_dir();
236
  //echo "<pre>".print_r($wp_upload_dir_data, true)."</pre>";
237
- $upload_path = $wp_upload_dir_data['basedir'];
238
- $upload_url = $wp_upload_dir_data['baseurl'];
 
 
 
 
 
 
 
 
239
 
240
  if(is_ssl()) {
241
  $upload_url = str_replace("http://", "https://", $upload_url);
@@ -358,7 +370,7 @@ if(count(explode(".",$current_version_number)) > 2) {
358
 
359
 
360
  //if there are any upgrades present, include them., thanks to nielo.info and lsdev.biz
361
- if($v1[0] >= 2.8){
362
  $upgrades = get_upgrades();
363
  foreach ($upgrades as $path=>$upgrade) {
364
  $upgrade_file = WPSC_UPGRADES_DIR . '/' . $path;
@@ -377,7 +389,7 @@ register_activation_hook(__FILE__, 'wpsc_install');
377
  if(!function_exists('wpsc_start_the_query')) {
378
  function wpsc_start_the_query() {
379
  global $wp_query, $wpsc_query, $wpsc_query_vars;
380
-
381
 
382
  if($wpsc_query == null) {
383
  if(count($wpsc_query_vars) < 1) {
@@ -413,8 +425,8 @@ if(!function_exists('wpsc_start_the_query')) {
413
 
414
  //echo "<pre>".print_r($wpsc_query_vars,true)."</pre>";
415
  //echo "<pre>".print_r($wpsc_query,true)."</pre>";
416
-
417
- $post_id = $wp_query->post->ID;
418
  $page_url = get_permalink($post_id);
419
  if(get_option('shopping_cart_url') == $page_url) {
420
  $_SESSION['wpsc_has_been_to_checkout'] = true;
@@ -430,6 +442,9 @@ add_action('template_redirect', 'wpsc_start_the_query', 0);
430
  /**
431
  * Check to see if the session exists, if not, start it
432
  */
 
 
 
433
  if((!is_array($_SESSION)) xor (!isset($_SESSION['nzshpcrt_cart'])) xor (!$_SESSION)) {
434
  session_start();
435
  }
@@ -525,6 +540,7 @@ function wpsc_register_post_types() {
525
  'label' => __('Products'),
526
  'singular_label' => __('Product'),
527
  'query_var' => true,
 
528
  'rewrite' => array(
529
  'slug' => $wpsc_page_titles['products'].'/%wpsc_product_category%',
530
  'with_front' => false
@@ -734,7 +750,7 @@ jQuery('.featured_toggle_<?php echo $product_id; ?>').html("<img class='grey-sta
734
  }
735
 
736
 
737
- if($_REQUEST['wpsc_admin_action'] == 'update_featured_product') {
738
  add_action('admin_init', 'wpsc_update_featured_products');
739
  }
740
 
@@ -836,4 +852,4 @@ function wpsc_display_featured_products_page() {
836
  }
837
 
838
  add_action('wpsc_top_of_products_page', 'wpsc_display_featured_products_page', 12);
839
- ?>
33
  define('IS_WP29', version_compare($version_processing[0], '2.9', '>='));
34
  define('IS_WP30', version_compare($version_processing[0], '3.0', '>='));
35
 
 
 
36
  // // we need to know where we are, rather than assuming where we are
37
 
38
  //Define the path to the plugin folder
151
  require_once(WPSC_FILE_PATH."/wpsc-includes/merchant.class.php");
152
  require_once(WPSC_FILE_PATH."/wpsc-includes/meta.functions.php");
153
  require_once(WPSC_FILE_PATH."/wpsc-includes/productfeed.php");
154
+
155
+ //add taxes
156
+ require_once(WPSC_FILE_PATH."/wpec-taxes/taxes_module.php");
157
+
158
  //exit(print_r($v1,true));
159
+ if(isset($v1[0]) && ($v1[0] >= 2.8)){
160
  require_once(WPSC_FILE_PATH."/wpsc-includes/upgrades.php");
161
  }
162
 
176
  $wpsc_title_data = array();
177
  $GLOBALS['nzshpcrt_imagesize_info'] = __('Note: if this is blank, the image will not be resized', 'wpsc');
178
  $nzshpcrt_log_states[0]['name'] = __('Order Received', 'wpsc');
179
+ $nzshpcrt_log_states[1]['name'] = '';
180
+ if (defined('TXT_WPSC_PROCESSING'))
181
+ $nzshpcrt_log_states[1]['name'] = TXT_WPSC_PROCESSING;
182
  $nzshpcrt_log_states[2]['name'] = __('Closed Order', 'wpsc');
183
 
184
 
210
 
211
 
212
  // if we are in the admin section, include the admin code
213
+ if(defined('WP_ADMIN') && (WP_ADMIN == true)) {
214
  require_once(WPSC_FILE_PATH."/wpsc-admin/admin.php");
215
  }
216
 
238
 
239
  $wp_upload_dir_data = wp_upload_dir();
240
  //echo "<pre>".print_r($wp_upload_dir_data, true)."</pre>";
241
+ $upload_path = '';
242
+ $upload_url = '';
243
+
244
+ if (isset($wp_upload_dir_data['basedir'])) {
245
+ $upload_path = $wp_upload_dir_data['basedir'];
246
+ }
247
+
248
+ if (isset($wp_upload_dir_data['baseurl'])) {
249
+ $upload_url = $wp_upload_dir_data['baseurl'];
250
+ }
251
 
252
  if(is_ssl()) {
253
  $upload_url = str_replace("http://", "https://", $upload_url);
370
 
371
 
372
  //if there are any upgrades present, include them., thanks to nielo.info and lsdev.biz
373
+ if(isset($v1[0]) && ($v1[0] >= 2.8)){
374
  $upgrades = get_upgrades();
375
  foreach ($upgrades as $path=>$upgrade) {
376
  $upgrade_file = WPSC_UPGRADES_DIR . '/' . $path;
389
  if(!function_exists('wpsc_start_the_query')) {
390
  function wpsc_start_the_query() {
391
  global $wp_query, $wpsc_query, $wpsc_query_vars;
392
+ $post_id = 0;
393
 
394
  if($wpsc_query == null) {
395
  if(count($wpsc_query_vars) < 1) {
425
 
426
  //echo "<pre>".print_r($wpsc_query_vars,true)."</pre>";
427
  //echo "<pre>".print_r($wpsc_query,true)."</pre>";
428
+ if(isset($wp_query->post->ID))
429
+ $post_id = $wp_query->post->ID;
430
  $page_url = get_permalink($post_id);
431
  if(get_option('shopping_cart_url') == $page_url) {
432
  $_SESSION['wpsc_has_been_to_checkout'] = true;
442
  /**
443
  * Check to see if the session exists, if not, start it
444
  */
445
+
446
+ if (!isset($_SESSION)) $_SESSION = null;
447
+
448
  if((!is_array($_SESSION)) xor (!isset($_SESSION['nzshpcrt_cart'])) xor (!$_SESSION)) {
449
  session_start();
450
  }
540
  'label' => __('Products'),
541
  'singular_label' => __('Product'),
542
  'query_var' => true,
543
+ 'register_meta_box_cb' => 'wpsc_meta_boxes',
544
  'rewrite' => array(
545
  'slug' => $wpsc_page_titles['products'].'/%wpsc_product_category%',
546
  'with_front' => false
750
  }
751
 
752
 
753
+ if(isset($_REQUEST['wpsc_admin_action']) && ($_REQUEST['wpsc_admin_action'] == 'update_featured_product')) {
754
  add_action('admin_init', 'wpsc_update_featured_products');
755
  }
756
 
852
  }
853
 
854
  add_action('wpsc_top_of_products_page', 'wpsc_display_featured_products_page', 12);
855
+ ?>
wpec-taxes/controllers/taxes_controller.class.php ADDED
@@ -0,0 +1,599 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author: Jeremy Smith - www.dnawebagency.com
4
+ * @description: wpec_taxes_controller contains all of the functions necessary
5
+ * to communicate with the taxes system.
6
+ **/
7
+ class wpec_taxes_controller
8
+ {
9
+ function __construct()
10
+ {
11
+ $this->wpec_taxes = new wpec_taxes();
12
+ }// __construct
13
+
14
+ /**
15
+ * @description: wpec_taxes_isincluded - returns true or false depending on
16
+ * whether or not the taxes are inclusive.
17
+ * @param: void
18
+ * @return: boolean true or false
19
+ **/
20
+ function wpec_taxes_isincluded()
21
+ {
22
+ return ($this->wpec_taxes->wpec_taxes_get_inprice()=='inclusive') ? true : false;
23
+ }// wpec_taxes_isincluded
24
+
25
+ /**
26
+ * @description: wpec_taxes_calculate_total - takes into account all tax logic
27
+ * settings and returns the calculated total tax.
28
+ * Expects wpsc_cart to be set.
29
+ *
30
+ * @param: void
31
+ * @return: array containing total tax and rate if applicable
32
+ **/
33
+ function wpec_taxes_calculate_total()
34
+ {
35
+ //get the cart - NOTE: billing country is selected_country and shipping country is delivery_country
36
+ global $wpsc_cart;
37
+
38
+ //initialize return variable
39
+ $returnable = 0;
40
+
41
+ //check if tax is enabled
42
+ if($this->wpec_taxes->wpec_taxes_get_enabled())
43
+ {
44
+ //get base country code
45
+ $wpec_base_country = get_option('base_country');
46
+
47
+ //run tax logic and calculate tax
48
+ if($this->wpec_taxes_run_logic())
49
+ {
50
+ //set tax region
51
+ $region = $this->wpec_taxes_retrieve_region();
52
+
53
+ //if the tax is inclusive calculate vat
54
+ if($this->wpec_taxes_isincluded())
55
+ {
56
+ //start the total_tax off at 0
57
+ $total_tax = 0;
58
+
59
+ //loop through products
60
+ foreach($wpsc_cart->cart_items as $cart_item)
61
+ {
62
+ //run wpec_taxes_calculate_included_tax
63
+ $taxes = $this->wpec_taxes_calculate_included_tax($cart_item);
64
+
65
+ $total_tax += $taxes['tax'];
66
+ }// foreach
67
+
68
+ $returnable = array('total'=>$total_tax);
69
+ }
70
+ else
71
+ {
72
+ //check if there are any rates setup for the base_country
73
+ if($this->wpec_taxes_rate_exists($wpec_base_country))
74
+ {
75
+ //calculate subtotal for the items
76
+ $taxable_total = $wpsc_cart->calculate_subtotal();
77
+
78
+ //get the rate for the country and region if set
79
+ $tax_rate = $this->wpec_taxes->wpec_taxes_get_rate($wpec_base_country, $region);
80
+
81
+ //is the region configured to apply tax on shipping? if so add shipping price to the taxable total
82
+ if($tax_rate['shipping'])
83
+ {
84
+ $taxable_total += $wpsc_cart->calculate_total_shipping();
85
+ }// if
86
+
87
+ //calculate tax
88
+ $returnable = array('total'=>$this->wpec_taxes_calculate_tax($taxable_total, $tax_rate['rate']), 'rate'=>$tax_rate['rate']);
89
+ }// if
90
+ }// if
91
+ }// if
92
+ } //if
93
+
94
+ return $returnable;
95
+ }// wpec_taxes_calculate_total
96
+
97
+ /**
98
+ * @description: wpec_taxes_run_logic - runs the tax logic as defined in the taxes settings page.
99
+ * returns true or false depending on whether taxes can be calculated.
100
+ *
101
+ * @param: void
102
+ * @return: boolean true or false
103
+ **/
104
+ function wpec_taxes_run_logic()
105
+ {
106
+ //initalize variables
107
+ global $wpsc_cart;
108
+ $wpec_base_country = get_option('base_country');
109
+
110
+ //check the tax logic. Is the tax applied to the billing country or shipping country or to both?
111
+ switch($this->wpec_taxes->wpec_taxes_get_logic())
112
+ {
113
+ case 'billing_shipping':
114
+ if(($wpsc_cart->selected_country==$wpec_base_country) && ($wpsc_cart->delivery_country==$wpec_base_country))
115
+ {$returnable=true;}
116
+ break;
117
+ case 'billing':
118
+ if($wpsc_cart->selected_country==$wpec_base_country)
119
+ {$returnable=true;}
120
+ break;
121
+ case 'shipping':
122
+ if($wpsc_cart->delivery_country==$wpec_base_country)
123
+ {$returnable = true;}
124
+ break;
125
+ default:
126
+ $returanble = false;
127
+ }// switch
128
+
129
+ return $returnable;
130
+ }// wpec_taxes_run_logic
131
+
132
+ /**
133
+ * @description: wpec_taxes_retrieve_region - retrieves the taxable region based on the logic settings
134
+ *
135
+ * @param: void
136
+ * @return: string containing region code
137
+ **/
138
+ function wpec_taxes_retrieve_region()
139
+ {
140
+ switch($this->wpec_taxes->wpec_taxes_get_logic())
141
+ {
142
+ case 'billing_shipping':
143
+ //need another setting - user needs to be able to specify which address to charge off of
144
+ if($this->wpec_taxes->wpec_taxes_get_billing_shipping_preference()=='billing_address')
145
+ {
146
+ $returnable = $this->wpec_taxes->wpec_taxes_get_region_code_by_id($wpsc_cart->selected_region);
147
+ }
148
+ else
149
+ {
150
+ $returnable = $this->wpec_taxes->wpec_taxes_get_region_code_by_id($wpsc_cart->delivery_region);
151
+ }// if
152
+ break;
153
+ case 'billing':
154
+ $returnable = $this->wpec_taxes->wpec_taxes_get_region_code_by_id($wpsc_cart->selected_region);
155
+ break;
156
+ case 'shipping':
157
+ $returnable = $this->wpec_taxes->wpec_taxes_get_region_code_by_id($wpsc_cart->delivery_region);
158
+ break;
159
+ default:
160
+ $returnable = false;
161
+ }// switch
162
+
163
+ return $returnable;
164
+ }// wpec_taxes_retrieve_region
165
+
166
+ /**
167
+ * @description: wpec_taxes_products_tax_exists - checks if tax is set
168
+ * for any of the cart items.
169
+ *
170
+ * @return: boolean - true if tax exists, false if not
171
+ **/
172
+ function wpec_taxes_products_tax_exists()
173
+ {
174
+ global $wpsc_cart;
175
+
176
+ $returnable = false;
177
+
178
+ //loop through items and check if tax is set
179
+ foreach($wpsc_cart->cart_items as $cart_item)
180
+ {
181
+ if(!empty($cart_item->tax))
182
+ {
183
+ //tax is set - set returnable to true and break out of the loop
184
+ $returnable = true;
185
+ break;
186
+ }
187
+ }// foreach
188
+
189
+ return $returnable;
190
+ }// wpec_taxes_products_tax_exists
191
+
192
+ /**
193
+ * @description: wpec_taxes_display_tax_bands - used to retrieve a select menu
194
+ * containing all of the tax bands setup including a "Disabled"
195
+ * option. Used on Add and Edit product pages.
196
+ *
197
+ * @param: input_settings (optional) - Expects an array of settings for the
198
+ * select menu generated.
199
+ * See: wpec_taxes_build_select_options()
200
+ * @param: custom_tax_band (optional) - Expects a string. If this is set then the
201
+ * default option for the generated select menu will be set to this.
202
+ * @return: string containing html select menu
203
+ **/
204
+ function wpec_taxes_display_tax_bands($input_settings=array(), $custom_tax_band=false)
205
+ {
206
+ //if taxes are included and not disabled continue else notify customer
207
+ if($this->wpec_taxes_isincluded() && $this->wpec_taxes->wpec_taxes_get_enabled())
208
+ {
209
+ //retrieve the bands and add the disabled value
210
+ $tax_bands = $this->wpec_taxes->wpec_taxes_get_bands();
211
+ if(!empty($tax_bands))
212
+ {
213
+ array_unshift($tax_bands, __('Disabled'));
214
+
215
+ //set select settings
216
+ $default_select_settings = array(
217
+ 'id' => 'wpec_taxes_band',
218
+ 'name' => 'wpec_taxes_band',
219
+ 'label' => __('Custom Tax Band')
220
+ );
221
+ $band_select_settings = wp_parse_args($input_settings, $default_select_settings);
222
+ extract($band_select_settings, EXTR_SKIP);
223
+
224
+ //set the default option
225
+ $default_option = (isset($custom_tax_band)) ? $custom_tax_band : __('Disabled');
226
+
227
+ //echo select
228
+ $returnable = $this->wpec_taxes_build_select_options($tax_bands, 'name', 'name', $default_option, $band_select_settings);
229
+ }
230
+ else
231
+ {
232
+ $returnable = '<p>'.__('No Tax Bands Setup. Set Tax Bands up in Settings &gt Taxes').'</p>';
233
+ }// if
234
+ }
235
+ else
236
+ {
237
+ $returnable = '<p>';
238
+ $returnable .= ($this->wpec_taxes->wpec_taxes_get_enabled()) ? __('Product prices are Tax Exclusive. See Settings &gt; Taxes') :
239
+ __('Taxes are not enabled. See Settings &gt; Taxes');
240
+ $returnable .= '</p>';
241
+ }// if
242
+
243
+ return $returnable;
244
+ }// wpec_taxes_display_tax_bands
245
+
246
+ /**
247
+ * @description: wpec_taxes_calculate_tax - a simple function to calculate tax based on a given
248
+ * price and tax percentage.
249
+ *
250
+ * @param: price - the price you wish to calculate tax for
251
+ * @param: tax_percentage - the percentage you wish to use to calculate the tax
252
+ * @return: calculated price
253
+ **/
254
+ function wpec_taxes_calculate_tax($price, $tax_percentage)
255
+ {
256
+ $returnable = 0;
257
+
258
+ if(!empty($tax_percentage))
259
+ {
260
+ $returnable = $price * ($tax_percentage/100);
261
+ }// if
262
+
263
+ return $returnable;
264
+ }// wpec_taxes_calculate_tax
265
+
266
+ /**
267
+ * @description: wpec_taxes_calculate_included_tax - provided a cart item
268
+ * this function will calcuate the included tax for it. It returns
269
+ * the tax to be added as well as the rate that was charged.
270
+ *
271
+ * @param: cart_item - the cart item that you wish to retrieve tax for
272
+ * @return: array containing the tax and rate or false depending on the logic settings
273
+ **/
274
+ function wpec_taxes_calculate_included_tax($cart_item)
275
+ {
276
+ global $wpsc_cart;
277
+ $returnable = false;
278
+
279
+ if($this->wpec_taxes_run_logic())
280
+ {
281
+ $wpec_base_country = get_option('base_country');
282
+ $region = $this->wpec_taxes_retrieve_region();
283
+
284
+ //get the tax percentage rate
285
+ $tax_rate = $this->wpec_taxes->wpec_taxes_get_included_rate($cart_item->meta[0]['wpec_taxes_band'], $wpec_base_country, $region);
286
+
287
+ //get the taxable price - unit price multiplied by qty
288
+ $taxable_price = $cart_item->unit_price * $cart_item->quantity;
289
+
290
+ $returnable = array('tax'=>$this->wpec_taxes_calculate_tax($taxable_price, $tax_rate), 'rate'=>$tax_rate);
291
+ }// if
292
+
293
+ return $returnable;
294
+
295
+ } //wpec_taxes_calculate_included_tax
296
+
297
+ /**
298
+ * @description: wpec_taxes_product_rate_percentage - returns the percentage for the specified tax band.
299
+ *
300
+ * @param: tax_band - the name of the band you wish to retrieve a percentage for
301
+ * @return: percentage rate
302
+ **/
303
+ function wpec_taxes_product_rate_percentage($tax_band)
304
+ {
305
+ //include global variables
306
+ global $wpsc_cart;
307
+
308
+ //initialize variables
309
+ $returnable = 0;
310
+
311
+ if($this->wpec_taxes_isincluded())
312
+ {
313
+ //get the base country
314
+ $wpec_base_country = get_option('base_country');
315
+
316
+ //get the region
317
+ $region = $this->wpec_taxes_retrieve_region();
318
+
319
+ //get the tax percentage rate
320
+ $returnable = $this->wpec_taxes->wpec_taxes_get_included_rate($tax_band, $wpec_base_country, $region);
321
+ }// if
322
+
323
+ return $returnable;
324
+ }// wpec_taxes_product_rate_percentage
325
+
326
+ /**
327
+ * @description: wpec_taxes_rate_exists - given a country code this will
328
+ * check if a tax rate exists for it.
329
+ * @param: country_code - the code of the country you wish to check rates for
330
+ * @return: true or false
331
+ **/
332
+ function wpec_taxes_rate_exists($country_code)
333
+ {
334
+ //initalize return variable
335
+ $returnable = false;
336
+
337
+ //retrieve rates
338
+ $tax_rates = $this->wpec_taxes->wpec_taxes_get_rates();
339
+
340
+ if(!empty($tax_rates))
341
+ {
342
+ foreach($tax_rates as $rate)
343
+ {
344
+ if($rate['country_code']==$country_code)
345
+ {
346
+ $returnable = true;
347
+ break;
348
+ }// if
349
+ }// foreach
350
+ }// if
351
+
352
+ return $returnable;
353
+ }// wpec_taxes_rate_exists
354
+
355
+ /**
356
+ * @description: wpec_taxes_build_input - builds a form input based on
357
+ * defined input settings.
358
+ *
359
+ * @param: input_settings(optional) - the settings for your input in array format.
360
+ * Example: wpec_taxes_build_input('id'=>'myforminput', 'type'=>'radio')
361
+ * Defaults to text input with wpec-taxes-input class.
362
+ * @return: string containing form input html
363
+ **/
364
+ function wpec_taxes_build_input($input_settings=array())
365
+ {
366
+ //input defaults
367
+ $defaults = array(
368
+ 'type' => 'text',
369
+ 'class'=> 'wpec-taxes-input',
370
+ 'label'=> ''
371
+ );
372
+ $settings = wp_parse_args($input_settings, $defaults);
373
+ extract($settings, EXTR_SKIP);
374
+
375
+ //begin the input html
376
+ $returnable = '<input ';
377
+
378
+ //loop through the defined settings and add them to the input
379
+ foreach($settings as $key => $setting)
380
+ {
381
+ if($key=='label'){continue;}
382
+ $returnable .= "{$key}='{$setting}'";
383
+ }// foreach
384
+
385
+ //close the input
386
+ $returnable .= ' />';
387
+
388
+ //wrap the input in the label if one was specified
389
+ if(!empty($settings['label']))
390
+ {
391
+ $returnable = '<label>'.$returnable.$settings['label'].'</label>';
392
+ }// if
393
+
394
+ return $returnable;
395
+ }// wpec_taxes_build_input
396
+
397
+ /**
398
+ * @description: wpec_taxes_get_select_options - takes an input array and returns html formatted options
399
+ *
400
+ * @param: input_array - expects array format to be like those returned by: get_results($query, ARRAY_A);
401
+ * @param: option_value - specify a key from input_array that you wish to use as the option value
402
+ * @param: option_text - specify a key from input_array that you wish to use as the option text
403
+ * @param: option_selected (optional) - specify a default option for your select.
404
+ * @param: select_settings (optional) - if you wish to return an entire select input you must provide
405
+ * select settings. This would be an array consisting of key-value
406
+ * pairs that you wish to specify.
407
+ * Example: array('id'=>'my-select-id', 'name'=>'my-name')
408
+ * @return: string
409
+ **/
410
+ function wpec_taxes_build_select_options($input_array, $option_value, $option_text, $option_selected=false, $select_settings='')
411
+ {
412
+ $returnable = '';
413
+ $options = '';
414
+
415
+ foreach($input_array as $value)
416
+ {
417
+ //if the selected value exists in the input array skip it and continue processing
418
+ if(is_array($value) && is_array($option_selected)) {
419
+ if(($value[$option_value]==$option_selected[$option_value]) || ($value[$option_value]==$option_selected))
420
+ {
421
+ continue;
422
+ }// if
423
+ }
424
+ $options .= (is_array($value)) ? "<option value='{$value[$option_value]}'>{$value[$option_text]}</option>" :
425
+ "<option value='{$value}'>{$value}</option>";
426
+ }// foreach
427
+ if(!empty($options))
428
+ {
429
+ //add default option - using !== operator so that blank values can be passed as the selected option
430
+ if($option_selected!==false)
431
+ {
432
+ $selected_option = (is_array($option_selected)) ? "<option selected='selected' value='{$option_selected[$option_value]}'>{$option_selected[$option_text]}</option>" :
433
+ "<option selected='selected' value='{$option_selected}'>{$option_selected}</option>";
434
+ $options = $selected_option.$options;
435
+ }// if
436
+
437
+ //create select if necessary or just return options
438
+ if($select_settings)
439
+ {
440
+ $returnable = '<select ';
441
+ foreach($select_settings as $key => $setting)
442
+ {
443
+ if($key=='label'){continue;}
444
+ $returnable .= "{$key}='{$setting}'";
445
+ }// foreach
446
+ $returnable .= ">{$options}</select>";
447
+ if(!empty($select_settings['label']))
448
+ {
449
+ $returnable = "<label>{$returnable} {$select_settings['label']}</label>";
450
+ }// if
451
+ }
452
+ else
453
+ {
454
+ $returnable = $options;
455
+ }// if
456
+ }// if
457
+
458
+ return $returnable;
459
+ }// wpec_taxes_get_select_options
460
+
461
+ /**
462
+ * @description: wpec_taxes_build_form - build the tax rate form
463
+ *
464
+ * @param: key(optional) - used as the array key for this form row.
465
+ * Defaults to 0
466
+ * @param: tax_rate(optional) - expects an array consisting of tax rate settings
467
+ * if specified the function will build return the
468
+ * form inputs with the tax_rate settings already
469
+ * selected. This is used to load the form information
470
+ * from the database.
471
+ * Default: false
472
+ * @param: type (optional) - expects a string. Used to set the id and include type
473
+ * specific options. Currently used to differentiate between
474
+ * rates and bands though it could be expanded in the future.
475
+ * Note: be sure to see the tax-settings page and taxes-functions
476
+ * pages to see where the types come into play.
477
+ **/
478
+ function wpec_taxes_build_form($key=0, $tax_rate=false, $type='rates')
479
+ {
480
+ //default settings
481
+ $country_select_settings = array(
482
+ 'id' =>"{$type}-country-{$key}",
483
+ 'name' =>"wpsc_options[wpec_taxes_{$type}][{$key}][country_code]",
484
+ 'class' =>'country',
485
+ 'onchange' => "wpec_taxes_get_regions({$key}, \"{$type}\")"
486
+ );
487
+ $rate_input_settings = array(
488
+ 'id' =>"{$type}-rate-{$key}",
489
+ 'name' =>"wpsc_options[wpec_taxes_{$type}][{$key}][rate]",
490
+ 'class'=>"taxes-{$type}",
491
+ 'size' =>3,
492
+ 'label'=>'&#37;'
493
+ );
494
+
495
+ //add name for tax band
496
+ if($type=='bands')
497
+ {
498
+ $bands_input_settings = array(
499
+ 'type' => 'text',
500
+ 'id' => "band-name-{$key}",
501
+ 'name' => "wpsc_options[wpec_taxes_{$type}][{$key}][name]",
502
+ 'class'=> 'taxes-band',
503
+ 'label'=> __('Name')
504
+ );
505
+ }
506
+ elseif($type=='rates')
507
+ {
508
+ $shipping_input_settings = array(
509
+ 'type' => 'checkbox',
510
+ 'id' => "shipping-{$key}",
511
+ 'name' => "wpsc_options[wpec_taxes_{$type}][{$key}][shipping]",
512
+ 'class'=> "taxes-{$type}",
513
+ 'label'=> __('Apply to Shipping')
514
+ );
515
+ }// if
516
+
517
+ if($tax_rate)
518
+ {
519
+ if(isset($tax_rate['rate']))
520
+ {
521
+ $rate_input_settings['value'] = $tax_rate['rate'];
522
+ }// if
523
+
524
+ if(isset($tax_rate['name']))
525
+ {
526
+ $bands_input_settings['value'] = $tax_rate['name'];
527
+ }// if
528
+
529
+ if(isset($tax_rate['country_code']))
530
+ {
531
+ $country_code = $tax_rate['country_code'];
532
+ }// if
533
+
534
+ if(isset($tax_rate['region_code']))
535
+ {
536
+ //set the region up
537
+ $region_select_settings = array(
538
+ 'id' => "region-{$key}",
539
+ 'name' => "wpsc_options[wpec_taxes_{$type}][{$key}][region_code]",
540
+ 'class'=> 'region'
541
+ );
542
+
543
+ //country code should be set - but just in case it's not
544
+ if(!isset($country_code))
545
+ {
546
+ $country_id = $this->wpec_taxes->wpec_taxes_get_region_information($tax_rate['region_code'], 'country_id');
547
+ $country_code = $this->wpec_taxes->wpec_taxes_get_country_information('isocode', array('id'=>$country_id));
548
+ }// if
549
+
550
+ $selected_region = array(
551
+ 'region_code'=>$tax_rate['region_code'],
552
+ 'name'=> $this->wpec_taxes->wpec_taxes_get_region_information($tax_rate['region_code'], 'name')
553
+ );
554
+
555
+ $regions = $this->wpec_taxes->wpec_taxes_get_regions($country_code);
556
+ $region_select = $this->wpec_taxes_build_select_options($regions, 'region_code', 'name', $selected_region, $region_select_settings);
557
+ }// if
558
+
559
+ if(isset($tax_rate['shipping']))
560
+ {
561
+ if($tax_rate['shipping']==1){$shipping_input_settings['checked']='checked';}
562
+ }// if
563
+
564
+ $selected_country = array(
565
+ 'isocode' => $country_code,
566
+ 'country' => $this->wpec_taxes->wpec_taxes_get_country_information('country', array('isocode'=>$country_code))
567
+ );
568
+ }
569
+ else
570
+ {
571
+ $selected_country = '';
572
+ }// if
573
+
574
+ //get countries
575
+ $countries = $this->wpec_taxes->wpec_taxes_get_countries();
576
+
577
+ //build the rate form based on the information gathered
578
+ if($type=='bands')
579
+ {
580
+ $returnable[] = $this->wpec_taxes_build_input($bands_input_settings).'<br />'; //add a break for the html formatting
581
+ }// if
582
+ $returnable[] = $this->wpec_taxes_build_input($rate_input_settings);
583
+ $returnable[] = $this->wpec_taxes_build_select_options($countries, 'isocode', 'country', $selected_country, $country_select_settings);
584
+ if(isset($region_select))
585
+ {
586
+ $returnable[] = $region_select;
587
+ }// if
588
+ if($type=='rates')
589
+ {
590
+ $returnable[] = $this->wpec_taxes_build_input($shipping_input_settings);
591
+ }// if
592
+ $returnable[] = "<a class='taxes-{$type}-delete' id='delete-{$key}' href='#'>".__('Delete')."</a>";
593
+
594
+ $returnable = "<p id='{$type}-row-{$key}' class='wpec-tax-{$type}'>".implode("\n", $returnable).'</p>';
595
+
596
+ return $returnable;
597
+ }// wpec_taxes_build_form
598
+ }// wpec_taxes_controller
599
+ ?>
wpec-taxes/models/taxes.class.php ADDED
@@ -0,0 +1,324 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class wpec_taxes
3
+ {
4
+ /**
5
+ * WPEC Taxes Options - any of these can be retrieved by get_option
6
+ *
7
+ * @var array
8
+ **/
9
+ private $taxes_options = array(
10
+ 'wpec_taxes_enabled' => 0,
11
+ 'wpec_taxes_inprice' => 'exclusive',
12
+ 'wpec_taxes_product' => 'add',
13
+ 'wpec_taxes_logic' => 'billing_shipping',
14
+ 'wpec_billing_shipping_preference' => 'billing_address',
15
+ 'wpec_taxes_rates' => '',
16
+ 'wpec_taxes_bands' => ''
17
+ );
18
+
19
+ function __construct()
20
+ {
21
+ $this->wpec_taxes_set_options();
22
+ }// __construct
23
+
24
+ /**
25
+ * Get Functions
26
+ **/
27
+ function wpec_taxes_get_enabled()
28
+ {
29
+ return $this->taxes_options['wpec_taxes_enabled'];
30
+ }
31
+
32
+ function wpec_taxes_get_inprice()
33
+ {
34
+ return $this->taxes_options['wpec_taxes_inprice'];
35
+ }
36
+
37
+ function wpec_taxes_get_product()
38
+ {
39
+ return $this->taxes_options['wpec_taxes_product'];
40
+ }
41
+
42
+ function wpec_taxes_get_logic()
43
+ {
44
+ return $this->taxes_options['wpec_taxes_logic'];
45
+ }
46
+
47
+ function wpec_taxes_get_billing_shipping_preference()
48
+ {
49
+ return $this->taxes_options['wpec_billing_shipping_preference'];
50
+ }
51
+
52
+ function wpec_taxes_get_rates()
53
+ {
54
+ return $this->taxes_options['wpec_taxes_rates'];
55
+ }
56
+
57
+ function wpec_taxes_get_bands()
58
+ {
59
+ return $this->taxes_options['wpec_taxes_bands'];
60
+ }
61
+
62
+ function wpec_taxes_get_options()
63
+ {
64
+ return $this->taxes_options;
65
+ }
66
+
67
+ /**
68
+ * @author: Jeremy Smith - www.dnawebagency.com
69
+ * @description: wpec_taxes_set_options - retrieves option information
70
+ * from the database.
71
+ * @param: void
72
+ * @return: null
73
+ **/
74
+ function wpec_taxes_set_options()
75
+ {
76
+ foreach(array_keys($this->taxes_options) as $key)
77
+ {
78
+ $options[$key] = get_option($key);
79
+ }// foreach
80
+
81
+ $returnable = wp_parse_args($options, $this->taxes_options);
82
+ extract($returnable, EXTR_SKIP);
83
+
84
+ $this->taxes_options = $returnable;
85
+ }// wpec_taxes_set_options
86
+
87
+ /**
88
+ * @author: Jeremy Smith - www.dnawebagency.com
89
+ * @description: wpec_taxes_get_rate - retrieves the tax rate for the given country
90
+ * and, if specified, region.
91
+ *
92
+ * @param: country_code - the isocode for the country whose tax rate you wish to retrieve.
93
+ * @param: region_code (optional) - the region code for the region tax rate you wish to retrieve.
94
+ * @return: array or false
95
+ **/
96
+ function wpec_taxes_get_rate($country_code, $region_code='')
97
+ {
98
+ //initialize return variable
99
+ $returnable = false;
100
+
101
+ //first check if the region given is part of the country
102
+ if(!empty($region_code))
103
+ {
104
+ $region_country_code = $this->wpec_taxes_get_region_information($region_code, 'country_id');
105
+ if($region_country_code != $country_code)
106
+ {
107
+ //reset region code if region provided not in country provided
108
+ $region_code = '';
109
+ }// if
110
+ }// if
111
+
112
+ if(!empty($this->taxes_options['wpec_taxes_rates']))
113
+ {
114
+ foreach($this->taxes_options['wpec_taxes_rates'] as $tax_rate)
115
+ {
116
+ if($tax_rate['country_code']==$country_code)
117
+ {
118
+ if(($region_code=='' && !isset($tax_rate['region_code'])) || $region_code==$tax_rate['region_code'])
119
+ {
120
+ $returnable = $tax_rate;
121
+ break;
122
+ }// if
123
+ }// if
124
+ }// foreach
125
+ }// if
126
+
127
+ return $returnable;
128
+ }// wpec_taxes_get_rate
129
+
130
+ /**
131
+ * @author: Jeremy Smith - www.dnawebagency.com
132
+ * @description: wpec_taxes_get_band_from_name - retrieves the tax band for the given name
133
+ *
134
+ * @param: name - the name of the tax band you wish to retrieve.
135
+ * @return: array or false
136
+ **/
137
+ function wpec_taxes_get_band_from_name($name)
138
+ {
139
+ //initialize return value
140
+ $returnable = false;
141
+
142
+ //search bands for name
143
+ if(!empty($this->taxes_options['wpec_taxes_bands']))
144
+ {
145
+ foreach($this->taxes_options['wpec_taxes_bands'] as $tax_band)
146
+ {
147
+ if($tax_band['name']==$name)
148
+ {
149
+ $returnable = $tax_band;
150
+ break;
151
+ }// if
152
+ }// foreach
153
+ }// if
154
+
155
+ return $returnable;
156
+ }// wpec_taxes_get_band_from_name
157
+
158
+ /**
159
+ * @description: wpec_taxes_get_included_rate - returns the precentage rate for the given tax band name,
160
+ * country code and region code. This retrieves the rate based on the current
161
+ * tax settings.
162
+ *
163
+ * @param: taxes_band_name - the name of the tax band you wish to retrieve a percentage rate for
164
+ * @param: country_code - isocode of the country that you wish to retrieve a percentage rate for
165
+ * @param: region_code(optional) - the code code for the region that you wish to retrieve a
166
+ * percentage rate for
167
+ **/
168
+ function wpec_taxes_get_included_rate($taxes_band_name, $country_code, $region_code='')
169
+ {
170
+ //set the tax_rate
171
+ $tax_rate = 0;
172
+
173
+ //get the tax band
174
+ $tax_band = $this->wpec_taxes_get_band_from_name($taxes_band_name);
175
+
176
+ //set the tax rate depending on product rate settings
177
+ switch($this->wpec_taxes_get_product())
178
+ {
179
+ case 'add':
180
+ $rate_array = $this->wpec_taxes_get_rate($country_code, $region_code);
181
+ $tax_rate += $rate_array['rate'];
182
+ case 'replace':
183
+ $tax_rate += $tax_band['rate'];
184
+ break;
185
+ }// switch
186
+
187
+ //return tax for this item
188
+ return $tax_rate;
189
+ }// wpec_taxes_get_included_rate
190
+
191
+ /**
192
+ * @author: Jeremy Smith - www.dnawebagency.com
193
+ * @description: wpec_taxes_get_countries - retrieves an array of countries
194
+ *
195
+ * @param: visibility (optional) - set to 'visible' or 'hidden' to retrieve
196
+ * visible or hidden countries. Default action
197
+ * is to retrieve any country.
198
+ * @return: array or false
199
+ **/
200
+ function wpec_taxes_get_countries($visibility='any')
201
+ {
202
+ switch($visibility)
203
+ {
204
+ case 'visible': $where = array('visible'=>1); break;
205
+ case 'hidden': $where = array('visible'=>0); break;
206
+ default: $where = false;
207
+ }// switch
208
+
209
+ return $this->wpec_taxes_get_country_information(array('country', 'isocode'), $where, 'country');
210
+ }// wpec_taxes_get_countries
211
+
212
+ /**
213
+ * @author: Jeremy Smith - www.dnawebagency.com
214
+ * @description: wpec_get_country_information - retrieves information about a country.
215
+ * Note: If only one column is specified this function will return the value
216
+ * of that column. If two or more columns are specified the results are
217
+ * returned in an array.
218
+ * @param: columns(optional) - specify a column name or multiple column names in an array.
219
+ * Default action is to return all columns.
220
+ * @param: where(optional) - specify where conditions in array format. Key is column
221
+ * and value is column value.
222
+ * Example: wpec_taxes_get_country_information('id', array('isocode'=>'CA'))
223
+ * Default action is to not limit results.
224
+ * Note: this function only compares using the equals sign (=).
225
+ * @param: order_by(optional) - specify a column name or multiple column names in an array.
226
+ * Default action is to not include an order by statement.
227
+ * @return: array, int, string or false
228
+ **/
229
+ function wpec_taxes_get_country_information($columns=false, $where=false, $order_by=false)
230
+ {
231
+ //database connection
232
+ global $wpdb;
233
+
234
+ //if columns are not set select everything
235
+ $columns = ($columns) ? $columns : array('*');
236
+
237
+ //change columns to array if not an array
238
+ if(!is_array($columns)){$columns = array($columns);}
239
+
240
+ //if where is set then formulate conditions
241
+ if($where)
242
+ {
243
+ foreach($where as $column => $condition)
244
+ {
245
+ $where_query[] = (is_numeric($condition)) ? "{$column}={$condition}" : "{$column}='{$condition}'";
246
+ }// foreach
247
+ }// if
248
+
249
+ //formulate query
250
+ $query = 'SELECT '.implode(',',$columns).' FROM '.WPSC_TABLE_CURRENCY_LIST;
251
+ if(isset($where_query))
252
+ {
253
+ $query .= ' WHERE '.implode(' AND ', $where_query);
254
+ }// if
255
+
256
+ //if order_by is set, add to query
257
+ if($order_by)
258
+ {
259
+ if(!is_array($order_by)){$order_by = array($order_by);}
260
+ $query .= ' ORDER BY '.implode(',',$order_by);
261
+ }// if
262
+
263
+ //return the result
264
+ return (count($columns)>1) ? $wpdb->get_results($query, ARRAY_A) : $wpdb->get_var($query);
265
+ }// wpec_taxes_get_country_information
266
+
267
+ /**
268
+ * @author: Jeremy Smith - www.dnawebagency.com
269
+ * @description: wpec_taxes_get_region_information - given a region code and column
270
+ * this function will return the resulting value.
271
+ * @param: region_code - code for this region
272
+ * @param: column(optional) - specify a column to retrieve
273
+ * Default action is to retrieve the id column.
274
+ * @return: int, string, or false
275
+ **/
276
+ function wpec_taxes_get_region_information($region_code, $column='id')
277
+ {
278
+ global $wpdb;
279
+ $query = "SELECT {$column} FROM ".WPSC_TABLE_REGION_TAX." WHERE code='{$region_code}'";
280
+ $result = $wpdb->get_var($query);
281
+
282
+ return $result;
283
+ }// wpec_taxes_get_region_information
284
+
285
+ /**
286
+ * @author: Jeremy Smith - www.dnawebagency.com
287
+ * @description: wpec_taxes_get_regions - given a isocode, such as CA, this function
288
+ * will return an array of regions within that country.
289
+ * @param: country - string variable containing isocode
290
+ * @return: array or false
291
+ **/
292
+ function wpec_taxes_get_regions($country)
293
+ {
294
+ //database connection
295
+ global $wpdb;
296
+
297
+ //get the id for the given country code
298
+ $country_id = $this->wpec_taxes_get_country_information('id', array('isocode'=>$country));
299
+
300
+ //get a list of regions for the country id
301
+ $query = 'SELECT name, code AS region_code FROM '.WPSC_TABLE_REGION_TAX." WHERE country_id=$country_id";
302
+ $result = $wpdb->get_results($query, ARRAY_A);
303
+
304
+ return $result;
305
+ }// wpec_taxes_get_regions
306
+
307
+ /**
308
+ * @author: Jeremy Smith - www.dnawebagency.com
309
+ * @description: wpec_taxes_get_region_code_by_id - given an id this funciton will
310
+ return the region code.
311
+ * @param: id - a region id
312
+ * @return: int or false
313
+ **/
314
+ function wpec_taxes_get_region_code_by_id($id)
315
+ {
316
+ //database connection
317
+ global $wpdb;
318
+
319
+ //get the region code
320
+ $query = 'SELECT code AS region_code FROM '.WPSC_TABLE_REGION_TAX." WHERE id=$id";
321
+ return $wpdb->get_var($query);
322
+ }// wpec_taxes_get_region_code_by_id
323
+ }// wpec_taxes
324
+ ?>
wpec-taxes/taxes_module.php ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Load required files
4
+ **/
5
+ require_once 'models/taxes.class.php';
6
+ require_once 'controllers/taxes_controller.class.php';
7
+
8
+ $version_identifier = WPSC_VERSION.".".WPSC_MINOR_VERSION;
9
+
10
+ //include required js file
11
+ wp_enqueue_script('wp-e-commerce-taxes-functions', WPSC_URL.'/wpec-taxes/view/js/taxes-functions.js', array('wp-e-commerce-admin'), $version_identifier, false);
12
+
13
+ /**
14
+ * @description: wpec_taxes_settings_page - used by wpec to display the admin settings page.
15
+ * @param: void
16
+ * @return: null;
17
+ **/
18
+ function wpec_taxes_settings_page()
19
+ {
20
+ require_once 'view/taxes-settings.php';
21
+ wpec_options_taxes();
22
+ }// wpec_taxes_settings_page
23
+
24
+ /**
25
+ * @author: Jeremy Smith - www.dnawebagency.com
26
+ * @description: wpec_taxes_ajax_controller - controller for any ajax
27
+ * functions needed for wpec_taxes
28
+ * @param: void
29
+ * @return: null
30
+ **/
31
+ function wpec_taxes_ajax_controller()
32
+ {
33
+ //include taxes controller
34
+ $wpec_taxes_controller = new wpec_taxes_controller;
35
+
36
+ switch($_REQUEST['wpec_taxes_action'])
37
+ {
38
+ case 'wpec_taxes_get_regions':
39
+ $regions = $wpec_taxes_controller->wpec_taxes->wpec_taxes_get_regions($_REQUEST['country_code']);
40
+ $key = $_REQUEST['current_key'];
41
+ $type = $_REQUEST['taxes_type'];
42
+ $default_option = array('region_code'=>'', 'name'=>'');
43
+ $select_settings = array(
44
+ 'id'=>"{$type}-region-{$key}",
45
+ 'name'=>"wpsc_options[wpec_taxes_{$type}][{$key}][region_code]",
46
+ 'class'=>'region'
47
+ );
48
+ $returnable = $wpec_taxes_controller->wpec_taxes_build_select_options($regions, 'region_code', 'name', $default_option, $select_settings);
49
+ break;
50
+ case 'wpec_taxes_build_rate_form':
51
+ $key = $_REQUEST['current_key'];
52
+ $returnable = $wpec_taxes_controller->wpec_taxes_build_form($key);
53
+ break;
54
+ case 'wpec_taxes_build_band_form':
55
+ $key = $_REQUEST['current_key'];
56
+ $returnable = $wpec_taxes_controller->wpec_taxes_build_form($key, false, 'bands');
57
+ break;
58
+ }// switch
59
+
60
+ //return the results
61
+ echo $returnable;
62
+
63
+ //die to avoid default 0 in ajax response
64
+ die();
65
+ }// wpec_taxes_ajax_controller
66
+
67
+ /**
68
+ * @author: Jeremy Smith - www.dnawebagency.com
69
+ * @description: wpec_submit_taxes_options - filters the options submitted in $_POST. Uses
70
+ * wpsc_submit_options to submit filtered array.
71
+ * @param: void
72
+ * @return: null
73
+ **/
74
+ function wpec_submit_taxes_options()
75
+ {
76
+ //define the name of the checkbox options
77
+ $taxes_check_options = array('wpec_taxes_enabled');
78
+
79
+ //check if checkbox options are checked and modify post output
80
+ foreach($taxes_check_options as $option)
81
+ {
82
+ $_POST['wpsc_options'][$option] = (isset($_POST['wpsc_options'][$option])) ? 1 : 0;
83
+ }// foreach
84
+
85
+ //currently there are two types - bands and rates
86
+ $taxes_rates_types = array('rates', 'bands');
87
+
88
+ foreach($taxes_rates_types as $taxes_type)
89
+ {
90
+ $saved_rates = array(); //keep track of saved rates
91
+ $exists = array(); //keep track of what rates or names have been saved
92
+
93
+ //check the rates
94
+ if(isset($_POST['wpsc_options']['wpec_taxes_'.$taxes_type]))
95
+ {
96
+ foreach($_POST['wpsc_options']['wpec_taxes_'.$taxes_type] as $tax_rate)
97
+ {
98
+ //if there is no country then skip
99
+ if(empty($tax_rate['country_code'])){continue;}
100
+
101
+ //bands - if the name already exists then skip - if not save it
102
+ if($taxes_type=='bands')
103
+ {
104
+ if(empty($tax_rate['name']) || in_array($tax_rate['name'], $exists) || $tax_rate['name']=='Disabled')
105
+ {
106
+ continue;
107
+ }
108
+ else
109
+ {
110
+ $exists[] = $tax_rate['name'];
111
+ $saved_rates[] = $tax_rate;
112
+ }// if
113
+ }// if
114
+
115
+ //rates - check the shipping checkbox
116
+ if($taxes_type=='rates')
117
+ {
118
+ //if there is no rate then skip
119
+ if(empty($tax_rate['rate'])){continue;}
120
+
121
+ $tax_rate['shipping'] = (isset($tax_rate['shipping'])) ? 1 : 0;
122
+
123
+ //check if country exists
124
+ if(array_key_exists($tax_rate['country_code'], $exists))
125
+ {
126
+ //if region already exists skip
127
+ if(array_search($tax_rate['region_code'], $exists[$tax_rate['country_code']])==$tax_rate['country_code']){continue;}
128
+ else
129
+ {
130
+ //it's not in the array add it
131
+ $exists[$tax_rate['country_code']][] = $tax_rate['region_code'];
132
+
133
+ //save it
134
+ $saved_rates[] = $tax_rate;
135
+ }// if
136
+ }
137
+ else
138
+ {
139
+ //add codes to exists array
140
+ $exists[$tax_rate['country_code']][] = $tax_rate['region_code'];
141
+
142
+ //save it
143
+ $saved_rates[] = $tax_rate;
144
+ }// if
145
+ }// if
146
+ }// foreach
147
+ }// if
148
+
149
+ //replace post tax rates with filtered rates
150
+ $_POST['wpsc_options']['wpec_taxes_'.$taxes_type] = $saved_rates;
151
+ }// foreach
152
+
153
+ //submit options using built in functions
154
+ wpsc_submit_options();
155
+ }// wpec_submit_taxes_options
156
+
157
+ /**
158
+ * Add actions used by wpec-taxes module
159
+ **/
160
+ add_action('wp_ajax_wpec_taxes_ajax', 'wpec_taxes_ajax_controller');
161
+
162
+ if(isset($_REQUEST['wpec_admin_action']) && $_REQUEST['wpec_admin_action'] == 'submit_taxes_options'){
163
+ add_action('admin_init', 'wpec_submit_taxes_options');
164
+ }
165
+ ?>
wpec-taxes/view/js/taxes-functions.js ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @author: Jeremy Smith - www.dnawebagency.com
3
+ * @description: File containing Javascript functions used in WPEC Taxes
4
+ * Module.
5
+ **/
6
+
7
+ /**
8
+ * @description: wpec_taxes_get_regions - retrieves regions select box from the server.
9
+ * Inserts the select box after the country.
10
+ *
11
+ * @param: key - integer. Used to select the id's of the form elements on the page.
12
+ * @return: null
13
+ **/
14
+ function wpec_taxes_get_regions(key, type)
15
+ {
16
+ //ajax variables to pass to the server
17
+ var data = {
18
+ action: 'wpec_taxes_ajax',
19
+ wpec_taxes_action: 'wpec_taxes_get_regions',
20
+ current_key: key,
21
+ taxes_type: type,
22
+ country_code: jQuery('#'+type+'-country-'+key).val()
23
+ };
24
+
25
+ //remove the current region input
26
+ jQuery('#'+type+'-region-'+key).remove();
27
+
28
+ //run ajax and process response
29
+ jQuery.get(ajaxurl, data, function(response) {
30
+ jQuery('#'+type+'-country-'+key).after(response);
31
+ });
32
+ }// wpec_taxes_get_regions
33
+
34
+ /**
35
+ * @description: wpec_taxes_count_rates - counts all elements with the wpec-tax-rates class.
36
+ *
37
+ * @param: void
38
+ * @return: integer
39
+ **/
40
+ function wpec_taxes_count_rates()
41
+ {
42
+ return jQuery('.wpec-tax-rates').size();
43
+ }// wpec_taxes_count_rates
44
+
45
+ /**
46
+ * @description: wpec_taxes_build_rate_form - retrieves an entire tax rate row from the server.
47
+ *
48
+ * @param: void
49
+ * @return: boolean false
50
+ **/
51
+ function wpec_taxes_build_rate_form()
52
+ {
53
+ var key = wpec_taxes_count_rates();
54
+
55
+ var data = {
56
+ action: 'wpec_taxes_ajax',
57
+ wpec_taxes_action: 'wpec_taxes_build_rate_form',
58
+ current_key: key
59
+ };
60
+
61
+ //run ajax and process response
62
+ jQuery.get(ajaxurl, data, function(response) {
63
+ jQuery('#add_taxes_rate').before(response);
64
+ });
65
+ return false;
66
+ }// wpec_taxes_tax_rate_form
67
+
68
+ /**
69
+ * @description: wpec_taxes_count_bands - counts all elements with the wpec-tax-bands class.
70
+ *
71
+ * @param: void
72
+ * @return: integer
73
+ **/
74
+ function wpec_taxes_count_bands()
75
+ {
76
+ return jQuery('.wpec-tax-bands').size();
77
+ }// wpec_taxes_count_rates
78
+
79
+ /**
80
+ * @description: wpec_taxes_build_band_form - retrieves an entire tax band row from the server.
81
+ *
82
+ * @param: void
83
+ * @return: boolean false
84
+ **/
85
+ function wpec_taxes_build_band_form()
86
+ {
87
+ var key = wpec_taxes_count_bands();
88
+
89
+ var data = {
90
+ action: 'wpec_taxes_ajax',
91
+ wpec_taxes_action: 'wpec_taxes_build_band_form',
92
+ current_key: key
93
+ };
94
+
95
+ //run ajax and process response
96
+ jQuery.get(ajaxurl, data, function(response) {
97
+ jQuery('#add_taxes_band').before(response);
98
+ });
99
+ return false;
100
+ }// wpec_taxes_tax_band_form
101
+
102
+ /**
103
+ * @description: wpec_taxes_delete_tax_rate - given a key will remove the associated
104
+ * tax rate form row.
105
+ *
106
+ * @param: key - integer. Used in referring to the id for the row.
107
+ * @return: null
108
+ **/
109
+ function wpec_taxes_delete_tax_rate(key)
110
+ {
111
+ if(isNaN(key))
112
+ {
113
+ var key = key.split('-');
114
+ key = key[1];
115
+ }
116
+
117
+ jQuery('#rates-row-'+key).remove();
118
+ }// wpec_taxes_delete_tax_rate
119
+
120
+ /**
121
+ * @description: wpec_taxes_delete_tax_band - given a key will remove the associated
122
+ * tax band form row.
123
+ *
124
+ * @param: key - integer. Used in referring to the id for the row.
125
+ * @return: null
126
+ **/
127
+ function wpec_taxes_delete_tax_band(key)
128
+ {
129
+ if(isNaN(key))
130
+ {
131
+ var key = key.split('-');
132
+ key = key[1];
133
+ }
134
+
135
+ jQuery('#bands-row-'+key).remove();
136
+ }// wpec_taxes_delete_tax_band
137
+
138
+ //bind the click function to the add_tax_rate link and initialize with 0
139
+ jQuery('#add_taxes_rate').live('click', function(){
140
+ wpec_taxes_build_rate_form();
141
+ return false;
142
+ });
143
+
144
+ //bind the click function to each new tax_rate delete link
145
+ jQuery('.taxes-rates-delete').live('click', function(){
146
+ wpec_taxes_delete_tax_rate(jQuery(this).attr('id'));
147
+ return false;
148
+ });
149
+
150
+ //bind the click function to the add_tax_band link and initialize with 0
151
+ jQuery('#add_taxes_band').live('click', function(){
152
+ wpec_taxes_build_band_form();
153
+ return false;
154
+ });
155
+
156
+ //bind the click function to each new tax_band delete link
157
+ jQuery('.taxes-bands-delete').live('click', function(){
158
+ wpec_taxes_delete_tax_band(jQuery(this).attr('id'));
159
+ return false;
160
+ });
wpec-taxes/view/taxes-settings.php ADDED
@@ -0,0 +1,168 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ function wpec_options_taxes()
3
+ {
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
+ <h2><?php echo __('Tax Settings'); ?></h2>
13
+ <p>
14
+ <label for='wpec_taxes_enabled'>
15
+ <input <?php if($wpec_taxes_options['wpec_taxes_enabled']){echo 'checked="checked"';} ?> type="checkbox" id='wpec_taxes_enabled' name='wpsc_options[wpec_taxes_enabled]' />
16
+ <?php echo __('Turn tax on'); ?>
17
+ </label>
18
+ </p>
19
+ <p>
20
+ <label for='wpec_taxes_inprice1'>
21
+ <input <?php if($wpec_taxes_options['wpec_taxes_inprice']=='exclusive'){echo 'checked="checked"';} ?> type="radio" value='exclusive' id='wpec_taxes_inprice1' name='wpsc_options[wpec_taxes_inprice]' />
22
+ <?php echo __('Product prices are tax exclusive - add tax to the price during checkout'); ?>
23
+ </label>
24
+ </p>
25
+ <p>
26
+ <label for='wpec_taxes_inprice2'>
27
+ <input <?php if($wpec_taxes_options['wpec_taxes_inprice']=='inclusive'){echo 'checked="checked"';} ?> type="radio" value='inclusive' id='wpec_taxes_inprice2' name='wpsc_options[wpec_taxes_inprice]' />
28
+ <?php echo __("Product prices are tax inclusive - during checkout the total price doesn't increase but tax is shown as a line item"); ?>
29
+ </label>
30
+ </p>
31
+ <h4><?php echo __('Product Specific Tax'); ?></h4>
32
+ <p>
33
+ <label for='wpec_taxes_product_1'>
34
+ <input <?php if($wpec_taxes_options['wpec_taxes_product']=='add'){echo 'checked="checked"';} ?> type="radio" value='add' id='wpec_taxes_product_1' name='wpsc_options[wpec_taxes_product]' />
35
+ <?php echo __('Add per product tax to tax percentage if product has a specific tax rate'); ?>
36
+ </label>
37
+ </p>
38
+ <p>
39
+ <label for='wpec_taxes_product_2'>
40
+ <input <?php if($wpec_taxes_options['wpec_taxes_product']=='replace'){echo 'checked="checked"';} ?> type="radio" value='replace' id='wpec_taxes_product_2' name='wpsc_options[wpec_taxes_product]' />
41
+ <?php echo __('Replace tax percentage with product specific tax rate'); ?>
42
+ </label>
43
+ </p>
44
+
45
+ <h4><?php echo __('Tax Logic'); ?></h4>
46
+ <p>
47
+ <label for='wpec_taxes_logic_1'>
48
+ <input <?php if($wpec_taxes_options['wpec_taxes_logic']=='billing_shipping'){echo 'checked="checked"';} ?> type="radio" value='billing_shipping' id='wpec_taxes_logic_1' name='wpsc_options[wpec_taxes_logic]' />
49
+ <?php echo __('Apply tax when Billing and Shipping Country is the same as Shops base location'); ?>
50
+ </label>
51
+ <div id='billing_shipping_preference_container' style='margin-left: 20px;'>
52
+ <p>
53
+ <label for='wpec_billing_preference'>
54
+ <input <?php if($wpec_taxes_options['wpec_taxes_logic']=='billing_shipping'&&$wpec_taxes_options['wpec_billing_shipping_preference']=='billing_address'){echo 'checked="checked"';} ?> type="radio" value='billing_address' id='wpec_billing_preference' name='wpsc_options[wpec_billing_shipping_preference]' />
55
+ <?php echo __('Apply tax to Billing Address'); ?>
56
+ </label>
57
+ </p>
58
+ <p>
59
+ <label for='wpec_shipping_preference'>
60
+ <input <?php if($wpec_taxes_options['wpec_taxes_logic']=='billing_shipping'&&$wpec_taxes_options['wpec_billing_shipping_preference']=='shipping_address'){echo 'checked="checked"';} ?> type="radio" value='shipping_address' id='wpec_shipping_preference' name='wpsc_options[wpec_billing_shipping_preference]' />
61
+ <?php echo __('Apply tax to Shipping Address'); ?>
62
+ </label>
63
+ </p>
64
+ </div>
65
+ </p>
66
+ <p>
67
+ <label for='wpec_taxes_logic_2'>
68
+ <input <?php if($wpec_taxes_options['wpec_taxes_logic']=='billing'){echo 'checked="checked"';} ?> type="radio" value='billing' id='wpec_taxes_logic_2' name='wpsc_options[wpec_taxes_logic]' />
69
+ <?php echo __('Apply tax when Billing Country is the same as Shops base location'); ?>
70
+ </label>
71
+ </p>
72
+ <p>
73
+ <label for='wpec_taxes_logic_3'>
74
+ <input <?php if($wpec_taxes_options['wpec_taxes_logic']=='shipping'){echo 'checked="checked"';} ?> type="radio" value='shipping' id='wpec_taxes_logic_3' name='wpsc_options[wpec_taxes_logic]' />
75
+ <?php echo __('Apply tax when Shipping Country is the same as Shops base location'); ?>
76
+ </label>
77
+ </p>
78
+ <div id='metabox-holder' class="metabox-holder">
79
+ <div id='wpec-taxes-rates-container' class='postbox'>
80
+ <h3 class='hndle' style='cursor: default'><?php echo __('Tax Rates'); ?></h3>
81
+ <div id='wpec-taxes-rates' class='inside'>
82
+ <!--Start Taxes Output-->
83
+ <?php
84
+ /**
85
+ * Add New Tax Rate - should add another paragraph with the
86
+ another key specified for the input array
87
+ * Delete - Should remove the given paragraph from the page
88
+ and either ajax delete it from the DB or mark it for
89
+ deletion and process it after the changes are made.
90
+ * Selecting a Country - should automatically populate the
91
+ regions select box. Selecting a different country should
92
+ remove the region select box. If the user selects a
93
+ different country with regions it shouldn't matter because
94
+ the code should automatically add the region select in.
95
+ * - Allow users to define tax for entire country even if regions exist.
96
+ * Shipping Tax - needs to be per region or per tax rate.
97
+ Remove the setting from the main Tax Settings area.
98
+ * Constraints -
99
+ 1. Should not allow a user to add more than one
100
+ tax rate for the same area.
101
+ 2. If a country tax rate is specified and then a region tax
102
+ rate, the region tax rate takes precedence.
103
+ **/
104
+
105
+ //if tax is included warn about shipping
106
+ if($wpec_taxes_controller->wpec_taxes_isincluded())
107
+ {
108
+ echo '<p>'.__('Note: Tax is not applied to shipping when product prices are tax inclusive.').'</p>';
109
+ }// if
110
+
111
+ //get current tax rates
112
+ $tax_rates = $wpec_taxes_controller->wpec_taxes->wpec_taxes_get_rates();
113
+ $tax_rate_count = 0;
114
+ if(!empty($tax_rates))
115
+ {
116
+ foreach($tax_rates as $tax_rate)
117
+ {
118
+ echo $wpec_taxes_controller->wpec_taxes_build_form($tax_rate_count, $tax_rate);
119
+ $tax_rate_count++;
120
+ }// foreach
121
+ }// if
122
+ ?>
123
+ <!--End Taxes Output-->
124
+ <p>
125
+ <a id="add_taxes_rate" href="#"><?php echo __('Add New Tax Rate'); ?></a>
126
+ </p>
127
+ </div>
128
+ </div>
129
+ <div id='wpec-taxes-bands-container' class='postbox'>
130
+ <h3 class='hndle' style='cursor: default'><?php echo __('Tax Bands'); ?></h3>
131
+ <div id='wpec-taxes-bands' class='inside'>
132
+
133
+ <?php
134
+ echo '<p>'.__('Note: Tax Bands are special tax rules you can create and apply on a per-product basis.').'</p>';
135
+
136
+ //echo message regarding inclusive tax
137
+ if(!$wpec_taxes_controller->wpec_taxes_isincluded())
138
+ {
139
+ echo '<p>'.__('Note: Tax Bands do not take affect when product prices are tax exclusive.').'</p>';
140
+ }// if
141
+
142
+ $tax_bands = $wpec_taxes_controller->wpec_taxes->wpec_taxes_get_bands();
143
+ $tax_band_count = 0;
144
+ if(!empty($tax_bands))
145
+ {
146
+ foreach($tax_bands as $tax_band)
147
+ {
148
+ echo $wpec_taxes_controller->wpec_taxes_build_form($tax_band_count, $tax_band, 'bands');
149
+ $tax_band_count++;
150
+ }// foreach
151
+ }// if
152
+ ?>
153
+ <p>
154
+ <a id="add_taxes_band" href="#"><?php echo __('Add New Tax Band'); ?></a>
155
+ </p>
156
+ </div>
157
+ </div><!--wpec-taxes-bands-container-->
158
+ </div><!--metabox-holder-->
159
+ <div class="submit">
160
+ <input type='hidden' name='wpec_admin_action' value='submit_taxes_options' />
161
+ <?php wp_nonce_field('update-options', 'wpsc-update-options'); ?>
162
+ <input type="submit" class='button-primary' value="Save Changes" name="submit_taxes" />
163
+ </div>
164
+ </div>
165
+ </form>
166
+ <?php
167
+ }// wpec_options_taxes
168
+ ?>
wpsc-admin/admin.php CHANGED
@@ -1,832 +1,838 @@
1
- <?php
2
- /**
3
- * WP eCommerce Main Admin functions
4
- *
5
- * These are the main WPSC Admin functions
6
- *
7
- * @package wp-e-commerce
8
- * @since 3.7
9
- */
10
-
11
-
12
- /// admin includes
13
- require_once(WPSC_FILE_PATH."/wpsc-admin/display-update.page.php");
14
- require_once(WPSC_FILE_PATH."/wpsc-admin/display-items.page.php");
15
- require_once(WPSC_FILE_PATH."/wpsc-admin/display-groups.page.php");
16
- require_once(WPSC_FILE_PATH."/wpsc-admin/display-variations.page.php");
17
- require_once(WPSC_FILE_PATH."/wpsc-admin/display-upgrades.page.php");
18
- require_once(WPSC_FILE_PATH."/wpsc-admin/includes/display-items-functions.php");
19
- require_once(WPSC_FILE_PATH."/wpsc-admin/includes/product-functions.php");
20
- require_once(WPSC_FILE_PATH."/wpsc-admin/includes/save-data.functions.php");
21
- require_once(WPSC_FILE_PATH."/wpsc-admin/includes/updating-functions.php");
22
- require_once(WPSC_FILE_PATH."/wpsc-admin/display-coupons.php");
23
-
24
- require_once(WPSC_FILE_PATH."/wpsc-admin/ajax-and-init.php");
25
-
26
- require_once(WPSC_FILE_PATH."/wpsc-admin/display-options-settings.page.php");
27
- require_once(WPSC_FILE_PATH."/wpsc-admin/display-sales-logs.php");
28
-
29
- if(($_SESSION['wpsc_activate_debug_page'] == true) || (defined('WPSC_ADD_DEBUG_PAGE') && (constant('WPSC_ADD_DEBUG_PAGE') == true))) {
30
- require_once(WPSC_FILE_PATH."/wpsc-admin/display-debug.page.php");
31
- }
32
-
33
- //settings pages include
34
- require_once(WPSC_FILE_PATH."/wpsc-admin/includes/settings-pages/general.php");
35
-
36
-
37
- if(get_option('wpsc_checkout_form_fields') == '') {
38
- $form_types = Array("text","email","address","city","country","delivery_address","delivery_city","delivery_country","textarea","heading","select","radio","checkbox");
39
- update_option('wpsc_checkout_form_fields', $form_types);
40
- }
41
-
42
- if(get_option('wpsc_checkout_form_sets') == '') {
43
- $form_sets = array('Default Checkout Forms');
44
- update_option('wpsc_checkout_form_sets', $form_sets);
45
- }
46
-
47
- /**
48
- * wpsc_admin_pages function, all the definitons of admin pages are stores here.
49
- * No parameters, returns nothing
50
- */
51
- function wpsc_admin_pages(){
52
- global $userdata;
53
- /*
54
- * Fairly standard wordpress plugin API stuff for adding the admin pages, rearrange the order to rearrange the pages
55
- * The bits to display the options page first on first use may be buggy, but tend not to stick around long enough to be identified and fixed
56
- * if you find bugs, feel free to fix them.
57
- *
58
- * If the permissions are changed here, they will likewise need to be changed for the other sections of the admin that either use ajax
59
- * or bypass the normal download system.
60
- */
61
- /// Code to enable or disable the debug page
62
- if(isset($_GET['wpsc_activate_debug_page'])) {
63
- if($_GET['wpsc_activate_debug_page'] == 'true') {
64
- // if true, enable it
65
- $_SESSION['wpsc_activate_debug_page'] = true;
66
- } else if($_GET['wpsc_activate_debug_page'] == 'false') {
67
- // if false, disable it
68
- $_SESSION['wpsc_activate_debug_page'] = false;
69
- }
70
- }
71
-
72
- if(function_exists('add_options_page')) {
73
- $base_page = 'wpsc-sales-logs';
74
-
75
- if ($userdata->user_level <= 2) {
76
- if(file_exists(WPSC_UPGRADES_DIR.'gold_cart_files/affiliates.php')) {
77
- require_once(WPSC_UPGRADES_DIR.'gold_cart_files/affiliates.php');
78
- add_object_page(__('Store', 'wpsc'), __('Store', 'wpsc'), 0, WPSC_URL.'/gold_cart_files/affiliates.php','affiliate_page', WPSC_URL."/images/credit_cards.png");
79
- } else {
80
- if (function_exists('add_object_page')) {
81
- add_object_page(__('Store', 'wpsc'), __('Store', 'wpsc'), 2, $base_page,array(), WPSC_URL."/images/credit_cards.png");
82
- } else {
83
- add_menu_page(__('Store', 'wpsc'), __('Store', 'wpsc'), 2, $base_page);
84
- }
85
- }
86
-
87
- } else {
88
- if (function_exists('add_object_page')) {
89
- add_object_page(__('Store', 'wpsc'), __('Store', 'wpsc'), 2, $base_page,array(), WPSC_URL."/images/credit_cards.png");
90
- } else {
91
- add_menu_page(__('Store', 'wpsc'), __('Store', 'wpsc'), 2, $base_page);
92
-
93
- }
94
- }
95
-
96
-
97
- $purchase_log_page = add_submenu_page($base_page, __('Sales', 'wpsc'), __('Sales', 'wpsc'), 7, 'wpsc-sales-logs', 'wpsc_display_sales_logs');
98
- $page_hooks[] = $purchase_log_page;
99
-
100
- global $show_update_page; //this global is set in /wpsc-admin/display-update.page.php
101
- if($show_update_page !== FALSE) :
102
- $page_hooks[] = add_submenu_page($base_page, __('Update', 'wpsc'), __('Update', 'wpsc'), 7, 'wpsc-update', 'wpsc_display_update_page');
103
- endif;
104
- //echo add_submenu_page($base_page,__("Products"), __("Products"), 7, 'wpsc-edit-products', 'wpsc_display_products_page');
105
- $edit_products_page = add_submenu_page($base_page,__('Products', 'wpsc'),__('Products', 'wpsc'), 7, 'wpsc-edit-products', 'wpsc_display_edit_products_page');
106
- $page_hooks[] = $edit_products_page;
107
-
108
- $page_hooks[] = add_submenu_page($base_page,__('Categories', 'wpsc'), __('Categories', 'wpsc'), 7, 'wpsc-edit-groups', 'wpsc_display_categories_page');
109
- //print_r($page_hooks);
110
-
111
- // add_submenu_page($base_page,__('Variations', 'wpsc'), __('Variations', 'wpsc'), 7, WPSC_DIR_NAME.'/display_variations.php');
112
- $page_hooks[] = add_submenu_page($base_page,__('Variations', 'wpsc'), __('Variations', 'wpsc'), 7, 'edit-tags.php?taxonomy=wpsc-variation');
113
-
114
- $box_order = get_option('wpsc_product_page_order');
115
- if ( is_array ($box_order["side"]) && is_array($box_order["advanced"]) ) {
116
- $box_order = array_merge($box_order["side"], $box_order["advanced"]);
117
- }
118
- foreach((array)$box_order as $box) {
119
- $boxes[$box] = ucwords(str_replace("_"," ",$box));
120
- } //exit('-->'.$help);
121
- if (function_exists('add_contextual_help')) {
122
-
123
- add_contextual_help(WPSC_DIR_NAME.'/display-log',"<a target='_blank' href='http://www.instinct.co.nz/e-commerce/sales/'>About this page</a>");
124
-
125
- add_contextual_help(WPSC_DIR_NAME.'/display-category',"<a target='_blank' href='http://www.instinct.co.nz/e-commerce/product-groups/'>About this page</a>");
126
- add_contextual_help(WPSC_DIR_NAME.'/display_variations',"<a target='_blank' href='http://www.instinct.co.nz/e-commerce/variations/'>About this page</a>");
127
- add_contextual_help(WPSC_DIR_NAME.'/display-coupons',"<a target='_blank' href='http://www.instinct.co.nz/e-commerce/marketing/'>About this page</a>");
128
- add_contextual_help(WPSC_DIR_NAME.'/options',"<a target='_blank' href='http://www.instinct.co.nz/e-commerce/shop-settings-general/'>General Settings</a><br />
129
- <a target='_blank' href='http://www.instinct.co.nz/e-commerce/presentation/'>Presentation Options</a> <br />
130
- <a target='_blank' href='http://www.instinct.co.nz/e-commerce/admin-settings/'>Admin Options</a> <br />
131
- <a target='_blank' href='http://www.instinct.co.nz/e-commerce/shipping/'>Shipping Options</a> <br />
132
- <a target='_blank' href='http://www.instinct.co.nz/e-commerce/payment-option/'>Payment Options</a> <br />");
133
- add_contextual_help(WPSC_DIR_NAME.'/display-items',"<a target='_blank' href='http://www.instinct.co.nz/e-commerce/products/'>About this page</a>");
134
- }
135
-
136
- if(IS_WPMU || $GLOBALS['wp_version'] == '3.0'){
137
- $page_hooks[] = add_submenu_page($base_page,__('Marketing', 'wpsc'), __('Marketing', 'wpsc'), 10,'wpsc_display_coupons_page','wpsc_display_coupons_page');
138
- }else{
139
- $page_hooks[] = add_submenu_page($base_page,__('Marketing', 'wpsc'), __('Marketing', 'wpsc'), 7,'wpsc_display_coupons_page','wpsc_display_coupons_page');
140
- }
141
-
142
- $edit_options_page = add_submenu_page($base_page,__('Settings', 'wpsc'), __('Settings', 'wpsc'), 7, 'wpsc-settings', 'wpsc_display_settings_page');
143
- $page_hooks[] = $edit_options_page;
144
-
145
- $page_hooks[] = add_submenu_page($base_page,__('Upgrades', 'wpsc'), __('Upgrades', 'wpsc'), 7, 'wpsc-upgrades', 'wpsc_display_upgrades_page');
146
- //$page_hooks[] = add_submenu_page($base_page,__('Upgrades (Old)', 'wpsc'), __('Upgrades (Old)', 'wpsc'), 7, 'wpsc-gold-options','wpsc_gold_shpcrt_options_page');
147
-
148
- if(($_SESSION['wpsc_activate_debug_page'] == true) || (defined('WPSC_ADD_DEBUG_PAGE') && (constant('WPSC_ADD_DEBUG_PAGE') == true))) {
149
- $page_hooks[] = add_submenu_page($base_page,__('- Debug'), __('- Debug'), 9, 'wpsc-debug', 'wpsc_debug_page');
150
- }
151
-
152
- $page_hooks = apply_filters( 'wpsc_additional_pages', $page_hooks, $base_page);
153
- do_action('wpsc_add_submenu');
154
- }
155
-
156
- //add_action('load-'.WPSC_DIR_NAME.'/display-coupons.php', 'wpsc_admin_include_coupon_js');
157
-
158
- // Include the javascript and CSS for this page
159
-
160
- foreach($page_hooks as $page_hook) {
161
- add_action("load-$page_hook", 'wpsc_admin_include_css_and_js');
162
-
163
- switch($page_hook) {
164
- case $edit_products_page:
165
- add_action("load-$page_hook", 'wpsc_admin_edit_products_page_js');
166
- break;
167
-
168
- case $edit_options_page:
169
- add_action("load-$page_hook", 'wpsc_admin_include_optionspage_css_and_js');
170
- break;
171
-
172
- case $purchase_log_page:
173
- add_action('admin_head', 'wpsc_product_log_rss_feed');
174
- break;
175
- case 'store_page_wpsc_display_coupons_page':
176
- add_action("load-$page_hook", 'wpsc_admin_include_coupon_js');
177
- break;
178
-
179
- }
180
-
181
- }
182
-
183
-
184
- /// some updating code is run from here, is as good a place as any, and better than some
185
- if((get_option('wpsc_trackingid_subject') == null) && (get_option('wpsc_trackingid_message') == null)) {
186
- update_option('wpsc_trackingid_subject', __('Product Tracking Email', 'wpsc'));
187
- update_option('wpsc_trackingid_message', __("Track & Trace means you may track the progress of your parcel with our online parcel tracker, just login to our website and enter the following Tracking ID to view the status of your order.\n\nTracking ID: %trackid%\n", 'wpsc'));
188
- }
189
- return;
190
- }
191
-
192
-
193
- function wpsc_product_log_rss_feed() {
194
- 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'/>";
195
- }
196
-
197
- function wpsc_admin_include_coupon_js() {
198
- $version_identifier = WPSC_VERSION.".".WPSC_MINOR_VERSION;
199
- wp_enqueue_script('wp-e-commerce-admin-parameters', $siteurl."/wp-admin/admin.php?wpsc_admin_dynamic_js=true", false, $version_identifier);
200
-
201
- wp_enqueue_style( 'wp-e-commerce-admin_2.7', WPSC_URL.'/wpsc-admin/css/settingspage.css', false, false, 'all' );
202
- wp_enqueue_script('livequery', WPSC_URL.'/wpsc-admin/js/jquery.livequery.js', array('jquery'), '1.0.3');
203
- wp_enqueue_style( 'wp-e-commerce-admin', WPSC_URL.'/wpsc-admin/css/admin.css', false, $version_identifier, 'all' );
204
- wp_enqueue_script('datepicker-ui', WPSC_URL."/js/ui.datepicker.js",array('jquery-ui-core'), $version_identifier);
205
- wp_enqueue_script('wp-e-commerce-admin_legacy', WPSC_URL.'/admin.js', array('jquery', 'jquery-ui-core', 'jquery-ui-sortable','datepicker-ui'), $version_identifier);
206
- }
207
-
208
-
209
- /**
210
- * wpsc_admin_css_and_js function, includes the wpsc_admin CSS and JS
211
- * No parameters, returns nothing
212
- */
213
- function wpsc_admin_include_css_and_js() {
214
- $siteurl = get_option('siteurl');
215
- if(is_ssl()) {
216
- $siteurl = str_replace("http://", "https://", $siteurl);
217
- }
218
- wp_admin_css( 'dashboard' );
219
- wp_admin_css( 'media' );
220
-
221
- $version_identifier = WPSC_VERSION.".".WPSC_MINOR_VERSION;
222
- wp_enqueue_script('jCrop', WPSC_URL.'/wpsc-admin/js/jquery.Jcrop.min.js', array('jquery'), '0.9.8');
223
- wp_enqueue_script('livequery', WPSC_URL.'/wpsc-admin/js/jquery.livequery.js', array('jquery'), '1.0.3');
224
-
225
-
226
- wp_enqueue_script('wp-e-commerce-admin-parameters', $siteurl."/wp-admin/admin.php?wpsc_admin_dynamic_js=true", false, $version_identifier);
227
- 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);
228
-
229
-
230
-
231
- wp_enqueue_script('wp-e-commerce-legacy-ajax', WPSC_URL.'/wpsc-admin/js/ajax.js', false, $version_identifier); // needs removing
232
- wp_enqueue_script('wp-e-commerce-variations', WPSC_URL.'/wpsc-admin/js/variations.js', array('jquery'), $version_identifier);
233
-
234
- //TODO - This should DEFINITELY come out when we convert to custom post types in the backend
235
- wp_deregister_script( 'postbox' );
236
-
237
- wp_enqueue_style( 'wp-e-commerce-admin', WPSC_URL.'/wpsc-admin/css/admin.css', false, $version_identifier, 'all' );
238
- wp_enqueue_style( 'wp-e-commerce-admin-dynamic', $siteurl."/wp-admin/admin.php?wpsc_admin_dynamic_css=true" , false, $version_identifier, 'all' );
239
- wp_localize_script( 'wp-e-commerce-tags', 'postL10n', array(
240
- 'tagsUsed' => __('Tags used on this post:'),
241
- 'add' => attribute_escape(__('Add')),
242
- 'addTag' => attribute_escape(__('Add new tag')),
243
- 'separate' => __('Separate tags with commas'),
244
- ));
245
- if(defined('WPSC_GOLD_DIR_NAME') && WPSC_GOLD_DIR_NAME != ''){
246
- wp_enqueue_style('gold_cart', WPSC_UPGRADES_URL . 'gold_cart_files/gold_cart.css',false, $version_identifier, 'all');
247
- }
248
-
249
- //jQuery wysiwyg
250
- // if ( user_can_richedit() ) {
251
- // wp_enqueue_script('editor');
252
- // }
253
- // wp_enqueue_script('media-upload');
254
- // wp_enqueue_style('thickbox');
255
-
256
- // Prototype breaks dragging and dropping, I need it gone
257
- wp_deregister_script('prototype');
258
- // remove the old javascript and CSS, we want it no more, it smells bad
259
- remove_action('admin_head', 'wpsc_admin_css');
260
- }
261
-
262
-
263
-
264
- function wpsc_admin_edit_products_page_js() {
265
- wp_enqueue_script('wp-e-commerce-tags', WPSC_URL.'/wpsc-admin/js/product_tagcloud.js', array('livequery'), $version_identifier);
266
- if ( user_can_richedit() ) {
267
- wp_enqueue_script('editor');
268
- }
269
- wp_enqueue_script('media-upload');
270
- wp_enqueue_style('thickbox');
271
-
272
- wp_enqueue_script('post');
273
- wp_enqueue_script('autosave');
274
-
275
-
276
- wp_enqueue_script('swfupload');
277
- wp_enqueue_script('swfupload-swfobject');
278
- wp_enqueue_script('swfupload-queue');
279
- wp_deregister_script('swfupload-handlers');
280
- wp_enqueue_script('wpsc-swfupload-handlers', WPSC_URL.'/wpsc-admin/js/wpsc-swfupload-handlers.js', false, $version_identifier);
281
-
282
- add_action( 'admin_head', 'wp_tiny_mce' );
283
-
284
- // remove cforms timymce code from running on the products page, because it breaks tinymce for us
285
- remove_filter( 'mce_external_plugins', 'cforms_plugin');
286
- remove_filter( 'mce_buttons', 'cforms_button');
287
-
288
- //add_action( 'admin_print_footer_scripts', 'wp_tiny_mce', 25 );
289
- wp_enqueue_script('quicktags');
290
- do_action('wpsc_admin_edit_products_js');
291
-
292
- }
293
- /**
294
- * wpsc_admin_include_optionspage_css_and_js function, includes the wpsc_admin CSS and JS for the specific options page
295
- * No parameters, returns nothing
296
- */
297
-
298
- function wpsc_admin_include_optionspage_css_and_js(){
299
- wp_enqueue_script('wp-e-commerce-js-ajax', WPSC_URL.'/js/ajax.js', false, $version_identifier);
300
-
301
- wp_enqueue_script('wp-e-commerce-js-ui-tabs', WPSC_URL.'/wpsc-admin/js/jquery-ui.js', false, $version_identifier);
302
- wp_enqueue_script('wp-e-commerce-js-dimensions', WPSC_URL.'/wpsc-admin/js/dimensions.js', false, $version_identifier);
303
- wp_enqueue_style( 'wp-e-commerce-admin_2.7', WPSC_URL.'/wpsc-admin/css/settingspage.css', false, false, 'all' );
304
- wp_enqueue_style( 'wp-e-commerce-ui-tabs', WPSC_URL.'/wpsc-admin/css/jquery.ui.tabs.css', false, $version_identifier, 'all' );
305
- }
306
-
307
- function wpsc_meta_boxes(){
308
- //$pagename = 'products_page_wpsc-edit-products';
309
-
310
- $pagename = 'store_page_wpsc-edit-products';
311
- add_meta_box('wpsc_product_category_and_tag_forms', 'Category and Tags', 'wpsc_product_category_and_tag_forms', $pagename, 'normal', 'high');
312
- add_meta_box('wpsc_product_price_and_stock_forms', 'Price and Stock', 'wpsc_product_price_and_stock_forms', $pagename, 'normal', 'high');
313
- add_meta_box('wpsc_product_download_forms', 'Product Download', 'wpsc_product_download_forms', $pagename, 'normal', 'high');
314
- add_meta_box('wpsc_product_image_forms', 'Product Images', 'wpsc_product_image_forms', $pagename, 'normal', 'high');
315
- add_meta_box('wpsc_product_shipping_forms', 'Shipping', 'wpsc_product_shipping_forms', $pagename, 'normal', 'high');
316
- add_meta_box('wpsc_product_variation_forms', 'Variation Control', 'wpsc_product_variation_forms', $pagename, 'normal', 'high');
317
- add_meta_box('wpsc_product_advanced_forms', 'Advanced Settings', 'wpsc_product_advanced_forms', $pagename, 'normal', 'high');
318
- }
319
-
320
- add_action('admin_menu', 'wpsc_meta_boxes');
321
-
322
- function wpsc_admin_dynamic_js() {
323
- header('Content-Type: text/javascript');
324
- header('Expires: '.gmdate('r',mktime(0,0,0,date('m'),(date('d')+12),date('Y'))).'');
325
- header('Cache-Control: public, must-revalidate, max-age=86400');
326
- header('Pragma: public');
327
-
328
- $siteurl = get_option('siteurl');
329
- $hidden_boxes = get_option('wpsc_hidden_box');
330
-
331
- $form_types1 = get_option('wpsc_checkout_form_fields');
332
- $unique_names1 = Array('billingfirstname', 'billinglastname', 'billingaddress', 'billingcity',
333
- 'billingcountry', 'billingemail', 'billingphone', 'billingpostcode',
334
- 'delivertoafriend', 'shippingfirstname', 'shippinglastname', 'shippingaddress',
335
- 'shippingcity', 'shippingstate', 'shippingcountry', 'shippingpostcode');
336
- foreach($form_types1 as $form_type) {
337
- $form_types .= "<option value='".$form_type."'>".__($form_type, 'wpsc')."</option>";
338
- }
339
-
340
- $unique_names = "<option value='-1'>Select a Unique Name</option>";
341
- foreach($unique_names1 as $unique_name){
342
- $unique_names.= "<option value='".$unique_name."'>".$unique_name."</option>";
343
- }
344
-
345
- $hidden_boxes = implode(',', (array)$hidden_boxes);
346
-
347
- echo "var base_url = '".$siteurl."';\n\r";
348
- echo "var WPSC_URL = '". WPSC_URL."';\n\r";
349
- echo "var WPSC_IMAGE_URL = '".WPSC_IMAGE_URL."';\n\r";
350
- echo "var WPSC_DIR_NAME = '".WPSC_DIR_NAME."';\n\r";
351
- echo "var WPSC_IMAGE_URL = '".WPSC_IMAGE_URL."';\n\r";
352
-
353
- // LightBox Configuration start
354
- echo "var fileLoadingImage = '".WPSC_URL."/images/loading.gif';\n\r";
355
- echo "var fileBottomNavCloseImage = '".WPSC_URL."/images/closelabel.gif';\n\r";
356
- echo "var fileThickboxLoadingImage = '".WPSC_URL."/images/loadingAnimation.gif';\n\r";
357
-
358
- echo "var resizeSpeed = 9;\n\r";
359
-
360
- echo "var borderSize = 10;\n\r";
361
-
362
- echo "var hidden_boxes = '".$hidden_boxes."';\n\r";
363
- echo "var IS_WP27 = '".IS_WP27."';\n\r";
364
- echo "var TXT_WPSC_DELETE = '".__('Delete', 'wpsc')."';\n\r";
365
- echo "var TXT_WPSC_TEXT = '".__('Text', 'wpsc')."';\n\r";
366
- echo "var TXT_WPSC_EMAIL = '".__('Email', 'wpsc')."';\n\r";
367
- echo "var TXT_WPSC_COUNTRY = '".__('Country', 'wpsc')."';\n\r";
368
- echo "var TXT_WPSC_TEXTAREA = '".__('Textarea', 'wpsc')."';\n\r";
369
- echo "var TXT_WPSC_HEADING = '".__('Heading', 'wpsc')."';\n\r";
370
- echo "var TXT_WPSC_COUPON = '".__('Coupon', 'wpsc')."';\n\r";
371
-
372
- echo "var HTML_FORM_FIELD_TYPES =\" ".$form_types."; \" \n\r";
373
- echo "var HTML_FORM_FIELD_UNIQUE_NAMES = \" ".$unique_names."; \" \n\r";
374
-
375
- echo "var TXT_WPSC_LABEL = '".__('Label', 'wpsc')."';\n\r";
376
- echo "var TXT_WPSC_LABEL_DESC = '".__('Label Description', 'wpsc')."';\n\r";
377
- echo "var TXT_WPSC_ITEM_NUMBER = '".__('Item Number', 'wpsc')."';\n\r";
378
- echo "var TXT_WPSC_LIFE_NUMBER = '".__('Life Number', 'wpsc')."';\n\r";
379
- echo "var TXT_WPSC_PRODUCT_CODE = '".__('Product Code', 'wpsc')."';\n\r";
380
- echo "var TXT_WPSC_PDF = '".__('PDF', 'wpsc')."';\n\r";
381
-
382
- echo "var TXT_WPSC_AND_ABOVE = '".__(' and above', 'wpsc')."';\n\r";
383
- echo "var TXT_WPSC_IF_PRICE_IS = '".__('If price is ', 'wpsc')."';\n\r";
384
- echo "var TXT_WPSC_IF_WEIGHT_IS = '".__('If weight is ', 'wpsc')."';\n\r";
385
-
386
- exit();
387
- }
388
- if($_GET['wpsc_admin_dynamic_js'] == 'true') {
389
- add_action("admin_init", 'wpsc_admin_dynamic_js');
390
- }
391
-
392
- function wpsc_admin_dynamic_css() {
393
- header('Content-Type: text/css');
394
- header('Expires: '.gmdate('r',mktime(0,0,0,date('m'),(date('d')+12),date('Y'))).'');
395
- header('Cache-Control: public, must-revalidate, max-age=86400');
396
- header('Pragma: public');
397
-
398
- $flash = apply_filters('flash_uploader', $flash);
399
-
400
- if($flash = 1) {
401
- ?>
402
- div.flash-image-uploader {
403
- display: block;
404
- }
405
-
406
- div.browser-image-uploader {
407
- display: none;
408
- }
409
- <?php
410
- } else {
411
- ?>
412
- div.flash-image-uploader {
413
- display: none;
414
- }
415
-
416
- div.browser-image-uploader {
417
- display: block;
418
- }
419
- <?php
420
- }
421
- exit();
422
- }
423
-
424
- if($_GET['wpsc_admin_dynamic_css'] == 'true') {
425
- add_action("admin_init", 'wpsc_admin_dynamic_css');
426
- }
427
-
428
-
429
- //add_action("admin_init", 'wpsc_admin_css_and_js');
430
- add_action('admin_menu', 'wpsc_admin_pages');
431
-
432
-
433
- /*
434
- * Inserts the summary box on the WordPress Dashboard
435
- */
436
-
437
- //if(function_exists('wp_add_dashboard_widget')) {
438
- if( IS_WP27 ) {
439
- add_action('wp_dashboard_setup','wpsc_dashboard_widget_setup');
440
- } else {
441
- add_action('activity_box_end', 'wpsc_admin_dashboard_rightnow');
442
- }
443
-
444
- function wpsc_admin_latest_activity() {
445
- global $wpdb;
446
- $totalOrders = $wpdb->get_var("SELECT COUNT(*) FROM `".WPSC_TABLE_PURCHASE_LOGS."`");
447
-
448
-
449
- /*
450
- * This is the right hand side for the past 30 days revenue on the wp dashboard
451
- */
452
- echo "<div id='leftDashboard'>";
453
- echo "<strong class='dashboardHeading'>".__('Last 30 Days', 'wpsc')."</strong><br />";
454
- echo "<p class='dashboardWidgetSpecial'>";
455
- // calculates total amount of orders for the month
456
- $year = date("Y");
457
- $month = date("m");
458
- $start_timestamp = mktime(0, 0, 0, $month, 1, $year);
459
- $end_timestamp = mktime(0, 0, 0, ($month+1), 0, $year);
460
- $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";
461
- $currentMonthOrders = $wpdb->get_var($sql);
462
-
463
- //calculates amount of money made for the month
464
- $currentMonthsSales = nzshpcrt_currency_display(admin_display_total_price($start_timestamp, $end_timestamp),1);
465
- echo $currentMonthsSales;
466
- echo "<span class='dashboardWidget'>".__('Sales', 'wpsc')."</span>";
467
- echo "</p>";
468
- echo "<p class='dashboardWidgetSpecial'>";
469
- echo "<span class='pricedisplay'>";
470
- echo $currentMonthOrders;
471
- echo "</span>";
472
- echo "<span class='dashboardWidget'>".__('Orders', 'wpsc')."</span>";
473
- echo "</p>";
474
- echo "<p class='dashboardWidgetSpecial'>";
475
- //echo "<span class='pricedisplay'>";
476
- //calculates average sales amount per order for the month
477
- if($currentMonthOrders > 0){
478
- $monthsAverage = ((int)admin_display_total_price($start_timestamp, $end_timestamp)/(int)$currentMonthOrders);
479
- echo nzshpcrt_currency_display($monthsAverage,1);
480
- }
481
- //echo "</span>";
482
- echo "<span class='dashboardWidget'>".__('Avg Orders', 'wpsc')."</span>";
483
- echo "</p>";
484
-
485
-
486
- echo "</div>";
487
- /*
488
- *This is the left side for the total life time revenue on the wp dashboard
489
- */
490
-
491
- echo "<div id='rightDashboard' >";
492
- echo "<strong class='dashboardHeading'>".__('Life Time', 'wpsc')."</strong><br />";
493
-
494
- echo "<p class='dashboardWidgetSpecial'>";
495
- echo nzshpcrt_currency_display(admin_display_total_price(),1);
496
- echo "<span class='dashboardWidget'>".__('Sales', 'wpsc')."</span>";
497
- echo "</p>";
498
- echo "<p class='dashboardWidgetSpecial'>";
499
- echo "<span class='pricedisplay'>";
500
- echo $totalOrders;
501
- echo "</span>";
502
- echo "<span class='dashboardWidget'>".__('Orders', 'wpsc')."</span>";
503
- echo "</p>";
504
- echo "<p class='dashboardWidgetSpecial'>";
505
- //echo "<span class='pricedisplay'>";
506
- //calculates average sales amount per order for the month
507
- if((admin_display_total_price() > 0) && ($totalOrders > 0) ) {
508
- $totalAverage = ((int)admin_display_total_price()/(int)$totalOrders);
509
- } else {
510
- $totalAverage = 0;
511
- }
512
- echo nzshpcrt_currency_display($totalAverage,1);
513
- //echo "</span>";
514
- echo "<span class='dashboardWidget'>".__('Avg Orders', 'wpsc')."</span>";
515
- echo "</p>";
516
- echo "</div>";
517
- echo "<div style='clear:both'></div>";
518
-
519
-
520
- }
521
- add_action('wpsc_admin_pre_activity','wpsc_admin_latest_activity');
522
-
523
-
524
-
525
-
526
-
527
- /*
528
- * Pre-2.7 Dashboard Information
529
- */
530
-
531
- function wpsc_admin_dashboard_rightnow() {
532
- $user = wp_get_current_user();
533
- if($user->user_level>9){
534
- echo "<div>";
535
- echo "<h3>".__('e-Commerce', 'wpsc')."</h3>";
536
- echo "<p>";
537
- do_action('wpsc_admin_pre_activity');
538
- // wpsc_admin_latest_activity();
539
- do_action('wpsc_admin_post_activity');
540
- echo "</div>";
541
- }
542
- }
543
-
544
- /*
545
- * Dashboard Widget for 2.7 (TRansom)
546
- */
547
- function wpsc_dashboard_widget_setup() {
548
- global $current_user;
549
- get_currentuserinfo();
550
- if($current_user->user_level>9) {
551
- wp_enqueue_style( 'wp-e-commerce-admin', WPSC_URL.'/wpsc-admin/css/admin.css', false, $version_identifier, 'all' );
552
- wp_add_dashboard_widget('wpsc_dashboard_widget', __('E-Commerce'),'wpsc_dashboard_widget');
553
- }
554
- }
555
- /*
556
- if(file_exists(WPSC_FILE_PATH."/wpsc-admin/includes/flot_graphs.php")){
557
- function wpsc_dashboard_quarterly_widget_setup() {
558
- wp_enqueue_script('flot', WPSC_URL.'/wpsc-admin/js/jquery.flot.pack.js', array('jquery'), '0.9.8');
559
- wp_enqueue_script('canvas', WPSC_URL.'/wpsc-admin/js/excanvas.pack.js', array('jquery', 'flot'), '0.9.8');
560
-
561
- wp_add_dashboard_widget('wpsc_quarterly_dashboard_widget', __('Sales by Quarter'),'wpsc_quarterly_dashboard_widget');
562
- }
563
- function wpsc_quarterly_dashboard_widget(){
564
- require_once(WPSC_FILE_PATH."/wpsc-admin/includes/flot_graphs.php");
565
- $flot = new flot();
566
-
567
- }
568
- }
569
- */
570
- function wpsc_get_quarterly_summary(){
571
- global $wpdb;
572
- (int)$firstquarter = get_option('wpsc_first_quart');
573
- (int)$secondquarter = get_option('wpsc_second_quart');
574
- (int)$thirdquarter = get_option('wpsc_third_quart');
575
- (int)$fourthquarter = get_option('wpsc_fourth_quart');
576
- (int)$finalquarter = get_option('wpsc_final_quart');
577
-
578
- $results[] = admin_display_total_price($thirdquarter+1, $fourthquarter);
579
- $results[] = admin_display_total_price($secondquarter+1, $thirdquarter);
580
- $results[] = admin_display_total_price($firstquarter+1, $secondquarter);
581
- $results[] = admin_display_total_price($finalquarter, $firstquarter);
582
- return $results;
583
- }
584
- function wpsc_quarterly_dashboard_widget(){
585
- if(get_option('wpsc_business_year_start') == false){
586
- ?>
587
- <form action='' method='post'>
588
- <label for='date_start'>Financial Year End: </label>
589
- <input id='date_start' type='text' class='pickdate' size='11' value='<?php echo get_option('wpsc_last_date'); ?>' name='add_start' />
590
- <!--<select name='add_start[day]'>
591
- <?php
592
- for($i = 1; $i <=31; ++$i) {
593
- $selected = '';
594
- if($i == date("d")) { $selected = "selected='selected'"; }
595
- echo "<option $selected value='$i'>$i</option>";
596
- }
597
- ?>
598
- </select>
599
- <select name='add_start[month]'>
600
- <?php
601
- for($i = 1; $i <=12; ++$i) {
602
- $selected = '';
603
- if($i == (int)date("m")) { $selected = "selected='selected'"; }
604
- echo "<option $selected value='$i'>".date("M",mktime(0, 0, 0, $i, 1, date("Y")))."</option>";
605
- }
606
- ?>
607
- </select>
608
- <select name='add_start[year]'>
609
- <?php
610
- for($i = date("Y"); $i <= (date("Y") +12); ++$i) {
611
- $selected = '';
612
- if($i == date("Y")) { $selected = "selected='true'"; }
613
- echo "<option $selected value='$i'>".$i."</option>";
614
- }
615
- ?>
616
- </select>-->
617
- <input type='hidden' name='wpsc_admin_action' value='wpsc_quarterly' />
618
- <input type='submit' class='button primary' value='Submit' name='wpsc_submit' />
619
- </form>
620
- <?php
621
- if(get_option('wpsc_first_quart') != ''){
622
- $firstquarter = get_option('wpsc_first_quart');
623
- $secondquarter = get_option('wpsc_second_quart');
624
- $thirdquarter = get_option('wpsc_third_quart');
625
- $fourthquarter = get_option('wpsc_fourth_quart');
626
- $finalquarter = get_option('wpsc_final_quart');
627
- $revenue = wpsc_get_quarterly_summary();
628
- $currsymbol = wpsc_get_currency_symbol();
629
- foreach($revenue as $rev){
630
- if($rev == ''){
631
- $totals[] = '0.00';
632
- }else{
633
- $totals[] = $rev;
634
- }
635
- }
636
- ?>
637
- <div id='box'>
638
- <p class='atglance'>
639
- <span class='wpsc_quart_left'>At a Glance</span>
640
- <span class='wpsc_quart_right'>Revenue</span>
641
- </p>
642
- <div style='clear:both'></div>
643
- <p class='quarterly'>
644
- <span class='wpsc_quart_left'><strong>01</strong>&nbsp; (<?php echo date('M Y',$thirdquarter).' - '.date('M Y',$fourthquarter); ?>)</span>
645
- <span class='wpsc_quart_right'><?php echo $currsymbol.' '.$totals[0]; ?></span></p>
646
- <p class='quarterly'>
647
- <span class='wpsc_quart_left'><strong>02</strong>&nbsp; (<?php echo date('M Y',$secondquarter).' - '.date('M Y',$thirdquarter); ?>)</span>
648
- <span class='wpsc_quart_right'><?php echo $currsymbol.' '.$totals[1]; ?></span></p>
649
- <p class='quarterly'>
650
- <span class='wpsc_quart_left'><strong>03</strong>&nbsp; (<?php echo date('M Y',$firstquarter).' - '.date('M Y',$secondquarter); ?>)</span>
651
- <span class='wpsc_quart_right'><?php echo $currsymbol.' '.$totals[2]; ?></span></p>
652
- <p class='quarterly'>
653
- <span class='wpsc_quart_left'><strong>04</strong>&nbsp; (<?php echo date('M Y',$finalquarter).' - '.date('M Y',$firstquarter); ?>)</span>
654
- <span class='wpsc_quart_right'><?php echo $currsymbol.' '.$totals[3]; ?></span>
655
- </p>
656
- <div style='clear:both'></div>
657
- </div>
658
- <?php
659
- }
660
- }
661
-
662
- }
663
- function wpsc_quarterly_setup(){
664
- global $current_user;
665
- get_currentuserinfo();
666
- if($current_user->user_level>9) {
667
- $version_identifier = WPSC_VERSION.".".WPSC_MINOR_VERSION;
668
- wp_enqueue_script('datepicker-ui', WPSC_URL."/js/ui.datepicker.js",array('jquery', 'jquery-ui-core', 'jquery-ui-sortable'), $version_identifier);
669
- wp_add_dashboard_widget('wpsc_quarterly_dashboard_widget', __('Sales by Quarter'),'wpsc_quarterly_dashboard_widget');
670
- }
671
- }
672
-
673
- add_action('wp_dashboard_setup', 'wpsc_quarterly_setup');
674
- function wpsc_dashboard_widget() {
675
- global $current_user;
676
- get_currentuserinfo();
677
- if($current_user->user_level>9) {
678
- do_action('wpsc_admin_pre_activity');
679
- do_action('wpsc_admin_post_activity');
680
- }
681
- }
682
-
683
- /*
684
- * END - Dashboard Widget for 2.7
685
- */
686
-
687
-
688
- /*
689
- * Dashboard Widget Last Four Month Sales.
690
- */
691
-
692
- function wpsc_dashboard_4months_widget(){
693
- global $wpdb;
694
-
695
- $this_year = date("Y"); //get current year and month
696
- $this_month = date("n");
697
-
698
- $months[] = mktime(0, 0, 0, $this_month-3, 1, $this_year); //generate unix time stamps fo 4 last months
699
- $months[] = mktime(0, 0, 0, $this_month-2, 1, $this_year);
700
- $months[] = mktime(0, 0, 0, $this_month-1, 1, $this_year);
701
- $months[] = mktime(0, 0, 0, $this_month, 1, $this_year);
702
-
703
- $products = $wpdb->get_results("SELECT `cart`.`prodid`,
704
- `cart`.`name`
705
- FROM `".WPSC_TABLE_CART_CONTENTS."` AS `cart`
706
- INNER JOIN `".WPSC_TABLE_PURCHASE_LOGS."` AS `logs`
707
- ON `cart`.`purchaseid` = `logs`.`id`
708
- WHERE `logs`.`processed` >= 2
709
- AND `logs`.`date` >= ".$months[0]."
710
- GROUP BY `cart`.`prodid`
711
- ORDER BY SUM(`cart`.`price` * `cart`.`quantity`) DESC
712
- LIMIT 4",ARRAY_A); //get 4 products with top income in 4 last months.
713
-
714
- $timeranges[0]["start"]= mktime(0, 0, 0, $this_month-3, 1, $this_year); //make array of time ranges
715
- $timeranges[0]["end"]= mktime(0, 0, 0, $this_month-2, 1, $this_year);
716
- $timeranges[1]["start"]= mktime(0, 0, 0, $this_month-2, 1, $this_year);
717
- $timeranges[1]["end"]= mktime(0, 0, 0, $this_month-1, 1, $this_year);
718
- $timeranges[2]["start"]= mktime(0, 0, 0, $this_month-1, 1, $this_year);
719
- $timeranges[2]["end"]= mktime(0, 0, 0, $this_month, 1, $this_year);
720
- $timeranges[3]["start"]= mktime(0, 0, 0, $this_month, 1, $this_year);
721
- $timeranges[3]["end"]= mktime();
722
-
723
-
724
- $prod_data = array();
725
- foreach ((array)$products as $product){ //run through products and get each product income amounts and name
726
- $sale_totals = array();
727
- foreach ($timeranges as $timerange){ //run through time ranges of product, and get its income over each time range
728
- $prodsql = "SELECT
729
- SUM(`cart`.`price` * `cart`.`quantity`) AS sum
730
- FROM `".WPSC_TABLE_CART_CONTENTS."` AS `cart`
731
- INNER JOIN `".WPSC_TABLE_PURCHASE_LOGS."` AS `logs`
732
- ON `cart`.`purchaseid` = `logs`.`id`
733
- WHERE `logs`.`processed` >= 2
734
- AND `logs`.`date` >= ".$timerange["start"]."
735
- AND `logs`.`date` < ".$timerange["end"]."
736
- AND `cart`.`prodid` = ".$product['prodid']."
737
- GROUP BY `cart`.`prodid`"; //get the amount of income that current product has generaterd over current time range
738
- $sale_totals[]= $wpdb->get_var($prodsql); //push amount to array
739
- }
740
- //$namesql = "SELECT `".WPSC_TABLE_PRODUCT_LIST."`.`name` FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE `".WPSC_TABLE_PRODUCT_LIST."`.`id` = ".$product['prodid'];
741
- //$name = $wpdb->get_results($namesql,ARRAY_A);
742
- $prod_data[]=array(
743
- 'sale_totals' => $sale_totals,
744
- 'product_name' => $product['name']); //result: array of 2: $prod_data[0] = array(income)
745
- $sums=array(); //reset array //$prod_data[1] = product name
746
- }
747
-
748
- $tablerow=1;
749
- $output.='<div style="padding-bottom:15px; ">Last four months of sales on a per product basis:</div>
750
- <table style="width:100%" border="0" cellspacing="0">
751
- <tr style="font-style:italic; color:#666;" height="20">
752
- <td colspan="2" style=" font-family:\'Times New Roman\', Times, serif; font-size:15px; border-bottom:solid 1px #000;">At a Glance</td>';
753
- foreach ($months as $mnth) {
754
- $output.='<td align="center" style=" font-family:\'Times New Roman\'; font-size:15px; border-bottom:solid 1px #000;">' . date("M", $mnth) . '</td>';
755
- }
756
- $output.='</tr>';
757
- foreach((array)$prod_data as $sales_data) {
758
- $output.='<tr height="20">
759
- <td width="20" style="font-weight:bold; color:#008080; border-bottom:solid 1px #000;">' . $tablerow . '</td>
760
- <td style="border-bottom:solid 1px #000;width:60px">' . $sales_data['product_name'] . '</td>';
761
- $currsymbol=wpsc_get_currency_symbol();
762
- $tablerow++;
763
- foreach ($sales_data['sale_totals'] as $amount) {
764
- $output.= '<td align="center" style="border-bottom:solid 1px #000;">' . $currsymbol . number_format(absint($amount),2) . '</td>';
765
- }
766
- $output.='</tr>';
767
- }
768
- $output.='</table>';
769
- echo $output;
770
- }
771
-
772
- function wpsc_dashboard_4months_widget_setup() {
773
- global $current_user;
774
- get_currentuserinfo();
775
- if($current_user->user_level == 10) {
776
- wp_add_dashboard_widget('wpsc_dashboard_4months_widget', __('Sales by'),'wpsc_dashboard_4months_widget');
777
- }
778
- }
779
-
780
- function wpsc_admin_4months_widget_rightnow() {
781
- $user = wp_get_current_user();
782
- if($user->user_level>9){
783
- echo "<div>";
784
- echo "<h3>".__('e-Commerce', 'wpsc')."</h3>";
785
- echo "<p>";
786
- wpsc_dashboard_4months_widget();
787
- echo "</div>";
788
- }
789
- }
790
-
791
- if( IS_WP27 ) {
792
- add_action('wp_dashboard_setup','wpsc_dashboard_4months_widget_setup');
793
- } else {
794
- add_action('activity_box_end', 'wpsc_admin_4months_widget_rightnow');
795
- }
796
-
797
- //Modification to allow for multiple column layout
798
-
799
- add_filter('screen_layout_columns', 'wpec_two_columns', 10, 2);
800
-
801
- function wpec_two_columns($columns, $screen) {
802
- if ($screen == 'store_page_wpsc-edit-products') {
803
- $columns['store_page_wpsc-edit-products'] = 2;
804
- }
805
- return $columns;
806
- }
807
- function wpsc_fav_action($actions) {
808
- $actions['admin.php?page=wpsc-edit-products&action=wpsc_add_edit'] = array('New Product', 'manage_options');
809
- return $actions;
810
- }
811
- add_filter('favorite_actions', 'wpsc_fav_action');
812
-
813
- function wpsc_admin_notices() {
814
- global $wpdb;
815
- // exit(get_option('wpsc_default_category'));
816
- if(get_option('wpsc_default_category') != 'all+list' && get_option('wpsc_default_category') != 'all' && get_option('wpsc_default_category') != 'list') {
817
- if((get_option('wpsc_default_category') < 1)) { // if there is no default category or it is deleted
818
- if(!$_POST['wpsc_default_category']) { // if we are not changing the default category
819
- echo "<div id='message' class='updated fade' style='background-color: rgb(255, 251, 204);'>";
820
- echo "<p>".__('Your "products page" is not currently set to display any products. You need to select a product grouping to display by default. <br /> This is set in the Shop Settings page.', 'wpsc')."</p>";
821
- echo "</div>\n\r";
822
- }
823
- }
824
- }
825
- }
826
-
827
- if(stristr($_GET['page'], WPSC_DIR_NAME)) {
828
- add_action('admin_notices', 'wpsc_admin_notices');
829
- }
830
-
831
-
 
 
 
 
 
 
832
  ?>
1
+ <?php
2
+ /**
3
+ * WP eCommerce Main Admin functions
4
+ *
5
+ * These are the main WPSC Admin functions
6
+ *
7
+ * @package wp-e-commerce
8
+ * @since 3.7
9
+ */
10
+
11
+
12
+ /// admin includes
13
+ require_once(WPSC_FILE_PATH."/wpsc-admin/display-update.page.php");
14
+ require_once(WPSC_FILE_PATH."/wpsc-admin/display-items.page.php");
15
+ require_once(WPSC_FILE_PATH."/wpsc-admin/display-groups.page.php");
16
+ require_once(WPSC_FILE_PATH."/wpsc-admin/display-variations.page.php");
17
+ require_once(WPSC_FILE_PATH."/wpsc-admin/display-upgrades.page.php");
18
+ require_once(WPSC_FILE_PATH."/wpsc-admin/includes/display-items-functions.php");
19
+ require_once(WPSC_FILE_PATH."/wpsc-admin/includes/product-functions.php");
20
+ require_once(WPSC_FILE_PATH."/wpsc-admin/includes/save-data.functions.php");
21
+ require_once(WPSC_FILE_PATH."/wpsc-admin/includes/updating-functions.php");
22
+ require_once(WPSC_FILE_PATH."/wpsc-admin/display-coupons.php");
23
+
24
+ require_once(WPSC_FILE_PATH."/wpsc-admin/ajax-and-init.php");
25
+
26
+ require_once(WPSC_FILE_PATH."/wpsc-admin/display-options-settings.page.php");
27
+ require_once(WPSC_FILE_PATH."/wpsc-admin/display-sales-logs.php");
28
+
29
+ if((isset($_SESSION['wpsc_activate_debug_page']) && ($_SESSION['wpsc_activate_debug_page'] == true)) || (defined('WPSC_ADD_DEBUG_PAGE') && (constant('WPSC_ADD_DEBUG_PAGE') == true))) {
30
+ require_once(WPSC_FILE_PATH."/wpsc-admin/display-debug.page.php");
31
+ }
32
+
33
+ //settings pages include
34
+ require_once(WPSC_FILE_PATH."/wpsc-admin/includes/settings-pages/general.php");
35
+
36
+
37
+ if(get_option('wpsc_checkout_form_fields') == '') {
38
+ $form_types = Array("text","email","address","city","country","delivery_address","delivery_city","delivery_country","textarea","heading","select","radio","checkbox");
39
+ update_option('wpsc_checkout_form_fields', $form_types);
40
+ }
41
+
42
+ if(get_option('wpsc_checkout_form_sets') == '') {
43
+ $form_sets = array('Default Checkout Forms');
44
+ update_option('wpsc_checkout_form_sets', $form_sets);
45
+ }
46
+
47
+ /**
48
+ * wpsc_admin_pages function, all the definitons of admin pages are stores here.
49
+ * No parameters, returns nothing
50
+ */
51
+ function wpsc_admin_pages(){
52
+ global $userdata;
53
+ /*
54
+ * Fairly standard wordpress plugin API stuff for adding the admin pages, rearrange the order to rearrange the pages
55
+ * The bits to display the options page first on first use may be buggy, but tend not to stick around long enough to be identified and fixed
56
+ * if you find bugs, feel free to fix them.
57
+ *
58
+ * If the permissions are changed here, they will likewise need to be changed for the other sections of the admin that either use ajax
59
+ * or bypass the normal download system.
60
+ */
61
+ /// Code to enable or disable the debug page
62
+ if(isset($_GET['wpsc_activate_debug_page'])) {
63
+ if($_GET['wpsc_activate_debug_page'] == 'true') {
64
+ // if true, enable it
65
+ $_SESSION['wpsc_activate_debug_page'] = true;
66
+ } else if($_GET['wpsc_activate_debug_page'] == 'false') {
67
+ // if false, disable it
68
+ $_SESSION['wpsc_activate_debug_page'] = false;
69
+ }
70
+ }
71
+
72
+ if(function_exists('add_options_page')) {
73
+ $base_page = 'wpsc-sales-logs';
74
+
75
+ if ($userdata->user_level <= 2) {
76
+ if(file_exists(WPSC_UPGRADES_DIR.'gold_cart_files/affiliates.php')) {
77
+ require_once(WPSC_UPGRADES_DIR.'gold_cart_files/affiliates.php');
78
+ add_object_page(__('Store', 'wpsc'), __('Store', 'wpsc'), 'subscriber', WPSC_URL.'/gold_cart_files/affiliates.php','affiliate_page', WPSC_URL."/images/credit_cards.png");
79
+ } else {
80
+ if (function_exists('add_object_page')) {
81
+ add_object_page(__('Store', 'wpsc'), __('Store', 'wpsc'), 'author', $base_page,array(), WPSC_URL."/images/credit_cards.png");
82
+ } else {
83
+ add_menu_page(__('Store', 'wpsc'), __('Store', 'wpsc'), 'author', $base_page);
84
+ }
85
+ }
86
+
87
+ } else {
88
+ if (function_exists('add_object_page')) {
89
+ add_object_page(__('Store', 'wpsc'), __('Store', 'wpsc'), 'administrator', $base_page,array(), WPSC_URL."/images/credit_cards.png");
90
+ } else {
91
+ add_menu_page(__('Store', 'wpsc'), __('Store', 'wpsc'), 'administrator', $base_page);
92
+
93
+ }
94
+ }
95
+
96
+
97
+ $purchase_log_page = add_submenu_page($base_page, __('Sales', 'wpsc'), __('Sales', 'wpsc'), 'administrator', 'wpsc-sales-logs', 'wpsc_display_sales_logs');
98
+ $page_hooks[] = $purchase_log_page;
99
+
100
+ global $show_update_page; //this global is set in /wpsc-admin/display-update.page.php
101
+ if($show_update_page !== FALSE) :
102
+ $page_hooks[] = add_submenu_page($base_page, __('Update', 'wpsc'), __('Update', 'wpsc'), 'administrator', 'wpsc-update', 'wpsc_display_update_page');
103
+ endif;
104
+ //echo add_submenu_page($base_page,__("Products"), __("Products"), 'editor', 'wpsc-edit-products', 'wpsc_display_products_page');
105
+ $edit_products_page = add_submenu_page($base_page,__('Products', 'wpsc'),__('Products', 'wpsc'), 'administrator', 'wpsc-edit-products', 'wpsc_display_edit_products_page');
106
+ $page_hooks[] = $edit_products_page;
107
+
108
+ $page_hooks[] = add_submenu_page($base_page,__('Categories', 'wpsc'), __('Categories', 'wpsc'), 'administrator', 'wpsc-edit-groups', 'wpsc_display_categories_page');
109
+ //print_r($page_hooks);
110
+
111
+ // add_submenu_page($base_page,__('Variations', 'wpsc'), __('Variations', 'wpsc'), 7, WPSC_DIR_NAME.'/display_variations.php');
112
+ $page_hooks[] = add_submenu_page($base_page,__('Variations', 'wpsc'), __('Variations', 'wpsc'), 'administrator', 'edit-tags.php?taxonomy=wpsc-variation');
113
+
114
+ $box_order = get_option('wpsc_product_page_order');
115
+ if ( isset($box_order["side"]) && is_array ($box_order["side"]) && is_array($box_order["advanced"]) ) {
116
+ $box_order = array_merge($box_order["side"], $box_order["advanced"]);
117
+ }
118
+ foreach((array)$box_order as $box) {
119
+ $boxes[$box] = ucwords(str_replace("_"," ",$box));
120
+ } //exit('-->'.$help);
121
+ if (function_exists('add_contextual_help')) {
122
+
123
+ add_contextual_help(WPSC_DIR_NAME.'/display-log',"<a target='_blank' href='http://www.instinct.co.nz/e-commerce/sales/'>About this page</a>");
124
+
125
+ add_contextual_help(WPSC_DIR_NAME.'/display-category',"<a target='_blank' href='http://www.instinct.co.nz/e-commerce/product-groups/'>About this page</a>");
126
+ add_contextual_help(WPSC_DIR_NAME.'/display_variations',"<a target='_blank' href='http://www.instinct.co.nz/e-commerce/variations/'>About this page</a>");
127
+ add_contextual_help(WPSC_DIR_NAME.'/display-coupons',"<a target='_blank' href='http://www.instinct.co.nz/e-commerce/marketing/'>About this page</a>");
128
+ add_contextual_help(WPSC_DIR_NAME.'/options',"<a target='_blank' href='http://www.instinct.co.nz/e-commerce/shop-settings-general/'>General Settings</a><br />
129
+ <a target='_blank' href='http://www.instinct.co.nz/e-commerce/presentation/'>Presentation Options</a> <br />
130
+ <a target='_blank' href='http://www.instinct.co.nz/e-commerce/admin-settings/'>Admin Options</a> <br />
131
+ <a target='_blank' href='http://www.instinct.co.nz/e-commerce/shipping/'>Shipping Options</a> <br />
132
+ <a target='_blank' href='http://www.instinct.co.nz/e-commerce/payment-option/'>Payment Options</a> <br />");
133
+ add_contextual_help(WPSC_DIR_NAME.'/display-items',"<a target='_blank' href='http://www.instinct.co.nz/e-commerce/products/'>About this page</a>");
134
+ }
135
+
136
+ if(IS_WPMU || $GLOBALS['wp_version'] == '3.0'){
137
+ $page_hooks[] = add_submenu_page($base_page,__('Marketing', 'wpsc'), __('Marketing', 'wpsc'), 'administrator','wpsc_display_coupons_page','wpsc_display_coupons_page');
138
+ }else{
139
+ $page_hooks[] = add_submenu_page($base_page,__('Marketing', 'wpsc'), __('Marketing', 'wpsc'), 'administrator','wpsc_display_coupons_page','wpsc_display_coupons_page');
140
+ }
141
+
142
+ $edit_options_page = add_submenu_page($base_page,__('Settings', 'wpsc'), __('Settings', 'wpsc'), 'administrator', 'wpsc-settings', 'wpsc_display_settings_page');
143
+ $page_hooks[] = $edit_options_page;
144
+
145
+ $page_hooks[] = add_submenu_page($base_page,__('Upgrades', 'wpsc'), __('Upgrades', 'wpsc'), 'administrator', 'wpsc-upgrades', 'wpsc_display_upgrades_page');
146
+ //$page_hooks[] = add_submenu_page($base_page,__('Upgrades (Old)', 'wpsc'), __('Upgrades (Old)', 'wpsc'), 'editor', 'wpsc-gold-options','wpsc_gold_shpcrt_options_page');
147
+
148
+ if( (isset($_SESSION['wpsc_activate_debug_page']) && ($_SESSION['wpsc_activate_debug_page'] == true)) || (defined('WPSC_ADD_DEBUG_PAGE') && (constant('WPSC_ADD_DEBUG_PAGE') == true))) {
149
+ $page_hooks[] = add_submenu_page($base_page,__('- Debug'), __('- Debug'), 'administrator', 'wpsc-debug', 'wpsc_debug_page');
150
+ }
151
+
152
+ $page_hooks = apply_filters( 'wpsc_additional_pages', $page_hooks, $base_page);
153
+ do_action('wpsc_add_submenu');
154
+ }
155
+
156
+ //add_action('load-'.WPSC_DIR_NAME.'/display-coupons.php', 'wpsc_admin_include_coupon_js');
157
+
158
+ // Include the javascript and CSS for this page
159
+
160
+ foreach($page_hooks as $page_hook) {
161
+ add_action("load-$page_hook", 'wpsc_admin_include_css_and_js');
162
+
163
+ switch($page_hook) {
164
+ case $edit_products_page:
165
+ add_action("load-$page_hook", 'wpsc_admin_edit_products_page_js');
166
+ break;
167
+
168
+ case $edit_options_page:
169
+ add_action("load-$page_hook", 'wpsc_admin_include_optionspage_css_and_js');
170
+ break;
171
+
172
+ case $purchase_log_page:
173
+ add_action('admin_head', 'wpsc_product_log_rss_feed');
174
+ break;
175
+ case 'store_page_wpsc_display_coupons_page':
176
+ add_action("load-$page_hook", 'wpsc_admin_include_coupon_js');
177
+ break;
178
+
179
+ }
180
+
181
+ }
182
+
183
+
184
+ /// some updating code is run from here, is as good a place as any, and better than some
185
+ if((get_option('wpsc_trackingid_subject') == null) && (get_option('wpsc_trackingid_message') == null)) {
186
+ update_option('wpsc_trackingid_subject', __('Product Tracking Email', 'wpsc'));
187
+ update_option('wpsc_trackingid_message', __("Track & Trace means you may track the progress of your parcel with our online parcel tracker, just login to our website and enter the following Tracking ID to view the status of your order.\n\nTracking ID: %trackid%\n", 'wpsc'));
188
+ }
189
+ return;
190
+ }
191
+
192
+
193
+ function wpsc_product_log_rss_feed() {
194
+ 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'/>";
195
+ }
196
+
197
+ function wpsc_admin_include_coupon_js() {
198
+ $version_identifier = WPSC_VERSION.".".WPSC_MINOR_VERSION;
199
+ $siteurl = get_option('siteurl');
200
+ wp_enqueue_script('wp-e-commerce-admin-parameters', $siteurl."/wp-admin/admin.php?wpsc_admin_dynamic_js=true", false, $version_identifier);
201
+
202
+ wp_enqueue_style( 'wp-e-commerce-admin_2.7', WPSC_URL.'/wpsc-admin/css/settingspage.css', false, false, 'all' );
203
+ wp_enqueue_script('livequery', WPSC_URL.'/wpsc-admin/js/jquery.livequery.js', array('jquery'), '1.0.3');
204
+ wp_enqueue_style( 'wp-e-commerce-admin', WPSC_URL.'/wpsc-admin/css/admin.css', false, $version_identifier, 'all' );
205
+ wp_enqueue_script('datepicker-ui', WPSC_URL."/js/ui.datepicker.js",array('jquery-ui-core'), $version_identifier);
206
+ wp_enqueue_script('wp-e-commerce-admin_legacy', WPSC_URL.'/admin.js', array('jquery', 'jquery-ui-core', 'jquery-ui-sortable','datepicker-ui'), $version_identifier);
207
+ }
208
+
209
+
210
+ /**
211
+ * wpsc_admin_css_and_js function, includes the wpsc_admin CSS and JS
212
+ * No parameters, returns nothing
213
+ */
214
+ function wpsc_admin_include_css_and_js() {
215
+ $siteurl = get_option('siteurl');
216
+ if(is_ssl()) {
217
+ $siteurl = str_replace("http://", "https://", $siteurl);
218
+ }
219
+ wp_admin_css( 'dashboard' );
220
+ wp_admin_css( 'media' );
221
+
222
+ $version_identifier = WPSC_VERSION.".".WPSC_MINOR_VERSION;
223
+ wp_enqueue_script('jCrop', WPSC_URL.'/wpsc-admin/js/jquery.Jcrop.min.js', array('jquery'), '0.9.8');
224
+ wp_enqueue_script('livequery', WPSC_URL.'/wpsc-admin/js/jquery.livequery.js', array('jquery'), '1.0.3');
225
+
226
+
227
+ wp_enqueue_script('wp-e-commerce-admin-parameters', $siteurl."/wp-admin/admin.php?wpsc_admin_dynamic_js=true", false, $version_identifier);
228
+ 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);
229
+
230
+
231
+
232
+ wp_enqueue_script('wp-e-commerce-legacy-ajax', WPSC_URL.'/wpsc-admin/js/ajax.js', false, $version_identifier); // needs removing
233
+ wp_enqueue_script('wp-e-commerce-variations', WPSC_URL.'/wpsc-admin/js/variations.js', array('jquery'), $version_identifier);
234
+
235
+ //TODO - This should DEFINITELY come out when we convert to custom post types in the backend
236
+ wp_deregister_script( 'postbox' );
237
+
238
+ wp_enqueue_style( 'wp-e-commerce-admin', WPSC_URL.'/wpsc-admin/css/admin.css', false, $version_identifier, 'all' );
239
+ wp_enqueue_style( 'wp-e-commerce-admin-dynamic', $siteurl."/wp-admin/admin.php?wpsc_admin_dynamic_css=true" , false, $version_identifier, 'all' );
240
+ wp_localize_script( 'wp-e-commerce-tags', 'postL10n', array(
241
+ 'tagsUsed' => __('Tags used on this post:'),
242
+ 'add' => esc_attr(__('Add')),
243
+ 'addTag' => esc_attr(__('Add new tag')),
244
+ 'separate' => __('Separate tags with commas'),
245
+ ));
246
+ if(defined('WPSC_GOLD_DIR_NAME') && WPSC_GOLD_DIR_NAME != ''){
247
+ wp_enqueue_style('gold_cart', WPSC_UPGRADES_URL . 'gold_cart_files/gold_cart.css',false, $version_identifier, 'all');
248
+ }
249
+
250
+ //jQuery wysiwyg
251
+ // if ( user_can_richedit() ) {
252
+ // wp_enqueue_script('editor');
253
+ // }
254
+ // wp_enqueue_script('media-upload');
255
+ // wp_enqueue_style('thickbox');
256
+
257
+ // Prototype breaks dragging and dropping, I need it gone
258
+ wp_deregister_script('prototype');
259
+ // remove the old javascript and CSS, we want it no more, it smells bad
260
+ remove_action('admin_head', 'wpsc_admin_css');
261
+ }
262
+
263
+
264
+
265
+ function wpsc_admin_edit_products_page_js() {
266
+ $version_identifier = WPSC_VERSION.".".WPSC_MINOR_VERSION;
267
+ wp_enqueue_script('wp-e-commerce-tags', WPSC_URL.'/wpsc-admin/js/product_tagcloud.js', array('livequery'), $version_identifier);
268
+ if ( user_can_richedit() ) {
269
+ wp_enqueue_script('editor');
270
+ }
271
+ wp_enqueue_script('media-upload');
272
+ wp_enqueue_style('thickbox');
273
+
274
+ wp_enqueue_script('post');
275
+ wp_enqueue_script('autosave');
276
+
277
+
278
+ wp_enqueue_script('swfupload');
279
+ wp_enqueue_script('swfupload-swfobject');
280
+ wp_enqueue_script('swfupload-queue');
281
+ wp_deregister_script('swfupload-handlers');
282
+ wp_enqueue_script('wpsc-swfupload-handlers', WPSC_URL.'/wpsc-admin/js/wpsc-swfupload-handlers.js', false, $version_identifier);
283
+
284
+ add_action( 'admin_head', 'wp_tiny_mce' );
285
+
286
+ // remove cforms timymce code from running on the products page, because it breaks tinymce for us
287
+ remove_filter( 'mce_external_plugins', 'cforms_plugin');
288
+ remove_filter( 'mce_buttons', 'cforms_button');
289
+
290
+ //add_action( 'admin_print_footer_scripts', 'wp_tiny_mce', 25 );
291
+ wp_enqueue_script('quicktags');
292
+ do_action('wpsc_admin_edit_products_js');
293
+
294
+ }
295
+ /**
296
+ * wpsc_admin_include_optionspage_css_and_js function, includes the wpsc_admin CSS and JS for the specific options page
297
+ * No parameters, returns nothing
298
+ */
299
+
300
+ function wpsc_admin_include_optionspage_css_and_js(){
301
+ $version_identifier = WPSC_VERSION.".".WPSC_MINOR_VERSION;
302
+ wp_enqueue_script('wp-e-commerce-js-ajax', WPSC_URL.'/js/ajax.js', false, $version_identifier);
303
+
304
+ wp_enqueue_script('wp-e-commerce-js-ui-tabs', WPSC_URL.'/wpsc-admin/js/jquery-ui.js', false, $version_identifier);
305
+ wp_enqueue_script('wp-e-commerce-js-dimensions', WPSC_URL.'/wpsc-admin/js/dimensions.js', false, $version_identifier);
306
+ wp_enqueue_style( 'wp-e-commerce-admin_2.7', WPSC_URL.'/wpsc-admin/css/settingspage.css', false, false, 'all' );
307
+ wp_enqueue_style( 'wp-e-commerce-ui-tabs', WPSC_URL.'/wpsc-admin/css/jquery.ui.tabs.css', false, $version_identifier, 'all' );
308
+ }
309
+
310
+ function wpsc_meta_boxes(){
311
+ //$pagename = 'products_page_wpsc-edit-products';
312
+
313
+ $pagename = 'store_page_wpsc-edit-products';
314
+ add_meta_box('wpsc_product_category_and_tag_forms', 'Category and Tags', 'wpsc_product_category_and_tag_forms', $pagename, 'normal', 'high');
315
+ add_meta_box('wpsc_product_price_and_stock_forms', 'Price and Stock', 'wpsc_product_price_and_stock_forms', $pagename, 'normal', 'high');
316
+ add_meta_box('wpsc_product_download_forms', 'Product Download', 'wpsc_product_download_forms', $pagename, 'normal', 'high');
317
+ add_meta_box('wpsc_product_image_forms', 'Product Images', 'wpsc_product_image_forms', $pagename, 'normal', 'high');
318
+ add_meta_box('wpsc_product_shipping_forms', 'Shipping', 'wpsc_product_shipping_forms', $pagename, 'normal', 'high');
319
+ add_meta_box('wpsc_product_variation_forms', 'Variation Control', 'wpsc_product_variation_forms', $pagename, 'normal', 'high');
320
+ add_meta_box('wpsc_product_advanced_forms', 'Advanced Settings', 'wpsc_product_advanced_forms', $pagename, 'normal', 'high');
321
+ }
322
+
323
+ add_action('admin_menu', 'wpsc_meta_boxes');
324
+
325
+ function wpsc_admin_dynamic_js() {
326
+ header('Content-Type: text/javascript');
327
+ header('Expires: '.gmdate('r',mktime(0,0,0,date('m'),(date('d')+12),date('Y'))).'');
328
+ header('Cache-Control: public, must-revalidate, max-age=86400');
329
+ header('Pragma: public');
330
+
331
+ $siteurl = get_option('siteurl');
332
+ $hidden_boxes = get_option('wpsc_hidden_box');
333
+
334
+ $form_types1 = get_option('wpsc_checkout_form_fields');
335
+ $unique_names1 = Array('billingfirstname', 'billinglastname', 'billingaddress', 'billingcity',
336
+ 'billingcountry', 'billingemail', 'billingphone', 'billingpostcode',
337
+ 'delivertoafriend', 'shippingfirstname', 'shippinglastname', 'shippingaddress',
338
+ 'shippingcity', 'shippingstate', 'shippingcountry', 'shippingpostcode');
339
+ $form_types = '';
340
+ foreach($form_types1 as $form_type) {
341
+ $form_types .= "<option value='".$form_type."'>".__($form_type, 'wpsc')."</option>";
342
+ }
343
+
344
+ $unique_names = "<option value='-1'>Select a Unique Name</option>";
345
+ foreach($unique_names1 as $unique_name){
346
+ $unique_names.= "<option value='".$unique_name."'>".$unique_name."</option>";
347
+ }
348
+
349
+ $hidden_boxes = implode(',', (array)$hidden_boxes);
350
+
351
+ echo "var base_url = '".$siteurl."';\n\r";
352
+ echo "var WPSC_URL = '". WPSC_URL."';\n\r";
353
+ echo "var WPSC_IMAGE_URL = '".WPSC_IMAGE_URL."';\n\r";
354
+ echo "var WPSC_DIR_NAME = '".WPSC_DIR_NAME."';\n\r";
355
+ echo "var WPSC_IMAGE_URL = '".WPSC_IMAGE_URL."';\n\r";
356
+
357
+ // LightBox Configuration start
358
+ echo "var fileLoadingImage = '".WPSC_URL."/images/loading.gif';\n\r";
359
+ echo "var fileBottomNavCloseImage = '".WPSC_URL."/images/closelabel.gif';\n\r";
360
+ echo "var fileThickboxLoadingImage = '".WPSC_URL."/images/loadingAnimation.gif';\n\r";
361
+
362
+ echo "var resizeSpeed = 9;\n\r";
363
+
364
+ echo "var borderSize = 10;\n\r";
365
+
366
+ echo "var hidden_boxes = '".$hidden_boxes."';\n\r";
367
+ echo "var IS_WP27 = '".IS_WP27."';\n\r";
368
+ echo "var TXT_WPSC_DELETE = '".__('Delete', 'wpsc')."';\n\r";
369
+ echo "var TXT_WPSC_TEXT = '".__('Text', 'wpsc')."';\n\r";
370
+ echo "var TXT_WPSC_EMAIL = '".__('Email', 'wpsc')."';\n\r";
371
+ echo "var TXT_WPSC_COUNTRY = '".__('Country', 'wpsc')."';\n\r";
372
+ echo "var TXT_WPSC_TEXTAREA = '".__('Textarea', 'wpsc')."';\n\r";
373
+ echo "var TXT_WPSC_HEADING = '".__('Heading', 'wpsc')."';\n\r";
374
+ echo "var TXT_WPSC_COUPON = '".__('Coupon', 'wpsc')."';\n\r";
375
+
376
+ echo "var HTML_FORM_FIELD_TYPES =\" ".$form_types."; \" \n\r";
377
+ echo "var HTML_FORM_FIELD_UNIQUE_NAMES = \" ".$unique_names."; \" \n\r";
378
+
379
+ echo "var TXT_WPSC_LABEL = '".__('Label', 'wpsc')."';\n\r";
380
+ echo "var TXT_WPSC_LABEL_DESC = '".__('Label Description', 'wpsc')."';\n\r";
381
+ echo "var TXT_WPSC_ITEM_NUMBER = '".__('Item Number', 'wpsc')."';\n\r";
382
+ echo "var TXT_WPSC_LIFE_NUMBER = '".__('Life Number', 'wpsc')."';\n\r";
383
+ echo "var TXT_WPSC_PRODUCT_CODE = '".__('Product Code', 'wpsc')."';\n\r";
384
+ echo "var TXT_WPSC_PDF = '".__('PDF', 'wpsc')."';\n\r";
385
+
386
+ echo "var TXT_WPSC_AND_ABOVE = '".__(' and above', 'wpsc')."';\n\r";
387
+ echo "var TXT_WPSC_IF_PRICE_IS = '".__('If price is ', 'wpsc')."';\n\r";
388
+ echo "var TXT_WPSC_IF_WEIGHT_IS = '".__('If weight is ', 'wpsc')."';\n\r";
389
+
390
+ exit();
391
+ }
392
+ if(isset($_GET['wpsc_admin_dynamic_js']) && ($_GET['wpsc_admin_dynamic_js'] == 'true')) {
393
+ add_action("admin_init", 'wpsc_admin_dynamic_js');
394
+ }
395
+
396
+ function wpsc_admin_dynamic_css() {
397
+ header('Content-Type: text/css');
398
+ header('Expires: '.gmdate('r',mktime(0,0,0,date('m'),(date('d')+12),date('Y'))).'');
399
+ header('Cache-Control: public, must-revalidate, max-age=86400');
400
+ header('Pragma: public');
401
+
402
+ $flash = apply_filters('flash_uploader', $flash);
403
+
404
+ if($flash = 1) {
405
+ ?>
406
+ div.flash-image-uploader {
407
+ display: block;
408
+ }
409
+
410
+ div.browser-image-uploader {
411
+ display: none;
412
+ }
413
+ <?php
414
+ } else {
415
+ ?>
416
+ div.flash-image-uploader {
417
+ display: none;
418
+ }
419
+
420
+ div.browser-image-uploader {
421
+ display: block;
422
+ }
423
+ <?php
424
+ }
425
+ exit();
426
+ }
427
+
428
+ if(isset($_GET['wpsc_admin_dynamic_css']) && ($_GET['wpsc_admin_dynamic_css'] == 'true')) {
429
+ add_action("admin_init", 'wpsc_admin_dynamic_css');
430
+ }
431
+
432
+
433
+ //add_action("admin_init", 'wpsc_admin_css_and_js');
434
+ add_action('admin_menu', 'wpsc_admin_pages');
435
+
436
+
437
+ /*
438
+ * Inserts the summary box on the WordPress Dashboard
439
+ */
440
+
441
+ //if(function_exists('wp_add_dashboard_widget')) {
442
+ if( IS_WP27 ) {
443
+ add_action('wp_dashboard_setup','wpsc_dashboard_widget_setup');
444
+ } else {
445
+ add_action('activity_box_end', 'wpsc_admin_dashboard_rightnow');
446
+ }
447
+
448
+ function wpsc_admin_latest_activity() {
449
+ global $wpdb;
450
+ $totalOrders = $wpdb->get_var("SELECT COUNT(*) FROM `".WPSC_TABLE_PURCHASE_LOGS."`");
451
+
452
+
453
+ /*
454
+ * This is the right hand side for the past 30 days revenue on the wp dashboard
455
+ */
456
+ echo "<div id='leftDashboard'>";
457
+ echo "<strong class='dashboardHeading'>".__('Last 30 Days', 'wpsc')."</strong><br />";
458
+ echo "<p class='dashboardWidgetSpecial'>";
459
+ // calculates total amount of orders for the month
460
+ $year = date("Y");
461
+ $month = date("m");
462
+ $start_timestamp = mktime(0, 0, 0, $month, 1, $year);
463
+ $end_timestamp = mktime(0, 0, 0, ($month+1), 0, $year);
464
+ $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";
465
+ $currentMonthOrders = $wpdb->get_var($sql);
466
+
467
+ //calculates amount of money made for the month
468
+ $currentMonthsSales = nzshpcrt_currency_display(admin_display_total_price($start_timestamp, $end_timestamp),1);
469
+ echo $currentMonthsSales;
470
+ echo "<span class='dashboardWidget'>".__('Sales', 'wpsc')."</span>";
471
+ echo "</p>";
472
+ echo "<p class='dashboardWidgetSpecial'>";
473
+ echo "<span class='pricedisplay'>";
474
+ echo $currentMonthOrders;
475
+ echo "</span>";
476
+ echo "<span class='dashboardWidget'>".__('Orders', 'wpsc')."</span>";
477
+ echo "</p>";
478
+ echo "<p class='dashboardWidgetSpecial'>";
479
+ //echo "<span class='pricedisplay'>";
480
+ //calculates average sales amount per order for the month
481
+ if($currentMonthOrders > 0){
482
+ $monthsAverage = ((int)admin_display_total_price($start_timestamp, $end_timestamp)/(int)$currentMonthOrders);
483
+ echo nzshpcrt_currency_display($monthsAverage,1);
484
+ }
485
+ //echo "</span>";
486
+ echo "<span class='dashboardWidget'>".__('Avg Orders', 'wpsc')."</span>";
487
+ echo "</p>";
488
+
489
+
490
+ echo "</div>";
491
+ /*
492
+ *This is the left side for the total life time revenue on the wp dashboard
493
+ */
494
+
495
+ echo "<div id='rightDashboard' >";
496
+ echo "<strong class='dashboardHeading'>".__('Life Time', 'wpsc')."</strong><br />";
497
+
498
+ echo "<p class='dashboardWidgetSpecial'>";
499
+ echo nzshpcrt_currency_display(admin_display_total_price(),1);
500
+ echo "<span class='dashboardWidget'>".__('Sales', 'wpsc')."</span>";
501
+ echo "</p>";
502
+ echo "<p class='dashboardWidgetSpecial'>";
503
+ echo "<span class='pricedisplay'>";
504
+ echo $totalOrders;
505
+ echo "</span>";
506
+ echo "<span class='dashboardWidget'>".__('Orders', 'wpsc')."</span>";
507
+ echo "</p>";
508
+ echo "<p class='dashboardWidgetSpecial'>";
509
+ //echo "<span class='pricedisplay'>";
510
+ //calculates average sales amount per order for the month
511
+ if((admin_display_total_price() > 0) && ($totalOrders > 0) ) {
512
+ $totalAverage = ((int)admin_display_total_price()/(int)$totalOrders);
513
+ } else {
514
+ $totalAverage = 0;
515
+ }
516
+ echo nzshpcrt_currency_display($totalAverage,1);
517
+ //echo "</span>";
518
+ echo "<span class='dashboardWidget'>".__('Avg Orders', 'wpsc')."</span>";
519
+ echo "</p>";
520
+ echo "</div>";
521
+ echo "<div style='clear:both'></div>";
522
+
523
+
524
+ }
525
+ add_action('wpsc_admin_pre_activity','wpsc_admin_latest_activity');
526
+
527
+
528
+
529
+
530
+
531
+ /*
532
+ * Pre-2.7 Dashboard Information
533
+ */
534
+
535
+ function wpsc_admin_dashboard_rightnow() {
536
+ $user = wp_get_current_user();
537
+ if($user->user_level>9){
538
+ echo "<div>";
539
+ echo "<h3>".__('e-Commerce', 'wpsc')."</h3>";
540
+ echo "<p>";
541
+ do_action('wpsc_admin_pre_activity');
542
+ // wpsc_admin_latest_activity();
543
+ do_action('wpsc_admin_post_activity');
544
+ echo "</div>";
545
+ }
546
+ }
547
+
548
+ /*
549
+ * Dashboard Widget for 2.7 (TRansom)
550
+ */
551
+ function wpsc_dashboard_widget_setup() {
552
+ global $current_user;
553
+ get_currentuserinfo();
554
+ if($current_user->user_level>9) {
555
+ $version_identifier = WPSC_VERSION.".".WPSC_MINOR_VERSION;
556
+ wp_enqueue_style( 'wp-e-commerce-admin', WPSC_URL.'/wpsc-admin/css/admin.css', false, $version_identifier, 'all' );
557
+ wp_add_dashboard_widget('wpsc_dashboard_widget', __('E-Commerce'),'wpsc_dashboard_widget');
558
+ }
559
+ }
560
+ /*
561
+ if(file_exists(WPSC_FILE_PATH."/wpsc-admin/includes/flot_graphs.php")){
562
+ function wpsc_dashboard_quarterly_widget_setup() {
563
+ wp_enqueue_script('flot', WPSC_URL.'/wpsc-admin/js/jquery.flot.pack.js', array('jquery'), '0.9.8');
564
+ wp_enqueue_script('canvas', WPSC_URL.'/wpsc-admin/js/excanvas.pack.js', array('jquery', 'flot'), '0.9.8');
565
+
566
+ wp_add_dashboard_widget('wpsc_quarterly_dashboard_widget', __('Sales by Quarter'),'wpsc_quarterly_dashboard_widget');
567
+ }
568
+ function wpsc_quarterly_dashboard_widget(){
569
+ require_once(WPSC_FILE_PATH."/wpsc-admin/includes/flot_graphs.php");
570
+ $flot = new flot();
571
+
572
+ }
573
+ }
574
+ */
575
+ function wpsc_get_quarterly_summary(){
576
+ global $wpdb;
577
+ (int)$firstquarter = get_option('wpsc_first_quart');
578
+ (int)$secondquarter = get_option('wpsc_second_quart');
579
+ (int)$thirdquarter = get_option('wpsc_third_quart');
580
+ (int)$fourthquarter = get_option('wpsc_fourth_quart');
581
+ (int)$finalquarter = get_option('wpsc_final_quart');
582
+
583
+ $results[] = admin_display_total_price($thirdquarter+1, $fourthquarter);
584
+ $results[] = admin_display_total_price($secondquarter+1, $thirdquarter);
585
+ $results[] = admin_display_total_price($firstquarter+1, $secondquarter);
586
+ $results[] = admin_display_total_price($finalquarter, $firstquarter);
587
+ return $results;
588
+ }
589
+ function wpsc_quarterly_dashboard_widget(){
590
+ if(get_option('wpsc_business_year_start') == false){
591
+ ?>
592
+ <form action='' method='post'>
593
+ <label for='date_start'>Financial Year End: </label>
594
+ <input id='date_start' type='text' class='pickdate' size='11' value='<?php echo get_option('wpsc_last_date'); ?>' name='add_start' />
595
+ <!--<select name='add_start[day]'>
596
+ <?php
597
+ for($i = 1; $i <=31; ++$i) {
598
+ $selected = '';
599
+ if($i == date("d")) { $selected = "selected='selected'"; }
600
+ echo "<option $selected value='$i'>$i</option>";
601
+ }
602
+ ?>
603
+ </select>
604
+ <select name='add_start[month]'>
605
+ <?php
606
+ for($i = 1; $i <=12; ++$i) {
607
+ $selected = '';
608
+ if($i == (int)date("m")) { $selected = "selected='selected'"; }
609
+ echo "<option $selected value='$i'>".date("M",mktime(0, 0, 0, $i, 1, date("Y")))."</option>";
610
+ }
611
+ ?>
612
+ </select>
613
+ <select name='add_start[year]'>
614
+ <?php
615
+ for($i = date("Y"); $i <= (date("Y") +12); ++$i) {
616
+ $selected = '';
617
+ if($i == date("Y")) { $selected = "selected='true'"; }
618
+ echo "<option $selected value='$i'>".$i."</option>";
619
+ }
620
+ ?>
621
+ </select>-->
622
+ <input type='hidden' name='wpsc_admin_action' value='wpsc_quarterly' />
623
+ <input type='submit' class='button primary' value='Submit' name='wpsc_submit' />
624
+ </form>
625
+ <?php
626
+ if(get_option('wpsc_first_quart') != ''){
627
+ $firstquarter = get_option('wpsc_first_quart');
628
+ $secondquarter = get_option('wpsc_second_quart');
629
+ $thirdquarter = get_option('wpsc_third_quart');
630
+ $fourthquarter = get_option('wpsc_fourth_quart');
631
+ $finalquarter = get_option('wpsc_final_quart');
632
+ $revenue = wpsc_get_quarterly_summary();
633
+ $currsymbol = wpsc_get_currency_symbol();
634
+ foreach($revenue as $rev){
635
+ if($rev == ''){
636
+ $totals[] = '0.00';
637
+ }else{
638
+ $totals[] = $rev;
639
+ }
640
+ }
641
+ ?>
642
+ <div id='box'>
643
+ <p class='atglance'>
644
+ <span class='wpsc_quart_left'>At a Glance</span>
645
+ <span class='wpsc_quart_right'>Revenue</span>
646
+ </p>
647
+ <div style='clear:both'></div>
648
+ <p class='quarterly'>
649
+ <span class='wpsc_quart_left'><strong>01</strong>&nbsp; (<?php echo date('M Y',$thirdquarter).' - '.date('M Y',$fourthquarter); ?>)</span>
650
+ <span class='wpsc_quart_right'><?php echo $currsymbol.' '.$totals[0]; ?></span></p>
651
+ <p class='quarterly'>
652
+ <span class='wpsc_quart_left'><strong>02</strong>&nbsp; (<?php echo date('M Y',$secondquarter).' - '.date('M Y',$thirdquarter); ?>)</span>
653
+ <span class='wpsc_quart_right'><?php echo $currsymbol.' '.$totals[1]; ?></span></p>
654
+ <p class='quarterly'>
655
+ <span class='wpsc_quart_left'><strong>03</strong>&nbsp; (<?php echo date('M Y',$firstquarter).' - '.date('M Y',$secondquarter); ?>)</span>
656
+ <span class='wpsc_quart_right'><?php echo $currsymbol.' '.$totals[2]; ?></span></p>
657
+ <p class='quarterly'>
658
+ <span class='wpsc_quart_left'><strong>04</strong>&nbsp; (<?php echo date('M Y',$finalquarter).' - '.date('M Y',$firstquarter); ?>)</span>
659
+ <span class='wpsc_quart_right'><?php echo $currsymbol.' '.$totals[3]; ?></span>
660
+ </p>
661
+ <div style='clear:both'></div>
662
+ </div>
663
+ <?php
664
+ }
665
+ }
666
+
667
+ }
668
+ function wpsc_quarterly_setup(){
669
+ global $current_user;
670
+ get_currentuserinfo();
671
+ if($current_user->user_level>9) {
672
+ $version_identifier = WPSC_VERSION.".".WPSC_MINOR_VERSION;
673
+ wp_enqueue_script('datepicker-ui', WPSC_URL."/js/ui.datepicker.js",array('jquery', 'jquery-ui-core', 'jquery-ui-sortable'), $version_identifier);
674
+ wp_add_dashboard_widget('wpsc_quarterly_dashboard_widget', __('Sales by Quarter'),'wpsc_quarterly_dashboard_widget');
675
+ }
676
+ }
677
+
678
+ add_action('wp_dashboard_setup', 'wpsc_quarterly_setup');
679
+ function wpsc_dashboard_widget() {
680
+ global $current_user;
681
+ get_currentuserinfo();
682
+ if($current_user->user_level>9) {
683
+ do_action('wpsc_admin_pre_activity');
684
+ do_action('wpsc_admin_post_activity');
685
+ }
686
+ }
687
+
688
+ /*
689
+ * END - Dashboard Widget for 2.7
690
+ */
691
+
692
+
693
+ /*
694
+ * Dashboard Widget Last Four Month Sales.
695
+ */
696
+
697
+ function wpsc_dashboard_4months_widget(){
698
+ global $wpdb;
699
+
700
+ $this_year = date("Y"); //get current year and month
701
+ $this_month = date("n");
702
+
703
+ $months[] = mktime(0, 0, 0, $this_month-3, 1, $this_year); //generate unix time stamps fo 4 last months
704
+ $months[] = mktime(0, 0, 0, $this_month-2, 1, $this_year);
705
+ $months[] = mktime(0, 0, 0, $this_month-1, 1, $this_year);
706
+ $months[] = mktime(0, 0, 0, $this_month, 1, $this_year);
707
+
708
+ $products = $wpdb->get_results("SELECT `cart`.`prodid`,
709
+ `cart`.`name`
710
+ FROM `".WPSC_TABLE_CART_CONTENTS."` AS `cart`
711
+ INNER JOIN `".WPSC_TABLE_PURCHASE_LOGS."` AS `logs`
712
+ ON `cart`.`purchaseid` = `logs`.`id`
713
+ WHERE `logs`.`processed` >= 2
714
+ AND `logs`.`date` >= ".$months[0]."
715
+ GROUP BY `cart`.`prodid`
716
+ ORDER BY SUM(`cart`.`price` * `cart`.`quantity`) DESC
717
+ LIMIT 4",ARRAY_A); //get 4 products with top income in 4 last months.
718
+
719
+ $timeranges[0]["start"]= mktime(0, 0, 0, $this_month-3, 1, $this_year); //make array of time ranges
720
+ $timeranges[0]["end"]= mktime(0, 0, 0, $this_month-2, 1, $this_year);
721
+ $timeranges[1]["start"]= mktime(0, 0, 0, $this_month-2, 1, $this_year);
722
+ $timeranges[1]["end"]= mktime(0, 0, 0, $this_month-1, 1, $this_year);
723
+ $timeranges[2]["start"]= mktime(0, 0, 0, $this_month-1, 1, $this_year);
724
+ $timeranges[2]["end"]= mktime(0, 0, 0, $this_month, 1, $this_year);
725
+ $timeranges[3]["start"]= mktime(0, 0, 0, $this_month, 1, $this_year);
726
+ $timeranges[3]["end"]= mktime();
727
+
728
+
729
+ $prod_data = array();
730
+ foreach ((array)$products as $product){ //run through products and get each product income amounts and name
731
+ $sale_totals = array();
732
+ foreach ($timeranges as $timerange){ //run through time ranges of product, and get its income over each time range
733
+ $prodsql = "SELECT
734
+ SUM(`cart`.`price` * `cart`.`quantity`) AS sum
735
+ FROM `".WPSC_TABLE_CART_CONTENTS."` AS `cart`
736
+ INNER JOIN `".WPSC_TABLE_PURCHASE_LOGS."` AS `logs`
737
+ ON `cart`.`purchaseid` = `logs`.`id`
738
+ WHERE `logs`.`processed` >= 2
739
+ AND `logs`.`date` >= ".$timerange["start"]."
740
+ AND `logs`.`date` < ".$timerange["end"]."
741
+ AND `cart`.`prodid` = ".$product['prodid']."
742
+ GROUP BY `cart`.`prodid`"; //get the amount of income that current product has generaterd over current time range
743
+ $sale_totals[]= $wpdb->get_var($prodsql); //push amount to array
744
+ }
745
+ //$namesql = "SELECT `".WPSC_TABLE_PRODUCT_LIST."`.`name` FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE `".WPSC_TABLE_PRODUCT_LIST."`.`id` = ".$product['prodid'];
746
+ //$name = $wpdb->get_results($namesql,ARRAY_A);
747
+ $prod_data[]=array(
748
+ 'sale_totals' => $sale_totals,
749
+ 'product_name' => $product['name']); //result: array of 2: $prod_data[0] = array(income)
750
+ $sums=array(); //reset array //$prod_data[1] = product name
751
+ }
752
+
753
+ $tablerow=1;
754
+ $output='';
755
+ $output.='<div style="padding-bottom:15px; ">Last four months of sales on a per product basis:</div>
756
+ <table style="width:100%" border="0" cellspacing="0">
757
+ <tr style="font-style:italic; color:#666;" height="20">
758
+ <td colspan="2" style=" font-family:\'Times New Roman\', Times, serif; font-size:15px; border-bottom:solid 1px #000;">At a Glance</td>';
759
+ foreach ($months as $mnth) {
760
+ $output.='<td align="center" style=" font-family:\'Times New Roman\'; font-size:15px; border-bottom:solid 1px #000;">' . date("M", $mnth) . '</td>';
761
+ }
762
+ $output.='</tr>';
763
+ foreach((array)$prod_data as $sales_data) {
764
+ $output.='<tr height="20">
765
+ <td width="20" style="font-weight:bold; color:#008080; border-bottom:solid 1px #000;">' . $tablerow . '</td>
766
+ <td style="border-bottom:solid 1px #000;width:60px">' . $sales_data['product_name'] . '</td>';
767
+ $currsymbol=wpsc_get_currency_symbol();
768
+ $tablerow++;
769
+ foreach ($sales_data['sale_totals'] as $amount) {
770
+ $output.= '<td align="center" style="border-bottom:solid 1px #000;">' . $currsymbol . number_format(absint($amount),2) . '</td>';
771
+ }
772
+ $output.='</tr>';
773
+ }
774
+ $output.='</table>';
775
+ echo $output;
776
+ }
777
+
778
+ function wpsc_dashboard_4months_widget_setup() {
779
+ global $current_user;
780
+ get_currentuserinfo();
781
+ if($current_user->user_level == 10) {
782
+ wp_add_dashboard_widget('wpsc_dashboard_4months_widget', __('Sales by'),'wpsc_dashboard_4months_widget');
783
+ }
784
+ }
785
+
786
+ function wpsc_admin_4months_widget_rightnow() {
787
+ $user = wp_get_current_user();
788
+ if($user->user_level>9){
789
+ echo "<div>";
790
+ echo "<h3>".__('e-Commerce', 'wpsc')."</h3>";
791
+ echo "<p>";
792
+ wpsc_dashboard_4months_widget();
793
+ echo "</div>";
794
+ }
795
+ }
796
+
797
+ if( IS_WP27 ) {
798
+ add_action('wp_dashboard_setup','wpsc_dashboard_4months_widget_setup');
799
+ } else {
800
+ add_action('activity_box_end', 'wpsc_admin_4months_widget_rightnow');
801
+ }
802
+
803
+ //Modification to allow for multiple column layout
804
+
805
+ add_filter('screen_layout_columns', 'wpec_two_columns', 10, 2);
806
+
807
+ function wpec_two_columns($columns, $screen) {
808
+ if ($screen == 'store_page_wpsc-edit-products') {
809
+ $columns['store_page_wpsc-edit-products'] = 2;
810
+ }
811
+ return $columns;
812
+ }
813
+ function wpsc_fav_action($actions) {
814
+ $actions['admin.php?page=wpsc-edit-products&action=wpsc_add_edit'] = array('New Product', 'manage_options');
815
+ return $actions;
816
+ }
817
+ add_filter('favorite_actions', 'wpsc_fav_action');
818
+
819
+ function wpsc_admin_notices() {
820
+ global $wpdb;
821
+ // exit(get_option('wpsc_default_category'));
822
+ if(get_option('wpsc_default_category') != 'all+list' && get_option('wpsc_default_category') != 'all' && get_option('wpsc_default_category') != 'list') {
823
+ if((get_option('wpsc_default_category') < 1)) { // if there is no default category or it is deleted
824
+ if(!$_POST['wpsc_default_category']) { // if we are not changing the default category
825
+ echo "<div id='message' class='updated fade' style='background-color: rgb(255, 251, 204);'>";
826
+ echo "<p>".__('Your "products page" is not currently set to display any products. You need to select a product grouping to display by default. <br /> This is set in the Shop Settings page.', 'wpsc')."</p>";
827
+ echo "</div>\n\r";
828
+ }
829
+ }
830
+ }
831
+ }
832
+
833
+ if(isset($_GET['page']) && (stristr($_GET['page'], WPSC_DIR_NAME))) {
834
+ add_action('admin_notices', 'wpsc_admin_notices');
835
+ }
836
+
837
+
838
  ?>
wpsc-admin/ajax-and-init.php CHANGED
@@ -9,50 +9,50 @@
9
  */
10
  //exit('<pre>'.print_r($_POST, true).'</pre>');
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
-
27
- if($_REQUEST['submit'] == 'Add Tracking ID') {
28
- add_action('admin_init', 'wpsc_ajax_add_tracking');
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
-
38
- if($_REQUEST['wpsc_admin_action'] == 'delete_currency_layer') {
39
- add_action('admin_init', 'wpsc_delete_currency_layer');
40
  }
41
 
42
 
43
  function wpsc_purchlog_email_trackid() {
44
- global $wpdb;
45
- $id = absint($_POST['purchlog_id']);
46
- $trackingid = $wpdb->get_var("SELECT `track_id` FROM ".WPSC_TABLE_PURCHASE_LOGS." WHERE `id`={$id} LIMIT 1");
47
 
48
- $message = get_option('wpsc_trackingid_message');
49
- $message = str_replace('%trackid%',$trackingid,$message);
50
  $message = str_replace('%shop_name%',get_option('blogname'),$message);
51
 
52
- $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");
53
- $email = $wpdb->get_var("SELECT `value` FROM `".WPSC_TABLE_SUBMITED_FORM_DATA."` WHERE `log_id`=".$id." AND `form_id` = '$email_form_field' LIMIT 1");
 
54
 
55
-
56
  $subject = get_option('wpsc_trackingid_subject');
57
  $subject = str_replace('%shop_name%',get_option('blogname'),$subject);
58
  wp_mail($email, $subject, $message,"From: ".get_option('return_email')." <".get_option('return_email').">");
@@ -60,569 +60,606 @@ if($_REQUEST['wpsc_admin_action'] == 'delete_currency_layer') {
60
  exit(true);
61
  }
62
 
63
-
64
- if($_REQUEST['wpsc_admin_action'] == 'purchlog_email_trackid') {
65
- add_action('admin_init', 'wpsc_purchlog_email_trackid');
66
  }
67
 
68
  function wpsc_ajax_sales_quarterly() {
69
- global $wpdb;
70
- $lastdate = $_POST['add_start'];
71
- $date = preg_split('/-/', $lastdate);
72
- $lastquart = mktime(0,0,0,$date[1], $date[2], $date[0]);
73
- //$lastdate = date('M d y', $lastquart);
74
- if($lastquart != get_option('wpsc_last_quarter')){
75
- update_option('wpsc_last_date', $lastdate);
76
- update_option('wpsc_fourth_quart', $lastquart);
77
- $thirdquart = mktime(0,0,0,$date[1]-3, $date[2], $date[0]);
78
- update_option('wpsc_third_quart', $thirdquart);
79
- $secondquart = mktime(0,0,0,$date[1]-6, $date[2], $date[0]);
80
- update_option('wpsc_second_quart', $secondquart);
81
- $firstquart = mktime(0,0,0,$date[1]-9, $date[2], $date[0]);
82
- update_option('wpsc_first_quart', $firstquart);
83
- $finalquart = mktime(0,0,0,$date[1], $date[2], $date[0]-1);
84
- update_option('wpsc_final_quart', $finalquart);
85
-
86
- }
87
-
88
-
89
- // exit($lastquart.' '.$firstquart.' '.$secondquart.' '.$thirdquart);
 
 
 
90
  }
91
-
92
-
93
- if($_REQUEST['wpsc_admin_action'] == 'wpsc_quarterly') {
94
- add_action('admin_init', 'wpsc_ajax_sales_quarterly');
95
  }
96
 
97
 
98
  function wpsc_ajax_load_product() {
99
- global $wpdb;
100
- $product_id = absint($_REQUEST['product']);
101
- check_admin_referer('edit-product_' . $product_id);
102
- wpsc_display_product_form($product_id);
103
- exit();
104
  }
105
-
106
-
107
-
108
- if($_REQUEST['wpsc_admin_action'] == 'load_product') {
109
- add_action('admin_init', 'wpsc_ajax_load_product');
110
  }
111
 
112
  function wpsc_crop_thumb() {
113
- global $wpdb;
114
- if ($_SERVER['REQUEST_METHOD'] == 'POST') {
115
- $targ_w = $targ_h = $_POST['thumbsize'];
116
- $jpeg_quality = $_POST['jpegquality'];
117
- $product_id = $_POST['product_id'];
118
-
119
- $image['x'] = absint($_POST['x']);
120
- $image['y'] = absint($_POST['y']);
121
- $image['w'] = absint($_POST['w']);
122
- $image['h'] = absint($_POST['h']);
123
-
124
-
125
- $imagename = basename($_POST['imagename']);
126
- $source = WPSC_IMAGE_DIR.$imagename;
127
- $destination = WPSC_THUMBNAIL_DIR.$imagename;
128
-
129
- if(is_file($source)) {
130
- $imagetype = getimagesize($source);
131
-
132
- switch($imagetype[2]) {
133
- case IMAGETYPE_JPEG:
134
- $img_r = imagecreatefromjpeg($source);
135
- break;
136
-
137
- case IMAGETYPE_GIF:
138
- $img_r = imagecreatefromgif($source);
139
- break;
140
-
141
- case IMAGETYPE_PNG:
142
- $img_r = imagecreatefrompng($source);
143
- break;
144
- }
145
- $dst_r = ImageCreateTrueColor( $targ_w, $targ_h );
146
- imagecopyresampled($dst_r,$img_r,0,0,$image['x'],$image['y'],$targ_w,$targ_h,$image['w'],$image['h']);
147
- imagejpeg($dst_r,$destination,$jpeg_quality);
148
- $cropped = true;
149
- }
150
- $sendback = wp_get_referer();
151
- if($cropped){
152
- $sendback = add_query_arg('product_id', $product_id, $sendback);
153
- }
154
- wp_redirect($sendback);
155
- //exit();
156
- }
157
  }
158
-
159
-
160
- if($_REQUEST['wpsc_admin_action'] == 'crop_thumb') {
161
- add_action('admin_init', 'wpsc_crop_thumb');
162
- }
163
 
164
- function wpsc_delete_file() {
165
- global $wpdb;
166
- $output = 0;
167
- $row_number = absint($_GET['row_number']);
168
- $product_id = absint($_GET['product_id']);
169
- $file_name = basename($_GET['file_name']);
170
- check_admin_referer('delete_file_'.$file_name);
171
-
172
-
173
- $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'"));
174
-
175
- wp_delete_post($product_id_to_delete, true);
176
 
177
- if($_POST['ajax'] !== 'true') {
178
- $sendback = wp_get_referer();
179
- wp_redirect($sendback);
180
- }
181
-
182
- echo "jQuery('#select_product_file_row_$row_number').fadeOut('fast',function() {\n";
183
- echo " jQuery(this).remove();\n";
184
- echo " jQuery('div.select_product_file p:even').removeClass('alt');\n";
185
- echo " jQuery('div.select_product_file p:odd').addClass('alt');\n";
186
- echo "});\n";
187
-
188
- exit("");
189
  }
190
 
191
-
192
- if($_REQUEST['wpsc_admin_action'] == 'delete_file') {
193
- add_action('admin_init', 'wpsc_delete_file');
194
- }
195
-
 
 
196
 
197
- function wpsc_bulk_modify_products() {
198
- global $wpdb;
199
- $doaction = $_GET['bulkAction'];
200
- $sendback = wp_get_referer();
201
- $product_ids = $_GET['post'];
202
- //exit( "<pre>".print_r($_GET,true)."</pre>");
203
- switch ( $doaction ) {
204
-
205
- case 'publish':
206
- foreach( (array) $product_ids as $product_id ) {
207
- $product_id = absint($product_id);
208
- wp_publish_post($product_id);
209
- $published++;
210
- }
211
- $sendback = add_query_arg('published', $published, $sendback);
212
- break;
213
-
214
- case 'unpublish':
215
- foreach( (array) $product_ids as $product_id ) {
216
- $product_id = absint($product_id);
217
- wp_update_post(array('ID' => $product_id, 'post_status' => 'draft'));
218
- $published++;
219
- }
220
- $sendback = add_query_arg('published', $published, $sendback);
221
- break;
222
-
223
-
224
- case 'trash':
225
- $trashed = 0;
226
- foreach( (array) $product_ids as $product_id ) {
227
- if ( !current_user_can('delete_post', $product_id) ) {
228
- wp_die( __('You are not allowed to move this product to the trash.', 'wpsc') );
229
- }
230
- if ( !wp_trash_post($product_id) ) {
231
- wp_die( __('Error in moving to trash...') );
232
- }
233
- $trashed++;
234
- }
235
- $sendback = add_query_arg( array('trashed' => $trashed, 'ids' => join(',', $product_ids)), $sendback );
236
- break;
237
-
238
- case 'untrash':
239
- $untrashed = 0;
240
- foreach( (array) $product_ids as $product_id ) {
241
- if ( !current_user_can('delete_post', $product_id) ) {
242
- wp_die( __('You are not allowed to restore this product from the trash.', 'wpsc') );
243
- }
244
- if ( !wp_untrash_post($product_id) ) {
245
- wp_die( __('Error in restoring from trash...') );
246
- }
247
- $untrashed++;
248
- }
249
- $sendback = add_query_arg('untrashed', $untrashed, $sendback);
250
- break;
251
 
252
- case 'delete':
253
- $deleted = 0;
254
- foreach( (array) $product_ids as $product_id ) {
255
- $product_del = & get_post($product_id);
256
-
257
- if ( !current_user_can('delete_post', $product_id) ) {
258
- wp_die( __('You are not allowed to delete this post.') );
259
- }
260
-
261
- if ( $product_del->post_type == 'attachment' ) {
262
- if ( ! wp_delete_attachment($product_id) ) {
263
- wp_die( __('Error in deleting...') );
264
- }
265
- } else {
266
- if ( !wp_delete_post($product_id) ) {
267
- wp_die( __('Error in deleting...') );
268
- }
269
- }
270
- $deleted++;
271
- }
272
- $sendback = add_query_arg('deleted', $deleted, $sendback);
273
- break;
274
-
275
-
276
- default:
277
- if(isset($_GET['search']) && !empty($_GET['search'])) {
278
- // urlencode the search query to allow for spaces, etc
279
- $sendback = add_query_arg('search',urlencode(stripslashes($_GET['search'])), $sendback);
280
- }
281
- break;
282
- }
283
-
284
- wp_redirect($sendback);
285
- exit();
286
  }
287
-
288
-
289
-
290
- if($_REQUEST['wpsc_admin_action'] == 'bulk_modify') {
291
- add_action('admin_init', 'wpsc_bulk_modify_products');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
292
  }
293
 
294
  function wpsc_modify_product_price() {
295
- global $wpdb;
296
- $product_data = array_pop($_POST['product_price']);
297
-
298
- $product_id = absint($product_data['id']);
299
- $product_price = (float)$product_data['price'];
300
- $product_nonce = $product_data['nonce'];
301
-
302
- if(wp_verify_nonce($product_nonce, 'edit-product_price-'.$product_id) ) {
303
- if(update_post_meta($product_id, '_wpsc_price', $product_price)) {
304
- echo "success = 1;\n\r";
305
- echo "new_price = '".nzshpcrt_currency_display($product_price, 1, true)."';\n\r";
306
- } else {
307
- echo "success = 0;\n\r";
308
- }
309
- } else {
310
- echo "success = -1;\n\r";
311
- }
312
- exit();
313
  }
314
 
315
-
316
- if($_REQUEST['wpsc_admin_action'] == 'modify_price') {
317
- add_action('admin_init', 'wpsc_modify_product_price');
318
  }
319
 
320
 
321
  function wpsc_modify_sales_product_price() {
322
- global $wpdb;
323
- // exit('<pre>'.print_r($_POST, true).'</pre>');
324
- $product_data = array_pop($_POST['sale_product_price']);
325
-
326
- $product_id = absint($product_data['id']);
327
- $product_price = (float)$product_data['price'];
328
- $product_nonce = $product_data['nonce'];
329
-
330
- if(wp_verify_nonce($product_nonce, 'sale-edit-product_price-'.$product_id) ) {
331
- if(update_post_meta($product_id, '_wpsc_special_price', $product_price)) {
332
- echo "success = 1;\n\r";
333
- echo "new_price = '".nzshpcrt_currency_display($product_price, 1, true)."';\n\r";
334
- } else {
335
- echo "success = 0;\n\r";
336
- }
337
- } else {
338
- echo "success = -1;\n\r";
339
- }
340
- exit();
341
  }
342
 
343
-
344
- if($_REQUEST['wpsc_admin_action'] == 'modify_sales_price') {
345
- add_action('admin_init', 'wpsc_modify_sales_product_price');
346
  }
347
 
348
 
349
 
350
  function wpsc_modify_sku() {
351
- global $wpdb;
352
- // exit('<pre>'.print_r($_POST, true).'</pre>');
353
- $product_data = array_pop($_POST['sku_field']);
354
-
355
- $product_id = absint($product_data['id']);
356
- $sku = $product_data['sku'];
357
- $product_nonce = $product_data['nonce'];
358
-
359
- if(wp_verify_nonce($product_nonce, 'edit-sku-'.$product_id) ) {
360
- if(update_post_meta($product_id, '_wpsc_sku', $sku)) {
361
- echo "success = 1;\n\r";
362
- echo "new_price = '".$sku."';\n\r";
363
- } else {
364
- echo "success = 0;\n\r";
365
- }
366
- } else {
367
- echo "success = -1;\n\r";
368
- }
369
- exit();
370
  }
371
 
372
-
373
- if($_REQUEST['wpsc_admin_action'] == 'modify_sku') {
374
- add_action('admin_init', 'wpsc_modify_sku');
375
  }
376
 
377
- function wpsc_walk_weight(&$value,$key, $weight)
378
- {
379
- if ( $key == 'weight' ) {
380
- $value = $weight ;
381
- }
382
- }
383
 
384
- function wpsc_modify_weight() {
385
- global $wpdb;
386
- // exit('<pre>'.print_r($_POST, true).'</pre>');
387
- $product_data = array_pop($_POST['weight_field']);
388
 
389
- $product_id = absint($product_data['id']);
390
- $weight = (float)($product_data['weight'] * 453.59237);
391
- $product_nonce = $product_data['nonce'];
392
 
393
- if(wp_verify_nonce($product_nonce, 'edit-weight-'.$product_id) ) {
394
 
395
- $old_array = get_product_meta ( $product_id, 'product_metadata' );
396
- $new_array = array_walk($old_array, "wpsc_walk_weight", $weight);
397
-
398
- if(update_product_meta($product_id, 'product_metadata', $new_array)) {
399
- echo "success = 1;\n\r";
400
- echo "new_price = '".wpsc_convert_weight($weight, "gram", $old_array["weight_unit"])."';\n\r";
401
- } else {
402
- echo "success = 0;\n\r";
403
- }
404
- } else {
405
- echo "success = -1;\n\r";
406
- }
407
- exit();
 
 
 
 
 
 
 
 
408
  }
409
 
410
-
411
- if($_REQUEST['wpsc_admin_action'] == 'modify_weight') {
412
- add_action('admin_init', 'wpsc_modify_weight');
413
  }
414
 
415
 
416
  function wpsc_modify_stock() {
417
- global $wpdb;
418
- // exit('<pre>'.print_r($_POST, true).'</pre>');
419
- $product_data = array_pop($_POST['stock_field']);
420
-
421
- $product_id = absint($product_data['id']);
422
- $stock = $product_data['stock'];
423
- $product_nonce = $product_data['nonce'];
424
-
425
- if(wp_verify_nonce($product_nonce, 'edit-stock-'.$product_id) ) {
426
- if(update_post_meta($product_id, '_wpsc_stock', $stock)) {
427
- echo "success = 1;\n\r";
428
- echo "new_price = '".$stock."';\n\r";
429
- } else {
430
- echo "success = 0;\n\r";
431
- }
432
- } else {
433
- echo "success = -1;\n\r";
434
- }
435
- exit();
436
  }
437
 
438
-
439
- if($_REQUEST['wpsc_admin_action'] == 'modify_stock') {
440
- add_action('admin_init', 'wpsc_modify_stock');
441
  }
442
-
443
-
444
  /**
445
- Function and action for deleting single products
446
  */
447
  function wpsc_delete_product() {
448
- global $wpdb;
449
-
450
- $deleted = 0;
451
- $product_id = absint($_GET['product']);
452
- check_admin_referer('delete_product_' . $product_id);
453
 
454
-
455
- if ( !current_user_can('delete_post', $product_id) ) {
456
- wp_die( __('You are not allowed to move this product to the trash.', 'wpsc') );
457
- }
458
- if ( !wp_trash_post($product_id) ) {
459
- wp_die( __('Error in moving to trash...') );
460
- }
461
- do_action('wpsc_delete_product', $product_id);
462
- $deleted = true;
463
-
464
- $sendback = wp_get_referer();
465
- if ( isset($deleted) ) {
466
- $sendback = add_query_arg('deleted', $deleted, $sendback);
467
- }
468
- //exit($sendback);
469
- wp_redirect($sendback);
470
- exit();
 
 
 
 
471
  }
472
-
473
-
474
-
475
- if($_REQUEST['wpsc_admin_action'] == 'trash') {
476
- add_action('admin_init', 'wpsc_delete_product');
477
  }
478
-
479
  /**
480
  Function and action for publishing or unpublishing single products
481
  */
482
  function wpsc_ajax_toggle_published() {
483
- global $wpdb;
484
-
485
- $product_id = absint($_GET['product']);
486
- check_admin_referer('toggle_publish_' . $product_id);
487
-
488
- $status = (wpsc_toggle_publish_status($product_id)) ? ('true') : ('false');
489
- $sendback = add_query_arg('flipped', "1", wp_get_referer());
490
- wp_redirect($sendback);
491
- exit();
492
  }
493
-
494
-
495
- if($_REQUEST['wpsc_admin_action'] == 'toggle_publish') {
496
- add_action('admin_init', 'wpsc_ajax_toggle_published');
497
  }
498
 
499
-
500
  /**
501
  Function and action for duplicating products,
 
 
502
  */
503
  function wpsc_duplicate_product() {
504
- global $wpdb;
505
- $product_id = absint($_GET['product']);
506
- check_admin_referer('duplicate_product_' . $product_id);
507
- if ($product_id > 0) {
508
- $sql = " INSERT INTO ".WPSC_TABLE_PRODUCT_LIST."( `name` , `description` , `additional_description` , `price` , `weight` , `weight_unit` , `pnp` , `international_pnp` , `file` , `image` , `quantity_limited` , `quantity` , `special` , `special_price` , `display_frontpage` , `notax` , `active` , `publish`, `donation` , `no_shipping` , `thumbnail_image` , `thumbnail_state` ) SELECT `name` , `description` , `additional_description` , `price` , `weight` , `weight_unit` , `pnp` , `international_pnp` , `file` , `image` , `quantity_limited` , `quantity` , `special` , `special_price` , `display_frontpage` , `notax` , `active` , `publish`, `donation` , `no_shipping` , `thumbnail_image` , `thumbnail_state` FROM ".WPSC_TABLE_PRODUCT_LIST." WHERE id = '".$product_id."' ";
509
- // exit($sql);
510
- $wpdb->query($sql);
511
- $new_id= $wpdb->get_var("SELECT LAST_INSERT_ID() AS `id` FROM `".WPSC_TABLE_PRODUCT_LIST."` LIMIT 1");
512
-
513
- //Inserting duplicated variations record.
514
- $variation_assocs = $wpdb->get_results("SELECT * FROM ".WPSC_TABLE_VARIATION_ASSOC." WHERE associated_id = ".$product_id, ARRAY_A);
515
- if(count($variation_assocs))foreach($variation_assocs as $variation_assoc){
516
- $wpdb->query("INSERT INTO ".WPSC_TABLE_VARIATION_ASSOC." VALUES ('', '".$variation_assoc['type']."', '".$variation_assoc['name']."', '".$new_id."', '".$variation_assoc['variation_id']."');");
517
- }
518
-
519
- $variation_combinations = $wpdb->get_results("SELECT * FROM ".WPSC_TABLE_VARIATION_COMBINATIONS." WHERE product_id = ".$product_id, ARRAY_A);
520
- if(count($variation_combinations))foreach($variation_combinations as $variation_combination){
521
- $variation_properties = $wpdb->get_results("SELECT * FROM ".WPSC_TABLE_VARIATION_PROPERTIES." WHERE id = ".$variation_combination['priceandstock_id'], ARRAY_A);
522
- $wpdb->query("INSERT INTO ".WPSC_TABLE_VARIATION_PROPERTIES." VALUES ('', '".$new_id."', '".$variation_properties[0]['stock']."', '".$variation_properties[0]['price']."', '".$variation_properties[0]['weight']."', '".$variation_properties[0]['weight_unit']."', '".$variation_properties[0]['visibility']."', '".$variation_properties[0]['file']."');");
523
- $new_prop_id= $wpdb->get_var("SELECT LAST_INSERT_ID() AS `id` FROM `".WPSC_TABLE_VARIATION_PROPERTIES."` LIMIT 1");
524
- $wpdb->query("INSERT INTO ".WPSC_TABLE_VARIATION_COMBINATIONS." VALUES ('".$new_id."', '".$new_prop_id."', '".$variation_combination['value_id']."', '".$variation_combination['variation_id']."', '".$variation_combination['all_variation_ids']."');");
525
- }
526
-
527
- $variation_values_assocs = $wpdb->get_results("SELECT * FROM ".WPSC_TABLE_VARIATION_VALUES_ASSOC." WHERE product_id = ".$product_id, ARRAY_A);
528
- if(count($variation_values_assocs))foreach($variation_values_assocs as $variation_values_assoc){
529
- $wpdb->query("INSERT INTO ".WPSC_TABLE_VARIATION_VALUES_ASSOC." VALUES ('', '".$new_id."', '".$variation_values_assoc['value_id']."', '".$variation_values_assoc['visible']."', '".$variation_values_assoc['variation_id']."');");
530
- }
531
- //end of variations
532
-
533
 
534
- //Inserting duplicated category record.
535
- $category_assoc = $wpdb->get_col("SELECT `category_id` FROM ".WPSC_TABLE_ITEM_CATEGORY_ASSOC." WHERE product_id = '".$product_id."'");
536
- $new_product_category = array();
537
- if (count($category_assoc) > 0) {
538
- foreach($category_assoc as $key => $category) {
539
- $new_product_category[] = "('".$new_id."','".$category."')";
540
-
541
- $check_existing = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_PRODUCT_ORDER."` WHERE `category_id` IN('$category') AND `order` IN('0') LIMIT 1;",ARRAY_A);
542
- if($wpdb->get_var("SELECT `id` FROM `".WPSC_TABLE_PRODUCT_ORDER."` WHERE `category_id` IN('$category') AND `product_id` IN('$product_id') LIMIT 1")) {
543
- $wpdb->query("UPDATE `".WPSC_TABLE_PRODUCT_ORDER."` SET `order` = '0' WHERE `category_id` IN('$category') AND `product_id` IN('$product_id') LIMIT 1;");
544
- } else {
545
- $wpdb->query("INSERT INTO `".WPSC_TABLE_PRODUCT_ORDER."` (`category_id`, `product_id`, `order`) VALUES ('$category', '$product_id', 0)");
546
- }
547
- if($check_existing != null) {
548
- $wpdb->query("UPDATE `".WPSC_TABLE_PRODUCT_ORDER."` SET `order` = (`order` + 1) WHERE `category_id` IN('$category') AND `product_id` NOT IN('$product_id') AND `order` < '0'");
549
- }
550
- }
551
- $wpdb->query("INSERT INTO ".WPSC_TABLE_ITEM_CATEGORY_ASSOC." (product_id, category_id) VALUES ".implode(",",$new_product_category));
552
- }
553
-
554
-
555
-
556
-
557
- //Inserting duplicated meta info
558
- $meta_values = $wpdb->get_results("SELECT `meta_key`, `meta_value`, `custom` FROM `".WPSC_TABLE_PRODUCTMETA."` WHERE product_id='".$product_id."' AND `meta_key` NOT IN ('url_name') ", ARRAY_A);
559
- $new_meta_value = array();
560
- if (count($meta_values)>0) {
561
- foreach($meta_values as $key => $meta) {
562
- $new_meta_value[] = "('".$new_id."','".$meta['meta_key']."','".$meta['meta_value']."','".$meta['custom']."')";
563
- }
564
- $wpdb->query("INSERT INTO `".WPSC_TABLE_PRODUCTMETA."` (`product_id`, `meta_key`, `meta_value`, `custom`) VALUES ".implode(",",$new_meta_value));
565
- }
566
-
567
-
568
-
569
- $product_name = $wpdb->get_var("SELECT `name` FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE `id` = '$new_id' LIMIT 1");
570
- if($product_name != '') {
571
- $tidied_name = strtolower(trim($product_name));
572
- $url_name = sanitize_title($tidied_name);
573
- $similar_names = $wpdb->get_row("SELECT COUNT(*) AS `count`, MAX(REPLACE(`meta_value`, '$url_name', '')) AS `max_number` FROM `".WPSC_TABLE_PRODUCTMETA."` WHERE `meta_key` IN ('url_name') AND `meta_value` REGEXP '^($url_name){1}[[:digit:]]*$' ",ARRAY_A);
574
- $extension_number = '';
575
- if($similar_names['count'] > 0) {
576
- $extension_number = (int)$similar_names['max_number']+1;
577
- }
578
- $url_name .= $extension_number;
579
- add_product_meta($new_id, 'url_name', $url_name,true);
580
- }
581
-
582
-
583
- $tags = wp_get_object_terms($product_id, 'product_tag', array('fields' => 'names'));
584
- wp_set_object_terms($new_id, $tags, 'product_tag');
585
-
586
- //Inserting duplicated image info
587
- $image_values = $wpdb->get_results("SELECT `image`, `width`, `height`, `image_order`, `meta` FROM ".WPSC_TABLE_PRODUCT_IMAGES." WHERE product_id='".$product_id."'", ARRAY_A);
588
- $new_image_value = array();
589
- if (count($image_values)>0){
590
- foreach($image_values as $key => $image) {
591
- if($image['image'] != '') {
592
- if(is_numeric($image['width']) && is_numeric($image['height'])) {
593
- $image['width'] = absint($image['width']);
594
- $image['height'] = absint($image['height']);
595
- } else {
596
- $image['width'] = 'null';
597
- $image['height'] = 'null';
598
- }
599
- $new_image_value[] = "('".$new_id."','".$image['image']."',".$image['width'].",".$image['height'].",'".$image['image_order']."','".$image['meta']."')";
600
- }
601
- }
602
- if(count($new_image_value) > 0) {
603
- $new_image_value = implode(",", $new_image_value);
604
- $sql = "INSERT INTO ".WPSC_TABLE_PRODUCT_IMAGES." (`product_id`, `image`, `width`, `height`, `image_order`, `meta`) VALUES ".$new_image_value;
605
- $wpdb->query($sql);
606
- }
607
- }
608
-
609
- $duplicated = true;
610
- }
611
-
612
- $sendback = wp_get_referer();
613
- if ( isset($duplicated) ) {
614
- $sendback = add_query_arg('duplicated', (int)$duplicated, $sendback);
615
- }
616
- wp_redirect($sendback);
617
- exit();
618
  }
619
 
620
- if ($_GET['wpsc_admin_action'] == 'duplicate_product') {
621
- add_action('admin_init', 'wpsc_duplicate_product');
 
 
 
 
 
 
622
  }
623
-
624
-
625
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
626
  function wpsc_purchase_log_csv() {
627
  global $wpdb,$user_level,$wp_rewrite;
628
  get_currentuserinfo();
@@ -630,343 +667,344 @@ function wpsc_purchase_log_csv() {
630
  //exit('in use');
631
  $form_sql = "SELECT * FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `active` = '1' AND `display_log` = '1';";
632
  $form_data = $wpdb->get_results($form_sql,ARRAY_A);
633
-
634
  $start_timestamp = $_GET['start_timestamp'];
635
  $end_timestamp = $_GET['end_timestamp'];
636
  $data = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `date` BETWEEN '$start_timestamp' AND '$end_timestamp' ORDER BY `date` DESC",ARRAY_A);
637
  // exit('<pre>'.print_r($data, true).'</pre>');
638
 
639
-
640
  header('Content-Type: text/csv');
641
  header('Content-Disposition: inline; filename="Purchase Log '.date("M-d-Y", $start_timestamp).' to '.date("M-d-Y", $end_timestamp).'.csv"');
642
-
643
  foreach((array)$data as $purchase) {
644
  $country_sql = "SELECT * FROM `".WPSC_TABLE_SUBMITED_FORM_DATA."` WHERE `log_id` = '".$purchase['id']."' AND `form_id` = '".get_option('country_form_field')."' LIMIT 1";
645
  $country_data = $wpdb->get_results($country_sql,ARRAY_A);
646
  $country = $country_data[0]['value'];
647
-
648
  $output .= "\"".$purchase['totalprice'] ."\",";
649
-
650
  foreach((array)$form_data as $form_field) {
651
  $collected_data_sql = "SELECT * FROM `".WPSC_TABLE_SUBMITED_FORM_DATA."` WHERE `log_id` = '".$purchase['id']."' AND `form_id` = '".$form_field['id']."' LIMIT 1";
652
  $collected_data = $wpdb->get_results($collected_data_sql,ARRAY_A);
653
  $collected_data = $collected_data[0];
654
  $output .= "\"".$collected_data['value']."\",";
655
- }
656
-
657
  if(get_option('payment_method') == 2) {
658
  $gateway_name = '';
659
  foreach($GLOBALS['nzshpcrt_gateways'] as $gateway) {
660
  if($purchase['gateway'] != 'testmode') {
661
  if($gateway['internalname'] == $purchase['gateway'] ) {
662
  $gateway_name = $gateway['name'];
663
- }
664
- } else {
665
- $gateway_name = "Manual Payment";
666
- }
667
- }
668
  $output .= "\"". $gateway_name ."\",";
669
- }
670
-
671
  if($purchase['processed'] < 1) {
672
  $purchase['processed'] = 1;
673
- }
674
  $stage_sql = "SELECT * FROM `".WPSC_TABLE_PURCHASE_STATUSES."` WHERE `id`='".$purchase['processed']."' AND `active`='1' LIMIT 1";
675
  $stage_data = $wpdb->get_results($stage_sql,ARRAY_A);
676
-
677
  $output .= "\"". $stage_data[0]['name'] ."\",";
678
-
679
  $output .= "\"". date("jS M Y",$purchase['date']) ."\"";
680
-
681
  $cartsql = "SELECT * FROM `".WPSC_TABLE_CART_CONTENTS."` WHERE `purchaseid`=".$purchase['id']."";
682
- $cart = $wpdb->get_results($cartsql,ARRAY_A) ;
683
  //exit(nl2br(print_r($cart,true)));
684
-
685
  foreach((array)$cart as $item) {
686
  $output .= ",";
687
- $product = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE `id`=".$item['prodid']." LIMIT 1",ARRAY_A);
688
- $skusql = "SELECT `meta_value` FROM `".WPSC_TABLE_PRODUCTMETA."` WHERE `meta_key`= 'sku' AND `product_id` = ".$item['prodid'];
689
  $skuvalue = $wpdb->get_var($skusql);
690
  $output .= "\"".$item['quantity']." ".str_replace('"', '\"',$product['name']).$variation_list."\"";
691
  $output .= ",".$skuvalue;
692
- }
693
  $output .= "\n"; // terminates the row/line in the CSV file
694
- }
695
  echo $output;
696
  exit();
697
- }
698
  }
699
- if($_REQUEST['wpsc_admin_action'] == 'wpsc_downloadcsv') {
700
- add_action('admin_init', 'wpsc_purchase_log_csv');
 
701
  }
702
 
703
 
704
  function wpsc_admin_ajax() {
705
  global $wpdb,$user_level,$wp_rewrite;
706
- get_currentuserinfo();
707
  if(is_numeric($_POST['catid'])) {
708
- /* fill category form */
709
- echo nzshpcrt_getcategoryform($_POST['catid']);
710
- exit();
711
- } else if(is_numeric($_POST['brandid'])) {
712
- /* fill brand form */
713
- echo nzshpcrt_getbrandsform($_POST['brandid']);
714
- exit();
715
- } else if(is_numeric($_POST['variation_id'])) {
716
- echo nzshpcrt_getvariationform($_POST['variation_id']);
717
- exit();
718
- }
719
-
720
-
721
- if ($_POST['action'] == 'product-page-order'){
722
- $current_order = get_option('wpsc_product_page_order');
723
- $new_order = $_POST['order'];
724
-
725
- if ( isset ( $new_order["advanced"] ) ) {
726
- $current_order["advanced"] = array_unique(explode(',', $new_order["advanced"]));
727
- }
728
- if ( isset ( $new_order["side"] ) ) {
729
- $current_order["side"] = array_unique(explode(',', $new_order["side"]));
730
- }
731
-
732
- update_option('wpsc_product_page_order', $current_order);
733
- exit(print_r($order,1));
734
- }
735
-
736
-
737
- function wpec_hide_box(&$value,$key, $p) {
738
-
739
- foreach ($p as $pkey => $val) {
740
- if ( $key == $pkey ) {
741
- $value = $val;
742
- }
743
- }
744
-
745
- }
746
-
747
- if ($_POST['action'] == 'postbox-hide'){
748
- $current_order = get_option('wpsc_product_page_order');
749
-
750
- $hidden_key = $_POST["hidden_val"];
751
- $hidden_val = $_POST["hidden"];
752
 
753
- $hidden = array ( $hidden_key => $hidden_val );
754
-
755
- array_walk($current_order["hiddenboxes"], "wpec_hide_box", $hidden);
756
-
757
- update_option('wpsc_product_page_order', $current_order);
758
- return print_r($current_order);
759
- }
760
-
761
- function wpec_close_box(&$value,$key, $p) {
762
- if ( in_array($key, $p) ) {
763
- $value = 0;
764
- } else {
765
- $value = 1;
766
- }
767
- }
768
- if ($_POST['action'] == 'closed-postboxes') {
769
- $current_order = get_option('wpsc_product_page_order');
770
-
771
- $closed = $_POST["closed"];
772
- $closed = array_unique(explode(',', $closed));
773
-
774
- array_walk($current_order["closedboxes"], "wpec_close_box", $closed);
775
-
776
- update_option('wpsc_product_page_order', $current_order);
777
- print_r($current_order);
778
- }
779
-
780
- // if ($_POST['del_prod'] == 'true') {
781
- // $ids = $_POST['del_prod_id'];
782
- // $ids = explode(',',$ids);
783
- // foreach ($ids as $id) {
784
- // $wpdb->query($wpdb->prepare("DELETE FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE `id`=%d", $id));
785
- // }
786
- // exit();
787
- // }
788
-
789
-
790
- if(($_POST['save_image_upload_state'] == "true") && is_numeric($_POST['image_upload_state'])) {
791
- //get_option('wpsc_image_upload_state');
792
- $upload_state = (int)(bool)$_POST['image_upload_state'];
793
- update_option('wpsc_use_flash_uploader', $upload_state);
794
- exit("done");
795
- }
796
-
797
- if(($_POST['remove_variation_value'] == "true") && is_numeric($_POST['variation_value_id'])) {
798
- $value_id = absint($_GET['variation_value_id']);
799
- echo wp_delete_term($value_id, 'wpsc-variation');
800
- exit();
801
- }
802
-
803
 
804
- if(($_POST['edit_variation_value_list'] == 'true') && is_numeric($_POST['variation_id']) && is_numeric($_POST['product_id'])) {
805
- $variation_id = (int)$_POST['variation_id'];
806
- $product_id = (int)$_POST['product_id'];
807
- $variations_processor = new nzshpcrt_variations();
808
- $variation_values = $variations_processor->falsepost_variation_values($variation_id);
809
- if(is_array($variation_values)) {
810
- //echo(print_r($variation_values,true));
811
- $check_variation_added = $wpdb->get_var("SELECT `id` FROM `".WPSC_TABLE_VARIATION_ASSOC."` WHERE `type` IN ('product') AND `associated_id` IN ('{$product_id}') AND `variation_id` IN ('{$variation_id}') LIMIT 1");
812
- //exit("<pre>".print_r($variation_values,true)."<pre>");
813
- if($check_variation_added == null) {
814
- $variations_processor->add_to_existing_product($product_id,$variation_values);
815
- }
816
- echo $variations_processor->display_attached_variations($product_id);
817
- echo $variations_processor->variations_grid_view($product_id);
818
- } else {
819
- echo "false";
820
- }
821
- exit();
822
- }
823
-
824
 
825
-
826
- if(($_POST['remove_form_field'] == "true") && is_numeric($_POST['form_id'])) {
827
- //exit(print_r($user,true));
828
- if(current_user_can('level_7')) {
829
- $wpdb->query($wpdb->prepare("UPDATE `".WPSC_TABLE_CHECKOUT_FORMS."` SET `active` = '0' WHERE `id` = %d LIMIT 1 ;", $_POST['form_id']));
830
- exit(' ');
831
- }
832
- }
833
-
834
-
835
- if($_POST['hide_ecom_dashboard'] == 'true') {
836
- require_once (ABSPATH . WPINC . '/rss.php');
837
- $rss = fetch_rss('http://www.instinct.co.nz/feed/');
838
- $rss->items = array_slice($rss->items, 0, 5);
839
- $rss_hash = sha1(serialize($rss->items));
840
- update_option('wpsc_ecom_news_hash', $rss_hash);
841
- exit(1);
842
- }
843
-
844
- if(($_POST['remove_meta'] == 'true') && is_numeric($_POST['meta_id'])) {
845
- $meta_id = (int)$_POST['meta_id'];
846
- if(delete_meta($meta_id)) {
847
- echo $meta_id;
848
- exit();
849
- }
850
- echo 0;
851
- exit();
852
- }
853
-
854
- if(($_REQUEST['log_state'] == "true") && is_numeric($_POST['id']) && is_numeric($_POST['value'])) {
855
- $newvalue = $_POST['value'];
856
- if ($_REQUEST['suspend']=='true'){
857
- if ($_REQUEST['value']==1){
858
- wpsc_member_dedeactivate_subscriptions($_POST['id']);
859
- } else {
860
- wpsc_member_deactivate_subscriptions($_POST['id']);
861
- }
862
- exit();
863
- } else {
864
-
865
- $log_data = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `id` = '".$_POST['id']."' LIMIT 1",ARRAY_A);
866
- if (($newvalue==2) && function_exists('wpsc_member_activate_subscriptions')){
867
- wpsc_member_activate_subscriptions($_POST['id']);
868
- }
869
-
870
- $update_sql = "UPDATE `".WPSC_TABLE_PURCHASE_LOGS."` SET `processed` = '".$newvalue."' WHERE `id` = '".$_POST['id']."' LIMIT 1";
871
- $wpdb->query($update_sql);
872
- //echo("/*");
873
- if(($newvalue > $log_data['processed']) && ($log_data['processed'] < 2)) {
874
- transaction_results($log_data['sessionid'],false);
875
- }
876
- //echo("*/");
877
- $stage_sql = "SELECT * FROM `".WPSC_TABLE_PURCHASE_STATUSES."` WHERE `id`='".$newvalue."' AND `active`='1' LIMIT 1";
878
- $stage_data = $wpdb->get_row($stage_sql,ARRAY_A);
879
-
880
- echo "document.getElementById(\"form_group_".$_POST['id']."_text\").innerHTML = '".$stage_data['name']."';\n";
881
- echo "document.getElementById(\"form_group_".$_POST['id']."_text\").style.color = '#".$stage_data['colour']."';\n";
882
-
883
-
884
- $year = date("Y");
885
- $month = date("m");
886
- $start_timestamp = mktime(0, 0, 0, $month, 1, $year);
887
- $end_timestamp = mktime(0, 0, 0, ($month+1), 0, $year);
888
-
889
- echo "document.getElementById(\"log_total_month\").innerHTML = '".addslashes(nzshpcrt_currency_display(admin_display_total_price($start_timestamp, $end_timestamp),1))."';\n";
890
- echo "document.getElementById(\"log_total_absolute\").innerHTML = '".addslashes(nzshpcrt_currency_display(admin_display_total_price(),1))."';\n";
891
- exit();
892
- }
893
- }
894
-
895
- if(($_POST['list_variation_values'] == "true")) {
896
- // retrieve the forms for associating variations and their values with products
897
- $variation_processor = new nzshpcrt_variations();
898
-
899
- $variations_selected = array();
900
- foreach((array)$_POST['variations'] as $variation_id => $checked) {
901
- $variations_selected[] = (int)$variation_id;
902
- }
903
-
904
- if(is_numeric($_POST['product_id']) && ($_POST['product_id'] > 0)) {
905
- $product_id = absint($_POST['product_id']);
906
- $selected_price = (float)$_POST['selected_price'];
907
-
908
- // variation values housekeeping
909
- $completed_variation_values = $variation_processor->edit_product_values($product_id,$_POST['edit_var_val'], $selected_price);
910
-
911
-
912
- // get all the currently associated variations from the database
913
- $associated_variations = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_VARIATION_ASSOC."` WHERE `type` IN ('product') AND `associated_id` IN ('{$product_id}')", ARRAY_A);
914
-
915
- $variations_still_associated = array();
916
- foreach((array)$associated_variations as $associated_variation) {
917
- // remove variations not checked that are in the database
918
- if(array_search($associated_variation['variation_id'], $variations_selected) === false) {
919
- $wpdb->query("DELETE FROM `".WPSC_TABLE_VARIATION_ASSOC."` WHERE `id` = '{$associated_variation['id']}' LIMIT 1");
920
- $wpdb->query("DELETE FROM `".WPSC_TABLE_VARIATION_VALUES_ASSOC."` WHERE `product_id` = '{$product_id}' AND `variation_id` = '{$associated_variation['variation_id']}' ");
921
- } else {
922
- // make an array for adding in the variations next step, for efficiency
923
- $variations_still_associated[] = $associated_variation['variation_id'];
924
- }
925
- }
926
-
927
- foreach((array)$variations_selected as $variation_id) {
928
- // add variations not already in the database that have been checked.
929
- $variation_values = $variation_processor->falsepost_variation_values($variation_id);
930
- if(array_search($variation_id, $variations_still_associated) === false) {
931
- $variation_processor->add_to_existing_product($product_id,$variation_values);
932
- }
933
- }
934
- //echo "/* ".print_r($variation_values,true)." */\n\r";
935
- echo "edit_variation_combinations_html = \"".str_replace(array("\n","\r"), array('\n','\r'), addslashes($variation_processor->variations_grid_view($product_id, (array)$completed_variation_values)))."\";\n";
936
-
937
- } else {
938
- if(count($variations_selected) > 0) {
939
- // takes an array of variations, returns a form for adding data to those variations.
940
- if((float)$_POST['selected_price'] > 0) {
941
- $selected_price = (float)$_POST['selected_price'];
942
- }
943
- $limited_stock = false;
944
- if($_POST['limited_stock'] == 'true') {
945
- $limited_stock = true;
946
- }
947
-
948
- $selected_variation_values = array();
949
- foreach($_POST['edit_var_val'] as $variation_value_array) {
950
- //echo "/* ".print_r($variation_value_array,true)." */\n\r";
951
- $selected_variation_values = array_merge(array_keys($variation_value_array), $selected_variation_values);
952
- }
953
-
954
- ////echo "/* ".print_r($selected_variation_values,true)." */\n\r";
955
- echo "edit_variation_combinations_html = \"".__('Edit Variation Set', 'wpsc')."<br />".str_replace(array("\n","\r"), array('\n','\r'), addslashes($variation_processor->variations_grid_view(0, (array)$variations_selected, (array)$selected_variation_values, $selected_price, $limited_stock)))."\";\n";
956
-
957
- } else {
958
- echo "edit_variation_combinations_html = \"\";\n";
959
- }
960
- }
961
- exit();
962
- }
963
-
964
-
965
- if(isset($_POST['language_setting']) && ($_GET['page'] = WPSC_DIR_NAME.'/wpsc-admin/display-options.page.php')) {
966
- if($user_level >= 7) {
967
- update_option('language_setting', $_POST['language_setting']);
968
- }
969
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
970
  }
971
 
972
 
@@ -975,7 +1013,7 @@ function wpsc_admin_sale_rss() {
975
  if(($_GET['rss'] == "true") && ($_GET['rss_key'] == 'key') && ($_GET['action'] == "purchase_log")) {
976
  $sql = "SELECT * FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `date`!='' ORDER BY `date` DESC";
977
  $purchase_log = $wpdb->get_results($sql,ARRAY_A);
978
- header("Content-Type: application/xml; charset=UTF-8");
979
  header('Content-Disposition: inline; filename="WP_E-Commerce_Purchase_Log.rss"');
980
  $output = '';
981
  $output .= "<?xml version='1.0'?>\n\r";
@@ -985,7 +1023,7 @@ function wpsc_admin_sale_rss() {
985
  $output .= " <link>".get_option('siteurl')."/wp-admin/admin.php?page=".WPSC_DIR_NAME."/display-log.php</link>\n\r";
986
  $output .= " <description>This is the WP E-Commerce Product Log RSS feed</description>\n\r";
987
  $output .= " <generator>WP E-Commerce Plugin</generator>\n\r";
988
-
989
  foreach((array)$purchase_log as $purchase) {
990
  $purchase_link = get_option('siteurl')."/wp-admin/admin.php?page=".WPSC_DIR_NAME."/display-log.php&amp;purchaseid=".$purchase['id'];
991
  $output .= " <item>\n\r";
@@ -995,92 +1033,93 @@ function wpsc_admin_sale_rss() {
995
  $output .= " <pubDate>".date("r",$purchase['date'])."</pubDate>\n\r";
996
  $output .= " <guid>$purchase_link</guid>\n\r";
997
  $output .= " </item>\n\r";
998
- }
999
  $output .= " </channel>\n\r";
1000
  $output .= "</rss>";
1001
  echo $output;
1002
  exit();
1003
- }
1004
  }
1005
 
1006
  function wpsc_swfupload_images() {
1007
- global $wpdb, $current_user, $user_ID;
1008
- // xdebug_start_trace();
1009
- $file = $_FILES['async-upload'];
1010
- $product_id = absint($_POST['product_id']);
1011
- $nonce = $_POST['_wpnonce'];
1012
- $output = '';
1013
- // 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
1014
- if ( is_ssl() && empty($_COOKIE[SECURE_AUTH_COOKIE]) && !empty($_REQUEST['auth_cookie']) ) {
1015
- $_COOKIE[SECURE_AUTH_COOKIE] = $_REQUEST['auth_cookie'];
1016
- } else if ( empty($_COOKIE[AUTH_COOKIE]) && !empty($_REQUEST['auth_cookie']) ) {
1017
- $_COOKIE[AUTH_COOKIE] = $_REQUEST['auth_cookie'];
1018
- }
1019
- unset($current_user);
1020
-
1021
- if(!current_user_can('upload_files') ) {
1022
- exit("status=-1;\n");
1023
- }
1024
-
1025
- if(!wp_verify_nonce($nonce, 'product-swfupload') ) {
1026
- exit("status=-1;\n");
1027
- }
1028
-
1029
-
1030
-
1031
- $id = media_handle_upload('async-upload', $product_id);
1032
 
1033
- //$object = array('post_author' => $user_ID, 'ping_status' => get_option('default_ping_status'), 'post_parent' => $product_id);
1034
-
1035
- // wp_insert_attachment($object, $file = false, $parent = 0);
1036
-
1037
- if (!is_wp_error($id)) {
1038
- //$src = $file['name'];
1039
- $src = wp_get_attachment_image_src($id);
1040
- //print_r($src);
1041
- $output .= "upload_status=1;\n";
1042
- $output .= "image_src='".$src[0]."';\n";
1043
- $output .= "image_id='$id';\n";
1044
- $output .= "product_id='$product_id';\n";
1045
- $output .= "replace_existing=0;";
1046
- } else {
1047
- $output .= "status=0;\n";
1048
- }
1049
-
1050
-
1051
- exit($output);
 
 
 
 
 
 
 
 
 
 
 
 
1052
  }
1053
 
1054
 
1055
  function wpsc_display_invoice() {
1056
 
1057
- global $body_id;
1058
-
1059
- $body_id = 'wpsc-packing-slip';
1060
  $purchase_id = (int)$_GET['purchaselog_id'];
1061
  include_once(WPSC_FILE_PATH."/admin-form-functions.php");
1062
  // echo "testing";
1063
- require_once(ABSPATH.'wp-admin/includes/media.php');
1064
- wp_iframe('wpsc_packing_slip', $purchase_id);
1065
  //wpsc_packing_slip($purchase_id);
1066
  exit();
1067
  }
1068
- if($_REQUEST['wpsc_admin_action'] == 'wpsc_display_invoice') {
1069
- add_action('admin_init', 'wpsc_display_invoice');
 
1070
  }
1071
-
1072
 
1073
  function wpsc_save_inline_price() {
1074
- global $wpdb;
1075
- $pid = $_POST['id'];
1076
- $new_price = $_POST['value'];
1077
- $new_price1 = str_replace('$','',$new_price);
1078
- $wpdb->query("UPDATE ".WPSC_TABLE_PRODUCT_LIST." SET price='$new_price1' WHERE id='$pid'");
1079
- exit($new_price);
1080
  }
1081
 
1082
- if($_GET['inline_price']=='true') {
1083
- add_action('admin_init', 'wpsc_save_inline_price', 0);
1084
  }
1085
 
1086
 
@@ -1088,445 +1127,445 @@ if($_GET['inline_price']=='true') {
1088
  * Purchase log ajax code starts here
1089
  */
1090
  function wpsc_purchlog_resend_email(){
1091
- global $wpdb;
1092
- $siteurl = get_option('siteurl');
1093
- $log_id = $_GET['email_buyer_id'];
1094
- if(is_numeric($log_id)) {
1095
-
1096
- $selectsql = "SELECT * FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `id`= ".$log_id." LIMIT 1";
1097
-
1098
- $purchase_log = $wpdb->get_row($selectsql,ARRAY_A) ;
1099
-
1100
- if(($purchase_log['gateway'] == "testmode") && ($purchase_log['processed'] < 2)) {
1101
- $message = get_option("wpsc_email_receipt");
1102
- $message_html = "<h2 style='font-size:16px;font-weight:bold;color:#000;border:0px;padding-top: 0px;' >".__('Your Order', 'wpsc')."</h2>";
1103
- } else {
1104
- $message = get_option("wpsc_email_receipt");
1105
- $message_html = $message;
1106
- }
1107
-
1108
- $order_url = $siteurl."/wp-admin/admin.php?page=".WPSC_DIR_NAME."/display-log.php&amp;purchcaseid=".$purchase_log['id'];
1109
-
1110
- $cartsql = "SELECT * FROM `".WPSC_TABLE_CART_CONTENTS."` WHERE `purchaseid`=".$purchase_log['id']."";
1111
- $cart = $wpdb->get_results($cartsql,ARRAY_A);
1112
- if($purchase_log['shipping_country'] != '') {
1113
- $billing_country = $purchase_log['billing_country'];
1114
- $shipping_country = $purchase_log['shipping_country'];
1115
- } else {
1116
- $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);
1117
- $billing_country = $country[0]['value'];
1118
- $shipping_country = $country[0]['value'];
1119
- }
1120
-
1121
- $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);
1122
- $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);
1123
- $email = $email_address[0]['value'];
1124
-
1125
- $previous_download_ids = array(0);
1126
-
1127
- if(($cart != null)) {
1128
- foreach($cart as $row) {
1129
- $link = "";
1130
- $productsql= "SELECT * FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE `id`=".$row['prodid']."";
1131
- $product_data = $wpdb->get_results($productsql,ARRAY_A) ;
1132
-
1133
- if($product_data[0]['file'] > 0) {
1134
- if($purchase_log['email_sent'] != 1) {
1135
- $wpdb->query("UPDATE `".WPSC_TABLE_DOWNLOAD_STATUS."` SET `active`='1' WHERE `fileid`='".$product_data[0]['file']."' AND `purchid` = '".$purchase_log['id']."' LIMIT 1");
1136
- }
1137
-
1138
- if (($purchase_log['processed'] >= 2)) {
1139
- $download_data = $wpdb->get_results("SELECT *
1140
- FROM `".WPSC_TABLE_DOWNLOAD_STATUS."` INNER JOIN `".WPSC_TABLE_PRODUCT_FILES."`
1141
- ON `".WPSC_TABLE_DOWNLOAD_STATUS."`.`fileid` = `".WPSC_TABLE_PRODUCT_FILES."`.`id`
1142
- WHERE `".WPSC_TABLE_DOWNLOAD_STATUS."`.`active`='1'
1143
- AND `".WPSC_TABLE_DOWNLOAD_STATUS."`.`purchid`='".$purchase_log['id']."'
1144
- AND (
1145
- `".WPSC_TABLE_DOWNLOAD_STATUS."`.`cartid` = '".$row['id']."'
1146
- OR (
1147
- `".WPSC_TABLE_DOWNLOAD_STATUS."`.`cartid` IS NULL
1148
- AND `".WPSC_TABLE_DOWNLOAD_STATUS."`.`fileid` = '{$product_data['file']}'
1149
- )
1150
- )
1151
- AND `".WPSC_TABLE_DOWNLOAD_STATUS."`.`id` NOT IN ('".implode("','",$previous_download_ids)."')",ARRAY_A);
1152
- $link=array();
1153
- //exit('IM HERE'.$errorcode.'<pre>'.print_r($download_data).'</pre>');
1154
- if(sizeof($download_data) != 0) {
1155
- foreach($download_data as $single_download){
1156
- if($single_download['uniqueid'] == null){// if the uniqueid is not equal to null, its "valid", regardless of what it is
1157
- $link[] = array("url"=>$siteurl."?downloadid=".$single_download['id'], "name" =>$single_download["filename"]);
1158
- } else {
1159
- $link[] = array("url"=>$siteurl."?downloadid=".$single_download['uniqueid'], "name" =>$single_download["filename"]);
1160
- }
1161
  }
1162
- }
1163
- $previous_download_ids[] = $download_data['id'];
1164
- $order_status= 4;
1165
- }
1166
- }
1167
- do_action('wpsc_confirm_checkout', $purchase_log['id']);
1168
-
1169
- $shipping = nzshpcrt_determine_item_shipping($row['prodid'], $row['quantity'], $shipping_country);
1170
- if (isset($_SESSION['quote_shipping'])){
1171
- $shipping = $_SESSION['quote_shipping'];
1172
- }
1173
- $total_shipping += $shipping;
1174
-
1175
- if($product_data[0]['special']==1) {
1176
- $price_modifier = $product_data[0]['special_price'];
1177
- } else {
1178
- $price_modifier = 0;
1179
- }
1180
-
1181
- $total+=($row['price']*$row['quantity']);
1182
- $message_price = nzshpcrt_currency_display(($row['price']*$row['quantity']), $product_data[0]['notax'], true);
1183
-
1184
- $shipping_price = nzshpcrt_currency_display($shipping, 1, true);
1185
-
1186
-
1187
-
1188
- if($link != '') {
1189
- $product_list .= " - ". $product_data['name'] . stripslashes($variation_list) ." ".$message_price ." ".__('Click to download', 'wpsc').":";
1190
- $product_list_html .= " - ". $product_data['name'] . stripslashes($variation_list) ." ".$message_price ."&nbsp;&nbsp;".__('Click to download', 'wpsc').":\n\r";
1191
- foreach($link as $single_link) {
1192
- $product_list .= "\n\r ".$single_link["name"].": ".$single_link["url"]."\n\r";
1193
- $product_list_html .= "<a href='".$single_link["url"]."'>".$single_link["name"]."</a>\n";
1194
- }
1195
- } else {
1196
- $plural = '';
1197
-
1198
- if($row['quantity'] > 1) {
1199
- $plural = "s";
1200
- }
1201
-
1202
- $product_list.= " - ".$row['quantity']." ". $product_data[0]['name'].$variation_list ." ". $message_price ."\n";
1203
- if ($shipping > 0) $product_list .= " - ". __('Shipping', 'wpsc').":".$shipping_price ."\n\r";
1204
- $product_list_html.= " - ".$row['quantity']." ". $product_data[0]['name'].$variation_list ." ". $message_price ."\n";
1205
- if ($shipping > 0) $product_list_html .= " - ". __('Shipping', 'wpsc').":".$shipping_price ."\n\r";
1206
- }
1207
-
1208
- $report.= " - ". $product_data[0]['name'] .$variation_list." ".$message_price ."\n";
1209
- }
1210
-
1211
- if($purchase_log['discount_data'] != '') {
1212
- $coupon_data = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_COUPON_CODES."` WHERE coupon_code='".$wpdb->escape($purchase_log['discount_data'])."' LIMIT 1",ARRAY_A);
1213
- if($coupon_data['use-once'] == 1) {
1214
- $wpdb->query("UPDATE `".WPSC_TABLE_COUPON_CODES."` SET `active`='0', `is-used`='1' WHERE `id`='".$coupon_data['id']."' LIMIT 1");
1215
- }
1216
- }
1217
- //$wpdb->query("UPDATE `".WPSC_TABLE_DOWNLOAD_STATUS."` SET `active`='1' WHERE `fileid`='".$product_data[0]['file']."' AND `purchid` = '".$purchase_log['id']."' LIMIT 1");
1218
- $total_shipping += $purchase_log['base_shipping'];
1219
-
1220
- $total = (($total+$total_shipping) - $purchase_log['discount_value']);
1221
- // $message.= "\n\r";
1222
- $product_list.= "Your Purchase No.: ".$purchase_log['id']."\n\r";
1223
- if($purchase_log['discount_value'] > 0) {
1224
- $discount_email.= __('Discount', 'wpsc').": ".nzshpcrt_currency_display($purchase_log['discount_value'], 1, true)."\n\r";
1225
- }
1226
- $total_shipping_email.= __('Total Shipping', 'wpsc').": ".nzshpcrt_currency_display($total_shipping,1,true)."\n\r";
1227
- $total_price_email.= __('Total', 'wpsc').": ".nzshpcrt_currency_display($total,1,true)."\n\r";
1228
- $product_list_html.= "Your Purchase No.: ".$purchase_log['id']."\n\n\r";
1229
- if($purchase_log['discount_value'] > 0) {
1230
- $discount_html.= __('Discount', 'wpsc').": ".nzshpcrt_currency_display($purchase_log['discount_value'], 1, true)."\n\r";
1231
- }
1232
- $total_shipping_html.= __('Total Shipping', 'wpsc').": ".nzshpcrt_currency_display($total_shipping,1,true)."\n\r";
1233
- $total_price_html.= __('Total', 'wpsc').": ".nzshpcrt_currency_display($total, 1,true)."\n\r";
1234
- if(isset($_GET['ti'])) {
1235
- $message.= "\n\r".__('Your Transaction ID', 'wpsc').": " . $_GET['ti'];
1236
- $message_html.= "\n\r".__('Your Transaction ID', 'wpsc').": " . $_GET['ti'];
1237
- $report.= "\n\r".__('Transaction ID', 'wpsc').": " . $_GET['ti'];
1238
- } else {
1239
- $report_id = "Purchase No.: ".$purchase_log['id']."\n\r";
1240
- }
1241
-
1242
-
1243
-
1244
- $message = str_replace('%product_list%',$product_list,$message);
1245
  $message = str_replace('%total_shipping%',$total_shipping_email,$message);
1246
  $message = str_replace('%total_price%',$total_price_email,$message);
1247
  //$message = str_replace('%order_status%',get_option('blogname'),$message);
1248
  $message = str_replace('%shop_name%',get_option('blogname'),$message);
1249
-
1250
  $report = str_replace('%product_list%',$report_product_list,$report);
1251
  $report = str_replace('%total_shipping%',$total_shipping_email,$report);
1252
  $report = str_replace('%total_price%',$total_price_email,$report);
1253
  $report = str_replace('%shop_name%',get_option('blogname'),$report);
1254
-
1255
  $message_html = str_replace('%product_list%',$product_list_html,$message_html);
1256
  $message_html = str_replace('%total_shipping%',$total_shipping_html,$message_html);
1257
  $message_html = str_replace('%total_price%',$total_price_email,$message_html);
1258
  $message_html = str_replace('%shop_name%',get_option('blogname'),$message_html);
1259
-
1260
-
1261
- // exit($message_html);
1262
- if(($email != '')) {
1263
- add_filter('wp_mail_from', 'wpsc_replace_reply_address', 0);
1264
- add_filter('wp_mail_from_name', 'wpsc_replace_reply_name', 0);
1265
- if($purchase_log['processed'] < 2) {
1266
- $payment_instructions = strip_tags(get_option('payment_instructions'));
1267
- $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;
1268
- $resent = (bool)wp_mail($email, __('Order Pending: Payment Required', 'wpsc'), $message);
1269
- $sent = 1;
1270
- } else {
1271
- $resent = (bool)wp_mail($email, __('Purchase Receipt', 'wpsc'), $message);
1272
- $sent = 1;
1273
- }
1274
- //echo "$message<br />";
1275
- //exit($email);
1276
- remove_filter('wp_mail_from_name', 'wpsc_replace_reply_name');
1277
- remove_filter('wp_mail_from', 'wpsc_replace_reply_address');
1278
- }
1279
- }
1280
-
1281
  }
1282
- $sendback = wp_get_referer();
1283
 
1284
- if ( isset($sent) ) {
1285
- $sendback = add_query_arg('sent', $sent, $sendback);
1286
- }
1287
- wp_redirect($sendback);
1288
- exit();
1289
  }
1290
 
1291
 
1292
 
1293
  if(isset($_REQUEST['email_buyer_id']) && is_numeric($_REQUEST['email_buyer_id'])) {
1294
- add_action('admin_init', 'wpsc_purchlog_resend_email');
1295
- }
1296
  function wpsc_purchlog_clear_download_items(){
1297
- global $wpdb;
1298
  //exit('Just about to redirect');
1299
- if(is_numeric($_GET['purchaselog_id'])) {
1300
- $purchase_id = (int)$_GET['purchaselog_id'];
1301
- $downloadable_items = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_DOWNLOAD_STATUS."` WHERE `purchid` IN ('$purchase_id')", ARRAY_A);
1302
-
1303
- $clear_locks_sql = "UPDATE`".WPSC_TABLE_DOWNLOAD_STATUS."` SET `ip_number` = '' WHERE `purchid` IN ('$purchase_id')";
1304
- $wpdb->query($clear_locks_sql);
1305
- $cleared =true;
1306
-
1307
- $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");
1308
- $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");
1309
-
1310
- foreach((array)$downloadable_items as $downloadable_item) {
1311
- $download_links .= $siteurl."?downloadid=".$downloadable_item['uniqueid']. "\n";
1312
- }
1313
-
1314
-
1315
- 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')."");
1316
-
1317
 
1318
- $sendback = wp_get_referer();
 
 
 
 
 
 
 
 
 
1319
 
1320
- if ( isset($cleared) ) {
1321
- $sendback = add_query_arg('cleared', $cleared, $sendback);
1322
- }
1323
- wp_redirect($sendback);
1324
- exit();
1325
- }
 
 
 
 
 
 
1326
 
1327
  }
1328
- if($_REQUEST['wpsc_admin_action'] == 'clear_locks') {
1329
- add_action('admin_init', 'wpsc_purchlog_clear_download_items');
1330
  }
1331
-
1332
  //call to search purchase logs
1333
-
1334
  function wpsc_purchlog_search_by(){
1335
  // exit('<pre>'.print_r($_POST,true).'</pre>');
1336
- //wpsc_search_purchlog_view($_POST['purchlogs_searchbox']);
1337
- }
1338
-
1339
- if($_REQUEST['wpsc_admin_action'] == 'purchlogs_search') {
1340
- add_action('admin_init', 'wpsc_purchlog_search_by');
1341
  }
1342
  //call to change view for purchase log
1343
-
1344
  function wpsc_purchlog_filter_by(){
1345
- //exit('filter is triggered'.print_r($_POST, true));
1346
- wpsc_change_purchlog_view($_POST['view_purchlogs_by'], $_POST['view_purchlogs_by_status']);
1347
- }
1348
-
1349
- if($_REQUEST['wpsc_admin_action'] == 'purchlog_filter_by') {
1350
- add_action('admin_init', 'wpsc_purchlog_filter_by');
1351
  }
1352
  //bulk actions for purchase log
1353
  function wpsc_purchlog_bulk_modify(){
1354
- if($_POST['purchlog_multiple_status_change'] != -1){
1355
- if(is_numeric($_POST['purchlog_multiple_status_change']) && $_POST['purchlog_multiple_status_change'] != 'delete'){
1356
- foreach((array)$_POST['purchlogids'] as $purchlogid){
1357
- //exit('<pre>'.print_r($purchlogid,true).'</pre>');
1358
- wpsc_purchlog_edit_status($purchlogid, $_POST['purchlog_multiple_status_change']);
1359
- $updated++;
1360
- }
1361
-
1362
- }elseif($_POST['purchlog_multiple_status_change'] == 'delete'){
1363
- foreach((array)$_POST['purchlogids'] as $purchlogid){
1364
-
1365
- wpsc_delete_purchlog($purchlogid);
1366
- $deleted++;
1367
- }
1368
- }
1369
-
1370
- }
1371
- $sendback = wp_get_referer();
1372
- if ( isset($updated) ) {
1373
- $sendback = add_query_arg('updated', $updated, $sendback);
1374
- }
1375
- if ( isset($deleted) ) {
1376
- $sendback = add_query_arg('deleted', $deleted, $sendback);
1377
- }
1378
- if ( isset($_POST['view_purchlogs_by']) ) {
1379
- $sendback = add_query_arg('view_purchlogs_by', $_POST['view_purchlogs_by'], $sendback);
1380
  }
1381
- if ( isset($_POST['view_purchlogs_by_status']) ) {
1382
- $sendback = add_query_arg('view_purchlogs_by_status', $_POST['view_purchlogs_by_status'], $sendback);
1383
  }
1384
- wp_redirect($sendback);
1385
- exit();
1386
  }
1387
 
1388
- if($_REQUEST['wpsc_admin_action2'] == 'purchlog_bulk_modify') {
1389
- add_action('admin_init', 'wpsc_purchlog_bulk_modify');
1390
  }
1391
  //edit purchase log status function
1392
  function wpsc_purchlog_edit_status($purchlog_id='', $purchlog_status='') {
1393
- global $wpdb;
1394
- if(($purchlog_id =='') && ($purchlog_status == '')){
1395
- $purchlog_id = absint($_POST['purchlog_id']);
1396
- $purchlog_status = absint($_POST['purchlog_status']);
1397
- }
1398
-
1399
- $log_data = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `id` = '{$purchlog_id}' LIMIT 1",ARRAY_A);
1400
- if (($purchlog_id==2) && function_exists('wpsc_member_activate_subscriptions')){
1401
- wpsc_member_activate_subscriptions($_POST['id']);
1402
- }
1403
 
1404
- // if the order is marked as failed, remove the claim on the stock
1405
- if($purchlog_status == 5) {
1406
- $wpdb->query("DELETE FROM `".WPSC_TABLE_CLAIMED_STOCK."` WHERE `cart_id` = '{$purchlog_id}' AND `cart_submitted` = '1'");
1407
- //echo "DELETE FROM `".WPSC_TABLE_CLAIMED_STOCK."` WHERE `cart_id` = '{$purchlog_id}' AND `cart_submitted` = '1'";
1408
- }
1409
 
1410
- $wpdb->query("UPDATE `".WPSC_TABLE_PURCHASE_LOGS."` SET processed='{$purchlog_status}' WHERE id='{$purchlog_id}'");
 
 
 
 
1411
 
1412
- if(($purchlog_id > $log_data['processed']) && ($log_data['processed'] <= 2) && $log_data['email_sent'] == 0) {
1413
- // transaction_results($log_data['sessionid'],false,null);
1414
- }
 
 
1415
  }
1416
 
1417
- if($_REQUEST['wpsc_admin_action'] == 'purchlog_edit_status') {
1418
- add_action('admin_init', 'wpsc_purchlog_edit_status');
1419
  }
1420
  /*
1421
  SELECT DISTINCT `products`.*, `category`.`category_id`,`order`.`order`, IF(ISNULL(`order`.`order`), 0, 1) AS `order_state` FROM `wp_wpsc_product_list` AS `products` LEFT JOIN `wp_wpsc_item_category_assoc` AS `category` ON `products`.`id` = `category`.`product_id` LEFT JOIN `wp_wpsc_product_order` AS `order` ON ( ( `products`.`id` = `order`.`product_id` ) AND ( `category`.`category_id` = `order`.`category_id` ) ) WHERE `products`.`publish`='1' AND `products`.`active` = '1' AND `category`.`category_id` IN ('3') ORDER BY `order_state` DESC, `products`.`id` DESC,`order`.`order` ASC LIMIT 0, 8
1422
  */
1423
  function wpsc_save_product_order() {
1424
  global $wpdb;
1425
-
1426
- $products = array();
1427
-
1428
- foreach($_POST['post'] as $product) {
1429
- $products[] = absint($product);
1430
- }
1431
-
1432
- print_r($products);
1433
-
1434
- foreach($products as $order=>$product_id) {
1435
-
1436
- $wpdb->query($wpdb->prepare("UPDATE `{$wpdb->posts}` SET `menu_order`='%d' WHERE `ID`='%d' LIMIT 1", $order, $product_id));
1437
 
1438
- }
1439
- $success = true;
1440
 
1441
- exit((string)$success);
 
 
 
 
 
 
 
 
 
 
 
 
 
1442
  }
1443
-
1444
-
1445
- if($_REQUEST['wpsc_admin_action'] == 'save_product_order') {
1446
- add_action('admin_init', 'wpsc_save_product_order');
1447
  }
1448
 
1449
  function wpsc_save_checkout_order() {
1450
  global $wpdb;
1451
- //exit('<pre>'.print_r($_POST, true).'</pre>');
1452
- $checkoutfields = $_POST['checkout'];
1453
- $order=1;
1454
- foreach($checkoutfields as $checkoutfield) {
1455
- $checkoutfield = absint($checkoutfield);
1456
- $wpdb->query("UPDATE `".WPSC_TABLE_CHECKOUT_FORMS."` SET `order` = '".$order."' WHERE `id`=".$checkoutfield);
1457
 
1458
- $order++;
1459
- }
1460
- $success = true;
1461
 
1462
- exit((string)$success);
1463
  }
1464
-
1465
-
1466
- if($_REQUEST['wpsc_admin_action'] == 'save_checkout_order') {
1467
- add_action('admin_init', 'wpsc_save_checkout_order');
1468
  }
1469
  /* Start Order Notes (by Ben) */
1470
  function wpsc_purchlogs_update_notes($purchlog_id = '', $purchlog_notes = '' ) {
1471
- global $wpdb;
1472
- if ( wp_verify_nonce( $_POST['wpsc_purchlogs_update_notes_nonce'], 'wpsc_purchlogs_update_notes' ) ) {
1473
- if ( ($purchlog_id == '') && ($purchlog_notes == '') ) {
1474
- $purchlog_id = absint($_POST['purchlog_id']);
1475
- $purchlog_notes = $wpdb->escape($_POST['purchlog_notes']);
1476
- }
1477
- $wpdb->query("UPDATE `" . WPSC_TABLE_PURCHASE_LOGS . "` SET notes='{$purchlog_notes}' WHERE id='{$purchlog_id}'");
1478
- }
1479
  }
1480
 
1481
- if ( $_REQUEST['wpsc_admin_action'] == 'purchlogs_update_notes' ) {
1482
- add_action('admin_init', 'wpsc_purchlogs_update_notes');
1483
  }
1484
  /* End Order Notes (by Ben) */
1485
 
1486
-
1487
  //delete a purchase log
1488
  function wpsc_delete_purchlog($purchlog_id='') {
1489
- global $wpdb;
1490
- $deleted = 0;
1491
- if($purchlog_id == ''){
1492
- $purchlog_id = absint($_GET['purchlog_id']);
1493
- check_admin_referer('delete_purchlog_' . $purchlog_id);
1494
- }
1495
-
1496
- if(is_numeric($purchlog_id)) {
1497
- $delete_log_form_sql = "SELECT * FROM `".WPSC_TABLE_CART_CONTENTS."` WHERE `purchaseid`='$purchlog_id'";
1498
- $cart_content = $wpdb->get_results($delete_log_form_sql,ARRAY_A);
1499
- }
1500
-
1501
- $purchlog_status = $wpdb->get_var("SELECT `processed` FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `id`=".$purchlog_id);
1502
- if($purchlog_status == 5 || $purchlog_status == 1) {
1503
- $wpdb->query("DELETE FROM `".WPSC_TABLE_CLAIMED_STOCK."` WHERE `cart_id` = '{$purchlog_id}' AND `cart_submitted` = '1'");
1504
- }
1505
 
1506
- $wpdb->query("DELETE FROM `".WPSC_TABLE_CART_CONTENTS."` WHERE `purchaseid`='$purchlog_id'");
1507
- $wpdb->query("DELETE FROM `".WPSC_TABLE_SUBMITED_FORM_DATA."` WHERE `log_id` IN ('$purchlog_id')");
1508
- $wpdb->query("DELETE FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `id`='$purchlog_id' LIMIT 1");
1509
-
1510
- $deleted = 1;
1511
-
1512
- if(is_numeric($_GET['purchlog_id'])){
1513
- $sendback = wp_get_referer();
1514
- $sendback = remove_query_arg('purchaselog_id', $sendback);
1515
- if ( isset($deleted) ) {
1516
- $sendback = add_query_arg('deleted', $deleted, $sendback);
1517
- }
1518
- wp_redirect($sendback);
1519
- exit();
1520
- }
 
 
 
 
 
 
 
 
 
 
1521
  }
1522
-
1523
-
1524
-
1525
- if($_REQUEST['wpsc_admin_action'] == 'delete_purchlog') {
1526
- add_action('admin_init', 'wpsc_delete_purchlog');
1527
  }
1528
-
1529
-
1530
 
1531
 
1532
 
@@ -1539,258 +1578,271 @@ function wpsc_ajax_get_shipping_form() {
1539
  $shippingname = $_REQUEST['shippingname'];
1540
  $_SESSION['previous_shipping_name'] = $shippingname;
1541
  $shipping_data = wpsc_get_shipping_form($shippingname);
1542
- $html_shipping_name = str_replace(Array("\n","\r") , Array("\\n","\\r"),addslashes($shipping_data['name']));
1543
- $shipping_form = str_replace(Array("\n","\r") , Array("\\n","\\r"),addslashes($shipping_data['form_fields']));
1544
- echo "shipping_name_html = '$html_shipping_name'; \n\r";
1545
- echo "shipping_form_html = '$shipping_form'; \n\r";
1546
- echo "has_submit_button = '{$shipping_data['has_submit_button']}'; \n\r";
1547
- //echo "<script type='text/javascript'>jQuery('.gateway_settings h3.hndle').livequery(function(){ jQuery(this).html('".$wpsc_shipping_modules[$shippingname]->name."')})</script>";
1548
  exit();
1549
  }
1550
-
1551
  function wpsc_crop_thumbnail_html() {
1552
- include(WPSC_FILE_PATH."/wpsc-admin/includes/crop.php");
1553
  exit();
1554
  }
1555
-
1556
-
1557
-
1558
- if ($_REQUEST['wpsc_admin_action'] == 'crop_image') {
1559
- add_action('admin_init','wpsc_crop_thumbnail_html');
1560
- }
1561
-
1562
-
1563
-
1564
- if($_REQUEST['wpsc_admin_action'] == 'get_shipping_form') {
1565
- add_action('admin_init', 'wpsc_ajax_get_shipping_form');
1566
- }
1567
-
1568
-
1569
-
1570
- /*
1571
- *Submit Options from Settings Pages,
1572
- *takes an array of options checks to see whether it is empty or the same as the exisiting values
1573
- *and if its not it updates them.
1574
- */
1575
- function wpsc_submit_options($selected='') {
1576
- global $wpdb, $wpsc_gateways;
1577
- //This is to change the Overall target market selection
1578
- check_admin_referer('update-options', 'wpsc-update-options');
1579
-
1580
- if($_POST['countrylist2'] != null || $selected != ''){
1581
- $AllSelected = false;
1582
- if( $selected == 'all'){
1583
- $wpdb->query("UPDATE `".WPSC_TABLE_CURRENCY_LIST."` SET visible = '1'");
1584
- $AllSelected = true;
1585
- return;
1586
- }
1587
- if( $selected == 'none'){
1588
- $wpdb->query("UPDATE `".WPSC_TABLE_CURRENCY_LIST."` SET visible = '0'");
1589
- $AllSelected = true;
1590
- return;
1591
- }
1592
- if($AllSelected != true){
1593
- $countrylist = $wpdb->get_col("SELECT id FROM `".WPSC_TABLE_CURRENCY_LIST."` ORDER BY country ASC ");
1594
- //find the countries not selected
1595
- $unselectedCountries = array_diff($countrylist, $_POST['countrylist2']);
1596
- foreach($unselectedCountries as $unselected){
1597
- $wpdb->query("UPDATE `".WPSC_TABLE_CURRENCY_LIST."` SET visible = 0 WHERE id = '".$unselected."' LIMIT 1");
1598
- }
1599
-
1600
- //find the countries that are selected
1601
- $selectedCountries = array_intersect($countrylist, $_POST['countrylist2']);
1602
- foreach($selectedCountries as $selected){
1603
- $wpdb->query("UPDATE `".WPSC_TABLE_CURRENCY_LIST."` SET visible = 1 WHERE id = '".$selected."' LIMIT 1");
1604
- }
1605
- }
1606
- }
1607
- //this is to change the base country and tax code for the shop
1608
- if((is_numeric($_POST['country_id']) && is_numeric($_POST['country_tax']))) {
1609
- $wpdb->query("UPDATE `".WPSC_TABLE_CURRENCY_LIST."` SET `tax` = '".$_POST['country_tax']."' WHERE `id` = '".$_POST['country_id']."' LIMIT 1 ;");
1610
- }
1611
-
1612
-
1613
- $previous_currency = get_option('currency_type');
1614
-
1615
- //To update options
1616
- if(isset($_POST['wpsc_options'])){
1617
- foreach($_POST['wpsc_options'] as $key=>$value){
1618
- if($value != get_option($key)) {
1619
- update_option($key, $value);
1620
- $updated++;
1621
- }
1622
- }
1623
- }
1624
-
1625
- if($previous_currency != get_option('currency_type')) {
1626
- $currency_code = $wpdb->get_var("SELECT `code` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `id` IN ('".absint(get_option('currency_type'))."')");
1627
-
1628
- $selected_gateways = get_option('custom_gateway_options');
1629
- $already_changed = array();
1630
- foreach($selected_gateways as $selected_gateway) {
1631
- if(isset($wpsc_gateways[$selected_gateway]['supported_currencies'])) {
1632
- if(in_array($currency_code, $wpsc_gateways[$selected_gateway]['supported_currencies']['currency_list'])) {
1633
-
1634
- $option_name = $wpsc_gateways[$selected_gateway]['supported_currencies']['option_name'];
1635
 
1636
- if(!in_array($option_name, $already_changed)) {
1637
- //echo $option_name;
1638
- update_option($option_name, $currency_code);
1639
- $already_changed[] = $option_name;
1640
- }
1641
- }
1642
- }
1643
- }
1644
 
1645
 
1646
- //exit("<pre>".print_r($selected_gateways,true)."</pre>");
1647
-
1648
- }
1649
 
1650
- foreach($GLOBALS['wpsc_shipping_modules'] as $shipping) {
1651
- $shipping->submit_form();
1652
- }
1653
 
1654
 
1655
- //This is for submitting shipping details to the shipping module
1656
- if($_POST['update_gateways'] == 'true') {
 
1657
 
1658
- update_option('custom_shipping_options', $_POST['custom_shipping_options']);
1659
 
1660
 
1661
- foreach($GLOBALS['wpsc_shipping_modules'] as $shipping) {
1662
- foreach((array)$_POST['custom_shipping_options'] as $shippingoption){
1663
- //echo $shipping->internal_name.' == '.$shippingoption;
1664
- if($shipping->internal_name == $shippingoption) {
1665
- //$shipping->submit_form();
1666
- $shipadd++;
1667
- }
1668
- }
1669
- }
1670
- }
1671
- $sendback = wp_get_referer();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1672
 
1673
- if ( isset($updated) ) {
1674
- $sendback = add_query_arg('updated', $updated, $sendback);
1675
- }
1676
- if ( isset($shipadd) ) {
1677
- $sendback = add_query_arg('shipadd', $shipadd, $sendback);
1678
- }
1679
- if(isset($_SESSION['wpsc_settings_curr_page'])){
1680
- $sendback = add_query_arg('tab', $_SESSION['wpsc_settings_curr_page'], $sendback);
1681
- }
1682
 
1683
- $sendback = add_query_arg('page', 'wpsc-settings', $sendback);
1684
- wp_redirect($sendback);
1685
- exit();
1686
- }
1687
-
1688
-
1689
 
1690
- if($_REQUEST['wpsc_admin_action'] == 'submit_options') {
1691
- add_action('admin_init', 'wpsc_submit_options');
1692
  }
1693
 
1694
  function wpsc_change_currency(){
1695
- if(is_numeric($_POST['currencyid'])){
1696
- $currency_data = $wpdb->get_results("SELECT `symbol`,`symbol_html`,`code` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `id`='".$_POST['currencyid']."' LIMIT 1",ARRAY_A) ;
1697
- $price_out = null;
1698
- if($currency_data[0]['symbol'] != '') {
1699
- $currency_sign = $currency_data[0]['symbol_html'];
1700
- } else {
1701
- $currency_sign = $currency_data[0]['code'];
1702
- }
1703
- echo $currency_sign;
1704
- }
1705
  }
1706
- if($_REQUEST['wpsc_admin_action'] == 'change_currency') {
1707
- add_action('admin_init', 'wpsc_change_currency');
1708
  }
1709
 
1710
  function wpsc_rearrange_images() {
1711
- global $wpdb;
1712
- //$wpdb->show_errors = true;
1713
- $images = explode(",",$_POST['order']);
1714
- $product_id = absint($_POST['product_id']);
1715
- $timestamp = time();
1716
-
1717
- $new_main_image = null;
1718
- $have_set_first_item = false;
1719
- $i = 0;
1720
- foreach($images as $image) {
1721
- if($image > 0) {
1722
- $wpdb->query($wpdb->prepare("UPDATE `{$wpdb->posts}` SET `menu_order`='%d' WHERE `ID`='%d' LIMIT 1", $i, $image));
1723
- $i++;
1724
- }
1725
- }
1726
- $output = wpsc_main_product_image_menu($product_id);
1727
- //echo "/*\n";
1728
- //echo print_r($_POST, true);
1729
- //echo print_r($images, true);
1730
- //echo "*/\n";
1731
- echo "image_menu = '';\n\r";
1732
- echo "image_id = '".$new_main_image."';\n\r";
1733
- exit();
1734
- }
1735
- if($_REQUEST['wpsc_admin_action'] == 'rearrange_images') {
1736
- add_action('admin_init', 'wpsc_rearrange_images');
1737
  }
1738
 
1739
 
1740
  function wpsc_delete_images() {
1741
- global $wpdb;
1742
- $product_id = absint($_POST['product_id']);
1743
- $element_id = $_POST['del_img_id'];
1744
- $image_id = absint(str_replace("product_image_", '', $element_id));
1745
- if($image_id > 0) {
1746
- $deletion_success = $wpdb->query("DELETE FROM `".WPSC_TABLE_PRODUCT_IMAGES."` WHERE `id`='{$image_id}' LIMIT 1");
1747
- echo "element_id = '$element_id';\n";
1748
- //echo "/*\n";
1749
- //print_r($deletion_success);
1750
- //echo "*/\n";
1751
-
1752
- if(($product_id > 0) && ($deletion_success == true)) {
1753
- $next_image = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_PRODUCT_IMAGES."` WHERE `product_id` = '{$product_id}' ORDER BY `image_order` ASC LIMIT 1",ARRAY_A);
1754
- if(count($next_image) > 0) {
1755
- $wpdb->query("UPDATE `".WPSC_TABLE_PRODUCT_LIST."` SET `image` = '{$next_image['id']}' WHERE `id` = '{$product_id}' LIMIT 1");
1756
- $output = wpsc_main_product_image_menu($product_id);
1757
-
1758
- $height = get_option('product_image_height');
1759
- $width = get_option('product_image_width');
1760
-
1761
- $image_input = WPSC_IMAGE_DIR . $next_image['file'];
1762
- $image_output = WPSC_THUMBNAIL_DIR . $next_image['file'];
1763
- if(($product['file'] != '') and file_exists($image_input)) {
1764
- image_processing($image_input, $image_output, $width, $height);
1765
- update_product_meta($product_id, 'thumbnail_width', $width);
1766
- update_product_meta($product_id, 'thumbnail_height', $height);
1767
- }
1768
- echo "image_menu='".str_replace(array("\n", "\r"), array('\n', '\r'), addslashes($output))."';\n";
1769
- echo "image_id='".$next_image['id']."';\n";
1770
- } else {
1771
- $wpdb->query("UPDATE `".WPSC_TABLE_PRODUCT_LIST."` SET `image` = NULL WHERE `id` = '{$product_id}' LIMIT 1");
1772
- }
1773
- }
1774
- }
1775
-
1776
- exit();
1777
- }
1778
-
1779
- if($_REQUEST['wpsc_admin_action'] == 'delete_images') {
1780
- add_action('admin_init', 'wpsc_delete_images');
1781
  }
1782
 
1783
  function wpsc_update_page_urls(){
1784
- global $wpdb;
1785
 
1786
  $wpsc_pageurl_option['product_list_url'] = '[productspage]';
1787
  $wpsc_pageurl_option['shopping_cart_url'] = '[shoppingcart]';
1788
  $check_chekout = $wpdb->get_var("SELECT `guid` FROM `{$wpdb->posts}` WHERE `post_content` LIKE '%[checkout]%' LIMIT 1");
1789
  if($check_chekout != null) {
1790
- $wpsc_pageurl_option['checkout_url'] = '[checkout]';
1791
- } else {
1792
- $wpsc_pageurl_option['checkout_url'] = '[checkout]';
1793
- }
1794
  $wpsc_pageurl_option['transact_url'] = '[transactionresults]';
1795
  $wpsc_pageurl_option['user_account_url'] = '[userlog]';
1796
  $changes_made = false;
@@ -1800,388 +1852,395 @@ function wpsc_update_page_urls(){
1800
  if(stristr(get_option($option_key), "https://")) {
1801
  $the_new_link = str_replace('http://', "https://",$the_new_link);
1802
  }
1803
-
1804
  update_option($option_key, $the_new_link);
1805
  $updated;
1806
- }
1807
- $sendback = wp_get_referer();
1808
 
1809
- if ( isset($updated) ) {
1810
- $sendback = add_query_arg('updated', $updated, $sendback);
1811
- }
1812
- if(isset($_SESSION['wpsc_settings_curr_page'])){
1813
- $sendback = add_query_arg('tab', $_SESSION['wpsc_settings_curr_page'], $sendback);
1814
- }
1815
- wp_redirect($sendback);
1816
 
1817
  exit();
1818
  }
1819
- if($_REQUEST['wpsc_admin_action'] == 'update_page_urls') {
1820
- add_action('admin_init', 'wpsc_update_page_urls');
 
1821
  }
1822
 
1823
  function wpsc_clean_categories(){
1824
  global $wpdb, $wp_rewrite;
1825
  //exit("<pre>".print_r($check_category_names,true)."</pre>");
1826
  $sql_query = "SELECT `id`, `name`, `active` FROM `".WPSC_TABLE_PRODUCT_CATEGORIES."`";
1827
- $sql_data = $wpdb->get_results($sql_query,ARRAY_A);
1828
- foreach((array)$sql_data as $datarow) {
1829
- if($datarow['active'] == 1) {
1830
- $tidied_name = trim($datarow['name']);
1831
- $tidied_name = strtolower($tidied_name);
1832
- $url_name = sanitize_title($tidied_name);
1833
- $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);
1834
- $extension_number = '';
1835
- if($similar_names['count'] > 0) {
1836
- $extension_number = (int)$similar_names['max_number']+2;
1837
- }
1838
- $url_name .= $extension_number;
1839
- $wpdb->query("UPDATE `".WPSC_TABLE_PRODUCT_CATEGORIES."` SET `nice-name` = '$url_name' WHERE `id` = '{$datarow['id']}' LIMIT 1 ;");
1840
- $updated;
1841
- } else if($datarow['active'] == 0) {
1842
- $wpdb->query("UPDATE `".WPSC_TABLE_PRODUCT_CATEGORIES."` SET `nice-name` = '' WHERE `id` = '{$datarow['id']}' LIMIT 1 ;");
1843
- $updated;
1844
- }
1845
- }
1846
- $wp_rewrite->flush_rules();
1847
- $sendback = wp_get_referer();
1848
-
1849
- if ( isset($updated) ) {
1850
- $sendback = add_query_arg('updated', $updated, $sendback);
1851
- }
1852
- if(isset($_SESSION['wpsc_settings_curr_page'])){
1853
- $sendback = add_query_arg('tab', $_SESSION['wpsc_settings_curr_page'], $sendback);
1854
- }
1855
- wp_redirect($sendback);
1856
 
1857
  exit();
1858
  }
1859
- if($_REQUEST['wpsc_admin_action'] == 'clean_categories') {
1860
- add_action('admin_init', 'wpsc_clean_categories');
 
1861
  }
1862
 
1863
  //change the regions tax settings
1864
  function wpsc_change_region_tax(){
1865
- global $wpdb;
1866
- if(is_array($_POST['region_tax'])) {
1867
- foreach($_POST['region_tax'] as $region_id => $tax) {
1868
- if(is_numeric($region_id) && is_numeric($tax)) {
1869
- $previous_tax = $wpdb->get_var("SELECT `tax` FROM `".WPSC_TABLE_REGION_TAX."` WHERE `id` = '$region_id' LIMIT 1");
1870
- if($tax != $previous_tax) {
1871
- $wpdb->query("UPDATE `".WPSC_TABLE_REGION_TAX."` SET `tax` = '$tax' WHERE `id` = '$region_id' LIMIT 1");
1872
- $changes_made = true;
1873
- }
1874
- }
1875
- }
1876
- $sendback = wp_get_referer();
1877
- //$sendback = remove_query_arg('isocode', $sendback);
1878
- wp_redirect($sendback);
1879
- }
1880
- }
1881
-
1882
- if($_REQUEST['wpsc_admin_action'] == 'change_region_tax') {
1883
- add_action('admin_init', 'wpsc_change_region_tax');
1884
  }
1885
 
1886
  function wpsc_product_files_existing() {
1887
- global $wpdb;
1888
-
1889
- //List all product_files, with checkboxes
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1890
 
1891
- $product_id = absint($_GET["product_id"]);
1892
- $file_list = wpsc_uploaded_files();
1893
-
1894
- $args = array(
1895
- 'post_type' => 'wpsc-product-file',
1896
- 'post_parent' => $product_id,
1897
- 'numberposts' => -1,
1898
- 'post_status' => 'all'
1899
- );
1900
- //echo "<pre>".print_r($file_list, true)."<pre>";
1901
- $attached_files = (array)get_posts($args);
1902
-
1903
- //echo "<pre>".print_r($attached_files, true)."<pre>";
1904
- foreach($attached_files as $key => $attached_file) {
1905
- $attached_files_by_file[$attached_file->post_title] = & $attached_files[$key];
1906
- }
1907
-
1908
- $output = "<span class='admin_product_notes select_product_note '>".__('Choose a downloadable file for this product:', 'wpsc')."</span><br>";
1909
- $output .= "<div class='ui-widget-content multiple-select select_product_file'>";
1910
- $output .= "<form method='post' class='product_upload'>";
1911
-
1912
- $num = 0;
1913
- foreach((array)$file_list as $file) {
1914
- $num++;
1915
- $checked_curr_file = "";
1916
- if (isset($attached_files_by_file[$file['display_filename']])){
1917
- $checked_curr_file = "checked='checked'";
1918
- }
1919
-
1920
- $output .= "<p ".((($num % 2) > 0) ? '' : "class='alt'")." id='select_product_file_row_$num'>\n";
1921
- $output .= " <input type='checkbox' name='select_product_file[]' value='".$file['real_filename']."' id='select_product_file_$num' ".$checked_curr_file." />\n";
1922
- $output .= " <label for='select_product_file_$num'>".$file['display_filename']."</label>\n";
1923
- $output .= "</p>\n";
1924
- }
1925
- $output .= "<input type='hidden' id='hidden_id' value='$product_id' />";
1926
- $output .= "<input type='submit' name='save' name='product_files_submit' class='button-primary prdfil' value='Save Product Files' />";
1927
- $output .= "</form>";
1928
- $output .= "</div>";
1929
- $output .= "<div class='".((is_numeric($product_id)) ? "edit_" : "")."select_product_handle'><div></div></div>";
1930
- $output .= "<script type='text/javascript'>\n\r";
1931
- $output .= "var select_min_height = ".(25*3).";\n\r";
1932
- $output .= "var select_max_height = ".(25*($num+1)).";\n\r";
1933
- $output .= "</script>";
1934
-
1935
-
1936
- echo $output;
1937
-
1938
  }
1939
 
1940
- if($_REQUEST['wpsc_admin_action'] == 'product_files_existing') {
1941
- add_action('admin_init', 'wpsc_product_files_existing');
1942
  }
1943
 
1944
  function prod_upload() {
1945
  global $wpdb, $product_id;
1946
- if($_REQUEST['wpsc_admin_action'] == 'product_files_upload') {
1947
-
1948
- foreach ($_REQUEST["select_product_file"] as $file) {
1949
- $duplicate = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE post_type = 'wpsc-product-file' AND post_title = '$file'", ARRAY_A);
1950
-
1951
- $type = $duplicate["post_mime_type"];
1952
- $url = $duplicate["guid"];
1953
- $title = $duplicate["post_title"];
1954
- $content = $duplicate["post_content"];
1955
-
1956
- // Construct the attachment array
1957
- $attachment = array(
1958
- 'post_mime_type' => $type,
1959
- 'guid' => $url,
1960
- 'post_parent' => $_REQUEST["product_id"],
1961
- 'post_title' => $title,
1962
- 'post_content' => $content,
1963
- 'post_type' => "wpsc-product-file",
1964
- 'post_status' => 'inherit'
1965
- );
1966
-
1967
- // Save the data
1968
- $id = wp_insert_post($attachment);
1969
- }
1970
- }
1971
- }
1972
  add_action('admin_init', 'prod_upload');
1973
 
1974
  //change the gateway settings
1975
  function wpsc_gateway_settings(){
1976
- global $wpdb;
1977
- //To update options
1978
- if(isset($_POST['wpsc_options'])){
1979
- foreach($_POST['wpsc_options'] as $key=>$value){
1980
- if($value != get_option($key)){
1981
- update_option($key, $value);
1982
- $updated++;
1983
- }
1984
- }
1985
- unset($_POST['wpsc_options']);
1986
- }
1987
-
1988
-
1989
-
1990
- if(is_array($_POST['user_defined_name'])) {
1991
- $payment_gateway_names = get_option('payment_gateway_names');
1992
- if(!is_array($payment_gateway_names)) {
1993
- $payment_gateway_names = array();
1994
- }
1995
- $payment_gateway_names = array_merge($payment_gateway_names, (array)$_POST['user_defined_name']);
1996
- update_option('payment_gateway_names', $payment_gateway_names);
1997
- }
1998
-
1999
- //exit('<pre>'.print_r($GLOBALS['nzshpcrt_gateways'],true).'</pre>');
2000
-
2001
- foreach($GLOBALS['nzshpcrt_gateways'] as $gateway) {
2002
- if($gateway['internalname'] == get_option('payment_gateway')) {
2003
- call_user_func_array($gateway['submit_function']);
2004
- $changes_made = true;
2005
- }
2006
- }
2007
- if(($_POST['payment_gw'] != null)) {
2008
- update_option('payment_gateway', $_POST['payment_gw']);
2009
- }
2010
- $sendback = wp_get_referer();
2011
-
2012
- if ( isset($updated) ) {
2013
- $sendback = add_query_arg('updated', $updated, $sendback);
2014
- }
2015
- if(isset($_SESSION['wpsc_settings_curr_page'])){
2016
- $sendback = add_query_arg('page', 'wpsc-settings', $sendback);
2017
- $sendback = add_query_arg('tab', $_SESSION['wpsc_settings_curr_page'], $sendback);
2018
- }
2019
- //sexit($sendback);
2020
- wp_redirect($sendback);
2021
- exit();
2022
-
2023
- }
2024
- if($_REQUEST['wpsc_gateway_settings'] == 'gateway_settings') {
2025
- add_action('admin_init', 'wpsc_gateway_settings');
 
 
 
2026
  }
2027
  function wpsc_check_form_options(){
2028
- global $wpdb;
2029
 
2030
- $id = $wpdb->escape($_POST['form_id']);
2031
- $sql = 'SELECT `options` FROM `'.WPSC_TABLE_CHECKOUT_FORMS.'` WHERE `id`='.$id;
2032
- $options = $wpdb->get_var($sql);
2033
- if($options != ''){
2034
- $options = unserialize($options);
2035
- $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>";
2036
 
2037
- foreach((array)$options as $key=>$value){
2038
- $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_URL."/images/trash.gif' alt='".__('Delete', 'wpsc')."' title='".__('Delete', 'wpsc')."' /></a></td></tr>";
2039
-
2040
- }
2041
 
2042
- }else{
2043
- $output = '';
2044
- }
2045
- exit($output);
2046
- }
2047
- if($_REQUEST['wpsc_admin_action']=='check_form_options'){
2048
- add_action('admin_init','wpsc_check_form_options');
 
 
2049
  }
2050
 
2051
  //handles the editing and adding of new checkout fields
2052
  function wpsc_checkout_settings(){
2053
- global $wpdb;
2054
- $wpdb->show_errors = true;
2055
  if(isset($_POST['selected_form_set'])){
2056
- $filter = $wpdb->escape($_POST['selected_form_set']);
2057
  }else{
2058
- $filter = 0;
2059
  }
2060
-
2061
- if($_POST['new_form_set'] != null) {
2062
- $new_form_set = $wpdb->escape(stripslashes($_POST['new_form_set']));
2063
- $form_set_key = sanitize_title($new_form_set);
2064
- $checkout_sets = get_option('wpsc_checkout_form_sets');
2065
-
2066
- $checkout_sets[$form_set_key] = $new_form_set;
2067
- update_option('wpsc_checkout_form_sets', $checkout_sets);
2068
- }
2069
-
2070
- // Save checkout options
2071
- if(is_array($_POST['wpsc_checkout_option_label'])){
2072
- foreach($_POST['wpsc_checkout_option_label'] as $form_id=> $values){
2073
- $options = array();
2074
- foreach((array)$values as $key => $form_option){
2075
- $options[$form_option] = $_POST['wpsc_checkout_option_value'][$form_id][$key];
2076
- }
2077
-
2078
- $options = serialize($options);
2079
- $sql = "UPDATE `".WPSC_TABLE_CHECKOUT_FORMS."` SET `options`='".$options."' WHERE id=".$form_id;
2080
- $wpdb->query($sql);
2081
- }
2082
- }
2083
-
2084
-
2085
- if($_POST['form_name'] != null) {
2086
- foreach($_POST['form_name'] as $form_id => $form_name) {
2087
- $form_name = $wpdb->escape($form_name);
2088
- $form_type = $wpdb->escape($_POST['form_type'][$form_id]);
2089
- $form_mandatory = 0;
2090
- if($_POST['form_mandatory'][$form_id] == 1) { $form_mandatory = 1; }
2091
- $form_display_log = 0;
2092
- if($_POST['form_display_log'][$form_id] == 1) { $form_display_log = 1; }
2093
- $unique_name = '';
2094
- if($_POST['unique_names'][$form_id] != '-1'){ $unique_name = $_POST['unique_names'][$form_id]; }
2095
- // $form_order = $_POST['form_order'][$form_id];
2096
- $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 ;");
2097
- //echo "UPDATE `".WPSC_TABLE_CHECKOUT_FORMS."` SET `name` = '$form_name', `type` = '$form_type', `mandatory` = '$form_mandatory', `display_log` = '$form_display_log',`unique_name`='".$unique_name."', `checkout_set`='".$filter."' WHERE `id` ='".$form_id."' LIMIT 1 ;";
2098
-
2099
- //echo "<br />";
2100
- }
2101
- }
2102
-
2103
- if($_POST['new_form_name'] != null) {
2104
- foreach($_POST['new_form_name'] as $form_id => $form_name) {
2105
- $form_type = $_POST['new_form_type'][$form_id];
2106
- $form_mandatory = 0;
2107
- if($_POST['new_form_mandatory'][$form_id] == 1) { $form_mandatory = 1; }
2108
- $form_display_log = 0;
2109
- if($_POST['new_form_display_log'][$form_id] == 1) { $form_display_log = 1; }
2110
- if($_POST['new_form_unique_name'][$form_id] != '-1') { $form_unique_name = $_POST['new_form_unique_name'][$form_id]; }
2111
-
2112
- $max_order_sql = "SELECT MAX(`order`) AS `order` FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `active` = '1';";
2113
-
2114
- if($_POST['new_form_order'][$form_id] != '') {
2115
- $order_number = $_POST['new_form_order'][$form_id];
2116
- } else {
2117
- $max_order_sql = $wpdb->get_results($max_order_sql,ARRAY_A);
2118
- $order_number = $max_order_sql[0]['order'] + 1;
2119
- }
2120
- $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."');");
2121
- $added++;
2122
- }
2123
- }
2124
-
2125
- if(isset($_POST['wpsc_options'])){
2126
- foreach($_POST['wpsc_options'] as $key=>$value){
2127
- if($value != get_option($key)){
2128
- update_option($key, $value);
2129
- $updated++;
2130
- }
2131
- }
2132
- }
2133
-
2134
- $sendback = wp_get_referer();
2135
- if(isset($form_set_key)) {
2136
- $sendback = add_query_arg('checkout-set', $form_set_key, $sendback);
2137
- } else if(isset($_POST['wpsc_form_set'])){
2138
- $filter = $_POST['wpsc_form_set'];
2139
- $sendback = add_query_arg('checkout-set', $filter, $sendback);
2140
- }
2141
-
2142
- if ( isset($updated) ) {
2143
- $sendback = add_query_arg('updated', $updated, $sendback);
2144
- }
2145
- if ( isset($added) ) {
2146
- $sendback = add_query_arg('added', $added, $sendback);
2147
- }
2148
- if(isset($_SESSION['wpsc_settings_curr_page'])){
2149
- $sendback = add_query_arg('tab', $_SESSION['wpsc_settings_curr_page'], $sendback);
2150
- }
2151
- $sendback = add_query_arg('page', 'wpsc-settings', $sendback);
2152
- wp_redirect($sendback);
2153
- exit();
2154
- }
2155
 
2156
-
2157
- if($_REQUEST['wpsc_admin_action'] == 'checkout_settings') {
2158
- add_action('admin_init', 'wpsc_checkout_settings');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2159
  }
2160
 
2161
 
2162
  function wpsc_google_shipping_settings(){
2163
- if (isset($_POST['submit'])) {
2164
- foreach((array)$_POST['google_shipping'] as $key=>$country) {
2165
- if ($country == 'on') {
2166
- $google_shipping_country[]=$key;
2167
- $updated++;
2168
- }
2169
- }
2170
- update_option('google_shipping_country',$google_shipping_country);
2171
- $sendback = wp_get_referer();
2172
- $sendback = remove_query_arg('googlecheckoutshipping', $sendback);
2173
-
2174
- if ( isset($updated) ) {
2175
- $sendback = add_query_arg('updated', $updated, $sendback);
2176
- }
2177
 
2178
- wp_redirect($sendback);
2179
- exit();
2180
- }
 
 
 
 
2181
  }
2182
 
2183
- if($_REQUEST['wpsc_admin_action'] == 'google_shipping_settings') {
2184
- add_action('admin_init', 'wpsc_google_shipping_settings');
2185
  }
2186
 
2187
  //for ajax call of settings page tabs
@@ -2189,58 +2248,59 @@ function wpsc_settings_page_ajax(){
2189
  global $wpdb;
2190
  $modified_page_title = $_POST['page_title'];
2191
  check_admin_referer($modified_page_title);
2192
- $page_title = str_replace("tab-","",$modified_page_title);
2193
-
2194
-
2195
- //require_once('includes/settings-pages/'.$functionname1.'.php');
2196
- //$functionname = "wpsc_options_".$functionname1;
2197
- //$html = $functionname();
2198
-
2199
- switch($page_title) {
2200
- case "checkout";
2201
- require_once('includes/settings-pages/checkout.php');
2202
- wpsc_options_checkout();
2203
- break;
2204
- case "gateway";
2205
- require_once('includes/settings-pages/gateway.php');
2206
- wpsc_options_gateway();
2207
- break;
2208
- case "shipping";
2209
- require_once('includes/settings-pages/shipping.php');
2210
- wpsc_options_shipping();
2211
- break;
2212
- case "admin";
2213
- require_once('includes/settings-pages/admin.php');
2214
- wpsc_options_admin();
2215
- break;
2216
-
2217
- case "presentation";
2218
- require_once('includes/settings-pages/presentation.php');
2219
- wpsc_options_presentation();
2220
- break;
2221
-
2222
- case "taxes":
2223
- require_once('includes/settings-pages/taxes.php');
2224
- wpsc_options_taxes();
2225
- break;
2226
-
2227
- case "import";
2228
- require_once('includes/settings-pages/import.php');
2229
- wpsc_options_import();
2230
- break;
2231
-
2232
- default;
2233
- case "general";
2234
- require_once('includes/settings-pages/general.php');
2235
- wpsc_options_general();
2236
- break;
2237
- }
2238
- $_SESSION['wpsc_settings_curr_page'] = $page_title;
2239
- exit($html);
2240
- }
2241
-
2242
- if($_REQUEST['wpsc_admin_action'] == 'settings_page_ajax') {
2243
- add_action('admin_init', 'wpsc_settings_page_ajax');
 
2244
  }
2245
 
2246
 
@@ -2250,176 +2310,407 @@ function wpsc_trigger_copy_themes(){
2250
  wpsc_copy_themes_to_uploads();
2251
 
2252
  $_SESSION['wpsc_themes_copied'] = true;
2253
- $sendback = wp_get_referer();
2254
- $sendback = add_query_arg('tab', $_SESSION['wpsc_settings_curr_page'], remove_query_arg('tab', $sendback));
2255
- wp_redirect($sendback);
2256
- exit();
2257
  }
2258
 
2259
- if($_REQUEST['wpsc_admin_action'] == 'copy_themes') {
2260
- add_action('admin_init', 'wpsc_trigger_copy_themes');
2261
  }
2262
 
2263
  function wpsc_mass_resize_thumbnails() {
2264
  global $wpdb;
2265
  check_admin_referer('mass_resize');
2266
 
2267
- if(isset($_GET['wpsc_options'])){
2268
- foreach($_GET['wpsc_options'] as $key=>$value){
2269
- if(($value != get_option($key)) and (absint($value) > 0)){
2270
- update_option($key, absint($value));
2271
- }
2272
- }
2273
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2274
 
2275
- $height = get_option('product_image_height');
2276
- $width = get_option('product_image_width');
2277
-
2278
- $product_data = $wpdb->get_results("SELECT `product`.`id`, `product`.`image` AS `image_id`, `images`.`image` AS `file` FROM `".WPSC_TABLE_PRODUCT_LIST."` AS `product` INNER JOIN `".WPSC_TABLE_PRODUCT_IMAGES."` AS `images` ON `product`.`image` = `images`.`id` WHERE `product`.`image` > 0 ",ARRAY_A);
2279
- foreach((array)$product_data as $product) {
2280
- $image_input = WPSC_IMAGE_DIR . $product['file'];
2281
- $image_output = WPSC_THUMBNAIL_DIR . $product['file'];
2282
- if(($product['file'] != '') and file_exists($image_input)) {
2283
- image_processing($image_input, $image_output, $width, $height);
2284
- update_product_meta($product['id'], 'thumbnail_width', $width);
2285
- update_product_meta($product['id'], 'thumbnail_height', $height);
2286
- } else {
2287
- $wpdb->query("DELETE FROM `".WPSC_TABLE_PRODUCT_IMAGES."` WHERE `id` IN('{$product['image_id']}') LIMIT 1");
2288
- $wpdb->query("UPDATE `".WPSC_TABLE_PRODUCT_LIST."` SET `image` = NULL WHERE `id` = '".$product['id']."' LIMIT 1");
2289
- }
2290
-
2291
- }
2292
-
2293
  $_SESSION['wpsc_thumbnails_resized'] = true;
2294
- $sendback = wp_get_referer();
2295
- $sendback = add_query_arg('tab', $_SESSION['wpsc_settings_curr_page'], remove_query_arg('tab', $sendback));
2296
- wp_redirect($sendback);
2297
- exit();
 
 
 
 
2298
  }
 
 
 
 
 
2299
 
2300
- if($_REQUEST['wpsc_admin_action'] == 'mass_resize_thumbnails') {
2301
- add_action('admin_init', 'wpsc_mass_resize_thumbnails');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2302
  }
2303
-
2304
 
2305
 
2306
 
2307
  function wpsc_delete_variation_set() {
2308
- global $wpdb;
2309
- check_admin_referer('delete-variation');
2310
-
2311
- if(is_numeric($_GET['deleteid'])){
2312
- $variation_id = absint($_GET['deleteid']);
2313
-
2314
- $variation_set = get_term($variation_id, 'wpsc-variation', ARRAY_A);
2315
-
2316
-
2317
- $variations = get_terms('wpsc-variation', array(
2318
- 'hide_empty' => 0,
2319
- 'parent' => $variation_id
2320
- ));
2321
-
2322
- foreach((array)$variations as $variation) {
2323
- $return_value = wp_delete_term($variation->term_id, 'wpsc-variation');
2324
- }
2325
-
2326
- if(!empty($variation_set)) {
2327
- $return_value = wp_delete_term($variation_set['term_id'], 'wpsc-variation');
2328
- }
2329
- //echo "<pre>".print_r($variation_set, true)."</pre>";
2330
- //exit();
2331
- $deleted = 1;
2332
- }
2333
-
2334
- $sendback = wp_get_referer();
2335
- if ( isset($deleted) ) {
2336
- $sendback = add_query_arg('deleted', $deleted, $sendback);
2337
- }
2338
- $sendback = remove_query_arg(array(
2339
- 'deleteid',
2340
- 'variation_id'
2341
- ), $sendback);
2342
-
2343
- wp_redirect($sendback);
2344
- exit();
2345
- }
2346
 
 
 
2347
 
2348
- function wpsc_delete_category() {
2349
- global $wpdb, $wp_rewrite;
2350
- check_admin_referer('delete-category');
2351
-
2352
- if(is_numeric($_GET['deleteid'])){
2353
- $category_id = absint($_GET['deleteid']);
2354
- $taxonomy='wpsc_product_category';
2355
- if($category_id > 0){
2356
- wp_delete_term($category_id, $taxonomy);
2357
- $wpdb->query("DELETE FROM `".WPSC_TABLE_META."` WHERE object_id = '".$category_id."' AND object_type = 'wpsc_category'");
2358
- }
2359
- update_option('wpsc_category_url_cache', array());
2360
- $wp_rewrite->flush_rules();
2361
-
2362
- $deleted = 1;
2363
- }
2364
-
2365
- $sendback = wp_get_referer();
2366
- if ( isset($deleted) ) {
2367
- $sendback = add_query_arg('deleted', $deleted, $sendback);
2368
- }
2369
- $sendback = remove_query_arg(array(
2370
- 'deleteid',
2371
- 'category_id'
2372
- ), $sendback);
2373
-
2374
- wp_redirect($sendback);
2375
- exit();
 
 
 
2376
  }
2377
-
2378
-
2379
 
2380
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2381
 
2382
  //other actions are here
2383
- if($_GET['display_invoice']=='true') {
2384
  add_action('admin_init', 'wpsc_display_invoice', 0);
2385
  }
2386
 
2387
-
2388
-
2389
- if($_REQUEST['wpsc_admin_action'] == 'wpsc_add_image') {
2390
- add_action('admin_init','wpsc_swfupload_images');
2391
  }
2392
 
2393
- if($_REQUEST['wpsc_admin_action'] == 'edit_product') {
2394
- add_action('admin_init', 'wpsc_admin_submit_product');
2395
  }
2396
-
2397
 
2398
- if($_GET['action'] == "purchase_log") {
2399
- add_action('admin_init', 'wpsc_admin_sale_rss');
 
2400
  }
2401
 
2402
 
2403
- if($_GET['purchase_log_csv'] == "true") {
2404
- add_action('admin_init', 'wpsc_purchase_log_csv');
2405
  }
2406
 
2407
- if(($_REQUEST['ajax'] == "true") && ($_REQUEST['admin'] == "true")) {
2408
- add_action('admin_init', 'wpsc_admin_ajax');
2409
  }
2410
 
2411
  // Variation set deleting init code starts here
2412
- if($_REQUEST['wpsc_admin_action'] == 'wpsc-delete-variation-set') {
2413
- add_action('admin_init', 'wpsc_delete_variation_set');
2414
  }
2415
 
2416
  // Variation set deleting init code starts here
2417
- if($_REQUEST['wpsc_admin_action'] == 'wpsc-delete-category') {
2418
- add_action('admin_init', 'wpsc-delete-category');
2419
  }
2420
 
2421
  // Category modification init code starts here
2422
- if($_REQUEST['wpsc_admin_action'] == 'wpsc-category-set') {
2423
- add_action('admin_init', 'wpsc_save_category_set');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2424
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2425
  ?>
9
  */
10
  //exit('<pre>'.print_r($_POST, true).'</pre>');
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
+
27
+ if(isset($_REQUEST['submit']) && ($_REQUEST['submit'] == 'Add Tracking ID')) {
28
+ add_action('admin_init', 'wpsc_ajax_add_tracking');
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
+
38
+ if(isset($_REQUEST['wpsc_admin_action']) && ($_REQUEST['wpsc_admin_action'] == 'delete_currency_layer')) {
39
+ add_action('admin_init', 'wpsc_delete_currency_layer');
40
  }
41
 
42
 
43
  function wpsc_purchlog_email_trackid() {
44
+ global $wpdb;
45
+ $id = absint($_POST['purchlog_id']);
46
+ $trackingid = $wpdb->get_var("SELECT `track_id` FROM ".WPSC_TABLE_PURCHASE_LOGS." WHERE `id`={$id} LIMIT 1");
47
 
48
+ $message = get_option('wpsc_trackingid_message');
49
+ $message = str_replace('%trackid%',$trackingid,$message);
50
  $message = str_replace('%shop_name%',get_option('blogname'),$message);
51
 
52
+ $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");
53
+ $email = $wpdb->get_var("SELECT `value` FROM `".WPSC_TABLE_SUBMITED_FORM_DATA."` WHERE `log_id`=".$id." AND `form_id` = '$email_form_field' LIMIT 1");
54
+
55
 
 
56
  $subject = get_option('wpsc_trackingid_subject');
57
  $subject = str_replace('%shop_name%',get_option('blogname'),$subject);
58
  wp_mail($email, $subject, $message,"From: ".get_option('return_email')." <".get_option('return_email').">");
60
  exit(true);
61
  }
62
 
63
+
64
+ if(isset($_REQUEST['wpsc_admin_action']) && ($_REQUEST['wpsc_admin_action'] == 'purchlog_email_trackid')) {
65
+ add_action('admin_init', 'wpsc_purchlog_email_trackid');
66
  }
67
 
68
  function wpsc_ajax_sales_quarterly() {
69
+ global $wpdb;
70
+ $lastdate = $_POST['add_start'];
71
+ $date = preg_split('/-/', $lastdate);
72
+ if (!isset($date[0])) $date[0] = 0;
73
+ if (!isset($date[1])) $date[1] = 0;
74
+ if (!isset($date[2])) $date[2] = 0;
75
+ $lastquart = mktime(0,0,0,$date[1], $date[2], $date[0]);
76
+ //$lastdate = date('M d y', $lastquart);
77
+ if($lastquart != get_option('wpsc_last_quarter')){
78
+ update_option('wpsc_last_date', $lastdate);
79
+ update_option('wpsc_fourth_quart', $lastquart);
80
+ $thirdquart = mktime(0,0,0,$date[1]-3, $date[2], $date[0]);
81
+ update_option('wpsc_third_quart', $thirdquart);
82
+ $secondquart = mktime(0,0,0,$date[1]-6, $date[2], $date[0]);
83
+ update_option('wpsc_second_quart', $secondquart);
84
+ $firstquart = mktime(0,0,0,$date[1]-9, $date[2], $date[0]);
85
+ update_option('wpsc_first_quart', $firstquart);
86
+ $finalquart = mktime(0,0,0,$date[1], $date[2], $date[0]-1);
87
+ update_option('wpsc_final_quart', $finalquart);
88
+
89
+ }
90
+
91
+
92
+ // exit($lastquart.' '.$firstquart.' '.$secondquart.' '.$thirdquart);
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_ajax_load_product() {
102
+ global $wpdb;
103
+ $product_id = absint($_REQUEST['product']);
104
+ check_admin_referer('edit-product_' . $product_id);
105
+ wpsc_display_product_form($product_id);
106
+ exit();
107
  }
108
+
109
+
110
+
111
+ if(isset($_REQUEST['wpsc_admin_action']) && ($_REQUEST['wpsc_admin_action'] == 'load_product')) {
112
+ add_action('admin_init', 'wpsc_ajax_load_product');
113
  }
114
 
115
  function wpsc_crop_thumb() {
116
+ global $wpdb;
117
+ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
118
+ $targ_w = $targ_h = $_POST['thumbsize'];
119
+ $jpeg_quality = $_POST['jpegquality'];
120
+ $product_id = $_POST['product_id'];
121
+
122
+ $image['x'] = absint($_POST['x']);
123
+ $image['y'] = absint($_POST['y']);
124
+ $image['w'] = absint($_POST['w']);
125
+ $image['h'] = absint($_POST['h']);
126
+
127
+
128
+ $imagename = basename($_POST['imagename']);
129
+ $source = WPSC_IMAGE_DIR.$imagename;
130
+ $destination = WPSC_THUMBNAIL_DIR.$imagename;
131
+
132
+ if(is_file($source)) {
133
+ $imagetype = getimagesize($source);
134
+
135
+ switch($imagetype[2]) {
136
+ case IMAGETYPE_JPEG:
137
+ $img_r = imagecreatefromjpeg($source);
138
+ break;
139
+
140
+ case IMAGETYPE_GIF:
141
+ $img_r = imagecreatefromgif($source);
142
+ break;
143
+
144
+ case IMAGETYPE_PNG:
145
+ $img_r = imagecreatefrompng($source);
146
+ break;
147
+ }
148
+ $dst_r = ImageCreateTrueColor( $targ_w, $targ_h );
149
+ imagecopyresampled($dst_r,$img_r,0,0,$image['x'],$image['y'],$targ_w,$targ_h,$image['w'],$image['h']);
150
+ imagejpeg($dst_r,$destination,$jpeg_quality);
151
+ $cropped = true;
152
+ }
153
+ $sendback = wp_get_referer();
154
+ if($cropped){
155
+ $sendback = add_query_arg('product_id', $product_id, $sendback);
156
+ }
157
+ wp_redirect($sendback);
158
+ //exit();
159
+ }
160
  }
 
 
 
 
 
161
 
 
 
 
 
 
 
 
 
 
 
 
 
162
 
163
+ if(isset($_REQUEST['wpsc_admin_action']) && ($_REQUEST['wpsc_admin_action'] == 'crop_thumb')) {
164
+ add_action('admin_init', 'wpsc_crop_thumb');
 
 
 
 
 
 
 
 
 
 
165
  }
166
 
167
+ function wpsc_delete_file() {
168
+ global $wpdb;
169
+ $output = 0;
170
+ $row_number = absint($_GET['row_number']);
171
+ $product_id = absint($_GET['product_id']);
172
+ $file_name = basename($_GET['file_name']);
173
+ check_admin_referer('delete_file_'.$file_name);
174
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
175
 
176
+ $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'"));
177
+
178
+ wp_delete_post($product_id_to_delete, true);
179
+
180
+ if($_POST['ajax'] !== 'true') {
181
+ $sendback = wp_get_referer();
182
+ wp_redirect($sendback);
183
+ }
184
+
185
+ echo "jQuery('#select_product_file_row_$row_number').fadeOut('fast',function() {\n";
186
+ echo " jQuery(this).remove();\n";
187
+ echo " jQuery('div.select_product_file p:even').removeClass('alt');\n";
188
+ echo " jQuery('div.select_product_file p:odd').addClass('alt');\n";
189
+ echo "});\n";
190
+
191
+ exit("");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
192
  }
193
+
194
+
195
+ if(isset($_REQUEST['wpsc_admin_action']) && ($_REQUEST['wpsc_admin_action'] == 'delete_file')) {
196
+ add_action('admin_init', 'wpsc_delete_file');
197
+ }
198
+
199
+
200
+ function wpsc_bulk_modify_products() {
201
+ global $wpdb;
202
+ $doaction = $_GET['bulkAction'];
203
+ $sendback = wp_get_referer();
204
+ $product_ids = $_GET['post'];
205
+ //exit( "<pre>".print_r($_GET,true)."</pre>");
206
+ switch ( $doaction ) {
207
+
208
+ case 'publish':
209
+ foreach( (array) $product_ids as $product_id ) {
210
+ $product_id = absint($product_id);
211
+ wp_publish_post($product_id);
212
+ $published++;
213
+ }
214
+ $sendback = add_query_arg('published', $published, $sendback);
215
+ break;
216
+
217
+ case 'unpublish':
218
+ foreach( (array) $product_ids as $product_id ) {
219
+ $product_id = absint($product_id);
220
+ wp_update_post(array('ID' => $product_id, 'post_status' => 'draft'));
221
+ $published++;
222
+ }
223
+ $sendback = add_query_arg('published', $published, $sendback);
224
+ break;
225
+
226
+
227
+ case 'trash':
228
+ $trashed = 0;
229
+ foreach( (array) $product_ids as $product_id ) {
230
+ if ( !current_user_can('delete_post', $product_id) ) {
231
+ wp_die( __('You are not allowed to move this product to the trash.', 'wpsc') );
232
+ }
233
+ if ( !wp_trash_post($product_id) ) {
234
+ wp_die( __('Error in moving to trash...') );
235
+ }
236
+ $trashed++;
237
+ }
238
+ $sendback = add_query_arg( array('trashed' => $trashed, 'ids' => join(',', $product_ids)), $sendback );
239
+ break;
240
+
241
+ case 'untrash':
242
+ $untrashed = 0;
243
+ foreach( (array) $product_ids as $product_id ) {
244
+ if ( !current_user_can('delete_post', $product_id) ) {
245
+ wp_die( __('You are not allowed to restore this product from the trash.', 'wpsc') );
246
+ }
247
+ if ( !wp_untrash_post($product_id) ) {
248
+ wp_die( __('Error in restoring from trash...') );
249
+ }
250
+ $untrashed++;
251
+ }
252
+ $sendback = add_query_arg('untrashed', $untrashed, $sendback);
253
+ break;
254
+
255
+ case 'delete':
256
+ $deleted = 0;
257
+ foreach( (array) $product_ids as $product_id ) {
258
+ $product_del = & get_post($product_id);
259
+
260
+ if ( !current_user_can('delete_post', $product_id) ) {
261
+ wp_die( __('You are not allowed to delete this post.') );
262
+ }
263
+
264
+ if ( $product_del->post_type == 'attachment' ) {
265
+ if ( ! wp_delete_attachment($product_id) ) {
266
+ wp_die( __('Error in deleting...') );
267
+ }
268
+ } else {
269
+ if ( !wp_delete_post($product_id) ) {
270
+ wp_die( __('Error in deleting...') );
271
+ }
272
+ }
273
+ $deleted++;
274
+ }
275
+ $sendback = add_query_arg('deleted', $deleted, $sendback);
276
+ break;
277
+
278
+
279
+ default:
280
+ if(isset($_GET['search']) && !empty($_GET['search'])) {
281
+ // urlencode the search query to allow for spaces, etc
282
+ $sendback = add_query_arg('search',urlencode(stripslashes($_GET['search'])), $sendback);
283
+ }
284
+ break;
285
+ }
286
+
287
+ wp_redirect($sendback);
288
+ exit();
289
+ }
290
+
291
+
292
+
293
+ if(isset($_REQUEST['wpsc_admin_action']) && ($_REQUEST['wpsc_admin_action'] == 'bulk_modify')) {
294
+ add_action('admin_init', 'wpsc_bulk_modify_products');
295
  }
296
 
297
  function wpsc_modify_product_price() {
298
+ global $wpdb;
299
+ $product_data = array_pop($_POST['product_price']);
300
+
301
+ $product_id = absint($product_data['id']);
302
+ $product_price = (float)$product_data['price'];
303
+ $product_nonce = $product_data['nonce'];
304
+
305
+ if(wp_verify_nonce($product_nonce, 'edit-product_price-'.$product_id) ) {
306
+ if(update_post_meta($product_id, '_wpsc_price', $product_price)) {
307
+ echo "success = 1;\n\r";
308
+ echo "new_price = '".nzshpcrt_currency_display($product_price, 1, true)."';\n\r";
309
+ } else {
310
+ echo "success = 0;\n\r";
311
+ }
312
+ } else {
313
+ echo "success = -1;\n\r";
314
+ }
315
+ exit();
316
  }
317
 
318
+
319
+ if(isset($_REQUEST['wpsc_admin_action']) && ($_REQUEST['wpsc_admin_action'] == 'modify_price')) {
320
+ add_action('admin_init', 'wpsc_modify_product_price');
321
  }
322
 
323
 
324
  function wpsc_modify_sales_product_price() {
325
+ global $wpdb;
326
+ // exit('<pre>'.print_r($_POST, true).'</pre>');
327
+ $product_data = array_pop($_POST['sale_product_price']);
328
+
329
+ $product_id = absint($product_data['id']);
330
+ $product_price = (float)$product_data['price'];
331
+ $product_nonce = $product_data['nonce'];
332
+
333
+ if(wp_verify_nonce($product_nonce, 'sale-edit-product_price-'.$product_id) ) {
334
+ if(update_post_meta($product_id, '_wpsc_special_price', $product_price)) {
335
+ echo "success = 1;\n\r";
336
+ echo "new_price = '".nzshpcrt_currency_display($product_price, 1, true)."';\n\r";
337
+ } else {
338
+ echo "success = 0;\n\r";
339
+ }
340
+ } else {
341
+ echo "success = -1;\n\r";
342
+ }
343
+ exit();
344
  }
345
 
346
+
347
+ if(isset($_REQUEST['wpsc_admin_action']) && ($_REQUEST['wpsc_admin_action'] == 'modify_sales_price')) {
348
+ add_action('admin_init', 'wpsc_modify_sales_product_price');
349
  }
350
 
351
 
352
 
353
  function wpsc_modify_sku() {
354
+ global $wpdb;
355
+ // exit('<pre>'.print_r($_POST, true).'</pre>');
356
+ $product_data = array_pop($_POST['sku_field']);
357
+
358
+ $product_id = absint($product_data['id']);
359
+ $sku = $product_data['sku'];
360
+ $product_nonce = $product_data['nonce'];
361
+
362
+ if(wp_verify_nonce($product_nonce, 'edit-sku-'.$product_id) ) {
363
+ if(update_post_meta($product_id, '_wpsc_sku', $sku)) {
364
+ echo "success = 1;\n\r";
365
+ echo "new_price = '".$sku."';\n\r";
366
+ } else {
367
+ echo "success = 0;\n\r";
368
+ }
369
+ } else {
370
+ echo "success = -1;\n\r";
371
+ }
372
+ exit();
373
  }
374
 
375
+
376
+ if(isset($_REQUEST['wpsc_admin_action']) && ($_REQUEST['wpsc_admin_action'] == 'modify_sku')) {
377
+ add_action('admin_init', 'wpsc_modify_sku');
378
  }
379
 
380
+ function wpsc_modify_weight() {
381
+ global $wpdb;
 
 
 
 
382
 
383
+ $product_data = array_pop($_POST['weight_field']);
 
 
 
384
 
385
+ $product_id = absint($product_data['id']);
386
+ $product_nonce = $product_data['nonce'];
 
387
 
388
+ if(wp_verify_nonce($product_nonce, 'edit-weight-'.$product_id) ) {
389
 
390
+ $old_array = get_product_meta( $product_id, 'product_metadata' );
391
+ $old_array = array_pop($old_array);
392
+
393
+ $weight = wpsc_convert_weight($product_data['weight'], $old_array["weight_unit"], "gram");
394
+
395
+ foreach ($old_array as $key=>$value) {
396
+ if($key == 'weight') {
397
+ $old_array[$key] = $weight;
398
+ }
399
+ }
400
+
401
+ if(update_product_meta($product_id, 'product_metadata', $old_array)) {
402
+ echo "success = 1;\n\r";
403
+ echo "new_price = '".wpsc_convert_weight($weight, "gram", $old_array["weight_unit"])."';\n\r";
404
+ } else {
405
+ echo "success = 0;\n\r";
406
+ }
407
+ } else {
408
+ echo "success = -1;\n\r";
409
+ }
410
+ exit();
411
  }
412
 
413
+ if(isset($_REQUEST['wpsc_admin_action']) && ($_REQUEST['wpsc_admin_action'] == 'modify_weight')) {
414
+ add_action('admin_init', 'wpsc_modify_weight');
 
415
  }
416
 
417
 
418
  function wpsc_modify_stock() {
419
+ global $wpdb;
420
+ // exit('<pre>'.print_r($_POST, true).'</pre>');
421
+ $product_data = array_pop($_POST['stock_field']);
422
+
423
+ $product_id = absint($product_data['id']);
424
+ $stock = $product_data['stock'];
425
+ $product_nonce = $product_data['nonce'];
426
+
427
+ if(wp_verify_nonce($product_nonce, 'edit-stock-'.$product_id) ) {
428
+ if(update_post_meta($product_id, '_wpsc_stock', $stock)) {
429
+ echo "success = 1;\n\r";
430
+ echo "new_price = '".$stock."';\n\r";
431
+ } else {
432
+ echo "success = 0;\n\r";
433
+ }
434
+ } else {
435
+ echo "success = -1;\n\r";
436
+ }
437
+ exit();
438
  }
439
 
440
+
441
+ if(isset($_REQUEST['wpsc_admin_action']) && ($_REQUEST['wpsc_admin_action'] == 'modify_stock')) {
442
+ add_action('admin_init', 'wpsc_modify_stock');
443
  }
444
+
445
+
446
  /**
447
+ Function and action for deleting single products
448
  */
449
  function wpsc_delete_product() {
450
+ global $wpdb;
 
 
 
 
451
 
452
+ $deleted = 0;
453
+ $product_id = absint($_GET['product']);
454
+ check_admin_referer('delete_product_' . $product_id);
455
+
456
+
457
+ if ( !current_user_can('delete_post', $product_id) ) {
458
+ wp_die( __('You are not allowed to move this product to the trash.', 'wpsc') );
459
+ }
460
+ if ( !wp_trash_post($product_id) ) {
461
+ wp_die( __('Error in moving to trash...') );
462
+ }
463
+ do_action('wpsc_delete_product', $product_id);
464
+ $deleted = true;
465
+
466
+ $sendback = wp_get_referer();
467
+ if ( isset($deleted) ) {
468
+ $sendback = add_query_arg('deleted', $deleted, $sendback);
469
+ }
470
+ //exit($sendback);
471
+ wp_redirect($sendback);
472
+ exit();
473
  }
474
+
475
+
476
+
477
+ if(isset($_REQUEST['wpsc_admin_action']) && ($_REQUEST['wpsc_admin_action'] == 'trash')) {
478
+ add_action('admin_init', 'wpsc_delete_product');
479
  }
480
+
481
  /**
482
  Function and action for publishing or unpublishing single products
483
  */
484
  function wpsc_ajax_toggle_published() {
485
+ global $wpdb;
486
+
487
+ $product_id = absint($_GET['product']);
488
+ check_admin_referer('toggle_publish_' . $product_id);
489
+
490
+ $status = (wpsc_toggle_publish_status($product_id)) ? ('true') : ('false');
491
+ $sendback = add_query_arg('flipped', "1", wp_get_referer());
492
+ wp_redirect($sendback);
493
+ exit();
494
  }
495
+
496
+
497
+ if(isset($_REQUEST['wpsc_admin_action']) && ($_REQUEST['wpsc_admin_action'] == 'toggle_publish')) {
498
+ add_action('admin_init', 'wpsc_ajax_toggle_published');
499
  }
500
 
501
+
502
  /**
503
  Function and action for duplicating products,
504
+ Refactored for 3.8
505
+ *Purposely not duplicating stick post status (logically, products are most often duplicated because they share many attributes, where products are generally 'featured' uniquely.)
506
  */
507
  function wpsc_duplicate_product() {
508
+ global $wpdb;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
509
 
510
+ // Get the original post
511
+ $id = absint($_GET['product']);
512
+ $post = wpsc_duplicate_this_dangit($id);
513
+
514
+ // Copy the post and insert it
515
+ if ( isset ( $post ) && $post != null ) {
516
+ $new_id = wpsc_duplicate_product_process($post);
517
+
518
+ $duplicated = true;
519
+ $sendback = wp_get_referer();
520
+ $sendback = add_query_arg('duplicated', (int)$duplicated, $sendback);
521
+
522
+ wp_redirect($sendback);
523
+ exit();
524
+
525
+ } else {
526
+ 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);
527
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
528
  }
529
 
530
+ function wpsc_duplicate_this_dangit($id) {
531
+ global $wpdb;
532
+ $post = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE ID=$id");
533
+ if ($post->post_type == "revision"){
534
+ $id = $post->post_parent;
535
+ $post = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE ID=$id");
536
+ }
537
+ return $post[0];
538
  }
539
+
540
+ function wpsc_duplicate_product_process($post) {
541
+ global $wpdb;
542
+
543
+ $new_post_date = $post->post_date;
544
+ $new_post_date_gmt = get_gmt_from_date($new_post_date);
545
+
546
+ $new_post_type = $post->post_type;
547
+ $post_content = str_replace("'", "''", $post->post_content);
548
+ $post_content_filtered = str_replace("'", "''", $post->post_content_filtered);
549
+ $post_excerpt = str_replace("'", "''", $post->post_excerpt);
550
+ $post_title = str_replace("'", "''", $post->post_title)." (Duplicate)";
551
+ $post_name = str_replace("'", "''", $post->post_name);
552
+ $comment_status = str_replace("'", "''", $post->comment_status);
553
+ $ping_status = str_replace("'", "''", $post->ping_status);
554
+
555
+ // Insert the new template in the post table
556
+ $wpdb->query(
557
+ "INSERT INTO $wpdb->posts
558
+ (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)
559
+ VALUES
560
+ ('$post->post_author', '$new_post_date', '$new_post_date_gmt', '$post_content', '$post_content_filtered', '$post_title', '$post_excerpt', '$post->post_status', '$new_post_type', '$comment_status', '$ping_status', '$post->post_password', '$post->to_ping', '$post->pinged', '$new_post_date', '$new_post_date_gmt', '$post->post_parent', '$post->menu_order', '$post->post_mime_type')");
561
+
562
+ $new_post_id = $wpdb->insert_id;
563
+
564
+ // Copy the taxonomies
565
+ wpsc_duplicate_taxonomies($post->ID, $new_post_id, $post->post_type);
566
+
567
+ // Copy the meta information
568
+ wpsc_duplicate_product_meta($post->ID, $new_post_id);
569
+
570
+ // Finds children (Which includes product files AND product images), their meta values, and duplicates them.
571
+ wpsc_duplicate_children($post->ID, $new_post_id);
572
+
573
+ return $new_post_id;
574
+ }
575
+
576
+ /**
577
+ * Copy the taxonomies of a post to another post
578
+ */
579
+ function wpsc_duplicate_taxonomies($id, $new_id, $post_type) {
580
+ global $wpdb;
581
+ if (isset($wpdb->terms)) {
582
+ // WordPress 2.3
583
+ $taxonomies = get_object_taxonomies($post_type); //array("category", "post_tag");
584
+ foreach ($taxonomies as $taxonomy) {
585
+ $post_terms = wp_get_object_terms($id, $taxonomy);
586
+ for ($i=0; $i<count($post_terms); $i++) {
587
+ wp_set_object_terms($new_id, $post_terms[$i]->slug, $taxonomy, true);
588
+ }
589
+ }
590
+ }
591
+ }
592
+
593
+ /**
594
+ * Copy the meta information of a post to another post
595
+ */
596
+ function wpsc_duplicate_product_meta($id, $new_id) {
597
+ global $wpdb;
598
+ $post_meta_infos = $wpdb->get_results("SELECT meta_key, meta_value FROM $wpdb->postmeta WHERE post_id=$id");
599
+
600
+ if ( count($post_meta_infos) != 0 ) {
601
+ $sql_query = "INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) ";
602
+
603
+ foreach ($post_meta_infos as $meta_info) {
604
+ $meta_key = $meta_info->meta_key;
605
+ $meta_value = addslashes($meta_info->meta_value);
606
+
607
+ $sql_query_sel[]= "SELECT $new_id, '$meta_key', '$meta_value'";
608
+
609
+ }
610
+ $sql_query.= implode(" UNION ALL ", $sql_query_sel);
611
+ $wpdb->query($sql_query);
612
+ }
613
+ }
614
+
615
+ /**
616
+ * Duplicates children product and children meta
617
+ */
618
+ function wpsc_duplicate_children($old_parent_id, $new_parent_id) {
619
+ global $wpdb;
620
+
621
+ //Get children products and duplicate them
622
+ $child_posts = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_parent = $old_parent_id");
623
+
624
+ foreach($child_posts as $child_post) {
625
+
626
+ $new_post_date = $child_post->post_date;
627
+ $new_post_date_gmt = get_gmt_from_date($new_post_date);
628
+
629
+ $new_post_type = $child_post->post_type;
630
+ $post_content = str_replace("'", "''", $child_post->post_content);
631
+ $post_content_filtered = str_replace("'", "''", $child_post->post_content_filtered);
632
+ $post_excerpt = str_replace("'", "''", $child_post->post_excerpt);
633
+ $post_title = str_replace("'", "''", $child_post->post_title);
634
+ $post_name = str_replace("'", "''", $child_post->post_name);
635
+ $comment_status = str_replace("'", "''", $child_post->comment_status);
636
+ $ping_status = str_replace("'", "''", $child_post->ping_status);
637
+
638
+ $wpdb->query(
639
+ "INSERT INTO $wpdb->posts
640
+ (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)
641
+ VALUES
642
+ ('$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')");
643
+
644
+ $old_post_id = $child_post->ID;
645
+ $new_post_id = $wpdb->insert_id;
646
+ $child_meta = $wpdb->get_results("SELECT post_id, meta_key, meta_value FROM $wpdb->postmeta WHERE post_id = $old_post_id");
647
+
648
+ foreach ($child_meta as $child_meta) {
649
+ $wpdb->query(
650
+ "INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value)
651
+ VALUES('$new_post_id', '$child_meta->meta_key', '$child_meta->meta_value')"
652
+ );
653
+ }
654
+ }
655
+ }
656
+
657
+ if (isset($_GET['wpsc_admin_action']) && ($_GET['wpsc_admin_action'] == 'duplicate_product')) {
658
+ add_action('admin_init', 'wpsc_duplicate_product');
659
+ }
660
+
661
+
662
+
663
  function wpsc_purchase_log_csv() {
664
  global $wpdb,$user_level,$wp_rewrite;
665
  get_currentuserinfo();
667
  //exit('in use');
668
  $form_sql = "SELECT * FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `active` = '1' AND `display_log` = '1';";
669
  $form_data = $wpdb->get_results($form_sql,ARRAY_A);
670
+
671
  $start_timestamp = $_GET['start_timestamp'];
672
  $end_timestamp = $_GET['end_timestamp'];
673
  $data = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `date` BETWEEN '$start_timestamp' AND '$end_timestamp' ORDER BY `date` DESC",ARRAY_A);
674
  // exit('<pre>'.print_r($data, true).'</pre>');
675
 
676
+
677
  header('Content-Type: text/csv');
678
  header('Content-Disposition: inline; filename="Purchase Log '.date("M-d-Y", $start_timestamp).' to '.date("M-d-Y", $end_timestamp).'.csv"');
679
+
680
  foreach((array)$data as $purchase) {
681
  $country_sql = "SELECT * FROM `".WPSC_TABLE_SUBMITED_FORM_DATA."` WHERE `log_id` = '".$purchase['id']."' AND `form_id` = '".get_option('country_form_field')."' LIMIT 1";
682
  $country_data = $wpdb->get_results($country_sql,ARRAY_A);
683
  $country = $country_data[0]['value'];
684
+
685
  $output .= "\"".$purchase['totalprice'] ."\",";
686
+
687
  foreach((array)$form_data as $form_field) {
688
  $collected_data_sql = "SELECT * FROM `".WPSC_TABLE_SUBMITED_FORM_DATA."` WHERE `log_id` = '".$purchase['id']."' AND `form_id` = '".$form_field['id']."' LIMIT 1";
689
  $collected_data = $wpdb->get_results($collected_data_sql,ARRAY_A);
690
  $collected_data = $collected_data[0];
691
  $output .= "\"".$collected_data['value']."\",";
692
+ }
693
+
694
  if(get_option('payment_method') == 2) {
695
  $gateway_name = '';
696
  foreach($GLOBALS['nzshpcrt_gateways'] as $gateway) {
697
  if($purchase['gateway'] != 'testmode') {
698
  if($gateway['internalname'] == $purchase['gateway'] ) {
699
  $gateway_name = $gateway['name'];
700
+ }
701
+ } else {
702
+ $gateway_name = "Manual Payment";
703
+ }
704
+ }
705
  $output .= "\"". $gateway_name ."\",";
706
+ }
707
+
708
  if($purchase['processed'] < 1) {
709
  $purchase['processed'] = 1;
710
+ }
711
  $stage_sql = "SELECT * FROM `".WPSC_TABLE_PURCHASE_STATUSES."` WHERE `id`='".$purchase['processed']."' AND `active`='1' LIMIT 1";
712
  $stage_data = $wpdb->get_results($stage_sql,ARRAY_A);
713
+
714
  $output .= "\"". $stage_data[0]['name'] ."\",";
715
+
716
  $output .= "\"". date("jS M Y",$purchase['date']) ."\"";
717
+
718
  $cartsql = "SELECT * FROM `".WPSC_TABLE_CART_CONTENTS."` WHERE `purchaseid`=".$purchase['id']."";
719
+ $cart = $wpdb->get_results($cartsql,ARRAY_A) ;
720
  //exit(nl2br(print_r($cart,true)));
721
+
722
  foreach((array)$cart as $item) {
723
  $output .= ",";
724
+ $product = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE `id`=".$item['prodid']." LIMIT 1",ARRAY_A);
725
+ $skusql = "SELECT `meta_value` FROM `".WPSC_TABLE_PRODUCTMETA."` WHERE `meta_key`= 'sku' AND `product_id` = ".$item['prodid'];
726
  $skuvalue = $wpdb->get_var($skusql);
727
  $output .= "\"".$item['quantity']." ".str_replace('"', '\"',$product['name']).$variation_list."\"";
728
  $output .= ",".$skuvalue;
729
+ }
730
  $output .= "\n"; // terminates the row/line in the CSV file
731
+ }
732
  echo $output;
733
  exit();
734
+ }
735
  }
736
+
737
+ if(isset($_REQUEST['wpsc_admin_action']) && ($_REQUEST['wpsc_admin_action'] == 'wpsc_downloadcsv')) {
738
+ add_action('admin_init', 'wpsc_purchase_log_csv');
739
  }
740
 
741
 
742
  function wpsc_admin_ajax() {
743
  global $wpdb,$user_level,$wp_rewrite;
744
+ get_currentuserinfo();
745
  if(is_numeric($_POST['catid'])) {
746
+ /* fill category form */
747
+ echo nzshpcrt_getcategoryform($_POST['catid']);
748
+ exit();
749
+ } else if(is_numeric($_POST['brandid'])) {
750
+ /* fill brand form */
751
+ echo nzshpcrt_getbrandsform($_POST['brandid']);
752
+ exit();
753
+ } else if(is_numeric($_POST['variation_id'])) {
754
+ echo nzshpcrt_getvariationform($_POST['variation_id']);
755
+ exit();
756
+ }
757
+
758
+
759
+ if ($_POST['action'] == 'product-page-order'){
760
+ $current_order = get_option('wpsc_product_page_order');
761
+ $new_order = $_POST['order'];
762
+
763
+ if ( isset ( $new_order["advanced"] ) ) {
764
+ $current_order["advanced"] = array_unique(explode(',', $new_order["advanced"]));
765
+ }
766
+ if ( isset ( $new_order["side"] ) ) {
767
+ $current_order["side"] = array_unique(explode(',', $new_order["side"]));
768
+ }
769
+
770
+ update_option('wpsc_product_page_order', $current_order);
771
+ exit(print_r($order,1));
772
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
773
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
774
 
775
+ function wpec_hide_box(&$value,$key, $p) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
776
 
777
+ foreach ($p as $pkey => $val) {
778
+ if ( $key == $pkey ) {
779
+ $value = $val;
780
+ }
781
+ }
782
+
783
+ }
784
+
785
+ if ($_POST['action'] == 'postbox-hide'){
786
+ $current_order = get_option('wpsc_product_page_order');
787
+
788
+ $hidden_key = $_POST["hidden_val"];
789
+ $hidden_val = $_POST["hidden"];
790
+
791
+ $hidden = array ( $hidden_key => $hidden_val );
792
+
793
+ array_walk($current_order["hiddenboxes"], "wpec_hide_box", $hidden);
794
+
795
+ update_option('wpsc_product_page_order', $current_order);
796
+ return print_r($current_order);
797
+ }
798
+
799
+ function wpec_close_box(&$value,$key, $p) {
800
+ if ( in_array($key, $p) ) {
801
+ $value = 0;
802
+ } else {
803
+ $value = 1;
804
+ }
805
+ }
806
+ if ($_POST['action'] == 'closed-postboxes') {
807
+ $current_order = get_option('wpsc_product_page_order');
808
+
809
+ $closed = $_POST["closed"];
810
+ $closed = array_unique(explode(',', $closed));
811
+
812
+ array_walk($current_order["closedboxes"], "wpec_close_box", $closed);
813
+
814
+ update_option('wpsc_product_page_order', $current_order);
815
+ print_r($current_order);
816
+ }
817
+
818
+ // if ($_POST['del_prod'] == 'true') {
819
+ // $ids = $_POST['del_prod_id'];
820
+ // $ids = explode(',',$ids);
821
+ // foreach ($ids as $id) {
822
+ // $wpdb->query($wpdb->prepare("DELETE FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE `id`=%d", $id));
823
+ // }
824
+ // exit();
825
+ // }
826
+
827
+
828
+ if(($_POST['save_image_upload_state'] == "true") && is_numeric($_POST['image_upload_state'])) {
829
+ //get_option('wpsc_image_upload_state');
830
+ $upload_state = (int)(bool)$_POST['image_upload_state'];
831
+ update_option('wpsc_use_flash_uploader', $upload_state);
832
+ exit("done");
833
+ }
834
+
835
+ if(($_POST['remove_variation_value'] == "true") && is_numeric($_POST['variation_value_id'])) {
836
+ $value_id = absint($_GET['variation_value_id']);
837
+ echo wp_delete_term($value_id, 'wpsc-variation');
838
+ exit();
839
+ }
840
+
841
+
842
+ if(($_POST['edit_variation_value_list'] == 'true') && is_numeric($_POST['variation_id']) && is_numeric($_POST['product_id'])) {
843
+ $variation_id = (int)$_POST['variation_id'];
844
+ $product_id = (int)$_POST['product_id'];
845
+ $variations_processor = new nzshpcrt_variations();
846
+ $variation_values = $variations_processor->falsepost_variation_values($variation_id);
847
+ if(is_array($variation_values)) {
848
+ //echo(print_r($variation_values,true));
849
+ $check_variation_added = $wpdb->get_var("SELECT `id` FROM `".WPSC_TABLE_VARIATION_ASSOC."` WHERE `type` IN ('product') AND `associated_id` IN ('{$product_id}') AND `variation_id` IN ('{$variation_id}') LIMIT 1");
850
+ //exit("<pre>".print_r($variation_values,true)."<pre>");
851
+ if($check_variation_added == null) {
852
+ $variations_processor->add_to_existing_product($product_id,$variation_values);
853
+ }
854
+ echo $variations_processor->display_attached_variations($product_id);
855
+ echo $variations_processor->variations_grid_view($product_id);
856
+ } else {
857
+ echo "false";
858
+ }
859
+ exit();
860
+ }
861
+
862
+
863
+
864
+ if(($_POST['remove_form_field'] == "true") && is_numeric($_POST['form_id'])) {
865
+ //exit(print_r($user,true));
866
+ if(current_user_can('level_7')) {
867
+ $wpdb->query($wpdb->prepare("UPDATE `".WPSC_TABLE_CHECKOUT_FORMS."` SET `active` = '0' WHERE `id` = %d LIMIT 1 ;", $_POST['form_id']));
868
+ exit(' ');
869
+ }
870
+ }
871
+
872
+
873
+ if($_POST['hide_ecom_dashboard'] == 'true') {
874
+ require_once (ABSPATH . WPINC . '/rss.php');
875
+ $rss = fetch_rss('http://www.instinct.co.nz/feed/');
876
+ $rss->items = array_slice($rss->items, 0, 5);
877
+ $rss_hash = sha1(serialize($rss->items));
878
+ update_option('wpsc_ecom_news_hash', $rss_hash);
879
+ exit(1);
880
+ }
881
+
882
+ if(($_POST['remove_meta'] == 'true') && is_numeric($_POST['meta_id'])) {
883
+ $meta_id = (int)$_POST['meta_id'];
884
+ if(delete_meta($meta_id)) {
885
+ echo $meta_id;
886
+ exit();
887
+ }
888
+ echo 0;
889
+ exit();
890
+ }
891
+
892
+ if(($_REQUEST['log_state'] == "true") && is_numeric($_POST['id']) && is_numeric($_POST['value'])) {
893
+ $newvalue = $_POST['value'];
894
+ if ($_REQUEST['suspend']=='true'){
895
+ if ($_REQUEST['value']==1){
896
+ wpsc_member_dedeactivate_subscriptions($_POST['id']);
897
+ } else {
898
+ wpsc_member_deactivate_subscriptions($_POST['id']);
899
+ }
900
+ exit();
901
+ } else {
902
+
903
+ $log_data = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `id` = '".$_POST['id']."' LIMIT 1",ARRAY_A);
904
+ if (($newvalue==2) && function_exists('wpsc_member_activate_subscriptions')){
905
+ wpsc_member_activate_subscriptions($_POST['id']);
906
+ }
907
+
908
+ $update_sql = "UPDATE `".WPSC_TABLE_PURCHASE_LOGS."` SET `processed` = '".$newvalue."' WHERE `id` = '".$_POST['id']."' LIMIT 1";
909
+ $wpdb->query($update_sql);
910
+ //echo("/*");
911
+ if(($newvalue > $log_data['processed']) && ($log_data['processed'] < 2)) {
912
+ transaction_results($log_data['sessionid'],false);
913
+ }
914
+ //echo("*/");
915
+ $stage_sql = "SELECT * FROM `".WPSC_TABLE_PURCHASE_STATUSES."` WHERE `id`='".$newvalue."' AND `active`='1' LIMIT 1";
916
+ $stage_data = $wpdb->get_row($stage_sql,ARRAY_A);
917
+
918
+ echo "document.getElementById(\"form_group_".$_POST['id']."_text\").innerHTML = '".$stage_data['name']."';\n";
919
+ echo "document.getElementById(\"form_group_".$_POST['id']."_text\").style.color = '#".$stage_data['colour']."';\n";
920
+
921
+
922
+ $year = date("Y");
923
+ $month = date("m");
924
+ $start_timestamp = mktime(0, 0, 0, $month, 1, $year);
925
+ $end_timestamp = mktime(0, 0, 0, ($month+1), 0, $year);
926
+
927
+ echo "document.getElementById(\"log_total_month\").innerHTML = '".addslashes(nzshpcrt_currency_display(admin_display_total_price($start_timestamp, $end_timestamp),1))."';\n";
928
+ echo "document.getElementById(\"log_total_absolute\").innerHTML = '".addslashes(nzshpcrt_currency_display(admin_display_total_price(),1))."';\n";
929
+ exit();
930
+ }
931
+ }
932
+
933
+ if(($_POST['list_variation_values'] == "true")) {
934
+ // retrieve the forms for associating variations and their values with products
935
+ $variation_processor = new nzshpcrt_variations();
936
+
937
+ $variations_selected = array();
938
+ foreach((array)$_POST['variations'] as $variation_id => $checked) {
939
+ $variations_selected[] = (int)$variation_id;
940
+ }
941
+
942
+ if(is_numeric($_POST['product_id']) && ($_POST['product_id'] > 0)) {
943
+ $product_id = absint($_POST['product_id']);
944
+ $selected_price = (float)$_POST['selected_price'];
945
+
946
+ // variation values housekeeping
947
+ $completed_variation_values = $variation_processor->edit_product_values($product_id,$_POST['edit_var_val'], $selected_price);
948
+
949
+
950
+ // get all the currently associated variations from the database
951
+ $associated_variations = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_VARIATION_ASSOC."` WHERE `type` IN ('product') AND `associated_id` IN ('{$product_id}')", ARRAY_A);
952
+
953
+ $variations_still_associated = array();
954
+ foreach((array)$associated_variations as $associated_variation) {
955
+ // remove variations not checked that are in the database
956
+ if(array_search($associated_variation['variation_id'], $variations_selected) === false) {
957
+ $wpdb->query("DELETE FROM `".WPSC_TABLE_VARIATION_ASSOC."` WHERE `id` = '{$associated_variation['id']}' LIMIT 1");
958
+ $wpdb->query("DELETE FROM `".WPSC_TABLE_VARIATION_VALUES_ASSOC."` WHERE `product_id` = '{$product_id}' AND `variation_id` = '{$associated_variation['variation_id']}' ");
959
+ } else {
960
+ // make an array for adding in the variations next step, for efficiency
961
+ $variations_still_associated[] = $associated_variation['variation_id'];
962
+ }
963
+ }
964
+
965
+ foreach((array)$variations_selected as $variation_id) {
966
+ // add variations not already in the database that have been checked.
967
+ $variation_values = $variation_processor->falsepost_variation_values($variation_id);
968
+ if(array_search($variation_id, $variations_still_associated) === false) {
969
+ $variation_processor->add_to_existing_product($product_id,$variation_values);
970
+ }
971
+ }
972
+ //echo "/* ".print_r($variation_values,true)." */\n\r";
973
+ echo "edit_variation_combinations_html = \"".str_replace(array("\n","\r"), array('\n','\r'), addslashes($variation_processor->variations_grid_view($product_id, (array)$completed_variation_values)))."\";\n";
974
+
975
+ } else {
976
+ if(count($variations_selected) > 0) {
977
+ // takes an array of variations, returns a form for adding data to those variations.
978
+ if((float)$_POST['selected_price'] > 0) {
979
+ $selected_price = (float)$_POST['selected_price'];
980
+ }
981
+ $limited_stock = false;
982
+ if($_POST['limited_stock'] == 'true') {
983
+ $limited_stock = true;
984
+ }
985
+
986
+ $selected_variation_values = array();
987
+ foreach($_POST['edit_var_val'] as $variation_value_array) {
988
+ //echo "/* ".print_r($variation_value_array,true)." */\n\r";
989
+ $selected_variation_values = array_merge(array_keys($variation_value_array), $selected_variation_values);
990
+ }
991
+
992
+ ////echo "/* ".print_r($selected_variation_values,true)." */\n\r";
993
+ echo "edit_variation_combinations_html = \"".__('Edit Variation Set', 'wpsc')."<br />".str_replace(array("\n","\r"), array('\n','\r'), addslashes($variation_processor->variations_grid_view(0, (array)$variations_selected, (array)$selected_variation_values, $selected_price, $limited_stock)))."\";\n";
994
+
995
+ } else {
996
+ echo "edit_variation_combinations_html = \"\";\n";
997
+ }
998
+ }
999
+ exit();
1000
+ }
1001
+
1002
+
1003
+ if(isset($_POST['language_setting']) && ($_GET['page'] = WPSC_DIR_NAME.'/wpsc-admin/display-options.page.php')) {
1004
+ if($user_level >= 7) {
1005
+ update_option('language_setting', $_POST['language_setting']);
1006
+ }
1007
+ }
1008
  }
1009
 
1010
 
1013
  if(($_GET['rss'] == "true") && ($_GET['rss_key'] == 'key') && ($_GET['action'] == "purchase_log")) {
1014
  $sql = "SELECT * FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `date`!='' ORDER BY `date` DESC";
1015
  $purchase_log = $wpdb->get_results($sql,ARRAY_A);
1016
+ header("Content-Type: application/xml; charset=UTF-8");
1017
  header('Content-Disposition: inline; filename="WP_E-Commerce_Purchase_Log.rss"');
1018
  $output = '';
1019
  $output .= "<?xml version='1.0'?>\n\r";
1023
  $output .= " <link>".get_option('siteurl')."/wp-admin/admin.php?page=".WPSC_DIR_NAME."/display-log.php</link>\n\r";
1024
  $output .= " <description>This is the WP E-Commerce Product Log RSS feed</description>\n\r";
1025
  $output .= " <generator>WP E-Commerce Plugin</generator>\n\r";
1026
+
1027
  foreach((array)$purchase_log as $purchase) {
1028
  $purchase_link = get_option('siteurl')."/wp-admin/admin.php?page=".WPSC_DIR_NAME."/display-log.php&amp;purchaseid=".$purchase['id'];
1029
  $output .= " <item>\n\r";
1033
  $output .= " <pubDate>".date("r",$purchase['date'])."</pubDate>\n\r";
1034
  $output .= " <guid>$purchase_link</guid>\n\r";
1035
  $output .= " </item>\n\r";
1036
+ }
1037
  $output .= " </channel>\n\r";
1038
  $output .= "</rss>";
1039
  echo $output;
1040
  exit();
1041
+ }
1042
  }
1043
 
1044
  function wpsc_swfupload_images() {
1045
+ global $wpdb, $current_user, $user_ID;
1046
+ // xdebug_start_trace();
1047
+ $file = $_FILES['async-upload'];
1048
+ $product_id = absint($_POST['product_id']);
1049
+ $nonce = $_POST['_wpnonce'];
1050
+ $output = '';
1051
+ // 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
1052
+ if ( is_ssl() && empty($_COOKIE[SECURE_AUTH_COOKIE]) && !empty($_REQUEST['auth_cookie']) ) {
1053
+ $_COOKIE[SECURE_AUTH_COOKIE] = $_REQUEST['auth_cookie'];
1054
+ } else if ( empty($_COOKIE[AUTH_COOKIE]) && !empty($_REQUEST['auth_cookie']) ) {
1055
+ $_COOKIE[AUTH_COOKIE] = $_REQUEST['auth_cookie'];
1056
+ }
1057
+ unset($current_user);
 
 
 
 
 
 
 
 
 
 
 
 
1058
 
1059
+ if(!current_user_can('upload_files') ) {
1060
+ exit("status=-1;\n");
1061
+ }
1062
+
1063
+ if(!wp_verify_nonce($nonce, 'product-swfupload') ) {
1064
+ exit("status=-1;\n");
1065
+ }
1066
+
1067
+
1068
+
1069
+ $id = media_handle_upload('async-upload', $product_id);
1070
+
1071
+ //$object = array('post_author' => $user_ID, 'ping_status' => get_option('default_ping_status'), 'post_parent' => $product_id);
1072
+
1073
+ // wp_insert_attachment($object, $file = false, $parent = 0);
1074
+
1075
+ if (!is_wp_error($id)) {
1076
+ //$src = $file['name'];
1077
+ $src = wp_get_attachment_image_src($id);
1078
+ //print_r($src);
1079
+ $output .= "upload_status=1;\n";
1080
+ $output .= "image_src='".$src[0]."';\n";
1081
+ $output .= "image_id='$id';\n";
1082
+ $output .= "product_id='$product_id';\n";
1083
+ $output .= "replace_existing=0;";
1084
+ } else {
1085
+ $output .= "status=0;\n";
1086
+ }
1087
+
1088
+
1089
+ exit($output);
1090
  }
1091
 
1092
 
1093
  function wpsc_display_invoice() {
1094
 
1095
+ global $body_id;
1096
+
1097
+ $body_id = 'wpsc-packing-slip';
1098
  $purchase_id = (int)$_GET['purchaselog_id'];
1099
  include_once(WPSC_FILE_PATH."/admin-form-functions.php");
1100
  // echo "testing";
1101
+ require_once(ABSPATH.'wp-admin/includes/media.php');
1102
+ wp_iframe('wpsc_packing_slip', $purchase_id);
1103
  //wpsc_packing_slip($purchase_id);
1104
  exit();
1105
  }
1106
+
1107
+ if(isset($_REQUEST['wpsc_admin_action']) && ($_REQUEST['wpsc_admin_action'] == 'wpsc_display_invoice')) {
1108
+ add_action('admin_init', 'wpsc_display_invoice');
1109
  }
1110
+
1111
 
1112
  function wpsc_save_inline_price() {
1113
+ global $wpdb;
1114
+ $pid = $_POST['id'];
1115
+ $new_price = $_POST['value'];
1116
+ $new_price1 = str_replace('$','',$new_price);
1117
+ $wpdb->query("UPDATE ".WPSC_TABLE_PRODUCT_LIST." SET price='$new_price1' WHERE id='$pid'");
1118
+ exit($new_price);
1119
  }
1120
 
1121
+ if(isset($_GET['inline_price']) && ($_GET['inline_price']=='true')) {
1122
+ add_action('admin_init', 'wpsc_save_inline_price', 0);
1123
  }
1124
 
1125
 
1127
  * Purchase log ajax code starts here
1128
  */
1129
  function wpsc_purchlog_resend_email(){
1130
+ global $wpdb;
1131
+ $siteurl = get_option('siteurl');
1132
+ $log_id = $_GET['email_buyer_id'];
1133
+ if(is_numeric($log_id)) {
1134
+
1135
+ $selectsql = "SELECT * FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `id`= ".$log_id." LIMIT 1";
1136
+
1137
+ $purchase_log = $wpdb->get_row($selectsql,ARRAY_A) ;
1138
+
1139
+ if(($purchase_log['gateway'] == "testmode") && ($purchase_log['processed'] < 2)) {
1140
+ $message = get_option("wpsc_email_receipt");
1141
+ $message_html = "<h2 style='font-size:16px;font-weight:bold;color:#000;border:0px;padding-top: 0px;' >".__('Your Order', 'wpsc')."</h2>";
1142
+ } else {
1143
+ $message = get_option("wpsc_email_receipt");
1144
+ $message_html = $message;
1145
+ }
1146
+
1147
+ $order_url = $siteurl."/wp-admin/admin.php?page=".WPSC_DIR_NAME."/display-log.php&amp;purchcaseid=".$purchase_log['id'];
1148
+
1149
+ $cartsql = "SELECT * FROM `".WPSC_TABLE_CART_CONTENTS."` WHERE `purchaseid`=".$purchase_log['id']."";
1150
+ $cart = $wpdb->get_results($cartsql,ARRAY_A);
1151
+ if($purchase_log['shipping_country'] != '') {
1152
+ $billing_country = $purchase_log['billing_country'];
1153
+ $shipping_country = $purchase_log['shipping_country'];
1154
+ } else {
1155
+ $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);
1156
+ $billing_country = $country[0]['value'];
1157
+ $shipping_country = $country[0]['value'];
1158
+ }
1159
+
1160
+ $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);
1161
+ $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);
1162
+ $email = $email_address[0]['value'];
1163
+
1164
+ $previous_download_ids = array(0);
1165
+
1166
+ if(($cart != null)) {
1167
+ foreach($cart as $row) {
1168
+ $link = "";
1169
+ $productsql= "SELECT * FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE `id`=".$row['prodid']."";
1170
+ $product_data = $wpdb->get_results($productsql,ARRAY_A) ;
1171
+
1172
+ if($product_data[0]['file'] > 0) {
1173
+ if($purchase_log['email_sent'] != 1) {
1174
+ $wpdb->query("UPDATE `".WPSC_TABLE_DOWNLOAD_STATUS."` SET `active`='1' WHERE `fileid`='".$product_data[0]['file']."' AND `purchid` = '".$purchase_log['id']."' LIMIT 1");
1175
+ }
1176
+
1177
+ if (($purchase_log['processed'] >= 2)) {
1178
+ $download_data = $wpdb->get_results("SELECT *
1179
+ FROM `".WPSC_TABLE_DOWNLOAD_STATUS."` INNER JOIN `".WPSC_TABLE_PRODUCT_FILES."`
1180
+ ON `".WPSC_TABLE_DOWNLOAD_STATUS."`.`fileid` = `".WPSC_TABLE_PRODUCT_FILES."`.`id`
1181
+ WHERE `".WPSC_TABLE_DOWNLOAD_STATUS."`.`active`='1'
1182
+ AND `".WPSC_TABLE_DOWNLOAD_STATUS."`.`purchid`='".$purchase_log['id']."'
1183
+ AND (
1184
+ `".WPSC_TABLE_DOWNLOAD_STATUS."`.`cartid` = '".$row['id']."'
1185
+ OR (
1186
+ `".WPSC_TABLE_DOWNLOAD_STATUS."`.`cartid` IS NULL
1187
+ AND `".WPSC_TABLE_DOWNLOAD_STATUS."`.`fileid` = '{$product_data['file']}'
1188
+ )
1189
+ )
1190
+ AND `".WPSC_TABLE_DOWNLOAD_STATUS."`.`id` NOT IN ('".implode("','",$previous_download_ids)."')",ARRAY_A);
1191
+ $link=array();
1192
+ //exit('IM HERE'.$errorcode.'<pre>'.print_r($download_data).'</pre>');
1193
+ if(sizeof($download_data) != 0) {
1194
+ foreach($download_data as $single_download){
1195
+ if($single_download['uniqueid'] == null){// if the uniqueid is not equal to null, its "valid", regardless of what it is
1196
+ $link[] = array("url"=>$siteurl."?downloadid=".$single_download['id'], "name" =>$single_download["filename"]);
1197
+ } else {
1198
+ $link[] = array("url"=>$siteurl."?downloadid=".$single_download['uniqueid'], "name" =>$single_download["filename"]);
1199
+ }
1200
  }
1201
+ }
1202
+ $previous_download_ids[] = $download_data['id'];
1203
+ $order_status= 4;
1204
+ }
1205
+ }
1206
+ do_action('wpsc_confirm_checkout', $purchase_log['id']);
1207
+
1208
+ $shipping = nzshpcrt_determine_item_shipping($row['prodid'], $row['quantity'], $shipping_country);
1209
+ if (isset($_SESSION['quote_shipping'])){
1210
+ $shipping = $_SESSION['quote_shipping'];
1211
+ }
1212
+ $total_shipping += $shipping;
1213
+
1214
+ if($product_data[0]['special']==1) {
1215
+ $price_modifier = $product_data[0]['special_price'];
1216
+ } else {
1217
+ $price_modifier = 0;
1218
+ }
1219
+
1220
+ $total+=($row['price']*$row['quantity']);
1221
+ $message_price = nzshpcrt_currency_display(($row['price']*$row['quantity']), $product_data[0]['notax'], true);
1222
+
1223
+ $shipping_price = nzshpcrt_currency_display($shipping, 1, true);
1224
+
1225
+
1226
+
1227
+ if($link != '') {
1228
+ $product_list .= " - ". $product_data['name'] . stripslashes($variation_list) ." ".$message_price ." ".__('Click to download', 'wpsc').":";
1229
+ $product_list_html .= " - ". $product_data['name'] . stripslashes($variation_list) ." ".$message_price ."&nbsp;&nbsp;".__('Click to download', 'wpsc').":\n\r";
1230
+ foreach($link as $single_link) {
1231
+ $product_list .= "\n\r ".$single_link["name"].": ".$single_link["url"]."\n\r";
1232
+ $product_list_html .= "<a href='".$single_link["url"]."'>".$single_link["name"]."</a>\n";
1233
+ }
1234
+ } else {
1235
+ $plural = '';
1236
+
1237
+ if($row['quantity'] > 1) {
1238
+ $plural = "s";
1239
+ }
1240
+
1241
+ $product_list.= " - ".$row['quantity']." ". $product_data[0]['name'].$variation_list ." ". $message_price ."\n";
1242
+ if ($shipping > 0) $product_list .= " - ". __('Shipping', 'wpsc').":".$shipping_price ."\n\r";
1243
+ $product_list_html.= " - ".$row['quantity']." ". $product_data[0]['name'].$variation_list ." ". $message_price ."\n";
1244
+ if ($shipping > 0) $product_list_html .= " - ". __('Shipping', 'wpsc').":".$shipping_price ."\n\r";
1245
+ }
1246
+
1247
+ $report.= " - ". $product_data[0]['name'] .$variation_list." ".$message_price ."\n";
1248
+ }
1249
+
1250
+ if($purchase_log['discount_data'] != '') {
1251
+ $coupon_data = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_COUPON_CODES."` WHERE coupon_code='".$wpdb->escape($purchase_log['discount_data'])."' LIMIT 1",ARRAY_A);
1252
+ if($coupon_data['use-once'] == 1) {
1253
+ $wpdb->query("UPDATE `".WPSC_TABLE_COUPON_CODES."` SET `active`='0', `is-used`='1' WHERE `id`='".$coupon_data['id']."' LIMIT 1");
1254
+ }
1255
+ }
1256
+ //$wpdb->query("UPDATE `".WPSC_TABLE_DOWNLOAD_STATUS."` SET `active`='1' WHERE `fileid`='".$product_data[0]['file']."' AND `purchid` = '".$purchase_log['id']."' LIMIT 1");
1257
+ $total_shipping += $purchase_log['base_shipping'];
1258
+
1259
+ $total = (($total+$total_shipping) - $purchase_log['discount_value']);
1260
+ // $message.= "\n\r";
1261
+ $product_list.= "Your Purchase No.: ".$purchase_log['id']."\n\r";
1262
+ if($purchase_log['discount_value'] > 0) {
1263
+ $discount_email.= __('Discount', 'wpsc').": ".nzshpcrt_currency_display($purchase_log['discount_value'], 1, true)."\n\r";
1264
+ }
1265
+ $total_shipping_email.= __('Total Shipping', 'wpsc').": ".nzshpcrt_currency_display($total_shipping,1,true)."\n\r";
1266
+ $total_price_email.= __('Total', 'wpsc').": ".nzshpcrt_currency_display($total,1,true)."\n\r";
1267
+ $product_list_html.= "Your Purchase No.: ".$purchase_log['id']."\n\n\r";
1268
+ if($purchase_log['discount_value'] > 0) {
1269
+ $discount_html.= __('Discount', 'wpsc').": ".nzshpcrt_currency_display($purchase_log['discount_value'], 1, true)."\n\r";
1270
+ }
1271
+ $total_shipping_html.= __('Total Shipping', 'wpsc').": ".nzshpcrt_currency_display($total_shipping,1,true)."\n\r";
1272
+ $total_price_html.= __('Total', 'wpsc').": ".nzshpcrt_currency_display($total, 1,true)."\n\r";
1273
+ if(isset($_GET['ti'])) {
1274
+ $message.= "\n\r".__('Your Transaction ID', 'wpsc').": " . $_GET['ti'];
1275
+ $message_html.= "\n\r".__('Your Transaction ID', 'wpsc').": " . $_GET['ti'];
1276
+ $report.= "\n\r".__('Transaction ID', 'wpsc').": " . $_GET['ti'];
1277
+ } else {
1278
+ $report_id = "Purchase No.: ".$purchase_log['id']."\n\r";
1279
+ }
1280
+
1281
+
1282
+
1283
+ $message = str_replace('%product_list%',$product_list,$message);
1284
  $message = str_replace('%total_shipping%',$total_shipping_email,$message);
1285
  $message = str_replace('%total_price%',$total_price_email,$message);
1286
  //$message = str_replace('%order_status%',get_option('blogname'),$message);
1287
  $message = str_replace('%shop_name%',get_option('blogname'),$message);
1288
+
1289
  $report = str_replace('%product_list%',$report_product_list,$report);
1290
  $report = str_replace('%total_shipping%',$total_shipping_email,$report);
1291
  $report = str_replace('%total_price%',$total_price_email,$report);
1292
  $report = str_replace('%shop_name%',get_option('blogname'),$report);
1293
+
1294
  $message_html = str_replace('%product_list%',$product_list_html,$message_html);
1295
  $message_html = str_replace('%total_shipping%',$total_shipping_html,$message_html);
1296
  $message_html = str_replace('%total_price%',$total_price_email,$message_html);
1297
  $message_html = str_replace('%shop_name%',get_option('blogname'),$message_html);
1298
+
1299
+
1300
+ // exit($message_html);
1301
+ if(($email != '')) {
1302
+ add_filter('wp_mail_from', 'wpsc_replace_reply_address', 0);
1303
+ add_filter('wp_mail_from_name', 'wpsc_replace_reply_name', 0);
1304
+ if($purchase_log['processed'] < 2) {
1305
+ $payment_instructions = strip_tags(get_option('payment_instructions'));
1306
+ $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;
1307
+ $resent = (bool)wp_mail($email, __('Order Pending: Payment Required', 'wpsc'), $message);
1308
+ $sent = 1;
1309
+ } else {
1310
+ $resent = (bool)wp_mail($email, __('Purchase Receipt', 'wpsc'), $message);
1311
+ $sent = 1;
1312
+ }
1313
+ //echo "$message<br />";
1314
+ //exit($email);
1315
+ remove_filter('wp_mail_from_name', 'wpsc_replace_reply_name');
1316
+ remove_filter('wp_mail_from', 'wpsc_replace_reply_address');
1317
+ }
1318
+ }
1319
+
1320
  }
1321
+ $sendback = wp_get_referer();
1322
 
1323
+ if ( isset($sent) ) {
1324
+ $sendback = add_query_arg('sent', $sent, $sendback);
1325
+ }
1326
+ wp_redirect($sendback);
1327
+ exit();
1328
  }
1329
 
1330
 
1331
 
1332
  if(isset($_REQUEST['email_buyer_id']) && is_numeric($_REQUEST['email_buyer_id'])) {
1333
+ add_action('admin_init', 'wpsc_purchlog_resend_email');
1334
+ }
1335
  function wpsc_purchlog_clear_download_items(){
1336
+ global $wpdb;
1337
  //exit('Just about to redirect');
1338
+ if(is_numeric($_GET['purchaselog_id'])) {
1339
+ $purchase_id = (int)$_GET['purchaselog_id'];
1340
+ $downloadable_items = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_DOWNLOAD_STATUS."` WHERE `purchid` IN ('$purchase_id')", ARRAY_A);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1341
 
1342
+ $clear_locks_sql = "UPDATE`".WPSC_TABLE_DOWNLOAD_STATUS."` SET `ip_number` = '' WHERE `purchid` IN ('$purchase_id')";
1343
+ $wpdb->query($clear_locks_sql);
1344
+ $cleared =true;
1345
+
1346
+ $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");
1347
+ $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");
1348
+
1349
+ foreach((array)$downloadable_items as $downloadable_item) {
1350
+ $download_links .= $siteurl."?downloadid=".$downloadable_item['uniqueid']. "\n";
1351
+ }
1352
 
1353
+
1354
+ 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')."");
1355
+
1356
+
1357
+ $sendback = wp_get_referer();
1358
+
1359
+ if ( isset($cleared) ) {
1360
+ $sendback = add_query_arg('cleared', $cleared, $sendback);
1361
+ }
1362
+ wp_redirect($sendback);
1363
+ exit();
1364
+ }
1365
 
1366
  }
1367
+ if(isset($_REQUEST['wpsc_admin_action']) && ($_REQUEST['wpsc_admin_action'] == 'clear_locks')) {
1368
+ add_action('admin_init', 'wpsc_purchlog_clear_download_items');
1369
  }
1370
+
1371
  //call to search purchase logs
1372
+
1373
  function wpsc_purchlog_search_by(){
1374
  // exit('<pre>'.print_r($_POST,true).'</pre>');
1375
+ //wpsc_search_purchlog_view($_POST['purchlogs_searchbox']);
1376
+ }
1377
+
1378
+ if(isset($_REQUEST['wpsc_admin_action']) && ($_REQUEST['wpsc_admin_action'] == 'purchlogs_search')) {
1379
+ add_action('admin_init', 'wpsc_purchlog_search_by');
1380
  }
1381
  //call to change view for purchase log
1382
+
1383
  function wpsc_purchlog_filter_by(){
1384
+ //exit('filter is triggered'.print_r($_POST, true));
1385
+ wpsc_change_purchlog_view($_POST['view_purchlogs_by'], $_POST['view_purchlogs_by_status']);
1386
+ }
1387
+
1388
+ if(isset($_REQUEST['wpsc_admin_action']) && ($_REQUEST['wpsc_admin_action'] == 'purchlog_filter_by')) {
1389
+ add_action('admin_init', 'wpsc_purchlog_filter_by');
1390
  }
1391
  //bulk actions for purchase log
1392
  function wpsc_purchlog_bulk_modify(){
1393
+ if($_POST['purchlog_multiple_status_change'] != -1){
1394
+ if(is_numeric($_POST['purchlog_multiple_status_change']) && $_POST['purchlog_multiple_status_change'] != 'delete'){
1395
+ foreach((array)$_POST['purchlogids'] as $purchlogid){
1396
+ //exit('<pre>'.print_r($purchlogid,true).'</pre>');
1397
+ wpsc_purchlog_edit_status($purchlogid, $_POST['purchlog_multiple_status_change']);
1398
+ $updated++;
1399
+ }
1400
+
1401
+ }elseif($_POST['purchlog_multiple_status_change'] == 'delete'){
1402
+ foreach((array)$_POST['purchlogids'] as $purchlogid){
1403
+
1404
+ wpsc_delete_purchlog($purchlogid);
1405
+ $deleted++;
1406
+ }
1407
+ }
1408
+
1409
+ }
1410
+ $sendback = wp_get_referer();
1411
+ if ( isset($updated) ) {
1412
+ $sendback = add_query_arg('updated', $updated, $sendback);
1413
+ }
1414
+ if ( isset($deleted) ) {
1415
+ $sendback = add_query_arg('deleted', $deleted, $sendback);
1416
+ }
1417
+ if ( isset($_POST['view_purchlogs_by']) ) {
1418
+ $sendback = add_query_arg('view_purchlogs_by', $_POST['view_purchlogs_by'], $sendback);
1419
  }
1420
+ if ( isset($_POST['view_purchlogs_by_status']) ) {
1421
+ $sendback = add_query_arg('view_purchlogs_by_status', $_POST['view_purchlogs_by_status'], $sendback);
1422
  }
1423
+ wp_redirect($sendback);
1424
+ exit();
1425
  }
1426
 
1427
+ if(isset($_REQUEST['wpsc_admin_action2']) && ($_REQUEST['wpsc_admin_action2'] == 'purchlog_bulk_modify')) {
1428
+ add_action('admin_init', 'wpsc_purchlog_bulk_modify');
1429
  }
1430
  //edit purchase log status function
1431
  function wpsc_purchlog_edit_status($purchlog_id='', $purchlog_status='') {
1432
+ global $wpdb;
1433
+ if(($purchlog_id =='') && ($purchlog_status == '')){
1434
+ $purchlog_id = absint($_POST['purchlog_id']);
1435
+ $purchlog_status = absint($_POST['purchlog_status']);
1436
+ }
 
 
 
 
 
1437
 
1438
+ $log_data = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `id` = '{$purchlog_id}' LIMIT 1",ARRAY_A);
1439
+ if (($purchlog_id==2) && function_exists('wpsc_member_activate_subscriptions')){
1440
+ wpsc_member_activate_subscriptions($_POST['id']);
1441
+ }
 
1442
 
1443
+ // if the order is marked as failed, remove the claim on the stock
1444
+ if($purchlog_status == 5) {
1445
+ $wpdb->query("DELETE FROM `".WPSC_TABLE_CLAIMED_STOCK."` WHERE `cart_id` = '{$purchlog_id}' AND `cart_submitted` = '1'");
1446
+ //echo "DELETE FROM `".WPSC_TABLE_CLAIMED_STOCK."` WHERE `cart_id` = '{$purchlog_id}' AND `cart_submitted` = '1'";
1447
+ }
1448
 
1449
+ $wpdb->query("UPDATE `".WPSC_TABLE_PURCHASE_LOGS."` SET processed='{$purchlog_status}' WHERE id='{$purchlog_id}'");
1450
+
1451
+ if(($purchlog_id > $log_data['processed']) && ($log_data['processed'] <= 2) && $log_data['email_sent'] == 0) {
1452
+ // transaction_results($log_data['sessionid'],false,null);
1453
+ }
1454
  }
1455
 
1456
+ if(isset($_REQUEST['wpsc_admin_action']) && ($_REQUEST['wpsc_admin_action'] == 'purchlog_edit_status')) {
1457
+ add_action('admin_init', 'wpsc_purchlog_edit_status');
1458
  }
1459
  /*
1460
  SELECT DISTINCT `products`.*, `category`.`category_id`,`order`.`order`, IF(ISNULL(`order`.`order`), 0, 1) AS `order_state` FROM `wp_wpsc_product_list` AS `products` LEFT JOIN `wp_wpsc_item_category_assoc` AS `category` ON `products`.`id` = `category`.`product_id` LEFT JOIN `wp_wpsc_product_order` AS `order` ON ( ( `products`.`id` = `order`.`product_id` ) AND ( `category`.`category_id` = `order`.`category_id` ) ) WHERE `products`.`publish`='1' AND `products`.`active` = '1' AND `category`.`category_id` IN ('3') ORDER BY `order_state` DESC, `products`.`id` DESC,`order`.`order` ASC LIMIT 0, 8
1461
  */
1462
  function wpsc_save_product_order() {
1463
  global $wpdb;
 
 
 
 
 
 
 
 
 
 
 
 
1464
 
1465
+ $products = array();
 
1466
 
1467
+ foreach($_POST['post'] as $product) {
1468
+ $products[] = absint($product);
1469
+ }
1470
+
1471
+ print_r($products);
1472
+
1473
+ foreach($products as $order=>$product_id) {
1474
+
1475
+ $wpdb->query($wpdb->prepare("UPDATE `{$wpdb->posts}` SET `menu_order`='%d' WHERE `ID`='%d' LIMIT 1", $order, $product_id));
1476
+
1477
+ }
1478
+ $success = true;
1479
+
1480
+ exit((string)$success);
1481
  }
1482
+
1483
+
1484
+ if(isset($_REQUEST['wpsc_admin_action']) && ($_REQUEST['wpsc_admin_action'] == 'save_product_order')) {
1485
+ add_action('admin_init', 'wpsc_save_product_order');
1486
  }
1487
 
1488
  function wpsc_save_checkout_order() {
1489
  global $wpdb;
1490
+ //exit('<pre>'.print_r($_POST, true).'</pre>');
1491
+ $checkoutfields = $_POST['checkout'];
1492
+ $order=1;
1493
+ foreach($checkoutfields as $checkoutfield) {
1494
+ $checkoutfield = absint($checkoutfield);
1495
+ $wpdb->query("UPDATE `".WPSC_TABLE_CHECKOUT_FORMS."` SET `order` = '".$order."' WHERE `id`=".$checkoutfield);
1496
 
1497
+ $order++;
1498
+ }
1499
+ $success = true;
1500
 
1501
+ exit((string)$success);
1502
  }
1503
+
1504
+
1505
+ if(isset($_REQUEST['wpsc_admin_action']) && ($_REQUEST['wpsc_admin_action'] == 'save_checkout_order')) {
1506
+ add_action('admin_init', 'wpsc_save_checkout_order');
1507
  }
1508
  /* Start Order Notes (by Ben) */
1509
  function wpsc_purchlogs_update_notes($purchlog_id = '', $purchlog_notes = '' ) {
1510
+ global $wpdb;
1511
+ if ( wp_verify_nonce( $_POST['wpsc_purchlogs_update_notes_nonce'], 'wpsc_purchlogs_update_notes' ) ) {
1512
+ if ( ($purchlog_id == '') && ($purchlog_notes == '') ) {
1513
+ $purchlog_id = absint($_POST['purchlog_id']);
1514
+ $purchlog_notes = $wpdb->escape($_POST['purchlog_notes']);
1515
+ }
1516
+ $wpdb->query("UPDATE `" . WPSC_TABLE_PURCHASE_LOGS . "` SET notes='{$purchlog_notes}' WHERE id='{$purchlog_id}'");
1517
+ }
1518
  }
1519
 
1520
+ if (isset($_REQUEST['wpsc_admin_action']) && ($_REQUEST['wpsc_admin_action'] == 'purchlogs_update_notes' )) {
1521
+ add_action('admin_init', 'wpsc_purchlogs_update_notes');
1522
  }
1523
  /* End Order Notes (by Ben) */
1524
 
1525
+
1526
  //delete a purchase log
1527
  function wpsc_delete_purchlog($purchlog_id='') {
1528
+ global $wpdb;
1529
+ $deleted = 0;
1530
+ if($purchlog_id == ''){
1531
+ $purchlog_id = absint($_GET['purchlog_id']);
1532
+ check_admin_referer('delete_purchlog_' . $purchlog_id);
1533
+ }
 
 
 
 
 
 
 
 
 
 
1534
 
1535
+ if(is_numeric($purchlog_id)) {
1536
+ $delete_log_form_sql = "SELECT * FROM `".WPSC_TABLE_CART_CONTENTS."` WHERE `purchaseid`='$purchlog_id'";
1537
+ $cart_content = $wpdb->get_results($delete_log_form_sql,ARRAY_A);
1538
+ }
1539
+
1540
+ $purchlog_status = $wpdb->get_var("SELECT `processed` FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `id`=".$purchlog_id);
1541
+ if($purchlog_status == 5 || $purchlog_status == 1) {
1542
+ $wpdb->query("DELETE FROM `".WPSC_TABLE_CLAIMED_STOCK."` WHERE `cart_id` = '{$purchlog_id}' AND `cart_submitted` = '1'");
1543
+ }
1544
+
1545
+ $wpdb->query("DELETE FROM `".WPSC_TABLE_CART_CONTENTS."` WHERE `purchaseid`='$purchlog_id'");
1546
+ $wpdb->query("DELETE FROM `".WPSC_TABLE_SUBMITED_FORM_DATA."` WHERE `log_id` IN ('$purchlog_id')");
1547
+ $wpdb->query("DELETE FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `id`='$purchlog_id' LIMIT 1");
1548
+
1549
+ $deleted = 1;
1550
+
1551
+ if(is_numeric($_GET['purchlog_id'])){
1552
+ $sendback = wp_get_referer();
1553
+ $sendback = remove_query_arg('purchaselog_id', $sendback);
1554
+ if ( isset($deleted) ) {
1555
+ $sendback = add_query_arg('deleted', $deleted, $sendback);
1556
+ }
1557
+ wp_redirect($sendback);
1558
+ exit();
1559
+ }
1560
  }
1561
+
1562
+
1563
+
1564
+ if(isset($_REQUEST['wpsc_admin_action']) && ($_REQUEST['wpsc_admin_action'] == 'delete_purchlog')) {
1565
+ add_action('admin_init', 'wpsc_delete_purchlog');
1566
  }
1567
+
1568
+
1569
 
1570
 
1571
 
1578
  $shippingname = $_REQUEST['shippingname'];
1579
  $_SESSION['previous_shipping_name'] = $shippingname;
1580
  $shipping_data = wpsc_get_shipping_form($shippingname);
1581
+ $html_shipping_name = str_replace(Array("\n","\r") , Array("\\n","\\r"),addslashes($shipping_data['name']));
1582
+ $shipping_form = str_replace(Array("\n","\r") , Array("\\n","\\r"),addslashes($shipping_data['form_fields']));
1583
+ echo "shipping_name_html = '$html_shipping_name'; \n\r";
1584
+ echo "shipping_form_html = '$shipping_form'; \n\r";
1585
+ echo "has_submit_button = '{$shipping_data['has_submit_button']}'; \n\r";
1586
+ //echo "<script type='text/javascript'>jQuery('.gateway_settings h3.hndle').livequery(function(){ jQuery(this).html('".$wpsc_shipping_modules[$shippingname]->name."')})</script>";
1587
  exit();
1588
  }
1589
+
1590
  function wpsc_crop_thumbnail_html() {
1591
+ include(WPSC_FILE_PATH."/wpsc-admin/includes/crop.php");
1592
  exit();
1593
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1594
 
 
 
 
 
 
 
 
 
1595
 
1596
 
1597
+ if (isset($_REQUEST['wpsc_admin_action']) && ($_REQUEST['wpsc_admin_action'] == 'crop_image')) {
1598
+ add_action('admin_init','wpsc_crop_thumbnail_html');
1599
+ }
1600
 
 
 
 
1601
 
1602
 
1603
+ if(isset($_REQUEST['wpsc_admin_action']) && ($_REQUEST['wpsc_admin_action'] == 'get_shipping_form')) {
1604
+ add_action('admin_init', 'wpsc_ajax_get_shipping_form');
1605
+ }
1606
 
 
1607
 
1608
 
1609
+ /*
1610
+ *Submit Options from Settings Pages,
1611
+ *takes an array of options checks to see whether it is empty or the same as the exisiting values
1612
+ *and if its not it updates them.
1613
+ */
1614
+ function wpsc_submit_options($selected='') {
1615
+ global $wpdb, $wpsc_gateways;
1616
+ $updated = 0;
1617
+
1618
+ //This is to change the Overall target market selection
1619
+ check_admin_referer('update-options', 'wpsc-update-options');
1620
+
1621
+ if (!isset($_POST['countrylist2'])) $_POST['countrylist2'] = '';
1622
+ if (!isset($_POST['country_id'])) $_POST['country_id'] = '';
1623
+ if (!isset($_POST['country_tax'])) $_POST['country_tax'] = '';
1624
+
1625
+ if($_POST['countrylist2'] != null || $selected != ''){
1626
+ $AllSelected = false;
1627
+ if( $selected == 'all'){
1628
+ $wpdb->query("UPDATE `".WPSC_TABLE_CURRENCY_LIST."` SET visible = '1'");
1629
+ $AllSelected = true;
1630
+ return;
1631
+ }
1632
+ if( $selected == 'none'){
1633
+ $wpdb->query("UPDATE `".WPSC_TABLE_CURRENCY_LIST."` SET visible = '0'");
1634
+ $AllSelected = true;
1635
+ return;
1636
+ }
1637
+ if($AllSelected != true){
1638
+ $countrylist = $wpdb->get_col("SELECT id FROM `".WPSC_TABLE_CURRENCY_LIST."` ORDER BY country ASC ");
1639
+ //find the countries not selected
1640
+ $unselectedCountries = array_diff($countrylist, $_POST['countrylist2']);
1641
+ foreach($unselectedCountries as $unselected){
1642
+ $wpdb->query("UPDATE `".WPSC_TABLE_CURRENCY_LIST."` SET visible = 0 WHERE id = '".$unselected."' LIMIT 1");
1643
+ }
1644
+
1645
+ //find the countries that are selected
1646
+ $selectedCountries = array_intersect($countrylist, $_POST['countrylist2']);
1647
+ foreach($selectedCountries as $selected){
1648
+ $wpdb->query("UPDATE `".WPSC_TABLE_CURRENCY_LIST."` SET visible = 1 WHERE id = '".$selected."' LIMIT 1");
1649
+ }
1650
+ }
1651
+ }
1652
+ //this is to change the base country and tax code for the shop
1653
+ /* OLD CODE PRESERVED - See new taxes system for taxes
1654
+ * if((is_numeric($_POST['country_id']) && is_numeric($_POST['country_tax']))) {
1655
+ $wpdb->query("UPDATE `".WPSC_TABLE_CURRENCY_LIST."` SET `tax` = '".$_POST['country_tax']."' WHERE `id` = '".$_POST['country_id']."' LIMIT 1 ;");
1656
+ }*/
1657
+
1658
+
1659
+ $previous_currency = get_option('currency_type');
1660
+
1661
+ //To update options
1662
+ if(isset($_POST['wpsc_options'])){
1663
+ foreach($_POST['wpsc_options'] as $key=>$value){
1664
+ if($value != get_option($key)) {
1665
+ update_option($key, $value);
1666
+ $updated++;
1667
+ }
1668
+ }
1669
+ }
1670
+
1671
+ if($previous_currency != get_option('currency_type')) {
1672
+ $currency_code = $wpdb->get_var("SELECT `code` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `id` IN ('".absint(get_option('currency_type'))."')");
1673
+
1674
+ $selected_gateways = get_option('custom_gateway_options');
1675
+ $already_changed = array();
1676
+ foreach($selected_gateways as $selected_gateway) {
1677
+ if(isset($wpsc_gateways[$selected_gateway]['supported_currencies'])) {
1678
+ if(in_array($currency_code, $wpsc_gateways[$selected_gateway]['supported_currencies']['currency_list'])) {
1679
+
1680
+ $option_name = $wpsc_gateways[$selected_gateway]['supported_currencies']['option_name'];
1681
+
1682
+ if(!in_array($option_name, $already_changed)) {
1683
+ //echo $option_name;
1684
+ update_option($option_name, $currency_code);
1685
+ $already_changed[] = $option_name;
1686
+ }
1687
+ }
1688
+ }
1689
+ }
1690
+
1691
+
1692
+ //exit("<pre>".print_r($selected_gateways,true)."</pre>");
1693
+
1694
+ }
1695
+
1696
+ foreach($GLOBALS['wpsc_shipping_modules'] as $shipping) {
1697
+ if (is_object($shipping))
1698
+ $shipping->submit_form();
1699
+ }
1700
+
1701
+
1702
+ //This is for submitting shipping details to the shipping module
1703
+ if (!isset($_POST['update_gateways'])) $_POST['update_gateways'] = '';
1704
+ if(!isset($_POST['custom_shipping_options'])) $_POST['custom_shipping_options'] = null;
1705
+ if($_POST['update_gateways'] == 'true') {
1706
+
1707
+ update_option('custom_shipping_options', $_POST['custom_shipping_options']);
1708
+
1709
+
1710
+ foreach($GLOBALS['wpsc_shipping_modules'] as $shipping) {
1711
+ foreach((array)$_POST['custom_shipping_options'] as $shippingoption){
1712
+ //echo $shipping->internal_name.' == '.$shippingoption;
1713
+ if($shipping->internal_name == $shippingoption) {
1714
+ //$shipping->submit_form();
1715
+ $shipadd++;
1716
+ }
1717
+ }
1718
+ }
1719
+ }
1720
+ $sendback = wp_get_referer();
1721
+
1722
+ if ( isset($updated) ) {
1723
+ $sendback = add_query_arg('updated', $updated, $sendback);
1724
+ }
1725
+ if ( isset($shipadd) ) {
1726
+ $sendback = add_query_arg('shipadd', $shipadd, $sendback);
1727
+ }
1728
+
1729
+ if (!isset($_SESSION['wpsc_settings_curr_page'])) $_SESSION['wpsc_settings_curr_page'] = '';
1730
+ if (!isset($_POST['page_title'])) $_POST['page_title'] = '';
1731
+ if(isset($_SESSION['wpsc_settings_curr_page'])){
1732
+ $sendback = add_query_arg('tab', $_SESSION['wpsc_settings_curr_page'], $sendback);
1733
+ }
1734
+
1735
+ $sendback = add_query_arg('page', 'wpsc-settings', $sendback);
1736
+ wp_redirect($sendback);
1737
+ exit();
1738
+ }
1739
 
 
 
 
 
 
 
 
 
 
1740
 
 
 
 
 
 
 
1741
 
1742
+ if(isset($_REQUEST['wpsc_admin_action']) && ($_REQUEST['wpsc_admin_action'] == 'submit_options')) {
1743
+ add_action('admin_init', 'wpsc_submit_options');
1744
  }
1745
 
1746
  function wpsc_change_currency(){
1747
+ if(is_numeric($_POST['currencyid'])){
1748
+ $currency_data = $wpdb->get_results("SELECT `symbol`,`symbol_html`,`code` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `id`='".$_POST['currencyid']."' LIMIT 1",ARRAY_A) ;
1749
+ $price_out = null;
1750
+ if($currency_data[0]['symbol'] != '') {
1751
+ $currency_sign = $currency_data[0]['symbol_html'];
1752
+ } else {
1753
+ $currency_sign = $currency_data[0]['code'];
1754
+ }
1755
+ echo $currency_sign;
1756
+ }
1757
  }
1758
+ if(isset($_REQUEST['wpsc_admin_action']) && ($_REQUEST['wpsc_admin_action'] == 'change_currency')) {
1759
+ add_action('admin_init', 'wpsc_change_currency');
1760
  }
1761
 
1762
  function wpsc_rearrange_images() {
1763
+ global $wpdb;
1764
+ //$wpdb->show_errors = true;
1765
+ $images = explode(",",$_POST['order']);
1766
+ $product_id = absint($_POST['product_id']);
1767
+ $timestamp = time();
1768
+
1769
+ $new_main_image = null;
1770
+ $have_set_first_item = false;
1771
+ $i = 0;
1772
+ foreach($images as $image) {
1773
+ if($image > 0) {
1774
+ $wpdb->query($wpdb->prepare("UPDATE `{$wpdb->posts}` SET `menu_order`='%d' WHERE `ID`='%d' LIMIT 1", $i, $image));
1775
+ $i++;
1776
+ }
1777
+ }
1778
+ $output = wpsc_main_product_image_menu($product_id);
1779
+ //echo "/*\n";
1780
+ //echo print_r($_POST, true);
1781
+ //echo print_r($images, true);
1782
+ //echo "*/\n";
1783
+ echo "image_menu = '';\n\r";
1784
+ echo "image_id = '".$new_main_image."';\n\r";
1785
+ exit();
1786
+ }
1787
+ if(isset($_REQUEST['wpsc_admin_action']) && ($_REQUEST['wpsc_admin_action'] == 'rearrange_images')) {
1788
+ add_action('admin_init', 'wpsc_rearrange_images');
1789
  }
1790
 
1791
 
1792
  function wpsc_delete_images() {
1793
+ global $wpdb;
1794
+ $product_id = absint($_POST['product_id']);
1795
+ $element_id = $_POST['del_img_id'];
1796
+ $image_id = absint(str_replace("product_image_", '', $element_id));
1797
+ if($image_id > 0) {
1798
+ $deletion_success = $wpdb->query("DELETE FROM `".WPSC_TABLE_PRODUCT_IMAGES."` WHERE `id`='{$image_id}' LIMIT 1");
1799
+ echo "element_id = '$element_id';\n";
1800
+ //echo "/*\n";
1801
+ //print_r($deletion_success);
1802
+ //echo "*/\n";
1803
+
1804
+ if(($product_id > 0) && ($deletion_success == true)) {
1805
+ $next_image = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_PRODUCT_IMAGES."` WHERE `product_id` = '{$product_id}' ORDER BY `image_order` ASC LIMIT 1",ARRAY_A);
1806
+ if(count($next_image) > 0) {
1807
+ $wpdb->query("UPDATE `".WPSC_TABLE_PRODUCT_LIST."` SET `image` = '{$next_image['id']}' WHERE `id` = '{$product_id}' LIMIT 1");
1808
+ $output = wpsc_main_product_image_menu($product_id);
1809
+
1810
+ $height = get_option('product_image_height');
1811
+ $width = get_option('product_image_width');
1812
+
1813
+ $image_input = WPSC_IMAGE_DIR . $next_image['file'];
1814
+ $image_output = WPSC_THUMBNAIL_DIR . $next_image['file'];
1815
+ if(($product['file'] != '') and file_exists($image_input)) {
1816
+ image_processing($image_input, $image_output, $width, $height);
1817
+ update_product_meta($product_id, 'thumbnail_width', $width);
1818
+ update_product_meta($product_id, 'thumbnail_height', $height);
1819
+ }
1820
+ echo "image_menu='".str_replace(array("\n", "\r"), array('\n', '\r'), addslashes($output))."';\n";
1821
+ echo "image_id='".$next_image['id']."';\n";
1822
+ } else {
1823
+ $wpdb->query("UPDATE `".WPSC_TABLE_PRODUCT_LIST."` SET `image` = NULL WHERE `id` = '{$product_id}' LIMIT 1");
1824
+ }
1825
+ }
1826
+ }
1827
+
1828
+ exit();
1829
+ }
1830
+
1831
+ if(isset($_REQUEST['wpsc_admin_action']) && ($_REQUEST['wpsc_admin_action'] == 'delete_images')) {
1832
+ add_action('admin_init', 'wpsc_delete_images');
1833
  }
1834
 
1835
  function wpsc_update_page_urls(){
1836
+ global $wpdb;
1837
 
1838
  $wpsc_pageurl_option['product_list_url'] = '[productspage]';
1839
  $wpsc_pageurl_option['shopping_cart_url'] = '[shoppingcart]';
1840
  $check_chekout = $wpdb->get_var("SELECT `guid` FROM `{$wpdb->posts}` WHERE `post_content` LIKE '%[checkout]%' LIMIT 1");
1841
  if($check_chekout != null) {
1842
+ $wpsc_pageurl_option['checkout_url'] = '[checkout]';
1843
+ } else {
1844
+ $wpsc_pageurl_option['checkout_url'] = '[checkout]';
1845
+ }
1846
  $wpsc_pageurl_option['transact_url'] = '[transactionresults]';
1847
  $wpsc_pageurl_option['user_account_url'] = '[userlog]';
1848
  $changes_made = false;
1852
  if(stristr(get_option($option_key), "https://")) {
1853
  $the_new_link = str_replace('http://', "https://",$the_new_link);
1854
  }
1855
+
1856
  update_option($option_key, $the_new_link);
1857
  $updated;
1858
+ }
1859
+ $sendback = wp_get_referer();
1860
 
1861
+ if ( isset($updated) ) {
1862
+ $sendback = add_query_arg('updated', $updated, $sendback);
1863
+ }
1864
+ if(isset($_SESSION['wpsc_settings_curr_page'])){
1865
+ $sendback = add_query_arg('tab', $_SESSION['wpsc_settings_curr_page'], $sendback);
1866
+ }
1867
+ wp_redirect($sendback);
1868
 
1869
  exit();
1870
  }
1871
+
1872
+ if(isset($_REQUEST['wpsc_admin_action']) && ($_REQUEST['wpsc_admin_action'] == 'update_page_urls')) {
1873
+ add_action('admin_init', 'wpsc_update_page_urls');
1874
  }
1875
 
1876
  function wpsc_clean_categories(){
1877
  global $wpdb, $wp_rewrite;
1878
  //exit("<pre>".print_r($check_category_names,true)."</pre>");
1879
  $sql_query = "SELECT `id`, `name`, `active` FROM `".WPSC_TABLE_PRODUCT_CATEGORIES."`";
1880
+ $sql_data = $wpdb->get_results($sql_query,ARRAY_A);
1881
+ foreach((array)$sql_data as $datarow) {
1882
+ if($datarow['active'] == 1) {
1883
+ $tidied_name = trim($datarow['name']);
1884
+ $tidied_name = strtolower($tidied_name);
1885
+ $url_name = sanitize_title($tidied_name);
1886
+ $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);
1887
+ $extension_number = '';
1888
+ if($similar_names['count'] > 0) {
1889
+ $extension_number = (int)$similar_names['max_number']+2;
1890
+ }
1891
+ $url_name .= $extension_number;
1892
+ $wpdb->query("UPDATE `".WPSC_TABLE_PRODUCT_CATEGORIES."` SET `nice-name` = '$url_name' WHERE `id` = '{$datarow['id']}' LIMIT 1 ;");
1893
+ $updated;
1894
+ } else if($datarow['active'] == 0) {
1895
+ $wpdb->query("UPDATE `".WPSC_TABLE_PRODUCT_CATEGORIES."` SET `nice-name` = '' WHERE `id` = '{$datarow['id']}' LIMIT 1 ;");
1896
+ $updated;
1897
+ }
1898
+ }
1899
+ $wp_rewrite->flush_rules();
1900
+ $sendback = wp_get_referer();
1901
+
1902
+ if ( isset($updated) ) {
1903
+ $sendback = add_query_arg('updated', $updated, $sendback);
1904
+ }
1905
+ if(isset($_SESSION['wpsc_settings_curr_page'])){
1906
+ $sendback = add_query_arg('tab', $_SESSION['wpsc_settings_curr_page'], $sendback);
1907
+ }
1908
+ wp_redirect($sendback);
1909
 
1910
  exit();
1911
  }
1912
+
1913
+ if(isset($_REQUEST['wpsc_admin_action']) && ($_REQUEST['wpsc_admin_action'] == 'clean_categories')) {
1914
+ add_action('admin_init', 'wpsc_clean_categories');
1915
  }
1916
 
1917
  //change the regions tax settings
1918
  function wpsc_change_region_tax(){
1919
+ global $wpdb;
1920
+ if(is_array($_POST['region_tax'])) {
1921
+ foreach($_POST['region_tax'] as $region_id => $tax) {
1922
+ if(is_numeric($region_id) && is_numeric($tax)) {
1923
+ $previous_tax = $wpdb->get_var("SELECT `tax` FROM `".WPSC_TABLE_REGION_TAX."` WHERE `id` = '$region_id' LIMIT 1");
1924
+ if($tax != $previous_tax) {
1925
+ $wpdb->query("UPDATE `".WPSC_TABLE_REGION_TAX."` SET `tax` = '$tax' WHERE `id` = '$region_id' LIMIT 1");
1926
+ $changes_made = true;
1927
+ }
1928
+ }
1929
+ }
1930
+ $sendback = wp_get_referer();
1931
+ //$sendback = remove_query_arg('isocode', $sendback);
1932
+ wp_redirect($sendback);
1933
+ }
1934
+ }
1935
+
1936
+ if(isset($_REQUEST['wpsc_admin_action']) && ($_REQUEST['wpsc_admin_action'] == 'change_region_tax')) {
1937
+ add_action('admin_init', 'wpsc_change_region_tax');
1938
  }
1939
 
1940
  function wpsc_product_files_existing() {
1941
+ global $wpdb;
1942
+
1943
+ //List all product_files, with checkboxes
1944
+
1945
+ $product_id = absint($_GET["product_id"]);
1946
+ $file_list = wpsc_uploaded_files();
1947
+
1948
+ $args = array(
1949
+ 'post_type' => 'wpsc-product-file',
1950
+ 'post_parent' => $product_id,
1951
+ 'numberposts' => -1,
1952
+ 'post_status' => 'all'
1953
+ );
1954
+ //echo "<pre>".print_r($file_list, true)."<pre>";
1955
+ $attached_files = (array)get_posts($args);
1956
+
1957
+ //echo "<pre>".print_r($attached_files, true)."<pre>";
1958
+ foreach($attached_files as $key => $attached_file) {
1959
+ $attached_files_by_file[$attached_file->post_title] = & $attached_files[$key];
1960
+ }
1961
+
1962
+ $output = "<span class='admin_product_notes select_product_note '>".__('Choose a downloadable file for this product:', 'wpsc')."</span><br>";
1963
+ $output .= "<div class='ui-widget-content multiple-select select_product_file'>";
1964
+ $output .= "<form method='post' class='product_upload'>";
1965
+
1966
+ $num = 0;
1967
+ foreach((array)$file_list as $file) {
1968
+ $num++;
1969
+ $checked_curr_file = "";
1970
+ if (isset($attached_files_by_file[$file['display_filename']])){
1971
+ $checked_curr_file = "checked='checked'";
1972
+ }
1973
+
1974
+ $output .= "<p ".((($num % 2) > 0) ? '' : "class='alt'")." id='select_product_file_row_$num'>\n";
1975
+ $output .= " <input type='checkbox' name='select_product_file[]' value='".$file['real_filename']."' id='select_product_file_$num' ".$checked_curr_file." />\n";
1976
+ $output .= " <label for='select_product_file_$num'>".$file['display_filename']."</label>\n";
1977
+ $output .= "</p>\n";
1978
+ }
1979
+ $output .= "<input type='hidden' id='hidden_id' value='$product_id' />";
1980
+ $output .= "<input type='submit' name='save' name='product_files_submit' class='button-primary prdfil' value='Save Product Files' />";
1981
+ $output .= "</form>";
1982
+ $output .= "</div>";
1983
+ $output .= "<div class='".((is_numeric($product_id)) ? "edit_" : "")."select_product_handle'><div></div></div>";
1984
+ $output .= "<script type='text/javascript'>\n\r";
1985
+ $output .= "var select_min_height = ".(25*3).";\n\r";
1986
+ $output .= "var select_max_height = ".(25*($num+1)).";\n\r";
1987
+ $output .= "</script>";
1988
+
1989
+
1990
+ echo $output;
1991
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1992
  }
1993
 
1994
+ if(isset($_REQUEST['wpsc_admin_action']) && ($_REQUEST['wpsc_admin_action'] == 'product_files_existing')) {
1995
+ add_action('admin_init', 'wpsc_product_files_existing');
1996
  }
1997
 
1998
  function prod_upload() {
1999
  global $wpdb, $product_id;
2000
+ if(isset($_REQUEST['wpsc_admin_action']) && ($_REQUEST['wpsc_admin_action'] == 'product_files_upload')) {
2001
+
2002
+ foreach ($_REQUEST["select_product_file"] as $file) {
2003
+ $duplicate = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE post_type = 'wpsc-product-file' AND post_title = '$file'", ARRAY_A);
2004
+
2005
+ $type = $duplicate["post_mime_type"];
2006
+ $url = $duplicate["guid"];
2007
+ $title = $duplicate["post_title"];
2008
+ $content = $duplicate["post_content"];
2009
+
2010
+ // Construct the attachment array
2011
+ $attachment = array(
2012
+ 'post_mime_type' => $type,
2013
+ 'guid' => $url,
2014
+ 'post_parent' => $_REQUEST["product_id"],
2015
+ 'post_title' => $title,
2016
+ 'post_content' => $content,
2017
+ 'post_type' => "wpsc-product-file",
2018
+ 'post_status' => 'inherit'
2019
+ );
2020
+
2021
+ // Save the data
2022
+ $id = wp_insert_post($attachment);
2023
+ }
2024
+ }
2025
+ }
2026
  add_action('admin_init', 'prod_upload');
2027
 
2028
  //change the gateway settings
2029
  function wpsc_gateway_settings(){
2030
+ global $wpdb;
2031
+ //To update options
2032
+ if(isset($_POST['wpsc_options'])){
2033
+ foreach($_POST['wpsc_options'] as $key=>$value){
2034
+ if($value != get_option($key)){
2035
+ update_option($key, $value);
2036
+ //$updated++;
2037
+ }
2038
+ }
2039
+ unset($_POST['wpsc_options']);
2040
+ }
2041
+
2042
+
2043
+
2044
+ if(is_array($_POST['user_defined_name'])) {
2045
+ $payment_gateway_names = get_option('payment_gateway_names');
2046
+ if(!is_array($payment_gateway_names)) {
2047
+ $payment_gateway_names = array();
2048
+ }
2049
+ $payment_gateway_names = array_merge($payment_gateway_names, (array)$_POST['user_defined_name']);
2050
+ update_option('payment_gateway_names', $payment_gateway_names);
2051
+ }
2052
+
2053
+ //exit('<pre>'.print_r($GLOBALS['nzshpcrt_gateways'],true).'</pre>');
2054
+
2055
+ foreach($GLOBALS['nzshpcrt_gateways'] as $gateway) {
2056
+ if($gateway['internalname'] == get_option('payment_gateway'))
2057
+ {
2058
+ if(isset($gateway['submit_function'])) {
2059
+ call_user_func_array($gateway['submit_function'], array());
2060
+ $changes_made = true;
2061
+ }
2062
+ }
2063
+ }
2064
+ if(($_POST['payment_gw'] != null)) {
2065
+ update_option('payment_gateway', $_POST['payment_gw']);
2066
+ }
2067
+ $sendback = wp_get_referer();
2068
+
2069
+ if ( isset($updated) ) {
2070
+ $sendback = add_query_arg('updated', $updated, $sendback);
2071
+ }
2072
+ if(isset($_SESSION['wpsc_settings_curr_page'])){
2073
+ $sendback = add_query_arg('page', 'wpsc-settings', $sendback);
2074
+ $sendback = add_query_arg('tab', $_SESSION['wpsc_settings_curr_page'], $sendback);
2075
+ }
2076
+ //sexit($sendback);
2077
+ wp_redirect($sendback);
2078
+ exit();
2079
+
2080
+ }
2081
+ if(isset($_REQUEST['wpsc_gateway_settings']) && ($_REQUEST['wpsc_gateway_settings'] == 'gateway_settings')) {
2082
+ add_action('admin_init', 'wpsc_gateway_settings');
2083
  }
2084
  function wpsc_check_form_options(){
2085
+ global $wpdb;
2086
 
2087
+ $id = $wpdb->escape($_POST['form_id']);
2088
+ $sql = 'SELECT `options` FROM `'.WPSC_TABLE_CHECKOUT_FORMS.'` WHERE `id`='.$id;
2089
+ $options = $wpdb->get_var($sql);
2090
+ if($options != ''){
2091
+ $options = unserialize($options);
2092
+ $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>";
2093
 
2094
+ foreach((array)$options as $key=>$value){
2095
+ $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_URL."/images/trash.gif' alt='".__('Delete', 'wpsc')."' title='".__('Delete', 'wpsc')."' /></a></td></tr>";
 
 
2096
 
2097
+ }
2098
+
2099
+ }else{
2100
+ $output = '';
2101
+ }
2102
+ exit($output);
2103
+ }
2104
+ if(isset($_REQUEST['wpsc_admin_action']) && ($_REQUEST['wpsc_admin_action']=='check_form_options')){
2105
+ add_action('admin_init','wpsc_check_form_options');
2106
  }
2107
 
2108
  //handles the editing and adding of new checkout fields
2109
  function wpsc_checkout_settings(){
2110
+ global $wpdb;
2111
+ $wpdb->show_errors = true;
2112
  if(isset($_POST['selected_form_set'])){
2113
+ $filter = $wpdb->escape($_POST['selected_form_set']);
2114
  }else{
2115
+ $filter = 0;
2116
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2117
 
2118
+ if($_POST['new_form_set'] != null) {
2119
+ $new_form_set = $wpdb->escape(stripslashes($_POST['new_form_set']));
2120
+ $form_set_key = sanitize_title($new_form_set);
2121
+ $checkout_sets = get_option('wpsc_checkout_form_sets');
2122
+
2123
+ $checkout_sets[$form_set_key] = $new_form_set;
2124
+ update_option('wpsc_checkout_form_sets', $checkout_sets);
2125
+ }
2126
+
2127
+ // Save checkout options
2128
+ if (!isset($_POST['wpsc_checkout_option_label'])) $_POST['wpsc_checkout_option_label'] = '';
2129
+
2130
+ if(is_array($_POST['wpsc_checkout_option_label'])){
2131
+ foreach($_POST['wpsc_checkout_option_label'] as $form_id=> $values){
2132
+ $options = array();
2133
+ foreach((array)$values as $key => $form_option){
2134
+ $options[$form_option] = $_POST['wpsc_checkout_option_value'][$form_id][$key];
2135
+ }
2136
+
2137
+ $options = serialize($options);
2138
+ $sql = "UPDATE `".WPSC_TABLE_CHECKOUT_FORMS."` SET `options`='".$options."' WHERE id=".$form_id;
2139
+ $wpdb->query($sql);
2140
+ }
2141
+ }
2142
+
2143
+
2144
+ if($_POST['form_name'] != null) {
2145
+ foreach($_POST['form_name'] as $form_id => $form_name) {
2146
+ $form_name = $wpdb->escape($form_name);
2147
+ $form_type = $wpdb->escape($_POST['form_type'][$form_id]);
2148
+ $form_mandatory = 0;
2149
+ if(isset($_POST['form_mandatory'][$form_id]) && ($_POST['form_mandatory'][$form_id] == 1)) { $form_mandatory = 1; }
2150
+ $form_display_log = 0;
2151
+ if(isset($_POST['form_display_log'][$form_id]) && ($_POST['form_display_log'][$form_id] == 1)) { $form_display_log = 1; }
2152
+ $unique_name = '';
2153
+ if($_POST['unique_names'][$form_id] != '-1'){ $unique_name = $_POST['unique_names'][$form_id]; }
2154
+ // $form_order = $_POST['form_order'][$form_id];
2155
+ $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 ;");
2156
+ //echo "UPDATE `".WPSC_TABLE_CHECKOUT_FORMS."` SET `name` = '$form_name', `type` = '$form_type', `mandatory` = '$form_mandatory', `display_log` = '$form_display_log',`unique_name`='".$unique_name."', `checkout_set`='".$filter."' WHERE `id` ='".$form_id."' LIMIT 1 ;";
2157
+
2158
+ //echo "<br />";
2159
+ }
2160
+ }
2161
+
2162
+ if(isset($_POST['new_form_name'])) {
2163
+ foreach($_POST['new_form_name'] as $form_id => $form_name) {
2164
+ $form_type = $_POST['new_form_type'][$form_id];
2165
+ $form_mandatory = 0;
2166
+ if($_POST['new_form_mandatory'][$form_id] == 1) { $form_mandatory = 1; }
2167
+ $form_display_log = 0;
2168
+ if(isset($_POST['new_form_display_log'][$form_id]) && $_POST['new_form_display_log'][$form_id] == 1) { $form_display_log = 1; }
2169
+ if($_POST['new_form_unique_name'][$form_id] != '-1') { $form_unique_name = $_POST['new_form_unique_name'][$form_id]; }
2170
+
2171
+ $max_order_sql = "SELECT MAX(`order`) AS `order` FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `active` = '1';";
2172
+
2173
+ if(isset($_POST['new_form_order'][$form_id]) && $_POST['new_form_order'][$form_id] != '') {
2174
+ $order_number = $_POST['new_form_order'][$form_id];
2175
+ } else {
2176
+ $max_order_sql = $wpdb->get_results($max_order_sql,ARRAY_A);
2177
+ $order_number = $max_order_sql[0]['order'] + 1;
2178
+ }
2179
+ $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."');");
2180
+ $added++;
2181
+ }
2182
+ }
2183
+
2184
+ if(isset($_POST['wpsc_options'])){
2185
+ foreach($_POST['wpsc_options'] as $key=>$value){
2186
+ if($value != get_option($key)){
2187
+ update_option($key, $value);
2188
+ $updated++;
2189
+ }
2190
+ }
2191
+ }
2192
+
2193
+ $sendback = wp_get_referer();
2194
+ if(isset($form_set_key)) {
2195
+ $sendback = add_query_arg('checkout-set', $form_set_key, $sendback);
2196
+ } else if(isset($_POST['wpsc_form_set'])){
2197
+ $filter = $_POST['wpsc_form_set'];
2198
+ $sendback = add_query_arg('checkout-set', $filter, $sendback);
2199
+ }
2200
+
2201
+ if ( isset($updated) ) {
2202
+ $sendback = add_query_arg('updated', $updated, $sendback);
2203
+ }
2204
+ if ( isset($added) ) {
2205
+ $sendback = add_query_arg('added', $added, $sendback);
2206
+ }
2207
+ if(isset($_SESSION['wpsc_settings_curr_page'])){
2208
+ $sendback = add_query_arg('tab', $_SESSION['wpsc_settings_curr_page'], $sendback);
2209
+ }
2210
+ $sendback = add_query_arg('page', 'wpsc-settings', $sendback);
2211
+ wp_redirect($sendback);
2212
+ exit();
2213
+ }
2214
+
2215
+
2216
+ if(isset($_REQUEST['wpsc_admin_action']) && ($_REQUEST['wpsc_admin_action'] == 'checkout_settings')) {
2217
+ add_action('admin_init', 'wpsc_checkout_settings');
2218
  }
2219
 
2220
 
2221
  function wpsc_google_shipping_settings(){
2222
+ if (isset($_POST['submit'])) {
2223
+ foreach((array)$_POST['google_shipping'] as $key=>$country) {
2224
+ if ($country == 'on') {
2225
+ $google_shipping_country[]=$key;
2226
+ $updated++;
2227
+ }
2228
+ }
2229
+ update_option('google_shipping_country',$google_shipping_country);
2230
+ $sendback = wp_get_referer();
2231
+ $sendback = remove_query_arg('googlecheckoutshipping', $sendback);
 
 
 
 
2232
 
2233
+ if ( isset($updated) ) {
2234
+ $sendback = add_query_arg('updated', $updated, $sendback);
2235
+ }
2236
+
2237
+ wp_redirect($sendback);
2238
+ exit();
2239
+ }
2240
  }
2241
 
2242
+ if(isset($_REQUEST['wpsc_admin_action']) && ($_REQUEST['wpsc_admin_action'] == 'google_shipping_settings')) {
2243
+ add_action('admin_init', 'wpsc_google_shipping_settings');
2244
  }
2245
 
2246
  //for ajax call of settings page tabs
2248
  global $wpdb;
2249
  $modified_page_title = $_POST['page_title'];
2250
  check_admin_referer($modified_page_title);
2251
+ $page_title = str_replace("tab-","",$modified_page_title);
2252
+
2253
+
2254
+ //require_once('includes/settings-pages/'.$functionname1.'.php');
2255
+ //$functionname = "wpsc_options_".$functionname1;
2256
+ //$html = $functionname();
2257
+ $html = "";
2258
+
2259
+ switch($page_title) {
2260
+ case "checkout";
2261
+ require_once('includes/settings-pages/checkout.php');
2262
+ wpsc_options_checkout();
2263
+ break;
2264
+ case "gateway";
2265
+ require_once('includes/settings-pages/gateway.php');
2266
+ wpsc_options_gateway();
2267
+ break;
2268
+ case "shipping";
2269
+ require_once('includes/settings-pages/shipping.php');
2270
+ wpsc_options_shipping();
2271
+ break;
2272
+ case "admin";
2273
+ require_once('includes/settings-pages/admin.php');
2274
+ wpsc_options_admin();
2275
+ break;
2276
+
2277
+ case "presentation";
2278
+ require_once('includes/settings-pages/presentation.php');
2279
+ wpsc_options_presentation();
2280
+ break;
2281
+
2282
+ case "taxes":
2283
+ wpec_taxes_settings_page(); //see wpec-taxes view
2284
+ break;
2285
+
2286
+ case "import";
2287
+ require_once('includes/settings-pages/import.php');
2288
+ wpsc_options_import();
2289
+ break;
2290
+
2291
+ default;
2292
+ case "general";
2293
+ require_once('includes/settings-pages/general.php');
2294
+ wpsc_options_general();
2295
+ break;
2296
+ }
2297
+
2298
+ $_SESSION['wpsc_settings_curr_page'] = $page_title;
2299
+ exit($html);
2300
+ }
2301
+
2302
+ if(isset($_REQUEST['wpsc_admin_action']) && ($_REQUEST['wpsc_admin_action'] == 'settings_page_ajax')) {
2303
+ add_action('admin_init', 'wpsc_settings_page_ajax');
2304
  }
2305
 
2306
 
2310
  wpsc_copy_themes_to_uploads();
2311
 
2312
  $_SESSION['wpsc_themes_copied'] = true;
2313
+ $sendback = wp_get_referer();
2314
+ $sendback = add_query_arg('tab', $_SESSION['wpsc_settings_curr_page'], remove_query_arg('tab', $sendback));
2315
+ wp_redirect($sendback);
2316
+ exit();
2317
  }
2318
 
2319
+ if(isset($_REQUEST['wpsc_admin_action']) && ($_REQUEST['wpsc_admin_action'] == 'copy_themes')) {
2320
+ add_action('admin_init', 'wpsc_trigger_copy_themes');
2321
  }
2322
 
2323
  function wpsc_mass_resize_thumbnails() {
2324
  global $wpdb;
2325
  check_admin_referer('mass_resize');
2326
 
2327
+ if(isset($_GET['wpsc_options'])){
2328
+ foreach($_GET['wpsc_options'] as $key=>$value){
2329
+ if(($value != get_option($key)) and (absint($value) > 0)){
2330
+ update_option($key, absint($value));
2331
+ }
2332
+ }
2333
+ }
2334
+
2335
+ $height = get_option('product_image_height');
2336
+ $width = get_option('product_image_width');
2337
+
2338
+ $product_data = $wpdb->get_results("SELECT `product`.`id`, `product`.`image` AS `image_id`, `images`.`image` AS `file` FROM `".WPSC_TABLE_PRODUCT_LIST."` AS `product` INNER JOIN `".WPSC_TABLE_PRODUCT_IMAGES."` AS `images` ON `product`.`image` = `images`.`id` WHERE `product`.`image` > 0 ",ARRAY_A);
2339
+ foreach((array)$product_data as $product) {
2340
+ $image_input = WPSC_IMAGE_DIR . $product['file'];
2341
+ $image_output = WPSC_THUMBNAIL_DIR . $product['file'];
2342
+ if(($product['file'] != '') and file_exists($image_input)) {
2343
+ image_processing($image_input, $image_output, $width, $height);
2344
+ update_product_meta($product['id'], 'thumbnail_width', $width);
2345
+ update_product_meta($product['id'], 'thumbnail_height', $height);
2346
+ } else {
2347
+ $wpdb->query("DELETE FROM `".WPSC_TABLE_PRODUCT_IMAGES."` WHERE `id` IN('{$product['image_id']}') LIMIT 1");
2348
+ $wpdb->query("UPDATE `".WPSC_TABLE_PRODUCT_LIST."` SET `image` = NULL WHERE `id` = '".$product['id']."' LIMIT 1");
2349
+ }
2350
+
2351
+ }
2352
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2353
  $_SESSION['wpsc_thumbnails_resized'] = true;
2354
+ $sendback = wp_get_referer();
2355
+ $sendback = add_query_arg('tab', $_SESSION['wpsc_settings_curr_page'], remove_query_arg('tab', $sendback));
2356
+ wp_redirect($sendback);
2357
+ exit();
2358
+ }
2359
+
2360
+ if(isset($_REQUEST['wpsc_admin_action']) && ($_REQUEST['wpsc_admin_action'] == 'mass_resize_thumbnails')) {
2361
+ add_action('admin_init', 'wpsc_mass_resize_thumbnails');
2362
  }
2363
+
2364
+
2365
+
2366
+ function wpsc_update_variations() {
2367
+ global $wpdb, $user_ID, $wp_query, $wpsc_products, $mode;
2368
 
2369
+ //Setup postdata
2370
+ $post_data = array();
2371
+ $post_data['edit_var_val'] = $_POST["edit_var_val"];
2372
+ $post_data['description'] = $_POST["description"];
2373
+ $post_data['additional_description'] = $_POST['additional_description'];
2374
+ $post_data['name'] = $_POST["name"];
2375
+ $product_id = absint($_POST["product_id"]);
2376
+
2377
+ //Add or delete variations
2378
+
2379
+ wpsc_edit_product_variations($product_id, $post_data);
2380
+
2381
+ // return admin table listing
2382
+ return wpsc_admin_product_listing($product_id);
2383
+ //return $post_data;
2384
+ }
2385
+
2386
+ if(isset($_REQUEST['wpsc_admin_action']) && ($_REQUEST['wpsc_admin_action'] == 'wpsc_update_variations')) {
2387
+ add_action('admin_init', 'wpsc_update_variations', 50);
2388
  }
2389
+
2390
 
2391
 
2392
 
2393
  function wpsc_delete_variation_set() {
2394
+ global $wpdb;
2395
+ check_admin_referer('delete-variation');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2396
 
2397
+ if(is_numeric($_GET['deleteid'])){
2398
+ $variation_id = absint($_GET['deleteid']);
2399
 
2400
+ $variation_set = get_term($variation_id, 'wpsc-variation', ARRAY_A);
2401
+
2402
+
2403
+ $variations = get_terms('wpsc-variation', array(
2404
+ 'hide_empty' => 0,
2405
+ 'parent' => $variation_id
2406
+ ));
2407
+
2408
+ foreach((array)$variations as $variation) {
2409
+ $return_value = wp_delete_term($variation->term_id, 'wpsc-variation');
2410
+ }
2411
+
2412
+ if(!empty($variation_set)) {
2413
+ $return_value = wp_delete_term($variation_set['term_id'], 'wpsc-variation');
2414
+ }
2415
+ //echo "<pre>".print_r($variation_set, true)."</pre>";
2416
+ //exit();
2417
+ $deleted = 1;
2418
+ }
2419
+
2420
+ $sendback = wp_get_referer();
2421
+ if ( isset($deleted) ) {
2422
+ $sendback = add_query_arg('deleted', $deleted, $sendback);
2423
+ }
2424
+ $sendback = remove_query_arg(array(
2425
+ 'deleteid',
2426
+ 'variation_id'
2427
+ ), $sendback);
2428
+
2429
+ wp_redirect($sendback);
2430
+ exit();
2431
  }
 
 
2432
 
2433
 
2434
+ function wpsc_delete_category() {
2435
+ global $wpdb, $wp_rewrite;
2436
+ check_admin_referer('delete-category');
2437
+
2438
+ if(is_numeric($_GET['deleteid'])){
2439
+ $category_id = absint($_GET['deleteid']);
2440
+ $taxonomy='wpsc_product_category';
2441
+ if($category_id > 0){
2442
+ wp_delete_term($category_id, $taxonomy);
2443
+ $wpdb->query("DELETE FROM `".WPSC_TABLE_META."` WHERE object_id = '".$category_id."' AND object_type = 'wpsc_category'");
2444
+ }
2445
+ update_option('wpsc_category_url_cache', array());
2446
+ $wp_rewrite->flush_rules();
2447
+
2448
+ $deleted = 1;
2449
+ }
2450
+
2451
+ $sendback = wp_get_referer();
2452
+ if ( isset($deleted) ) {
2453
+ $sendback = add_query_arg('deleted', $deleted, $sendback);
2454
+ }
2455
+ $sendback = remove_query_arg(array(
2456
+ 'deleteid',
2457
+ 'category_id'
2458
+ ), $sendback);
2459
+
2460
+ wp_redirect($sendback);
2461
+ exit();
2462
+ }
2463
 
2464
  //other actions are here
2465
+ if(isset($_GET['display_invoice']) && ($_GET['display_invoice']=='true')) {
2466
  add_action('admin_init', 'wpsc_display_invoice', 0);
2467
  }
2468
 
2469
+ if(isset($_REQUEST['wpsc_admin_action']) && ($_REQUEST['wpsc_admin_action'] == 'wpsc_add_image')) {
2470
+ add_action('admin_init','wpsc_swfupload_images');
 
 
2471
  }
2472
 
2473
+ if(isset($_REQUEST['wpsc_admin_action']) && ($_REQUEST['wpsc_admin_action'] == 'edit_product')) {
2474
+ add_action('admin_init', 'wpsc_admin_submit_product');
2475
  }
 
2476
 
2477
+
2478
+ if(isset($_GET['action']) && ($_GET['action'] == "purchase_log")) {
2479
+ add_action('admin_init', 'wpsc_admin_sale_rss');
2480
  }
2481
 
2482
 
2483
+ if(isset($_GET['purchase_log_csv']) && ($_GET['purchase_log_csv'] == "true")) {
2484
+ add_action('admin_init', 'wpsc_purchase_log_csv');
2485
  }
2486
 
2487
+ if(isset($_REQUEST['ajax']) && isset($_REQUEST['admin']) && ($_REQUEST['ajax'] == "true") && ($_REQUEST['admin'] == "true")) {
2488
+ add_action('admin_init', 'wpsc_admin_ajax');
2489
  }
2490
 
2491
  // Variation set deleting init code starts here
2492
+ if(isset($_REQUEST['wpsc_admin_action']) && ($_REQUEST['wpsc_admin_action'] == 'wpsc-delete-variation-set')) {
2493
+ add_action('admin_init', 'wpsc_delete_variation_set');
2494
  }
2495
 
2496
  // Variation set deleting init code starts here
2497
+ if(isset($_REQUEST['wpsc_admin_action']) && ($_REQUEST['wpsc_admin_action'] == 'wpsc-delete-category')) {
2498
+ add_action('admin_init', 'wpsc_delete_category');
2499
  }
2500
 
2501
  // Category modification init code starts here
2502
+ if(isset($_REQUEST['wpsc_admin_action']) && ($_REQUEST['wpsc_admin_action'] == 'wpsc-category-set')) {
2503
+ add_action('admin_init', 'wpsc_save_category_set');
2504
+ }
2505
+
2506
+ function flat_price($price) {
2507
+
2508
+ if (isset($price) && !empty($price) && strchr($price, '-') === false && strchr($price, '+') === false && strchr($price, '%') === false)
2509
+ return true;
2510
+ }
2511
+
2512
+ function percentile_price($price) {
2513
+ if(isset($price) && !empty($price) && ( strchr($price, '-') || strchr($price, '+') ) && strchr($price, '%') )
2514
+ return true;
2515
+ }
2516
+
2517
+ function differential_price($price) {
2518
+
2519
+ if (isset($price) && !empty($price) && ( strchr($price, '-') || strchr($price, '+') ) && strchr($price, '%') === false )
2520
+ return true;
2521
+
2522
+ }
2523
+
2524
+ add_action ( 'wpsc-variation_edit_form_fields', 'variation_price_field' );
2525
+ add_action ( 'wpsc-variation_edit_form_fields', 'variation_price_field_check' );
2526
+ add_action ( 'wpsc-variation_add_form_fields', 'variation_price_field' );
2527
+
2528
+ function variation_price_field( $variation ) {
2529
+
2530
+ //If it doesn't exist, let's create a multi-dimensional associative array that will contain all of the term/price associations
2531
+
2532
+ $term_prices = get_option( 'term_prices' );
2533
+ if(is_object($variation)) {
2534
+ $term_id = $variation->term_id;
2535
+ }
2536
+ if ( empty($term_prices) || !is_array($term_prices) ) {
2537
+
2538
+ $term_prices = array();
2539
+ if(isset($term_id)) {
2540
+ $term_prices[$term_id] = array();
2541
+ $term_prices[$term_id]["price"] = '';
2542
+ $term_prices[$term_id]["checked"] = '';
2543
+ }
2544
+ add_option('term_prices', $term_prices);
2545
+
2546
+ }
2547
+
2548
+ if ( isset($term_id) && is_array ( $term_prices ) && array_key_exists ( $term_id, $term_prices ) ) {
2549
+ $price = $term_prices[$term_id]["price"] ;
2550
+ } else {
2551
+ $price = '';
2552
+ }
2553
+
2554
+ ?>
2555
+
2556
+ <tr class="form-field">
2557
+ <th scope="row" valign="top"><label for="variation_price"><?php _e('Variation Price') ?></label></th>
2558
+ <td>
2559
+ <input type="text" name="variation_price" id="variation_price" style="width:50px;" value="<?php echo $price; ?>"><br />
2560
+ <span class="description">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%).</span>
2561
+ </div>
2562
+ </td>
2563
+ </tr>
2564
+ <?php
2565
+
2566
  }
2567
+
2568
+ function variation_price_field_check( $variation ) {
2569
+
2570
+ $term_prices = get_option( 'term_prices' );
2571
+
2572
+ if ( is_array ( $term_prices ) && array_key_exists ( $variation->term_id, $term_prices ) ) {
2573
+ $checked = ($term_prices[$variation->term_id]["checked"] == 'checked') ? 'checked' : '';
2574
+ } else {
2575
+ $checked = '';
2576
+ }
2577
+
2578
+ ?>
2579
+ <tr class="form-field">
2580
+ <th scope="row" valign="top"><label for="apply_to_current"><?php _e('Apply to current variations?') ?></label></th>
2581
+ <td>
2582
+ <span class="description"><input type="checkbox" name="apply_to_current" id="apply_to_current" style="width:2%;" <?php echo $checked; ?> />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.</span>
2583
+ </td>
2584
+ </tr>
2585
+ <?php
2586
+ }
2587
+
2588
+ add_action ( 'edited_wpsc-variation', 'save_term_prices');
2589
+ add_action ( 'created_wpsc-variation', 'save_term_prices');
2590
+
2591
+ function save_term_prices( $term_id ) {
2592
+
2593
+ // First - Saves options from input
2594
+ if ( isset( $_POST['variation_price'] ) || isset($_POST["apply_to_current"]) ) {
2595
+
2596
+ $term_prices = get_option( 'term_prices' );
2597
+
2598
+ $term_prices[$term_id]["price"] = $_POST["variation_price"];
2599
+ $term_prices[$term_id]["checked"] = (isset($_POST["apply_to_current"])) ? "checked" : "unchecked";
2600
+
2601
+ update_option( 'term_prices', $term_prices);
2602
+
2603
+ }
2604
+
2605
+ // 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
2606
+
2607
+ if ( isset( $_POST["apply_to_current"] ) ) {
2608
+
2609
+ //Check for flat, percentile or differential
2610
+ $var_price_type = '';
2611
+
2612
+ if (flat_price($_POST["variation_price"])) {
2613
+ $var_price_type = 'flat';
2614
+ } elseif ( differential_price($_POST["variation_price"]) ) {
2615
+ $var_price_type = 'differential';
2616
+ }elseif (percentile_price($_POST["variation_price"])) {
2617
+ $var_price_type = 'percentile';
2618
+ }
2619
+
2620
+ //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)
2621
+
2622
+ $products_to_mod = get_objects_in_term($term_id, "wpsc-variation");
2623
+
2624
+ $product_parents = array();
2625
+
2626
+ foreach ( (array) $products_to_mod as $get_parent ) {
2627
+
2628
+ $post = get_post($get_parent);
2629
+
2630
+ if (!$post->post_parent) {
2631
+ $product_parents[] = $post->ID;
2632
+ }
2633
+
2634
+ }
2635
+
2636
+ //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)
2637
+
2638
+ foreach($product_parents as $parent) {
2639
+ $args = array(
2640
+ 'post_parent' => $parent,
2641
+ 'post_type' => 'wpsc-product'
2642
+ );
2643
+ $children = get_children($args, ARRAY_A);
2644
+
2645
+ foreach($children as $childrens) {
2646
+ $parent = $childrens["post_parent"];
2647
+ $children_ids[$parent][] = $childrens["ID"];
2648
+ $children_ids[$parent] = array_intersect($children_ids[$parent], $products_to_mod);
2649
+ }
2650
+ }
2651
+
2652
+ //Got the right kids, let's grab their parent pricing and modify their pricing based on var_price_type
2653
+
2654
+ foreach ( (array) $children_ids as $parents => $kids) {
2655
+
2656
+ $kids = array_values($kids);
2657
+ $parent_pricing = get_product_meta($parents, "price", true);
2658
+
2659
+ foreach ($kids as $kiddos) {
2660
+
2661
+ $child_pricing = get_product_meta($kiddos, "price", true);
2662
+
2663
+ if ($var_price_type == 'flat') {
2664
+
2665
+ update_product_meta($kiddos, "price", floatval($_POST["variation_price"]));
2666
+
2667
+ } elseif ($var_price_type == 'percentile') {
2668
+
2669
+ //Are we decreasing or increasing the price?
2670
+
2671
+ if (strchr($_POST["variation_price"], '-') ) {
2672
+ $negative = true;
2673
+ } else {
2674
+ $positive = true;
2675
+ }
2676
+
2677
+ //Now, let's get the parent product price, +/- by the percentage given
2678
+ $percentage = (floatval($_POST["variation_price"]) / 100);
2679
+
2680
+ if ($positive) {
2681
+ $price = $parent_pricing + ($parent_pricing * $percentage);
2682
+ } elseif ($negative) {
2683
+ $price = $parent_pricing - ($parent_pricing * $percentage);
2684
+ }
2685
+
2686
+ update_product_meta($kiddos, "price", $price);
2687
+
2688
+ }elseif($var_price_type == 'differential') {
2689
+
2690
+ //Are we decreasing or increasing the price?
2691
+ if (strchr($_POST["variation_price"], '-') ) {
2692
+ $negative = true;
2693
+ } else {
2694
+ $positive = true;
2695
+ }
2696
+
2697
+ //Now, let's get the parent product price, +/- by the differential given
2698
+ $differential = (floatval($_POST["variation_price"]));
2699
+
2700
+ if ($positive) {
2701
+ $price = $parent_pricing + $differential;
2702
+ } elseif ($negative) {
2703
+ $price = $parent_pricing - $differential;
2704
+ }
2705
+
2706
+ update_product_meta($kiddos, "price", $price);
2707
+ }
2708
+ }
2709
+ }
2710
+
2711
+ //@todo - Should probably refactor this at some point - very procedural, WAY too many foreach loops for my liking :) But it does the trick
2712
+
2713
+ }
2714
+
2715
+ }
2716
  ?>
wpsc-admin/css/admin.css CHANGED
@@ -1320,15 +1320,16 @@ color: #D54E21;
1320
  }
1321
 
1322
  .multiple-select {
1323
- background:#FFFFFF none repeat scroll 0 0;
1324
- display:inline-block;
1325
- height:120px;
1326
- margin:0;
1327
- overflow-x:hidden;
1328
- overflow-y:auto;
1329
- padding:0;
1330
- position:relative;
1331
- width:250px;
 
1332
  }
1333
 
1334
  table.category_forms a.delete_button {
@@ -1813,5 +1814,13 @@ div.wpsc_clear {
1813
 
1814
  ul.wpsc_categories {
1815
  clear: both;
 
1816
 
 
 
 
 
 
 
 
1817
  }
1320
  }
1321
 
1322
  .multiple-select {
1323
+ background: white none repeat scroll 0px 0px;
1324
+ border: 1px solid #DFDFDF;
1325
+ display: inline-block;
1326
+ height: 120px;
1327
+ margin: 10px 0;
1328
+ overflow-x: hidden;
1329
+ overflow-y: auto;
1330
+ padding: 0px;
1331
+ position: relative;
1332
+ width:98%
1333
  }
1334
 
1335
  table.category_forms a.delete_button {
1814
 
1815
  ul.wpsc_categories {
1816
  clear: both;
1817
+ }
1818
 
1819
+ a.update_variations, a.update_variations_action
1820
+ {
1821
+ float:left;
1822
+ margin:10px;
1823
+ }
1824
+ a.update_variations_action {
1825
+ display:none;
1826
  }
wpsc-admin/display-coupons.php CHANGED
@@ -3,7 +3,7 @@ function wpsc_display_coupons_page(){
3
  global $wpdb;
4
  if(isset($_POST) && is_array($_POST) && !empty($_POST)) {
5
 
6
- if(isset($_POST['add_coupon']) && ($_POST['add_coupon'] == 'true')&& (!($_POST['is_edit_coupon'] == 'true'))) {
7
  $coupon_code = $_POST['add_coupon_code'];
8
  $discount = (double)$_POST['add_discount'];
9
  // cast to boolean, then integer, prevents the value from being anything but 1 or 0
@@ -36,15 +36,18 @@ function wpsc_display_coupons_page(){
36
  $coupon_data['expiry'] = $coupon_data['expiry']." 00:00:00";
37
  $check_values = $wpdb->get_row("SELECT `id`, `coupon_code`, `value`, `is-percentage`, `use-once`, `active`, `start`, `expiry` FROM `".WPSC_TABLE_COUPON_CODES."` WHERE `id` = '$coupon_id'", ARRAY_A);
38
  //sort both arrays to make sure that if they contain the same stuff, that they will compare to be the same, may not need to do this, but what the heck
39
-
40
- ksort($check_values); ksort($coupon_data);
41
- if($check_values != $coupon_data) {
 
 
 
42
  $insert_array = array();
43
  foreach($coupon_data as $coupon_key => $coupon_value) {
44
  if(($coupon_key == "submit_coupon") || ($coupon_key == "delete_coupon")) {
45
  continue;
46
  }
47
- if($coupon_value != $check_values[$coupon_key]) {
48
  $insert_array[] = "`$coupon_key` = '$coupon_value'";
49
  }
50
  }
@@ -79,7 +82,7 @@ function wpsc_display_coupons_page(){
79
 
80
  }
81
 
82
- if($coupon_data['delete_coupon'] != '') {
83
  $wpdb->query("DELETE FROM `".WPSC_TABLE_COUPON_CODES."` WHERE `id` = '$coupon_id' LIMIT 1;");
84
  }
85
  }
@@ -108,20 +111,20 @@ function wpsc_display_coupons_page(){
108
  $sql ="UPDATE `".WPSC_TABLE_COUPON_CODES."` SET `condition`='".serialize($conditions)."' WHERE `id` = '".(int)$_POST['coupon_id']."' LIMIT 1";
109
  $wpdb->query($sql);
110
  }
111
- if($_POST['change-settings'] == 'true') {
112
- if($_POST['wpsc_also_bought'] == 'on') {
113
  update_option('wpsc_also_bought', 1);
114
  } else {
115
  update_option('wpsc_also_bought', 0);
116
  }
117
 
118
- if($_POST['display_find_us'] == 'on') {
119
  update_option('display_find_us', 1);
120
  } else {
121
  update_option('display_find_us', 0);
122
  }
123
 
124
- if($_POST['wpsc_share_this'] == 'on') {
125
  update_option('wpsc_share_this', 1);
126
  } else {
127
  update_option('wpsc_share_this', 0);
3
  global $wpdb;
4
  if(isset($_POST) && is_array($_POST) && !empty($_POST)) {
5
 
6
+ if(isset($_POST['add_coupon']) && ($_POST['add_coupon'] == 'true')&& (!isset($_POST['is_edit_coupon']) || !($_POST['is_edit_coupon'] == 'true'))) {
7
  $coupon_code = $_POST['add_coupon_code'];
8
  $discount = (double)$_POST['add_discount'];
9
  // cast to boolean, then integer, prevents the value from being anything but 1 or 0
36
  $coupon_data['expiry'] = $coupon_data['expiry']." 00:00:00";
37
  $check_values = $wpdb->get_row("SELECT `id`, `coupon_code`, `value`, `is-percentage`, `use-once`, `active`, `start`, `expiry` FROM `".WPSC_TABLE_COUPON_CODES."` WHERE `id` = '$coupon_id'", ARRAY_A);
38
  //sort both arrays to make sure that if they contain the same stuff, that they will compare to be the same, may not need to do this, but what the heck
39
+
40
+ if($check_values != null)
41
+ ksort($check_values);
42
+ ksort($coupon_data);
43
+ if($check_values != $coupon_data)
44
+ {
45
  $insert_array = array();
46
  foreach($coupon_data as $coupon_key => $coupon_value) {
47
  if(($coupon_key == "submit_coupon") || ($coupon_key == "delete_coupon")) {
48
  continue;
49
  }
50
+ if(isset($check_values[$coupon_key]) && $coupon_value != $check_values[$coupon_key]) {
51
  $insert_array[] = "`$coupon_key` = '$coupon_value'";
52
  }
53
  }
82
 
83
  }
84
 
85
+ if(isset($coupon_data['delete_coupon']) && $coupon_data['delete_coupon'] != '') {
86
  $wpdb->query("DELETE FROM `".WPSC_TABLE_COUPON_CODES."` WHERE `id` = '$coupon_id' LIMIT 1;");
87
  }
88
  }
111
  $sql ="UPDATE `".WPSC_TABLE_COUPON_CODES."` SET `condition`='".serialize($conditions)."' WHERE `id` = '".(int)$_POST['coupon_id']."' LIMIT 1";
112
  $wpdb->query($sql);
113
  }
114
+ if(isset($_POST['change-settings']) && $_POST['change-settings'] == 'true') {
115
+ if(isset($_POST['wpsc_also_bought']) && $_POST['wpsc_also_bought'] == 'on') {
116
  update_option('wpsc_also_bought', 1);
117
  } else {
118
  update_option('wpsc_also_bought', 0);
119
  }
120
 
121
+ if(isset($_POST['display_find_us']) && $_POST['display_find_us'] == 'on') {
122
  update_option('display_find_us', 1);
123
  } else {
124
  update_option('display_find_us', 0);
125
  }
126
 
127
+ if(isset($_POST['wpsc_share_this']) && $_POST['wpsc_share_this'] == 'on') {
128
  update_option('wpsc_share_this', 1);
129
  } else {
130
  update_option('wpsc_share_this', 0);
wpsc-admin/display-groups.page.php CHANGED
@@ -1,444 +1,517 @@
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
-
12
- /**
13
- * wpsc_display_categories_page, assembles the category page
14
- * @param nothing
15
- * @return nothing
16
- */
17
-
18
- function wpsc_display_categories_page() {
19
- $columns = array(
20
- 'img' => __('Image', 'wpsc'),
21
- 'title' => __('Name', 'wpsc'),
22
- 'edit' => __('Edit', 'wpsc')
23
- );
24
- register_column_headers('display-categories-list', $columns);
25
-
26
- ?>
27
- <script language='javascript' type='text/javascript'>
28
- function conf() {
29
- var check = confirm("<?php echo __('Are you sure you want to delete this category?', 'wpsc');?>");
30
- if(check) {
31
- return true;
32
- } else {
33
- return false;
34
- }
35
- }
36
-
37
- <?php
38
-
39
- ?>
40
- </script><noscript>
41
- </noscript>
42
-
43
- <div class="wrap">
44
- <?php // screen_icon(); ?>
45
- <h2><?php echo wp_specialchars( __('Display categories', 'wpsc') ); ?> </h2>
46
- <p>
47
- <?php echo __('Categorizing your products into groups help your customers find them. '.
48
- 'For instance if you sell hats and trousers you might want to setup a Group called clothes and add hats and trousers to that group.', 'wpsc');?>
49
- </p>
50
- <?php if (isset($_GET['deleted']) || isset($_GET['message'])) { ?>
51
- <div id="message" class="updated fade">
52
- <p>
53
- <?php
54
- if (isset($_GET['deleted']) ) {
55
- _e("Thanks, the category has been deleted", 'wpsc');
56
- unset($_GET['deleted']);
57
- }
58
-
59
-
60
- if (isset($_GET['message']) ) {
61
- _e("Thanks, the category has been edited", 'wpsc');
62
- unset($_GET['message']);
63
- }
64
-
65
-
66
- $_SERVER['REQUEST_URI'] = remove_query_arg( array('deleted', 'message'), $_SERVER['REQUEST_URI'] );
67
- ?>
68
- </p>
69
- </div>
70
- <?php } ?>
71
-
72
- <div id="col-container" class=''>
73
- <div id="col-right">
74
- <div id='poststuff' class="col-wrap">
75
- <form id="modify-category-groups" method="post" action="" enctype="multipart/form-data" >
76
- <?php
77
- wpsc_admin_category_forms($_GET['category_id']);
78
- ?>
79
- </form>
80
- </div>
81
- </div>
82
-
83
- <div id="col-left">
84
- <div class="col-wrap">
85
- <?php
86
- wpsc_admin_category_group_list();
87
- ?>
88
- </div>
89
- </div>
90
- </div>
91
-
92
-
93
- </div>
94
- <?php
95
- }
96
-
97
-
98
- /**
99
- * wpsc_admin_category_group_list, prints the left hand side of the edit categories page
100
- * @param nothing
101
- * @return nothing
102
- */
103
-
104
-
105
- function wpsc_admin_category_group_list() {
106
- global $wpdb;
107
- ?>
108
- <table class="widefat page" id='wpsc_category_list' cellspacing="0">
109
- <thead>
110
- <tr>
111
- <?php print_column_headers('display-categories-list'); ?>
112
- </tr>
113
- </thead>
114
-
115
- <tfoot>
116
- <tr>
117
- <?php print_column_headers('display-categories-list', false); ?>
118
- </tr>
119
- </tfoot>
120
-
121
- <tbody>
122
- <?php
123
- wpsc_list_categories('wpsc_admin_display_category_row', null, 0);
124
- ?>
125
- </tbody>
126
- </table>
127
- <?php
128
- }
129
-
130
- /**
131
- * wpsc_admin_display_category_row, recursively displays category rows according to their parent categories
132
- * @param object - category data
133
- * @param integer - execution depth, default = 0
134
- * @return nothing
135
- */
136
-
137
- function wpsc_admin_display_category_row($category,$subcategory_level = 0) {
138
- //echo "<pre>".print_r($category,true)."</pre>";
139
- $category_image = wpsc_get_categorymeta($category->term_id, 'image');
140
- ?>
141
- <tr>
142
- <td colspan='3' class='colspan'>
143
- <table class="category-edit" id="category-<?php echo $category->term_id; ?>">
144
- <tr>
145
- <td class='manage-column column-img'>
146
- <?php if($subcategory_level > 0) { ?>
147
- <div class='category-image-container' style='margin-left: <?php echo (1*$subcategory_level) -1; ?>em;'>
148
- <img class='category_indenter' src='<?php echo WPSC_URL; ?>/images/indenter.gif' alt='' title='' />
149
- <?php } ?>
150
-
151
- <?php if($category_image !=null) { ?>
152
- <img src='<?php echo WPSC_CATEGORY_URL.$category_image; ?>' title='".$category->name; ?>' alt='".$category->name; ?>' width='30' height='30' />
153
- <?php } else { ?>
154
- <img src='<?php echo WPSC_URL; ?>/images/no-image-uploaded.gif' title='<?php echo $category->name; ?>' alt='<?php echo $category->name; ?>' width='30' height='30' />
155
- <?php } ?>
156
- <?php if($subcategory_level > 0) { ?>
157
- </div>
158
- <?php } ?>
159
- </td>
160
-
161
- <td class='manage-column column-title'>
162
- <?php echo htmlentities(stripslashes($category->name), ENT_QUOTES, 'UTF-8'); ?>
163
- </td>
164
-
165
- <td class='manage-column column-edit'>
166
- <a href='<?php echo add_query_arg('category_id', $category->term_id); ?>'><?php echo __('Edit', 'wpsc'); ?></a>
167
- </td>
168
- </tr>
169
- </table>
170
- </td>
171
- </tr>
172
- <?php
173
- }
174
-
175
- /*
176
- * wpsc_admin_category_group_list, prints the right hand side of the edit categories page
177
- * @param int $category_id the category ID
178
- * nothing returned
179
- */
180
- function wpsc_admin_category_forms($category_id = null) {
181
- global $wpdb;
182
- $category_value_count = 0;
183
- $category_name = '';
184
- if($category_id > 0 ) {
185
- $category_id = absint($category_id);
186
-
187
- $category = get_term($category_id, 'wpsc_product_category', ARRAY_A);
188
- $category['nice-name'] = wpsc_get_categorymeta($category['term_id'], 'nice-name');
189
- $category['description'] = wpsc_get_categorymeta($category['term_id'], 'description');
190
- $category['image'] = wpsc_get_categorymeta($category['term_id'], 'image');
191
- $category['fee'] = wpsc_get_categorymeta($category['term_id'], 'fee');
192
- $category['active'] = wpsc_get_categorymeta($category['term_id'], 'active');
193
- $category['order'] = wpsc_get_categorymeta($category['term_id'], 'order');
194
- }
195
-
196
- ?>
197
- <table class='category_forms'>
198
- <tr>
199
- <td>
200
- <?php echo __('Name', 'wpsc'); ?>:
201
- </td>
202
- <td>
203
- <input type='text' class="text" name='name' value='<?php echo $category['name']; ?>' />
204
- </td>
205
- </tr>
206
-
207
- <tr>
208
- <td><?php _e('Description', 'wpsc'); ?> </td>
209
- <td>
210
- <textarea name='description' cols='40' rows='8' ><?php echo stripslashes($category['description']); ?></textarea>
211
- </td>
212
- </tr>
213
- </tr>
214
-
215
- <tr>
216
- <td>
217
- <?php _e('Category Parent', 'wpsc'); ?>
218
- </td>
219
- <td>
220
- <?php
221
- $top_parent=$category;
222
- while(absint($top_parent['parent']>0)){
223
- $top_parent = get_term_by('id', $top_parent['parent'], 'wpsc_product_category', ARRAY_A);
224
- }
225
- wpsc_parent_category_list($top_parent['term_id'], $category['term_id'], $category['parent']);
226
- ?>
227
- </td>
228
- </tr>
229
-
230
-
231
- <tr>
232
- <td>
233
- <?php _e('Group&nbsp;Image', 'wpsc'); ?>
234
- </td>
235
- <td>
236
- <input type='file' name='image' value='' />
237
- </td>
238
- </tr>
239
- <?php
240
- if(function_exists("getimagesize")) {
241
- if($category['image'] != '') {
242
- $imagepath = WPSC_CATEGORY_DIR . $category['image'];
243
- $imagetype = @getimagesize($imagepath); //previously exif_imagetype()
244
- ?>
245
- <tr>
246
- <td>
247
- </td>
248
- <td>
249
- <?php _e('Height', 'wpsc'); ?>
250
- <input type='text' size='6' name='height' value='<?php echo $imagetype[1]; ?>' />
251
- <?php _e('Width', 'wpsc'); ?>
252
- <input type='text' size='6' name='width' value='<?php echo $imagetype[0]; ?>' />
253
- <br />
254
- <span class='wpscsmall description'><?php echo $nzshpcrt_imagesize_info; ?></span>
255
- <br />
256
- <span class='wpscsmall description'>
257
- <?php _e('You can upload thumbnail images for each group.'.
258
- 'To display Group details in your shop you must configure '.
259
- 'these settings under <a href="admin.php?page=wpsc-settings&tab=presentation">Presentation Settings</a>.', 'wpsc'); ?>
260
- </span>
261
- </td>
262
- </tr>
263
- <?php } else { ?>
264
- <tr>
265
- <td>
266
- </td>
267
- <td>
268
- <?php _e('Height', 'wpsc'); ?>
269
- <input type='text' size='6' name='height' value='<?php echo get_option('product_image_height'); ?>' />
270
- <?php _e('Width', 'wpsc'); ?>
271
- <input type='text' size='6' name='width' value='<?php echo get_option('product_image_width'); ?>' />
272
- <br />
273
- <span class='wpscsmall description'><?php echo $nzshpcrt_imagesize_info; ?></span>
274
- <br />
275
-
276
- <span class='wpscsmall description'>
277
- <?php _e('You can upload thumbnail images for each group.'.
278
- 'To display Group details in your shop you must configure '.
279
- 'these settings under <a href="admin.php?page=wpsc-settings&tab=presentation">Presentation Settings</a>.', 'wpsc'); ?>
280
- </span>
281
- </td>
282
- </tr>
283
- <?php
284
- }
285
- }
286
- ?>
287
- <tr>
288
- <td>
289
- <?php _e('Delete Image', 'wpsc'); ?>
290
- </td>
291
- <td>
292
- <input type='checkbox' name='deleteimage' value='1' />
293
- </td>
294
- </tr>
295
-
296
- <tr>
297
- <td colspan='2' class='category_presentation_settings'>
298
- <h4><?php _e('Presentation Settings', 'wpsc'); ?></h4>
299
- <span class='small'><?php _e('To over-ride the presentation settings for this group you can enter in your prefered settings here', 'wpsc'); ?></span>
300
- </td>
301
- </tr>
302
-
303
- <tr>
304
- <td>
305
- <?php _e('Catalog View', 'wpsc'); ?>
306
- </td>
307
- <td>
308
- <?php
309
- if ($category['display_type'] == 'grid') {
310
- $display_type1="selected='selected'";
311
- } else if ($category['display_type'] == 'default') {
312
- $display_type2="selected='selected'";
313
- }
314
-
315
- switch($category['display_type']) {
316
- case "default":
317
- $category_view1 = "selected ='selected'";
318
- break;
319
-
320
- case "grid":
321
- if(function_exists('product_display_grid')) {
322
- $category_view3 = "selected ='selected'";
323
- break;
324
- }
325
-
326
- case "list":
327
- if(function_exists('product_display_list')) {
328
- $category_view2 = "selected ='selected'";
329
- break;
330
- }
331
-
332
- default:
333
- $category_view0 = "selected ='selected'";
334
- break;
335
- }
336
- ?>
337
- <select name='display_type'>
338
- <option value=''<?php echo $category_view0; ?> ><?php _e('Please select', 'wpsc'); ?></option>
339
- <option value='default' <?php echo $category_view1; ?> ><?php _e('Default View', 'wpsc'); ?></option>
340
- <?php if(function_exists('product_display_list')) {?>
341
- <option value='list' <?php echo $category_view2; ?>><?php _e('List View', 'wpsc'); ?></option>
342
- <?php } else { ?>
343
- <option value='list' disabled='disabled' <?php echo $category_view2; ?>><?php _e('List View', 'wpsc'); ?></option>
344
- <?php } ?>
345
- <?php if(function_exists('product_display_grid')) { ?>
346
- <option value='grid' <?php echo $category_view3; ?>><?php _e('Grid View', 'wpsc'); ?></option>
347
- <?php } else { ?>
348
- <option value='grid' disabled='disabled' <?php echo $category_view3; ?>><?php _e('Grid View', 'wpsc'); ?></option>
349
- <?php } ?>
350
- </select>
351
- </td>
352
- </tr>
353
-
354
-
355
- <?php if(function_exists("getimagesize")) { ?>
356
- <tr>
357
- <td>
358
- <?php _e('Thumbnail&nbsp;Size', 'wpsc'); ?>
359
- </td>
360
- <td>
361
- <?php _e('Height', 'wpsc'); ?> <input type='text' value='<?php echo $category['image_height']; ?>' name='product_height' size='6'/>
362
- <?php _e('Width', 'wpsc'); ?> <input type='text' value='<?php echo $category['image_width']; ?>' name='product_width' size='6'/> <br/>
363
- </td>
364
- </tr>
365
- <?php } ?>
366
-
367
-
368
-
369
- <tr>
370
- <td colspan='2' class='category_presentation_settings'>
371
- <h4><?php _e('Checkout Settings', 'wpsc'); ?></h4>
372
-
373
- </td>
374
- </tr>
375
-
376
-
377
- <?php $used_additonal_form_set = wpsc_get_categorymeta($category['term_id'], 'use_additonal_form_set'); ?>
378
- <tr>
379
- <td>
380
- <?php _e("This category requires additional checkout form fields",'wpsc'); ?>
381
- </td>
382
- <td>
383
-
384
- <select name='use_additonal_form_set'>
385
- <option value=''><?php _e("None",'wpsc'); ?></option>
386
- <?php
387
- $checkout_sets = get_option('wpsc_checkout_form_sets');
388
- unset($checkout_sets[0]);
389
- foreach((array)$checkout_sets as $key => $value) {
390
- $selected_state = "";
391
- if($used_additonal_form_set == $key) {
392
- $selected_state = "selected='selected'";
393
- } ?>
394
- <option <?php echo $selected_state; ?> value='<?php echo $key; ?>'><?php echo stripslashes($value); ?></option>
395
- <?php
396
- }
397
- ?>
398
- </select>
399
- </td>
400
- </tr>
401
-
402
-
403
- <tr>
404
- <td colspan='2'> </td>
405
- </tr>
406
-
407
- <?php $uses_billing_address = (bool)wpsc_get_categorymeta($category['term_id'], 'uses_billing_address'); ?>
408
- <tr>
409
- <td>
410
- <?php _e("Products in this category use the billing address to calculate shipping",'wpsc'); ?>
411
- </td>
412
- <td>
413
- <label><input type='radio' value='1' name='uses_billing_address' <?php echo (($uses_billing_address == true) ? "checked='checked'" : ""); ?> /><?php _e("Yes",'wpsc'); ?></label>
414
- <label><input type='radio' value='0' name='uses_billing_address' <?php echo (($uses_billing_address != true) ? "checked='checked'" : ""); ?> /><?php _e("No",'wpsc'); ?></label>
415
- </td>
416
- </tr>
417
-
418
- <tr>
419
- <td>
420
- </td>
421
- <td>
422
- <?php wp_nonce_field('edit-category', 'wpsc-edit-category'); ?>
423
- <input type='hidden' name='wpsc_admin_action' value='wpsc-category-set' />
424
-
425
- <?php if($category_id > 0) { ?>
426
- <?php
427
- $nonced_url = wp_nonce_url("admin.php?wpsc_admin_action=wpsc-delete-category&amp;deleteid={$category_id}", 'delete-category');
428
- ?>
429
- <input type='hidden' name='category_id' value='<?php echo $category_id; ?>' />
430
- <input type='hidden' name='submit_action' value='edit' />
431
- <input class='button' style='float:left;' type='submit' name='submit' value='<?php echo __('Edit', 'wpsc'); ?>' />
432
- <a class='button delete_button' href='<?php echo $nonced_url; ?>' onclick="return conf();" ><?php echo __('Delete', 'wpsc'); ?></a>
433
- <?php } else { ?>
434
- <input type='hidden' name='submit_action' value='add' />
435
- <input class='button' type='submit' name='submit' value='<?php echo __('Add', 'wpsc');?>' />
436
- <?php } ?>
437
- </td>
438
- </tr>
439
- </table>
440
- <?php
441
- }
442
-
443
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
444
  ?>
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
+
12
+ /**
13
+ * wpsc_display_categories_page, assembles the category page
14
+ * @param nothing
15
+ * @return nothing
16
+ */
17
+
18
+ function wpsc_display_categories_page() {
19
+ $output = "";
20
+ $columns = array(
21
+ 'img' => __('Image', 'wpsc'),
22
+ 'title' => __('Name', 'wpsc'),
23
+ 'edit' => __('Edit', 'wpsc')
24
+ );
25
+ register_column_headers('display-categories-list', $columns);
26
+
27
+ ?>
28
+ <script language='javascript' type='text/javascript'>
29
+ function conf() {
30
+ var check = confirm("<?php echo __('Are you sure you want to delete this category?', 'wpsc');?>");
31
+ if(check) {
32
+ return true;
33
+ } else {
34
+ return false;
35
+ }
36
+ }
37
+
38
+ <?php
39
+
40
+ ?>
41
+ </script><noscript>
42
+ </noscript>
43
+
44
+ <div class="wrap">
45
+ <?php // screen_icon(); ?>
46
+ <h2><?php echo esc_html( __('Display categories', 'wpsc') ); ?> </h2>
47
+ <p>
48
+ <?php echo __('Categorizing your products into groups help your customers find them. '.
49
+ 'For instance if you sell hats and trousers you might want to setup a Group called clothes and add hats and trousers to that group.', 'wpsc');?>
50
+ </p>
51
+ <?php if (isset($_GET['deleted']) || isset($_GET['message'])) { ?>
52
+ <div id="message" class="updated fade">
53
+ <p>
54
+ <?php
55
+ if (isset($_GET['deleted']) ) {
56
+ _e("Thanks, the category has been deleted", 'wpsc');
57
+ unset($_GET['deleted']);
58
+ }
59
+
60
+
61
+ if (isset($_GET['message']) ) {
62
+ if ($_GET['message'] == 'empty_term_name')
63
+ _e("Please give a category name", 'wpsc');
64
+ else
65
+ _e("Thanks, the category has been edited", 'wpsc');
66
+
67
+ unset($_GET['message']);
68
+ }
69
+
70
+
71
+ $_SERVER['REQUEST_URI'] = remove_query_arg( array('deleted', 'message'), $_SERVER['REQUEST_URI'] );
72
+ ?>
73
+ </p>
74
+ </div>
75
+ <?php } ?>
76
+
77
+ <div id="col-container" class=''>
78
+ <div id="col-right" style="width:39%">
79
+ <div class="col-wrap">
80
+ <?php
81
+ wpsc_admin_category_group_list();
82
+ ?>
83
+ </div>
84
+ </div>
85
+
86
+ <div id="col-left" style="width:59%">
87
+ <div id='poststuff' class="col-wrap">
88
+ <?php if ( isset( $_GET["category_id"] ) ) {
89
+ ?>
90
+ <div class="postbox">
91
+ <?php
92
+ $product = get_term($_GET["category_id"], "wpsc_product_category" );
93
+
94
+ $output .= "<h3 class='hndle'>".str_replace("[categorisation]", htmlentities(stripslashes($product->name)), __('You are editing the &quot;[categorisation]&quot; Category', 'wpsc'))."</h3>\n\r";
95
+ $output .="<div class='inside'>\n\r";
96
+ $output .= "<div class='editing_this_group form_table'>";
97
+ $output .="<dl>\n\r";
98
+ $output .=" <dt>Display Category Shortcode: </dt>\n\r";
99
+ $output .=" <dd> [wpsc_products category_url_name='{$product->slug}']</dd>\n\r";
100
+ $output .=" <dt>Display Category Template Tag: </dt>\n\r";
101
+ $output .=" <dd> &lt;?php echo wpsc_display_products_page(array('category_url_name'=>'{$product->slug}')); ?&gt;</dd>\n\r";
102
+ $output .="</dl>\n\r";
103
+
104
+ $output .= "</div>";
105
+
106
+ echo $output;
107
+ } ?>
108
+ <form id="modify-category-groups" method="post" action="" enctype="multipart/form-data" >
109
+ <?php
110
+ $category_id = null;
111
+ if (isset($_GET['category_id']))
112
+ $category_id = $_GET['category_id'];
113
+ wpsc_admin_category_forms($category_id);
114
+ ?>
115
+ </form>
116
+ <?php if ( isset( $category_id ) ) { echo "</div>";} ?>
117
+ </div>
118
+ </div>
119
+ </div>
120
+ </div>
121
+
122
+
123
+ </div>
124
+ <?php
125
+ }
126
+
127
+
128
+ /**
129
+ * wpsc_admin_category_group_list, prints the left hand side of the edit categories page
130
+ * @param nothing
131
+ * @return nothing
132
+ */
133
+
134
+
135
+ function wpsc_admin_category_group_list() {
136
+ global $wpdb;
137
+ ?>
138
+ <table class="widefat page" id='wpsc_category_list' cellspacing="0">
139
+ <thead>
140
+ <tr>
141
+ <?php print_column_headers('display-categories-list'); ?>
142
+ </tr>
143
+ </thead>
144
+
145
+ <tfoot>
146
+ <tr>
147
+ <?php print_column_headers('display-categories-list', false); ?>
148
+ </tr>
149
+ </tfoot>
150
+
151
+ <tbody>
152
+ <?php
153
+ wpsc_list_categories('wpsc_admin_display_category_row', null, 0);
154
+ ?>
155
+ </tbody>
156
+ </table>
157
+ <?php
158
+ }
159
+
160
+ /**
161
+ * wpsc_admin_display_category_row, recursively displays category rows according to their parent categories
162
+ * @param object - category data
163
+ * @param integer - execution depth, default = 0
164
+ * @return nothing
165
+ */
166
+
167
+ function wpsc_admin_display_category_row($category,$subcategory_level = 0) {
168
+ //echo "<pre>".print_r($category,true)."</pre>";
169
+ $category_image = wpsc_get_categorymeta($category->term_id, 'image');
170
+ ?>
171
+ <tr>
172
+ <td colspan='3' class='colspan'>
173
+ <table class="category-edit" id="category-<?php echo $category->term_id; ?>">
174
+ <tr>
175
+ <td class='manage-column column-img'>
176
+ <?php if($subcategory_level > 0) { ?>
177
+ <div class='category-image-container' style='margin-left: <?php echo (1*$subcategory_level) -1; ?>em;'>
178
+ <img class='category_indenter' src='<?php echo WPSC_URL; ?>/images/indenter.gif' alt='' title='' />
179
+ <?php } ?>
180
+
181
+ <?php if($category_image !=null) { ?>
182
+ <img src='<?php echo WPSC_CATEGORY_URL.$category_image; ?>' title='".$category->name; ?>' alt='".$category->name; ?>' width='30' height='30' />
183
+ <?php } else { ?>
184
+ <img src='<?php echo WPSC_URL; ?>/images/no-image-uploaded.gif' title='<?php echo $category->name; ?>' alt='<?php echo $category->name; ?>' width='30' height='30' />
185
+ <?php } ?>
186
+ <?php if($subcategory_level > 0) { ?>
187
+ </div>
188
+ <?php } ?>
189
+ </td>
190
+
191
+ <td class='manage-column column-title'>
192
+ <?php echo htmlentities(stripslashes($category->name), ENT_QUOTES, 'UTF-8'); ?>
193
+ </td>
194
+
195
+ <td class='manage-column column-edit'>
196
+ <a href='<?php echo add_query_arg('category_id', $category->term_id); ?>'><?php echo __('Edit', 'wpsc'); ?></a>
197
+ </td>
198
+ </tr>
199
+ </table>
200
+ </td>
201
+ </tr>
202
+ <?php
203
+ }
204
+
205
+ /*
206
+ * wpsc_admin_category_group_list, prints the right hand side of the edit categories page
207
+ * @param int $category_id the category ID
208
+ * nothing returned
209
+ */
210
+ function wpsc_admin_category_forms($category_id = null) {
211
+ global $wpdb;
212
+ $category_value_count = 0;
213
+ $category_name = '';
214
+ if($category_id > 0 ) {
215
+ $category_id = absint($category_id);
216
+
217
+ $category = get_term($category_id, 'wpsc_product_category', ARRAY_A);
218
+ $category['nice-name'] = wpsc_get_categorymeta($category['term_id'], 'nice-name');
219
+ $category['description'] = wpsc_get_categorymeta($category['term_id'], 'description');
220
+ $category['image'] = wpsc_get_categorymeta($category['term_id'], 'image');
221
+ $category['fee'] = wpsc_get_categorymeta($category['term_id'], 'fee');
222
+ $category['active'] = wpsc_get_categorymeta($category['term_id'], 'active');
223
+ $category['order'] = wpsc_get_categorymeta($category['term_id'], 'order');
224
+ }
225
+
226
+ ?>
227
+ <table class='category_forms'>
228
+ <tr>
229
+ <td>
230
+ <?php echo __('Name', 'wpsc'); ?>:
231
+ </td>
232
+ <td>
233
+ <input type='text' class="text" name='name' value='<?php if(isset($category['name'])) echo $category['name']; ?>' />
234
+ </td>
235
+ </tr>
236
+
237
+ <tr>
238
+ <td><?php _e('Description', 'wpsc'); ?> </td>
239
+ <td>
240
+ <textarea name='description' cols='40' rows='8' ><?php if (isset($category['description'])) echo stripslashes($category['description']); ?></textarea>
241
+ </td>
242
+ </tr>
243
+ </tr>
244
+
245
+ <tr>
246
+ <td>
247
+ <?php _e('Category Parent', 'wpsc'); ?>
248
+ </td>
249
+ <td>
250
+ <?php
251
+ $taxonomies = array('wpsc_product_category');
252
+ $args = array('orderby'=>'name', 'hide_empty' => 0);
253
+ $select = wpsc_parent_category_list($taxonomies, $args);
254
+ echo $select;
255
+ ?>
256
+ </td>
257
+ </tr>
258
+
259
+
260
+ <tr>
261
+ <td>
262
+ <?php _e('Group&nbsp;Image', 'wpsc'); ?>
263
+ </td>
264
+ <td>
265
+ <input type='file' name='image' value='' />
266
+ </td>
267
+ </tr>
268
+ <?php
269
+ if(function_exists("getimagesize")) {
270
+ if(isset($category['image']) && ($category['image'] != '')) {
271
+ $imagepath = WPSC_CATEGORY_DIR . $category['image'];
272
+ $imagetype = @getimagesize($imagepath); //previously exif_imagetype()
273
+ ?>
274
+ <tr>
275
+ <td>
276
+ </td>
277
+ <td>
278
+ <?php _e('Height', 'wpsc'); ?>
279
+ <input type='text' size='6' name='height' value='<?php echo $imagetype[1]; ?>' />
280
+ <?php _e('Width', 'wpsc'); ?>
281
+ <input type='text' size='6' name='width' value='<?php echo $imagetype[0]; ?>' />
282
+ <br />
283
+ <span class='wpscsmall description'><?php echo $nzshpcrt_imagesize_info; ?></span>
284
+ <br />
285
+ <span class='wpscsmall description'>
286
+ <?php _e('You can upload thumbnail images for each group.'.
287
+ 'To display Group details in your shop you must configure '.
288
+ 'these settings under <a href="admin.php?page=wpsc-settings&tab=presentation">Presentation Settings</a>.', 'wpsc'); ?>
289
+ </span>
290
+ </td>
291
+ </tr>
292
+ <?php } else { ?>
293
+ <tr>
294
+ <td>
295
+ </td>
296
+ <td>
297
+ <?php _e('Height', 'wpsc'); ?>
298
+ <input type='text' size='6' name='height' value='<?php echo get_option('product_image_height'); ?>' />
299
+ <?php _e('Width', 'wpsc'); ?>
300
+ <input type='text' size='6' name='width' value='<?php echo get_option('product_image_width'); ?>' />
301
+ <br />
302
+ <span class='wpscsmall description'><?php if (isset($nzshpcrt_imagesize_info)) echo $nzshpcrt_imagesize_info; ?></span>
303
+ <br />
304
+
305
+ <span class='wpscsmall description'>
306
+ <?php _e('You can upload thumbnail images for each group.'.
307
+ 'To display Group details in your shop you must configure '.
308
+ 'these settings under <a href="admin.php?page=wpsc-settings&tab=presentation">Presentation Settings</a>.', 'wpsc'); ?>
309
+ </span>
310
+ </td>
311
+ </tr>
312
+ <?php
313
+ }
314
+ }
315
+ ?>
316
+ <tr>
317
+ <td>
318
+ <?php _e('Delete Image', 'wpsc'); ?>
319
+ </td>
320
+ <td>
321
+ <input type='checkbox' name='deleteimage' value='1' />
322
+ </td>
323
+ </tr>
324
+
325
+ </table>
326
+ <br />
327
+ <div class="postbox">
328
+ <h3 class="hndle"><?php _e('Target Market Restrictions'); ?></h3>
329
+ <div class="inside">
330
+ <?php
331
+
332
+ /* START OF TARGET MARKET SELECTION */
333
+ $category_id = '';
334
+ if (isset($_GET["category_id"])) $category_id = $_GET["category_id"];
335
+ $countrylist = $wpdb->get_results("SELECT id,country,visible FROM `".WPSC_TABLE_CURRENCY_LIST."` ORDER BY country ASC ",ARRAY_A);
336
+ $selectedCountries = $wpdb->get_col("SELECT countryid FROM `".WPSC_TABLE_CATEGORY_TM."` WHERE categoryid=".$category_id." AND visible= 1");
337
+ // exit('<pre>'.print_r($countrylist,true).'</pre><br /><pre>'.print_r($selectedCountries,true).'</pre>');
338
+ $output = '';
339
+ $output .= " <tr>\n\r";
340
+ $output .= " <td>\n\r";
341
+ $output .= __('Target Markets', 'wpsc').":\n\r";
342
+ $output .= " </td>\n\r";
343
+ $output .= " <td>\n\r";
344
+
345
+ if(@extension_loaded('suhosin')) {
346
+ $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.
347
+ ",'wpsc')."</em>";
348
+
349
+ } else {
350
+ $output .= "<span>Select: <a href='' class='wpsc_select_all'>All</a>&nbsp; <a href='' class='wpsc_select_none'>None</a></span><br />";
351
+ $output .= " <div id='resizeable' class='ui-widget-content multiple-select'>\n\r";
352
+ foreach($countrylist as $country){
353
+ if(in_array($country['id'], $selectedCountries))
354
+ /* if($country['visible'] == 1) */{
355
+ $output .= " <input type='checkbox' name='countrylist2[]' value='".$country['id']."' checked='".$country['visible']."' />".$country['country']."<br />\n\r";
356
+ }else{
357
+ $output .= " <input type='checkbox' name='countrylist2[]' value='".$country['id']."' />".$country['country']."<br />\n\r";
358
+ }
359
+
360
+ }
361
+ $output .= " </div><br /><br />";
362
+ $output .= " <span class='wpscsmall description'>Select the markets you are selling this category to.<span>\n\r";
363
+ }
364
+
365
+ $output .= " </td>\n\r";
366
+
367
+ $output .= " </tr>\n\r";
368
+ ////////
369
+ echo $output;
370
+ ?>
371
+ </div>
372
+ </div>
373
+ <div class="postbox">
374
+ <h3 class="hndle"><?php _e('Presentation Settings', 'wpsc'); ?></h3>
375
+ <div class="inside">
376
+ <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 />
377
+ <table class='category_forms'>
378
+ <tr>
379
+ <td>
380
+ <?php _e('Catalog View', 'wpsc'); ?>
381
+ </td>
382
+ <td>
383
+ <?php
384
+ if (!isset($category['display_type'])) $category['display_type'] = '';
385
+
386
+ if ($category['display_type'] == 'grid') {
387
+ $display_type1="selected='selected'";
388
+ } else if ($category['display_type'] == 'default') {
389
+ $display_type2="selected='selected'";
390
+ }
391
+
392
+ switch($category['display_type']) {
393
+ case "default":
394
+ $category_view1 = "selected ='selected'";
395
+ break;
396
+
397
+ case "grid":
398
+ if(function_exists('product_display_grid')) {
399
+ $category_view3 = "selected ='selected'";
400
+ break;
401
+ }
402
+
403
+ case "list":
404
+ if(function_exists('product_display_list')) {
405
+ $category_view2 = "selected ='selected'";
406
+ break;
407
+ }
408
+
409
+ default:
410
+ $category_view0 = "selected ='selected'";
411
+ break;
412
+ }
413
+ ?>
414
+ <select name='display_type'>
415
+ <option value=''<?php echo $category_view0; ?> ><?php _e('Please select', 'wpsc'); ?></option>
416
+ <option value='default' <?php if (isset($category_view1)) echo $category_view1; ?> ><?php _e('Default View', 'wpsc'); ?></option>
417
+ <?php if(function_exists('product_display_list')) {?>
418
+ <option value='list' <?php echo $category_view2; ?>><?php _e('List View', 'wpsc'); ?></option>
419
+ <?php } else { ?>
420
+ <option value='list' disabled='disabled' <?php if (isset($category_view2)) echo $category_view2; ?>><?php _e('List View', 'wpsc'); ?></option>
421
+ <?php } ?>
422
+ <?php if(function_exists('product_display_grid')) { ?>
423
+ <option value='grid' <?php if (isset($category_view3)) echo $category_view3; ?>><?php _e('Grid View', 'wpsc'); ?></option>
424
+ <?php } else { ?>
425
+ <option value='grid' disabled='disabled' <?php if (isset($category_view3)) echo $category_view3; ?>><?php _e('Grid View', 'wpsc'); ?></option>
426
+ <?php } ?>
427
+ </select> <br /><br />
428
+ </td>
429
+ </tr>
430
+
431
+
432
+ <?php if(function_exists("getimagesize")) { ?>
433
+ <tr>
434
+ <td>
435
+ <?php _e('Thumbnail&nbsp;Size', 'wpsc'); ?>
436
+ </td>
437
+ <td>
438
+ <?php _e('Height', 'wpsc'); ?> <input type='text' value='<?php if (isset($category['image_height'])) echo $category['image_height']; ?>' name='product_height' size='6'/>
439
+ <?php _e('Width', 'wpsc'); ?> <input type='text' value='<?php if (isset($category['image_width'])) echo $category['image_width']; ?>' name='product_width' size='6'/> <br/>
440
+ </td>
441
+ </tr>
442
+ <?php } ?>
443
+ </table>
444
+ </div>
445
+ </div>
446
+ <div class="postbox">
447
+ <h3 class="hndle"><?php _e('Checkout Settings', 'wpsc'); ?></h3>
448
+ <div class="inside">
449
+ <table class='category_forms'>
450
+ <?php
451
+ if (!isset($category['term_id'])) $category['term_id'] = '';
452
+ $used_additonal_form_set = wpsc_get_categorymeta($category['term_id'], 'use_additonal_form_set'); ?>
453
+ <tr>
454
+ <td>
455
+ <?php _e("This category requires additional checkout form fields",'wpsc'); ?>
456
+ </td>
457
+ <td>
458
+
459
+ <select name='use_additonal_form_set'>
460
+ <option value=''><?php _e("None",'wpsc'); ?></option>
461
+ <?php
462
+ $checkout_sets = get_option('wpsc_checkout_form_sets');
463
+ unset($checkout_sets[0]);
464
+ foreach((array)$checkout_sets as $key => $value) {
465
+ $selected_state = "";
466
+ if($used_additonal_form_set == $key) {
467
+ $selected_state = "selected='selected'";
468
+ } ?>
469
+ <option <?php echo $selected_state; ?> value='<?php echo $key; ?>'><?php echo stripslashes($value); ?></option>
470
+ <?php
471
+ }
472
+ ?>
473
+ </select>
474
+ </td>
475
+ </tr>
476
+
477
+ <?php $uses_billing_address = (bool)wpsc_get_categorymeta($category['term_id'], 'uses_billing_address'); ?>
478
+ <tr>
479
+ <td>
480
+ <?php _e("Products in this category use the billing address to calculate shipping",'wpsc'); ?>
481
+ </td>
482
+ <td>
483
+ <label><input type='radio' value='1' name='uses_billing_address' <?php echo (($uses_billing_address == true) ? "checked='checked'" : ""); ?> /><?php _e("Yes",'wpsc'); ?></label>
484
+ <label><input type='radio' value='0' name='uses_billing_address' <?php echo (($uses_billing_address != true) ? "checked='checked'" : ""); ?> /><?php _e("No",'wpsc'); ?></label>
485
+ </td>
486
+ </tr>
487
+
488
+ </table>
489
+ </div></div>
490
+ <table class="category_forms">
491
+ <tr>
492
+ <td>
493
+ </td>
494
+ <td>
495
+ <?php wp_nonce_field('edit-category', 'wpsc-edit-category'); ?>
496
+ <input type='hidden' name='wpsc_admin_action' value='wpsc-category-set' />
497
+
498
+ <?php if($category_id > 0) { ?>
499
+ <?php
500
+ $nonced_url = wp_nonce_url("admin.php?wpsc_admin_action=wpsc-delete-category&amp;deleteid={$category_id}", 'delete-category');
501
+ ?>
502
+ <input type='hidden' name='category_id' value='<?php echo $category_id; ?>' />
503
+ <input type='hidden' name='submit_action' value='edit' />
504
+ <input class='button-primary' style='float:left;' type='submit' name='submit' value='<?php echo __('Edit Category', 'wpsc'); ?>' />
505
+ <a class='delete_button' style="text-decoration:none;" href='<?php echo $nonced_url; ?>' onclick="return conf();" ><?php echo __('Delete', 'wpsc'); ?></a>
506
+ <?php } else { ?>
507
+ <input type='hidden' name='submit_action' value='add' />
508
+ <input class='button-primary' type='submit' name='submit' value='<?php echo __('Add Category', 'wpsc');?>' />
509
+ <?php } ?>
510
+ </td>
511
+ </tr>
512
+ </table>
513
+ <?php
514
+ }
515
+
516
+
517
  ?>
wpsc-admin/display-items.page.php CHANGED
@@ -24,7 +24,11 @@ function wpsc_image_downsize($id, $size) {
24
 
25
  function wpsc_display_edit_products_page() {
26
  global $wpdb, $wp_query, $wpsc_products;
27
- $category_id = absint($_GET['category_id']);
 
 
 
 
28
 
29
  $columns = array(
30
  'cb' => '<input type="checkbox" />',
@@ -35,8 +39,11 @@ function wpsc_display_edit_products_page() {
35
  'price' => 'Price',
36
  'sale_price' => 'Sale Price',
37
  'SKU' => 'SKU',
38
- 'categories' => 'Categories',
39
  );
 
 
 
40
  register_column_headers('display-product-list', $columns);
41
 
42
  $baseurl = includes_url('js/tinymce');
@@ -46,10 +53,10 @@ function wpsc_display_edit_products_page() {
46
  <?php // screen_icon(); ?>
47
  <div id="icon_card"><br /></div>
48
  <h2>
49
- <a href="admin.php?page=wpsc-edit-products" class="nav-tab nav-tab-active" id="manage"><?php echo wp_specialchars( __('Manage Products', 'wpsc') ); ?></a>
50
- <a href="<?php echo wp_nonce_url("admin.php?page=wpsc-edit-products&action=wpsc_add_edit", "_add_product"); ?>" class="nav-tab" id="add"><?php echo wp_specialchars( __('Add New', 'wpsc') ); ?></a>
51
  </h2>
52
- <?php if(isset($_GET['ErrMessage']) && is_array($_SESSION['product_error_messages'])){ ?>
53
  <div id="message" class="error fade">
54
  <p>
55
  <?php
@@ -66,13 +73,17 @@ function wpsc_display_edit_products_page() {
66
  <?php if (isset($_GET['published']) || isset($_GET['skipped']) || isset($_GET['updated']) || isset($_GET['deleted']) || isset($_GET['message']) || isset($_GET['duplicated']) ) { ?>
67
  <div id="message" class="updated fade">
68
  <p>
69
- <?php if ( isset($_GET['updated'])) {
70
- printf( __ngettext( '%s product updated.', '%s products updated.', $_GET['updated'] ), number_format_i18n( $_GET['updated'] ) );
 
 
 
 
71
  unset($_GET['updated']);
72
  }
73
 
74
  if ( isset($_GET['published'])) {
75
- printf( __ngettext( '%s product updated.', '%s products updated.', $_GET['published'] ), number_format_i18n( $_GET['published'] ) );
76
  unset($_GET['published']);
77
  }
78
 
@@ -82,17 +93,16 @@ function wpsc_display_edit_products_page() {
82
  }
83
 
84
  if ( isset($_GET['deleted'])) {
85
- printf( __ngettext( 'Product deleted.', '%s products deleted.', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) );
86
  unset($_GET['deleted']);
87
  }
88
-
89
- if ( isset($_GET['trashed'])) {
90
- printf( __ngettext( 'Product trashed.', '%s products deleted.', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) );
91
  unset($_GET['trashed']);
92
  }
93
 
94
  if ( isset($_GET['duplicated']) ) {
95
- printf( __ngettext( 'Product duplicated.', '%s products duplicated.', $_GET['duplicated'] ), number_format_i18n( $_GET['duplicated'] ) );
96
  unset($_GET['duplicated']);
97
  }
98
 
@@ -150,7 +160,7 @@ function wpsc_display_edit_products_page() {
150
 
151
  $('#doaction, #doaction2').click(function(){
152
  if ( $('select[name^="action"]').val() == 'delete' ) {
153
- var m = '<?php echo js_escape(__("You are about to delete the selected products.\n 'Cancel' to stop, 'OK' to delete.")); ?>';
154
  return showNotice.warn(m);
155
  }
156
  });
@@ -159,7 +169,9 @@ function wpsc_display_edit_products_page() {
159
  })(jQuery);
160
  /* ]]> */
161
  </script>
162
- <?php if ( $_GET["action"] != "wpsc_add_edit" ) { ?>
 
 
163
  <div id="wpsc-col-left">
164
  <div class="col-wrap">
165
  <?php
@@ -188,7 +200,9 @@ function wpsc_display_edit_products_page() {
188
  <div id="poststuff" class="metabox-holder<?php echo 2 == $screen_layout_columns ? ' has-right-sidebar' : ''; ?>">
189
  <form id="modify-products" method="post" action="" enctype="multipart/form-data" >
190
  <?php
191
- $product_id = absint($_GET['product']);
 
 
192
  wpsc_display_product_form($product_id);
193
  ?>
194
  </form>
@@ -210,8 +224,8 @@ function wpsc_display_edit_products_page() {
210
  function wpsc_edit_variations_request_sql($sql) {
211
  global $wpdb;
212
 
213
- if(is_numeric($_GET['parent_product'])) {
214
- $parent_product = absint($_GET['parent_product']);
215
  $product_term_data = wp_get_object_terms($parent_product, 'wpsc-variation');
216
 
217
  $parent_terms = array();
@@ -259,13 +273,14 @@ function wpsc_admin_products_list($category_id = 0) {
259
  global $wp_query, $wpdb, $_wp_column_headers;
260
  // set is_sortable to false to start with
261
  $is_sortable = false;
 
262
  $page = null;
263
  // 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.
264
  $itempp = 20;
265
 
266
  $num_products = $wpdb->get_var("SELECT COUNT(DISTINCT `products`.`id`) FROM $wpdb->posts AS `products` WHERE `products`.`post_type`= 'wpsc-product' AND `products`.`post_parent`= 0 $search_sql");
267
- if(is_numeric($_GET['parent_product'])) {
268
- $parent_product = absint($_GET['parent_product']);
269
  $num_products = $wpdb->get_var("SELECT COUNT(DISTINCT `products`.`id`) FROM $wpdb->posts AS `products` WHERE `products`.`post_type`= 'wpsc-product' AND `products`.`post_parent`= $parent_product $search_sql");
270
  }
271
 
@@ -274,53 +289,27 @@ function wpsc_admin_products_list($category_id = 0) {
274
  }
275
 
276
  $search_input = '';
277
- if($_GET['search']) {
278
  $search_input = stripslashes($_GET['search']);
279
 
280
  $search_string = "%".$wpdb->escape($search_input)."%";
281
 
282
  $search_sql = "AND (`products`.`name` LIKE '".$search_string."' OR `products`.`description` LIKE '".$search_string."')";
283
 
284
- } else {
 
 
285
  $search_sql = '';
286
  }
287
 
288
  $search_sql = apply_filters('wpsc_admin_products_list_search_sql', $search_sql);
289
 
290
- if($_GET['pageno'] > 0) {
291
  $page = absint($_GET['pageno']);
292
  } else {
293
  $page = 1;
294
  }
295
  $start = (int)($page * $itempp) - $itempp;
296
-
297
- if(is_numeric($_GET['parent_product'])) {
298
- $parent_product = absint($_GET['parent_product']);
299
-
300
- $query = array(
301
- 'post_type' => 'wpsc-product',
302
- 'posts_per_page' => $itempp,
303
- 'orderby' => 'menu_order post_title',
304
- 'post_parent' => $parent_product,
305
- 'post_status' => 'all',
306
- 'order' => "ASC",
307
- 'offset' => $start
308
- );
309
-
310
- $parent_product_data['post'] = get_post($parent_product);
311
- $args = array(
312
- 'post_type' => 'attachment',
313
- 'numberposts' => 1,
314
- 'post_status' => null,
315
- 'post_parent' => $parent_product,
316
- 'orderby' => 'menu_order',
317
- 'order' => 'ASC'
318
- );
319
- $image_data = (array)get_posts($args);
320
- $parent_product_data['image'] = array_shift($image_data);
321
-
322
- add_filter('posts_request', 'wpsc_edit_variations_request_sql');
323
- } else {
324
 
325
  $query = array(
326
  'post_type' => 'wpsc-product',
@@ -332,7 +321,7 @@ function wpsc_admin_products_list($category_id = 0) {
332
 
333
  if(isset($_GET['category'])) {
334
  $category_id = $_GET['category'];
335
- $query['products'] = $category_id;
336
  }
337
 
338
 
@@ -340,8 +329,6 @@ function wpsc_admin_products_list($category_id = 0) {
340
  $search = $_GET['search'];
341
  $query['s'] = $search;
342
  }
343
-
344
- }
345
 
346
  //$posts = get_posts( $query );
347
  //wp($query);
@@ -361,8 +348,6 @@ function wpsc_admin_products_list($category_id = 0) {
361
 
362
  $this_page_url = stripslashes($_SERVER['REQUEST_URI']);
363
 
364
-
365
-
366
  //$posts = get_object_taxonomies('wpsc-product');
367
 
368
  //echo "<pre>".print_r($posts, true)."</pre>";
@@ -432,6 +417,10 @@ function wpsc_admin_products_list($category_id = 0) {
432
 
433
  <tbody>
434
  <?php
 
 
 
 
435
  wpsc_admin_product_listing($parent_product_data);
436
  //echo "<pre>".print_r($wp_query, true)."</pre>";
437
  if(count($wp_query->posts) < 1) {
@@ -453,7 +442,9 @@ function wpsc_admin_products_list($category_id = 0) {
453
  function wpsc_admin_category_dropdown() {
454
  global $wpdb,$category_data;
455
  $siteurl = get_option('siteurl');
456
- $category_slug = $_GET['category'];
 
 
457
 
458
  $url = urlencode(remove_query_arg(array('product_id','category_id')));
459
 
@@ -482,6 +473,8 @@ function wpsc_admin_category_options($category, $subcategory_level = 0, $categor
482
  } else {
483
  if($category_slug == $category->slug) {
484
  $selected = "selected='selected'";
 
 
485
  }
486
  $output = "<option $selected value='{$category->slug}'>".str_repeat("-", $subcategory_level - 1).stripslashes($category->name)."</option>\n";
487
  }
24
 
25
  function wpsc_display_edit_products_page() {
26
  global $wpdb, $wp_query, $wpsc_products;
27
+
28
+
29
+ $category_id = 0;
30
+ if(isset($_GET['category_id']))
31
+ $category_id = absint($_GET['category_id']);
32
 
33
  $columns = array(
34
  'cb' => '<input type="checkbox" />',
39
  'price' => 'Price',
40
  'sale_price' => 'Sale Price',
41
  'SKU' => 'SKU',
42
+ 'categories' => 'Categories'
43
  );
44
+ if(isset($_GET["product"]) && $_GET["product"] != '') {
45
+ unset($columns["categories"]);
46
+ }
47
  register_column_headers('display-product-list', $columns);
48
 
49
  $baseurl = includes_url('js/tinymce');
53
  <?php // screen_icon(); ?>
54
  <div id="icon_card"><br /></div>
55
  <h2>
56
+ <a href="admin.php?page=wpsc-edit-products" class="nav-tab nav-tab-active" id="manage"><?php echo esc_html( __('Manage Products', 'wpsc') ); ?></a>
57
+ <a href="<?php echo wp_nonce_url("admin.php?page=wpsc-edit-products&action=wpsc_add_edit", "_add_product"); ?>" class="nav-tab" id="add"><?php echo (isset($_GET['product'])) ? __('Add New', 'wpsc') : __('Edit Product', 'wpsc') ; ?></a>
58
  </h2>
59
+ <?php if(isset($_GET['ErrMessage']) && isset($_SESSION['product_error_messages']) && is_array($_SESSION['product_error_messages'])){ ?>
60
  <div id="message" class="error fade">
61
  <p>
62
  <?php
73
  <?php if (isset($_GET['published']) || isset($_GET['skipped']) || isset($_GET['updated']) || isset($_GET['deleted']) || isset($_GET['message']) || isset($_GET['duplicated']) ) { ?>
74
  <div id="message" class="updated fade">
75
  <p>
76
+ <?php
77
+
78
+ if(!isset($_GET['deleted'])) $_GET['deleted'] = 0.00;
79
+
80
+ if ( isset($_GET['updated'])) {
81
+ printf( _n( '%s product updated.', '%s products updated.', $_GET['updated'] ), number_format_i18n( $_GET['updated'] ) );
82
  unset($_GET['updated']);
83
  }
84
 
85
  if ( isset($_GET['published'])) {
86
+ printf( _n( '%s product updated.', '%s products updated.', $_GET['published'] ), number_format_i18n( $_GET['published'] ) );
87
  unset($_GET['published']);
88
  }
89
 
93
  }
94
 
95
  if ( isset($_GET['deleted'])) {
96
+ printf( _n( 'Product deleted.', '%s products deleted.', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) );
97
  unset($_GET['deleted']);
98
  }
99
+ if ( isset($_GET['trashed']) && isset( $_GET['deleted'])) {
100
+ printf( _n( 'Product trashed.', '%s products deleted.', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) );
 
101
  unset($_GET['trashed']);
102
  }
103
 
104
  if ( isset($_GET['duplicated']) ) {
105
+ printf( _n( 'Product duplicated.', '%s products duplicated.', $_GET['duplicated'] ), number_format_i18n( $_GET['duplicated'] ) );
106
  unset($_GET['duplicated']);
107
  }
108
 
160
 
161
  $('#doaction, #doaction2').click(function(){
162
  if ( $('select[name^="action"]').val() == 'delete' ) {
163
+ var m = '<?php echo esc_js(__("You are about to delete the selected products.\n 'Cancel' to stop, 'OK' to delete.")); ?>';
164
  return showNotice.warn(m);
165
  }
166
  });
169
  })(jQuery);
170
  /* ]]> */
171
  </script>
172
+ <?php
173
+ if(!isset($_GET["action"])) $_GET["action"] = '';
174
+ if (($_GET["action"] != "wpsc_add_edit" )) { ?>
175
  <div id="wpsc-col-left">
176
  <div class="col-wrap">
177
  <?php
200
  <div id="poststuff" class="metabox-holder<?php echo 2 == $screen_layout_columns ? ' has-right-sidebar' : ''; ?>">
201
  <form id="modify-products" method="post" action="" enctype="multipart/form-data" >
202
  <?php
203
+ $product_id = 0;
204
+ if(isset($_GET['product']))
205
+ $product_id = absint($_GET['product']);
206
  wpsc_display_product_form($product_id);
207
  ?>
208
  </form>
224
  function wpsc_edit_variations_request_sql($sql) {
225
  global $wpdb;
226
 
227
+ if(is_numeric($_GET['product'])) {
228
+ $parent_product = absint($_GET['product']);
229
  $product_term_data = wp_get_object_terms($parent_product, 'wpsc-variation');
230
 
231
  $parent_terms = array();
273
  global $wp_query, $wpdb, $_wp_column_headers;
274
  // set is_sortable to false to start with
275
  $is_sortable = false;
276
+ $search_sql = '';
277
  $page = null;
278
  // 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.
279
  $itempp = 20;
280
 
281
  $num_products = $wpdb->get_var("SELECT COUNT(DISTINCT `products`.`id`) FROM $wpdb->posts AS `products` WHERE `products`.`post_type`= 'wpsc-product' AND `products`.`post_parent`= 0 $search_sql");
282
+ if(isset($_GET['product']) && (is_numeric($_GET['product']))) {
283
+ $parent_product = absint($_GET['product']);
284
  $num_products = $wpdb->get_var("SELECT COUNT(DISTINCT `products`.`id`) FROM $wpdb->posts AS `products` WHERE `products`.`post_type`= 'wpsc-product' AND `products`.`post_parent`= $parent_product $search_sql");
285
  }
286
 
289
  }
290
 
291
  $search_input = '';
292
+ if(isset($_GET['search'])) {
293
  $search_input = stripslashes($_GET['search']);
294
 
295
  $search_string = "%".$wpdb->escape($search_input)."%";
296
 
297
  $search_sql = "AND (`products`.`name` LIKE '".$search_string."' OR `products`.`description` LIKE '".$search_string."')";
298
 
299
+ }
300
+ else
301
+ {
302
  $search_sql = '';
303
  }
304
 
305
  $search_sql = apply_filters('wpsc_admin_products_list_search_sql', $search_sql);
306
 
307
+ if(isset($_GET['pageno']) && ($_GET['pageno'] > 0)) {
308
  $page = absint($_GET['pageno']);
309
  } else {
310
  $page = 1;
311
  }
312
  $start = (int)($page * $itempp) - $itempp;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
313
 
314
  $query = array(
315
  'post_type' => 'wpsc-product',
321
 
322
  if(isset($_GET['category'])) {
323
  $category_id = $_GET['category'];
324
+ $query['wpsc_product_category'] = $category_id;
325
  }
326
 
327
 
329
  $search = $_GET['search'];
330
  $query['s'] = $search;
331
  }
 
 
332
 
333
  //$posts = get_posts( $query );
334
  //wp($query);
348
 
349
  $this_page_url = stripslashes($_SERVER['REQUEST_URI']);
350
 
 
 
351
  //$posts = get_object_taxonomies('wpsc-product');
352
 
353
  //echo "<pre>".print_r($posts, true)."</pre>";
417
 
418
  <tbody>
419
  <?php
420
+
421
+ if(!isset($parent_product_data))
422
+ $parent_product_data = null;
423
+
424
  wpsc_admin_product_listing($parent_product_data);
425
  //echo "<pre>".print_r($wp_query, true)."</pre>";
426
  if(count($wp_query->posts) < 1) {
442
  function wpsc_admin_category_dropdown() {
443
  global $wpdb,$category_data;
444
  $siteurl = get_option('siteurl');
445
+ $category_slug =0;
446
+ if(isset($_GET['category']))
447
+ $category_slug = $_GET['category'];
448
 
449
  $url = urlencode(remove_query_arg(array('product_id','category_id')));
450
 
473
  } else {
474
  if($category_slug == $category->slug) {
475
  $selected = "selected='selected'";
476
+ }else {
477
+ $selected = '';
478
  }
479
  $output = "<option $selected value='{$category->slug}'>".str_repeat("-", $subcategory_level - 1).stripslashes($category->name)."</option>\n";
480
  }
wpsc-admin/display-options-settings.page.php CHANGED
@@ -4,21 +4,25 @@
4
  */
5
 
6
  // clear the previously selected shipping form session variable if you are not on the shipping page
7
- if($_GET['tab'] != 'shipping') {
8
- $_SESSION['previous_shipping_name'] = '';
9
- }
10
-
11
-
 
12
  function wpsc_display_settings_page(){
13
  ?>
14
  <div id="wpsc_options" class="wrap">
15
  <?php wpsc_the_settings_tabs();
 
16
  if(isset($_GET['tab'])){
17
  $page = $_GET['tab'];
18
  }else{
19
  $page = 'general';
20
  }
21
 
 
 
22
  if(preg_match("/[a-zA-Z]{2,4}/",$_GET['isocode'])) {
23
  include(WPSC_FILE_PATH.'/tax_and_shipping.php');
24
  return;
@@ -32,7 +36,7 @@ if (isset($_GET['googlecheckoutshipping'])) {
32
  if(isset($_GET['selected_all'])){
33
  wpsc_submit_options($_GET['selected_all']);
34
  }
35
- if($_SESSION['wpsc_thumbnails_resized'] == true) {
36
  ?>
37
  <div class="updated fade below-h2" id="message" style="background-color: rgb(255, 251, 204);">
38
  <p><?php _e("Thanks, your thumbnail images have been resized."); ?></p>
@@ -68,8 +72,7 @@ switch($page) {
68
  break;
69
 
70
  case "taxes":
71
- require_once('includes/settings-pages/taxes.php');
72
- wpsc_options_taxes();
73
  break;
74
 
75
  case "import";
@@ -83,6 +86,7 @@ switch($page) {
83
  wpsc_options_general();
84
  break;
85
  }
 
86
  $_SESSION['wpsc_settings_curr_page'] = $page;
87
  ?>
88
  </div>
@@ -101,7 +105,7 @@ function wpsc_settings_tabs() {
101
  'general' => __('General', 'wpsc'), // handler action suffix => tab text
102
  'presentation' => __('Presentation', 'wpsc'),
103
  'admin' => __('Admin', 'wpsc'),
104
- 'taxes' => __('Taxes','wpsc'),
105
  'shipping' => __('Shipping', 'wpsc'),
106
  'gateway' => __('Payments', 'wpsc'),
107
  'checkout' => __('Checkout', 'wpsc'),
@@ -114,7 +118,7 @@ function wpsc_settings_tabs() {
114
  * Display settings tabs
115
  */
116
  function wpsc_the_settings_tabs(){
117
- global $redir_tab;
118
  $tabs = wpsc_settings_tabs();
119
 
120
  if ( !empty($tabs) ) {
@@ -136,8 +140,8 @@ global $redir_tab;
136
  $href = add_query_arg(array('tab'=>$callback, 's'=>false, 'paged'=>false, 'post_mime_type'=>false, 'm'=>false));
137
  $href = remove_query_arg('isocode', $href);
138
  $href = wp_nonce_url($href, "tab-$callback");
139
- $link = "<a href='" . clean_url($href) . "'$class>$text</a>";
140
- echo "\t<li id='" . attribute_escape("tab-$callback") . "'>$link</li>\n";
141
  }
142
  //echo "<li id='tab-spacer' ><a href='' alt='' style='width:33.4%;float:right;'>&nbsp;</a></li>";
143
  echo "</ul>\n";
@@ -163,8 +167,6 @@ function country_list($selected_country = null) {
163
  return $output;
164
  }
165
 
166
-
167
-
168
  /*
169
  * Get Shipping Form for wp-admin
170
  */
@@ -186,20 +188,20 @@ function wpsc_settings_page_update_notification(){
186
  if (isset($_GET['skipped']) || isset($_GET['updated']) || isset($_GET['deleted']) || isset($_GET['shipadd']) ) { ?>
187
  <div id="message" class="updated fade"><p>
188
  <?php if ( isset($_GET['updated']) && (int) $_GET['updated'] ) {
189
- printf( __ngettext( ' Setting Options Updated. ' , ' %s Settings Options Updated. ', $_GET['updated'] ), number_format_i18n( $_GET['updated'] ) );
190
  unset($_GET['updated']);
191
  }
192
 
193
  if ( isset($_GET['deleted']) && (int) $_GET['deleted'] ) {
194
- printf( __ngettext( '%s Setting Option deleted. ', '%s Setting Option deleted. ', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) );
195
  unset($_GET['deleted']);
196
  }
197
  if ( isset($_GET['shipadd']) && (int) $_GET['shipadd'] ) {
198
- printf( __ngettext( ' Shipping Option Updated.', ' Shipping Option Updated.', $_GET['shipadd'] ), number_format_i18n( $_GET['shipadd'] ) );
199
  unset($_GET['shipadd']);
200
  }
201
  if ( isset($_GET['added']) && (int) $_GET['added'] ) {
202
- printf( __ngettext( '%s Checkout Field Added.', '%s Checkout Fields Added.', $_GET['added'] ), number_format_i18n( $_GET['added'] ) );
203
  unset($_GET['added']);
204
  }
205
 
@@ -212,4 +214,4 @@ if (isset($_GET['skipped']) || isset($_GET['updated']) || isset($_GET['deleted']
212
  }
213
  }
214
 
215
- ?>
4
  */
5
 
6
  // clear the previously selected shipping form session variable if you are not on the shipping page
7
+
8
+ if((!isset($_GET['tab']) || $_GET['tab'] != 'shipping') ) {
9
+ $_SESSION['previous_shipping_name'] = '';
10
+ }
11
+
12
+
13
  function wpsc_display_settings_page(){
14
  ?>
15
  <div id="wpsc_options" class="wrap">
16
  <?php wpsc_the_settings_tabs();
17
+
18
  if(isset($_GET['tab'])){
19
  $page = $_GET['tab'];
20
  }else{
21
  $page = 'general';
22
  }
23
 
24
+ if (!isset($_GET['isocode'])) $_GET['isocode'] = '';
25
+
26
  if(preg_match("/[a-zA-Z]{2,4}/",$_GET['isocode'])) {
27
  include(WPSC_FILE_PATH.'/tax_and_shipping.php');
28
  return;
36
  if(isset($_GET['selected_all'])){
37
  wpsc_submit_options($_GET['selected_all']);
38
  }
39
+ if(isset($_SESSION['wpsc_thumbnails_resized']) && ($_SESSION['wpsc_thumbnails_resized'] == true)) {
40
  ?>
41
  <div class="updated fade below-h2" id="message" style="background-color: rgb(255, 251, 204);">
42
  <p><?php _e("Thanks, your thumbnail images have been resized."); ?></p>
72
  break;
73
 
74
  case "taxes":
75
+ wpec_taxes_settings_page(); //see wpec-taxes view
 
76
  break;
77
 
78
  case "import";
86
  wpsc_options_general();
87
  break;
88
  }
89
+
90
  $_SESSION['wpsc_settings_curr_page'] = $page;
91
  ?>
92
  </div>
105
  'general' => __('General', 'wpsc'), // handler action suffix => tab text
106
  'presentation' => __('Presentation', 'wpsc'),
107
  'admin' => __('Admin', 'wpsc'),
108
+ 'taxes' => __('Taxes','wpsc'), //perhaps add with filter in the future
109
  'shipping' => __('Shipping', 'wpsc'),
110
  'gateway' => __('Payments', 'wpsc'),
111
  'checkout' => __('Checkout', 'wpsc'),
118
  * Display settings tabs
119
  */
120
  function wpsc_the_settings_tabs(){
121
+ global $redir_tab;
122
  $tabs = wpsc_settings_tabs();
123
 
124
  if ( !empty($tabs) ) {
140
  $href = add_query_arg(array('tab'=>$callback, 's'=>false, 'paged'=>false, 'post_mime_type'=>false, 'm'=>false));
141
  $href = remove_query_arg('isocode', $href);
142
  $href = wp_nonce_url($href, "tab-$callback");
143
+ $link = "<a href='" . esc_url($href) . "'$class>$text</a>";
144
+ echo "\t<li id='" . esc_attr("tab-$callback") . "'>$link</li>\n";
145
  }
146
  //echo "<li id='tab-spacer' ><a href='' alt='' style='width:33.4%;float:right;'>&nbsp;</a></li>";
147
  echo "</ul>\n";
167
  return $output;
168
  }
169
 
 
 
170
  /*
171
  * Get Shipping Form for wp-admin
172
  */
188
  if (isset($_GET['skipped']) || isset($_GET['updated']) || isset($_GET['deleted']) || isset($_GET['shipadd']) ) { ?>
189
  <div id="message" class="updated fade"><p>
190
  <?php if ( isset($_GET['updated']) && (int) $_GET['updated'] ) {
191
+ printf( _n( ' Setting Options Updated. ' , ' %s Settings Options Updated. ', $_GET['updated'] ), number_format_i18n( $_GET['updated'] ) );
192
  unset($_GET['updated']);
193
  }
194
 
195
  if ( isset($_GET['deleted']) && (int) $_GET['deleted'] ) {
196
+ printf( _n( '%s Setting Option deleted. ', '%s Setting Option deleted. ', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) );
197
  unset($_GET['deleted']);
198
  }
199
  if ( isset($_GET['shipadd']) && (int) $_GET['shipadd'] ) {
200
+ printf( _n( ' Shipping Option Updated.', ' Shipping Option Updated.', $_GET['shipadd'] ), number_format_i18n( $_GET['shipadd'] ) );
201
  unset($_GET['shipadd']);
202
  }
203
  if ( isset($_GET['added']) && (int) $_GET['added'] ) {
204
+ printf( _n( '%s Checkout Field Added.', '%s Checkout Fields Added.', $_GET['added'] ), number_format_i18n( $_GET['added'] ) );
205
  unset($_GET['added']);
206
  }
207
 
214
  }
215
  }
216
 
217
+ ?>
wpsc-admin/display-sales-logs.php CHANGED
@@ -11,7 +11,11 @@ if(!isset($purchlogs)){
11
  $purchlogs = new wpsc_purchaselogs();
12
  }
13
  function wpsc_display_sales_logs() {
14
- $subpage = $_GET['subpage'];
 
 
 
 
15
  switch($subpage) {
16
  case 'upgrade-purchase-logs':
17
  wpsc_upgrade_purchase_logs();
@@ -21,13 +25,13 @@ if(!isset($purchlogs)){
21
  wpsc_display_sales_log_index();
22
  break;
23
  }
24
- }
25
 
26
  function wpsc_display_sales_log_index() {
27
  ?>
28
  <div class="wrap">
29
  <?php //screen_icon(); ?>
30
- <h2><?php echo wp_specialchars( __('Sales', 'wpsc') ); ?> </h2>
31
  <?php //START OF PURCHASE LOG DEFAULT VIEW ?>
32
  <?php
33
  if(isset($_GET['view_purchlogs_by']) || isset($_GET['view_purchlogs_by_status'])) {
@@ -52,7 +56,7 @@ if(!isset($purchlogs)){
52
  if (isset($_GET['skipped']) || isset($_GET['updated']) || isset($_GET['deleted']) || isset($_GET['locked']) ) { ?>
53
  <div id="message" class="updated fade"><p>
54
  <?php if ( isset($_GET['updated']) && (int) $_GET['updated'] ) {
55
- printf( __ngettext( '%s Purchase Log updated.', '%s Purchase Logs updated.', $_GET['updated'] ), number_format_i18n( $_GET['updated'] ) );
56
  unset($_GET['updated']);
57
  }
58
 
@@ -60,12 +64,12 @@ if(!isset($purchlogs)){
60
  unset($_GET['skipped']);
61
 
62
  if ( isset($_GET['locked']) && (int) $_GET['locked'] ) {
63
- printf( __ngettext( '%s product not updated, somebody is editing it.', '%s products not updated, somebody is editing them.', $_GET['locked'] ), number_format_i18n( $_GET['locked'] ) );
64
  unset($_GET['locked']);
65
  }
66
 
67
  if ( isset($_GET['deleted']) && (int) $_GET['deleted'] ) {
68
- printf( __ngettext( '%s Purchase Log deleted.', '%s Purchase Logs deleted.', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) );
69
  unset($_GET['deleted']);
70
  }
71
  ?>
@@ -100,11 +104,11 @@ if(!isset($purchlogs)){
100
  <div id="message" class="updated fade"><p>
101
  <?php
102
  if ( isset($_GET['cleared']) && $_GET['cleared']==true ) {
103
- printf( __ngettext( 'Downloads for this log have been released.', 'Downloads for this log have been released.', $_GET['cleared'] ), $_GET['cleared']);
104
  unset($_GET['cleared']);
105
  }
106
  if ( isset($_GET['sent']) && (int) $_GET['sent'] ) {
107
- printf( __ngettext( 'Receipt has been resent ', 'Receipt has been resent ', $_GET['sent'] ), $_GET['sent'] );
108
  unset($_GET['sent']);
109
  }
110
  ?> </p></div>
@@ -115,11 +119,6 @@ if(!isset($purchlogs)){
115
 
116
  <?php
117
  $page_back = remove_query_arg( array('locked', 'skipped', 'updated', 'deleted','purchaselog_id'), $_SERVER['REQUEST_URI'] );
118
- if(wpsc_tax_isincluded() == false){
119
- $taxlabel = __('Tax','wpsc');
120
- }else{
121
- $taxlabel = __('Tax Included','wpsc');
122
- }
123
 
124
  $columns = array(
125
  'title' => __('Name','wpsc'),
@@ -127,10 +126,16 @@ if(!isset($purchlogs)){
127
  'quantity' => __('Quantity','wpsc'),
128
  'price' => __('Price','wpsc'),
129
  'shipping' => __('Shipping','wpsc'),
130
- 'tax' => $taxlabel,
131
  // 'discount' => 'Discount',
132
  'total' => __('Total','wpsc')
133
  );
 
 
 
 
 
 
134
  register_column_headers('display-purchaselog-details', $columns);
135
  ?>
136
  <div id='post-body' class='has-sidebar' style='width:95%;'>
@@ -201,7 +206,15 @@ if(!isset($purchlogs)){
201
  <th><?php _e('Discount','wpsc'); ?> </th>
202
  <td><?php echo wpsc_display_purchlog_discount(); ?></td>
203
  </tr>
204
-
 
 
 
 
 
 
 
 
205
  <tr>
206
  <td colspan='5'></td>
207
  <th><?php _e('Shipping','wpsc'); ?> </th>
@@ -245,7 +258,7 @@ if(!isset($purchlogs)){
245
 
246
  <br /><br class='small' /><img src='<?php echo WPSC_URL; ?>/images/email_go.png' alt='email icon' />&ensp;<a href='<?php echo add_query_arg('email_buyer_id',$_GET['purchaselog_id']); ?>'><?php echo __('Resend Receipt to Buyer', 'wpsc'); ?></a>
247
 
248
- <br /><br class='small' /><a class='submitdelete' title='<?php echo attribute_escape(__('Delete this log')); ?>' href='<?php echo wp_nonce_url("page.php?wpsc_admin_action=delete_purchlog&amp;purchlog_id=".$_GET['purchaselog_id'], 'delete_purchlog_' .$_GET['purchaselog_id']); ?>' onclick="if ( confirm(' <?php echo js_escape(sprintf( __("You are about to delete this log '%s'\n 'Cancel' to stop, 'OK' to delete.",'wpsc'), wpsc_purchaselog_details_date() )) ?>') ) { return true;}return false;"><img src='<?php echo WPSC_URL."/images/cross.png"; ?>' alt='delete icon' /> &nbsp;<?php echo __('Remove this record', 'wpsc') ?></a>
249
 
250
  <br /><br class='small' />&emsp;&ensp; <a href='<?php echo $page_back ?>'><?php echo __('Go Back', 'wpsc'); ?></a>
251
  <br /><br />
@@ -466,7 +479,7 @@ if(!isset($purchlogs)){
466
  $(document).ready(function(){
467
  $('#doaction, #doaction2').click(function(){
468
  if ( $('select[name^="purchlog_multiple_status_change"]').val() == 'delete' ) {
469
- var m = '<?php echo js_escape(__("You are about to delete the selected purchase logs.\n 'Cancel' to stop, 'OK' to delete.")); ?>';
470
  return showNotice.warn(m);
471
  }
472
  });
@@ -502,7 +515,7 @@ if(!isset($purchlogs)){
502
  <a href='http://checkout.google.com/' rel=''><img class='google_checkout_logo' src='<?php echo WPSC_URL."/images/checkout_logo.jpg"; ?>' alt='google checkout' /></a>
503
  <?php } ?>
504
  </td><!-- Status -->
505
- <td><a class='submitdelete' title='<?php echo attribute_escape(__('Delete this log')); ?>' href='<?php echo wp_nonce_url("page.php?wpsc_admin_action=delete_purchlog&amp;purchlog_id=".wpsc_the_purch_item_id(), 'delete_purchlog_' . wpsc_the_purch_item_id()); ?>' onclick="if ( confirm(' <?php echo js_escape(sprintf( __("You are about to delete this log '%s'\n 'Cancel' to stop, 'OK' to delete."), wpsc_the_purch_item_date() )) ?>') ) { return true;}return false;"><img class='wpsc_pushdown_img' src='<?php echo WPSC_URL."/images/cross.png"; ?>' alt='delete icon' /><?php _e('Delete') ?></a></td><!-- Delete -->
506
  <td>
507
  <a class='wpsc_show_trackingid' title='<?php echo wpsc_the_purch_item_id(); ?>' href=''>+ tracking id</a>
508
  </td>
@@ -544,7 +557,7 @@ if(!isset($purchlogs)){
544
  <td><?php echo wpsc_purchaselog_details_quantity(); ?></td> <!-- QUANTITY! -->
545
  <td><?php echo nzshpcrt_currency_display(wpsc_purchaselog_details_price(),true); ?></td> <!-- PRICE! -->
546
  <td><?php echo nzshpcrt_currency_display(wpsc_purchaselog_details_shipping(),true); ?></td> <!-- SHIPPING! -->
547
- <td><?php echo wpsc_purchaselog_details_tax(); ?></td> <!-- TAX! -->
548
  <?php /* <td><?php echo nzshpcrt_currency_display(wpsc_purchaselog_details_discount(),true); ?></td> <!-- DISCOUNT! --> */ ?>
549
  <td><?php echo nzshpcrt_currency_display(wpsc_purchaselog_details_total(),true); ?></td> <!-- TOTAL! -->
550
  </tr>
@@ -637,7 +650,17 @@ function wpsc_custom_checkout_fields(){
637
 
638
  }
639
 
 
 
 
 
 
 
 
 
 
 
640
  function wpsc_upgrade_purchase_logs() {
641
  include(WPSC_FILE_PATH.'/wpsc-admin/includes/purchlogs_upgrade.php');
642
  }
643
- ?>
11
  $purchlogs = new wpsc_purchaselogs();
12
  }
13
  function wpsc_display_sales_logs() {
14
+
15
+ $subpage ='';
16
+ if(isset($_GET['subpage']))
17
+ $subpage = $_GET['subpage'];
18
+
19
  switch($subpage) {
20
  case 'upgrade-purchase-logs':
21
  wpsc_upgrade_purchase_logs();
25
  wpsc_display_sales_log_index();
26
  break;
27
  }
28
+ }
29
 
30
  function wpsc_display_sales_log_index() {
31
  ?>
32
  <div class="wrap">
33
  <?php //screen_icon(); ?>
34
+ <h2><?php echo esc_html( __('Sales', 'wpsc') ); ?> </h2>
35
  <?php //START OF PURCHASE LOG DEFAULT VIEW ?>
36
  <?php
37
  if(isset($_GET['view_purchlogs_by']) || isset($_GET['view_purchlogs_by_status'])) {
56
  if (isset($_GET['skipped']) || isset($_GET['updated']) || isset($_GET['deleted']) || isset($_GET['locked']) ) { ?>
57
  <div id="message" class="updated fade"><p>
58
  <?php if ( isset($_GET['updated']) && (int) $_GET['updated'] ) {
59
+ printf( _n( '%s Purchase Log updated.', '%s Purchase Logs updated.', $_GET['updated'] ), number_format_i18n( $_GET['updated'] ) );
60
  unset($_GET['updated']);
61
  }
62
 
64
  unset($_GET['skipped']);
65
 
66
  if ( isset($_GET['locked']) && (int) $_GET['locked'] ) {
67
+ printf( _n( '%s product not updated, somebody is editing it.', '%s products not updated, somebody is editing them.', $_GET['locked'] ), number_format_i18n( $_GET['locked'] ) );
68
  unset($_GET['locked']);
69
  }
70
 
71
  if ( isset($_GET['deleted']) && (int) $_GET['deleted'] ) {
72
+ printf( _n( '%s Purchase Log deleted.', '%s Purchase Logs deleted.', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) );
73
  unset($_GET['deleted']);
74
  }
75
  ?>
104
  <div id="message" class="updated fade"><p>
105
  <?php
106
  if ( isset($_GET['cleared']) && $_GET['cleared']==true ) {
107
+ printf( _n( 'Downloads for this log have been released.', 'Downloads for this log have been released.', $_GET['cleared'] ), $_GET['cleared']);
108
  unset($_GET['cleared']);
109
  }
110
  if ( isset($_GET['sent']) && (int) $_GET['sent'] ) {
111
+ printf( _n( 'Receipt has been resent ', 'Receipt has been resent ', $_GET['sent'] ), $_GET['sent'] );
112
  unset($_GET['sent']);
113
  }
114
  ?> </p></div>
119
 
120
  <?php
121
  $page_back = remove_query_arg( array('locked', 'skipped', 'updated', 'deleted','purchaselog_id'), $_SERVER['REQUEST_URI'] );
 
 
 
 
 
122
 
123
  $columns = array(
124
  'title' => __('Name','wpsc'),
126
  'quantity' => __('Quantity','wpsc'),
127
  'price' => __('Price','wpsc'),
128
  'shipping' => __('Shipping','wpsc'),
129
+ 'tax' => '',
130
  // 'discount' => 'Discount',
131
  'total' => __('Total','wpsc')
132
  );
133
+
134
+ if(wpec_display_product_tax())
135
+ {
136
+ $columns['tax'] = __('Tax Included','wpsc');
137
+ }// if
138
+
139
  register_column_headers('display-purchaselog-details', $columns);
140
  ?>
141
  <div id='post-body' class='has-sidebar' style='width:95%;'>
206
  <th><?php _e('Discount','wpsc'); ?> </th>
207
  <td><?php echo wpsc_display_purchlog_discount(); ?></td>
208
  </tr>
209
+
210
+ <?php if(!wpec_display_product_tax()) { ?>
211
+ <tr>
212
+ <td colspan='5'></td>
213
+ <th><?php _e('Taxes','wpsc'); ?> </th>
214
+ <td><?php echo wpec_display_purchlog_taxes(); ?></td>
215
+ </tr>
216
+ <?php } ?>
217
+
218
  <tr>
219
  <td colspan='5'></td>
220
  <th><?php _e('Shipping','wpsc'); ?> </th>
258
 
259
  <br /><br class='small' /><img src='<?php echo WPSC_URL; ?>/images/email_go.png' alt='email icon' />&ensp;<a href='<?php echo add_query_arg('email_buyer_id',$_GET['purchaselog_id']); ?>'><?php echo __('Resend Receipt to Buyer', 'wpsc'); ?></a>
260
 
261
+ <br /><br class='small' /><a class='submitdelete' title='<?php echo esc_attr(__('Delete this log')); ?>' href='<?php echo wp_nonce_url("page.php?wpsc_admin_action=delete_purchlog&amp;purchlog_id=".$_GET['purchaselog_id'], 'delete_purchlog_' .$_GET['purchaselog_id']); ?>' onclick="if ( confirm(' <?php echo esc_js(sprintf( __("You are about to delete this log '%s'\n 'Cancel' to stop, 'OK' to delete.",'wpsc'), wpsc_purchaselog_details_date() )) ?>') ) { return true;}return false;"><img src='<?php echo WPSC_URL."/images/cross.png"; ?>' alt='delete icon' /> &nbsp;<?php echo __('Remove this record', 'wpsc') ?></a>
262
 
263
  <br /><br class='small' />&emsp;&ensp; <a href='<?php echo $page_back ?>'><?php echo __('Go Back', 'wpsc'); ?></a>
264
  <br /><br />
479
  $(document).ready(function(){
480
  $('#doaction, #doaction2').click(function(){
481
  if ( $('select[name^="purchlog_multiple_status_change"]').val() == 'delete' ) {
482
+ var m = '<?php echo esc_js(__("You are about to delete the selected purchase logs.\n 'Cancel' to stop, 'OK' to delete.")); ?>';
483
  return showNotice.warn(m);
484
  }
485
  });
515
  <a href='http://checkout.google.com/' rel=''><img class='google_checkout_logo' src='<?php echo WPSC_URL."/images/checkout_logo.jpg"; ?>' alt='google checkout' /></a>
516
  <?php } ?>
517
  </td><!-- Status -->
518
+ <td><a class='submitdelete' title='<?php echo esc_attr(__('Delete this log')); ?>' href='<?php echo wp_nonce_url("page.php?wpsc_admin_action=delete_purchlog&amp;purchlog_id=".wpsc_the_purch_item_id(), 'delete_purchlog_' . wpsc_the_purch_item_id()); ?>' onclick="if ( confirm(' <?php echo esc_js(sprintf( __("You are about to delete this log '%s'\n 'Cancel' to stop, 'OK' to delete."), wpsc_the_purch_item_date() )) ?>') ) { return true;}return false;"><img class='wpsc_pushdown_img' src='<?php echo WPSC_URL."/images/cross.png"; ?>' alt='delete icon' /><?php _e('Delete') ?></a></td><!-- Delete -->
519
  <td>
520
  <a class='wpsc_show_trackingid' title='<?php echo wpsc_the_purch_item_id(); ?>' href=''>+ tracking id</a>
521
  </td>
557
  <td><?php echo wpsc_purchaselog_details_quantity(); ?></td> <!-- QUANTITY! -->
558
  <td><?php echo nzshpcrt_currency_display(wpsc_purchaselog_details_price(),true); ?></td> <!-- PRICE! -->
559
  <td><?php echo nzshpcrt_currency_display(wpsc_purchaselog_details_shipping(),true); ?></td> <!-- SHIPPING! -->
560
+ <td><?php if(wpec_display_product_tax()) { echo wpsc_purchaselog_details_tax(); } ?></td> <!-- TAX! -->
561
  <?php /* <td><?php echo nzshpcrt_currency_display(wpsc_purchaselog_details_discount(),true); ?></td> <!-- DISCOUNT! --> */ ?>
562
  <td><?php echo nzshpcrt_currency_display(wpsc_purchaselog_details_total(),true); ?></td> <!-- TOTAL! -->
563
  </tr>
650
 
651
  }
652
 
653
+ /**
654
+ * @description: determines whether or not to display the product tax or not
655
+ * @return: boolean
656
+ **/
657
+ function wpec_display_product_tax()
658
+ {
659
+ global $purchlogitem;
660
+ return ($purchlogitem->extrainfo->wpec_taxes_total == 0.00) ? true : false;
661
+ }// wpec_display_product_tax
662
+
663
  function wpsc_upgrade_purchase_logs() {
664
  include(WPSC_FILE_PATH.'/wpsc-admin/includes/purchlogs_upgrade.php');
665
  }
666
+ ?>
wpsc-admin/display-update.page.php CHANGED
@@ -26,7 +26,7 @@ if(get_option('wpsc_version') < 3.8 || !get_option('wpsc_version')) :
26
  function wpsc_display_update_notice() {
27
  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>";
28
  }
29
- if($_GET['page'] != 'wpsc-update') :
30
  add_action('admin_notices', 'wpsc_display_update_notice');
31
  endif;
32
 
@@ -43,10 +43,10 @@ function wpsc_display_update_page() {
43
  ?>
44
  <div class="wrap">
45
  <?php // screen_icon(); ?>
46
- <h2><?php echo wp_specialchars( __('Update WP e-Commerce', 'wpsc') ); ?> </h2>
47
  <br />
48
  <?php
49
- if($_POST['run_updates']) :
50
  echo 'Updating Categories...';
51
  wpsc_convert_category_groups();
52
  echo '<br />Updating Variations...';
26
  function wpsc_display_update_notice() {
27
  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>";
28
  }
29
+ if(isset($_GET['page']) && $_GET['page'] != 'wpsc-update') :
30
  add_action('admin_notices', 'wpsc_display_update_notice');
31
  endif;
32
 
43
  ?>
44
  <div class="wrap">
45
  <?php // screen_icon(); ?>
46
+ <h2><?php echo esc_html( __('Update WP e-Commerce', 'wpsc') ); ?> </h2>
47
  <br />
48
  <?php
49
+ if(isset($_POST['run_updates'])) :
50
  echo 'Updating Categories...';
51
  wpsc_convert_category_groups();
52
  echo '<br />Updating Variations...';
wpsc-admin/display-upgrades.page.php CHANGED
@@ -124,7 +124,7 @@ function wpsc_display_upgrades_page() {
124
 
125
 
126
  function wpsc_reset_api_key() {
127
- if($_POST['reset_api_key'] == 'true') {
128
  if($_POST['activation_name'] != null) {
129
  $target = "http://instinct.co.nz/wp-goldcart-api/api_register.php?name=".$_POST['activation_name']."&key=".$_POST['activation_key']."&url=".get_option('siteurl')."";
130
  //exit($target);
124
 
125
 
126
  function wpsc_reset_api_key() {
127
+ if(isset($_POST['reset_api_key']) && ($_POST['reset_api_key'] == 'true')) {
128
  if($_POST['activation_name'] != null) {
129
  $target = "http://instinct.co.nz/wp-goldcart-api/api_register.php?name=".$_POST['activation_name']."&key=".$_POST['activation_key']."&url=".get_option('siteurl')."";
130
  //exit($target);
wpsc-admin/display-variations.page.php CHANGED
@@ -34,7 +34,7 @@ function wpsc_display_variations_page() {
34
 
35
  <div class="wrap">
36
  <?php // screen_icon(); ?>
37
- <h2><?php echo wp_specialchars( __('Display Variations', 'wpsc') ); ?> </h2>
38
  <p>
39
  <?php echo __('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');?>
40
  </p>
34
 
35
  <div class="wrap">
36
  <?php // screen_icon(); ?>
37
+ <h2><?php echo esc_html( __('Display Variations', 'wpsc') ); ?> </h2>
38
  <p>
39
  <?php echo __('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');?>
40
  </p>
wpsc-admin/includes/display-items-functions.php CHANGED
@@ -1,1533 +1,1664 @@
1
- <?php
2
- /**
3
- * WPSC Product form generation functions
4
- *
5
- * @package wp-e-commerce
6
- * @since 3.7
7
- */
8
- //$closed_postboxes = (array)get_usermeta( $current_user->ID, 'editproduct');
9
- //$variations_processor = new nzshpcrt_variations;
10
-
11
-
12
- $wpsc_product_defaults =array (
13
- 'id' => '0',
14
- 'name' => '',
15
- 'description' => '',
16
- 'additional_description' => '',
17
- 'price' => '0.00',
18
- 'weight' => '0',
19
- 'weight_unit' => 'pound',
20
- 'pnp' => '0.00',
21
- 'international_pnp' => '0.00',
22
- 'file' => '0',
23
- 'image' => '',
24
- 'category' => '0',
25
- 'brand' => '0',
26
- 'quantity_limited' => '0',
27
- 'quantity' => '0',
28
- 'special' => '0',
29
- 'special_price' => '',
30
- 'display_frontpage' => '0',
31
- 'notax' => '0',
32
- 'publish' => '1',
33
- 'active' => '1',
34
- 'donation' => '0',
35
- 'no_shipping' => '0',
36
- 'thumbnail_image' => '',
37
- 'thumbnail_state' => '1',
38
- 'meta' =>
39
- array (
40
- 'external_link' => NULL,
41
- 'merchant_notes' => NULL,
42
- 'sku' => NULL,
43
- 'engrave' => '0',
44
- 'can_have_uploaded_image' => '0',
45
- 'table_rate_price' =>
46
- array (
47
- 'quantity' =>
48
- array (
49
- 0 => '',
50
- ),
51
- 'table_price' =>
52
- array (
53
- 0 => '',
54
- ),
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
- {
66
- foreach ($array1 as $key => $value)
67
- {
68
- // create new key in $array, if it is empty or not an array
69
- if (!isset($array[$key]) || (isset($array[$key]) && !is_array($array[$key])))
70
- {
71
- $array[$key] = array();
72
- }
73
-
74
- // overwrite the value in the base array
75
- if (is_array($value))
76
- {
77
- $value = recurse($array[$key], $value);
78
- }
79
- $array[$key] = $value;
80
- }
81
- return $array;
82
- }
83
-
84
- // handle the arguments, merge one by one
85
- $args = func_get_args();
86
- $array = $args[0];
87
- if (!is_array($array))
88
- {
89
- return $array;
90
- }
91
- for ($i = 1; $i < count($args); $i++)
92
- {
93
- if (is_array($args[$i]))
94
- {
95
- $array = recurse($array, $args[$i]);
96
- }
97
- }
98
- return $array;
99
- }
100
- }
101
-
102
- function wpsc_populate_product_data($product_id, $wpsc_product_defaults) {
103
- global $wpdb;
104
- $product = get_post($product_id);
105
- //print("<pre>" . print_r($product, true) . "</pre>");
106
-
107
- $product_data['id'] = $product->ID;
108
- $product_data['name'] = $product->post_title;
109
- $product_data['post_type'] = $product->post_type;
110
- $product_data['post_status'] = $product->post_status;
111
- $product_data['description'] = $product->post_content;
112
- $product_data['additional_description'] = $product->post_excerpt;
113
- // get the list of categories this product is associated with
114
-
115
- $product_data['categories'] = wp_get_product_categories($product->ID);
116
- $product_data['tags'] = wp_get_product_tags($product->ID);
117
- $product_data['category_ids'] = array();
118
-
119
- $product_data['product_object'] = $product;
120
-
121
- foreach((array)$product_data['categories'] as $category_item) {
122
- $product_data['category_ids'][] = (int)$category_item->term_id;
123
- }
124
-
125
-
126
- // Meta Values come straight from the meta table
127
- $product_data['meta'] = array();
128
- $product_data['meta'] = get_post_meta($product->ID, '');
129
- if ( is_array ( $product_data['meta'] ) ) {
130
- foreach($product_data['meta'] as $meta_name => $meta_value) {
131
- $product_data['meta'][$meta_name] = maybe_unserialize(array_pop($meta_value));
132
- }
133
- }
134
- //$sql ="SELECT `meta_key`, `meta_value` FROM ".WPSC_TABLE_PRODUCTMETA." WHERE `meta_key` LIKE 'currency%' AND `product_id`=".$product_id;
135
- //$product_data['newCurr']= $wpdb->get_results($sql, ARRAY_A);
136
- $product_data['dimensions'] = get_product_meta($product_id, 'dimensions',true);
137
-
138
- // Transformed Values have been altered in some way since being extracted from some data source
139
- $product_data['transformed'] = array();
140
- $product_data['transformed']['weight'] = wpsc_convert_weight($product_data['meta']['_wpsc_product_metadata']['weight'], "gram", $product_data['meta']['_wpsc_product_metadata']['display_weight_as']);
141
-
142
- //echo "<pre>".print_r($product_data,true)."</pre>";
143
- if(function_exists('wp_insert_term')) {
144
- $term_relationships = $wpdb->get_results("SELECT * FROM `{$wpdb->term_relationships}` WHERE object_id = '{$product_data['id']}'", ARRAY_A);
145
-
146
- foreach ((array)$term_relationships as $term_relationship) {
147
- $tt_ids[] = $term_relationship['term_taxonomy_id'];
148
- }
149
- foreach ((array)$tt_ids as $tt_id) {
150
- $term_ids[] = $wpdb->get_var("SELECT `term_id` FROM `{$wpdb->term_taxonomy}` WHERE `term_taxonomy_id` = '{$tt_id}' AND `taxonomy` = 'product_tag' LIMIT 1");
151
- }
152
- foreach ((array)$term_ids as $term_id ) {
153
- if ($term_id != NULL){
154
- $tags[] = $wpdb->get_var("SELECT `name` FROM `{$wpdb->terms}` WHERE `term_id`='{$term_id}' LIMIT 1");
155
- }
156
- }
157
- if ($tags != NULL){
158
- $imtags = implode(',', $tags);
159
- }
160
- }
161
- return $product_data;
162
- }
163
-
164
- function wpsc_display_product_form ($product_id = 0) {
165
- global $wpdb, $wpsc_product_defaults;
166
- $product_id = absint($product_id);
167
-
168
- if($product_id > 0) {
169
- $product_data = wpsc_populate_product_data($product_id, $wpsc_product_defaults);
170
- } else {
171
- if(isset($_SESSION['wpsc_failed_product_post_data']) && (count($_SESSION['wpsc_failed_product_post_data']) > 0 )) {
172
- $product_data = array_merge($wpsc_product_defaults, $_SESSION['wpsc_failed_product_post_data']);
173
- $_SESSION['wpsc_failed_product_post_data'] = null;
174
- } else {
175
- $product_data = $wpsc_product_defaults;
176
- }
177
- }
178
-
179
- $current_user = wp_get_current_user();
180
-
181
- // we put the closed postboxes array into the product data to propagate it to each form without having it global.
182
- $product_data['closed_postboxes'] = (array)get_usermeta( $current_user->ID, 'closedpostboxes_products_page_wpsc-edit-products');
183
- $product_data['hidden_postboxes'] = (array)get_usermeta( $current_user->ID, 'metaboxhidden_products_page_wpsc-edit-products');
184
-
185
- if(count($product_data) > 0) {
186
- wpsc_product_basic_details_form($product_data);
187
- }
188
- }
189
- /*
190
- Stop-gap function replicating native WP functionality
191
- */
192
-
193
- function add_new_product_id() {
194
- global $wpdb;
195
- $prod_id = $wpdb->get_var($wpdb->prepare("SELECT MAX( ID ) FROM $wpdb->posts"));
196
- $prod_id = $prod_id + 1;
197
-
198
- $wpdb->query( $wpdb->prepare( "INSERT INTO $wpdb->posts ( post_author, post_date, post_date_gmt, post_title, post_status, post_parent, post_type)
199
- VALUES ( %d, %s, %s, %s, %s, %d, %s )",
200
- 1, 'CURDATE()', 'CURDATE()', 'stopgap', 'inherit', $prod_id, 'attachment' ) );
201
-
202
- return $prod_id;
203
- }
204
-
205
- function delete_stopgap() {
206
- global $wpdb;
207
- $wpdb->query( "DELETE FROM $wpdb->posts WHERE post_parent = $uploading_iframe_ID AND post_title = 'stopgap'" );
208
- }
209
- if($product_data['id'] > 0) {
210
- add_action('transition_post_status', 'delete_stopgap');
211
- }
212
- function wpsc_product_basic_details_form(&$product_data) {
213
- global $wpdb,$nzshpcrt_imagesize_info, $user_ID;
214
- $product = $product_data['product_object'];
215
- $post_ID = (int) $product_data["id"];
216
- /*<h3 class='hndle'><?php echo __('Product Details', 'wpsc'); ?> <?php echo __('(enter in your product details here)', 'wpsc'); ?></h3>*/
217
- ?>
218
- <h3 class='form_heading' style="display:none;">
219
- <?php
220
- if($product_data['id'] > 0) {
221
- echo __('Edit Product', 'wpsc');
222
- } else {
223
- echo __('Add New', 'wpsc');
224
- $product_data["id"] = $_GET["product"] = add_new_product_id();
225
- }
226
- $form_extra = '';
227
- if ( 'auto-draft' == $product->post_status ) {
228
- if ( 'edit' == $action )
229
- $product->post_title = '';
230
- $autosave = false;
231
- $form_extra .= "<input type='hidden' id='auto_draft' name='auto_draft' value='1' />";
232
- } else {
233
- $autosave = wp_get_post_autosave( $product_data["id"] );
234
- }
235
-
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
- $sticky = get_option( 'sticky_posts' );
240
- if ( in_array ( $product_data["id"], $sticky ) )
241
- $sticky_checked = 'checked="checked" ';
242
-
243
- ?>
244
- </h3>
245
- <div id="side-info-column" class="inner-sidebar">
246
- <div id="side-sortables" class='meta-box-sortables-wpec ui-sortable'>
247
- <?php wp_nonce_field($nonce_action); ?>
248
- <input type="hidden" id="user-id" name="user_ID" value="<?php echo (int) $user_ID ?>" />
249
- <input type="hidden" id="hiddenaction" name="action" value="<?php echo esc_attr($form_action) ?>" />
250
- <input type="hidden" id="originalaction" name="originalaction" value="<?php echo esc_attr($form_action) ?>" />
251
- <input type="hidden" id="post_author" name="post_author" value="<?php echo esc_attr( $product->post_author ); ?>" />
252
- <input type="hidden" id="post_type" name="post_type" value="<?php echo esc_attr($product->post_type) ?>" />
253
- <input type="hidden" id="original_post_status" name="original_post_status" value="<?php echo esc_attr($product->post_status) ?>" />
254
- <input type="hidden" id="referredby" name="referredby" value="<?php echo esc_url(stripslashes(wp_get_referer())); ?>" />
255
- <?php
256
- if ( 'draft' != $product->post_status )
257
- wp_original_referer_field(true, 'previous');
258
-
259
- echo $form_extra;
260
-
261
- wp_nonce_field( 'autosave', 'autosavenonce', false );
262
- ?>
263
- <input type='hidden' name='product_id' id='product_id' value='<?php echo (int) $product_data["id"]; ?>' />
264
- <input type='hidden' name='wpsc_admin_action' value='edit_product' />
265
- <?php wp_nonce_field('edit-product', 'wpsc-edit-product'); ?>
266
-
267
- <?php /*
268
- <input class='button-primary' style='float:left;' type='submit' name='submit' value='<?php if($product_data['id'] > 0) { _e('Update Product', 'wpsc'); } else { _e('Add New Product', 'wpsc'); } ?>' />&nbsp;
269
- */ ?>
270
- <div id="submitdiv" class="postbox">
271
- <div class="handlediv" title="Click to toggle"><br></div><h3 class="hndle"><span>Publish</span></h3>
272
- <div class="inside publish">
273
- <div class="submitbox" id="submitpost"><br />
274
- <span id="sticky-span" style="display: inline; "><input id="sticky" name="sticky" type="checkbox" <?php echo $sticky_checked; ?>value="sticky" tabindex="4"> <label for="sticky" class="selectit">Stick this product to the front page</label><br></span>
275
- <div id="minor-publishing">
276
- <div id="minor-publishing-actions">
277
- <div id="save-action">
278
- <?php
279
- if(($product->post_status == 'draft') || ($product->post_status == null)) {
280
- ?>
281
- <input type='submit' value='<?php _e('Save Draft', 'wpsc'); ?>' class='button button-highlighted' id="save-post" name='save' />
282
- <?php
283
- } else {
284
- ?>
285
- <input type='submit' value='<?php _e('Unpublish', 'wpsc'); ?>' class='button button-highlighted' id='save-post' name='unpublish' />
286
- <?php
287
- }
288
- ?>
289
- </div>
290
- <div id="preview-action">
291
- <a class="preview button" id="post-preview" href="<?php echo wpsc_product_url( $product_data['id'] ); ?>"><?php _e('View Product') ?></a>
292
- </div>
293
- <div class="clear"></div>
294
- </div>
295
- </div>
296
- <div id="major-publishing-actions">
297
- <div id="delete-action">
298
- <a class='submitdelete deletion' title='<?php echo attribute_escape(__('Delete this product')); ?>' href='<?php echo wp_nonce_url("page.php?wpsc_admin_action=trash&amp;product={$product_data['id']}", 'delete_product_' . $product_data['id']); ?>' onclick="if ( confirm(' <?php echo js_escape(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') ?>
299
- </a><br />
300
- </div>
301
- <div id="publishing-action">
302
- <?php
303
- if(($product->post_status == 'draft') || ($product->post_status == null)) {
304
- ?>
305
- <input type='submit' value='<?php _e('Publish', 'wpsc'); ?>' id='publish' class='button-primary' name='publish' />
306
- <?php
307
- } else {
308
- ?>
309
- <input type='submit' value='<?php _e('Update', 'wpsc'); ?>' id='publish' class='button-primary' name='save' />
310
- <?php
311
- }
312
- ?>
313
- </div>
314
- <div class="clear"></div>
315
- </div>
316
- </div>
317
- </div>
318
- </div>
319
-
320
-
321
- <?php
322
-
323
- $default_order = array(
324
- "advanced" => array(
325
- "wpsc_product_shipping_forms",
326
- "wpsc_product_variation_forms",
327
- "wpsc_product_advanced_forms"
328
- ),
329
- "side" => array(
330
- "wpsc_product_category_and_tag_forms",
331
- "wpsc_product_price_and_stock_forms",
332
- "wpsc_product_image_forms",
333
- "wpsc_product_download_forms"
334
- ),
335
- "closedboxes" => array(
336
- "wpsc_product_shipping_forms" => 1,
337
- "wpsc_product_variation_forms" => 1,
338
- "wpsc_product_advanced_forms" => 1,
339
- "wpsc_product_category_and_tag_forms" => 1,
340
- "wpsc_product_price_and_stock_forms" => 1,
341
- "wpsc_product_image_forms" => 1,
342
- "wpsc_product_download_forms" => 1
343
- ),
344
- "hiddenboxes" => array(
345
- "wpsc_product_shipping_forms" => 1,
346
- "wpsc_product_variation_forms" => 1,
347
- "wpsc_product_advanced_forms" => 1,
348
- "wpsc_product_category_and_tag_forms" => 1,
349
- "wpsc_product_price_and_stock_forms" => 1,
350
- "wpsc_product_image_forms" => 1,
351
- "wpsc_product_download_forms" => 1
352
- )
353
- );
354
-
355
- $order = get_option('wpsc_product_page_order');
356
-
357
- $order = apply_filters( 'wpsc_products_page_forms', $order);
358
-
359
- if ( ( $order == '' ) || ( count ( $order, COUNT_RECURSIVE ) < 24 ) || ( count ( $order ) == count ( $order, COUNT_RECURSIVE ) ) ) {
360
- $order = $default_order;
361
- }
362
- $check_missing_items = array_diff($default_order, $order);
363
-
364
- if(count($check_missing_items) > 0) {
365
- $order = array_merge($check_missing_items, $order);
366
- }
367
-
368
- update_option('wpsc_product_page_order', $order);
369
-
370
- // if this is a child product, we need to filter out the variations box here
371
- if($product_data['product_object']->post_parent > 0) {
372
- $variation_box_key = array_search('wpsc_product_variation_forms', $order);
373
- if(is_numeric($variation_box_key) && isset($order[$variation_box_key])) {
374
- unset($order[$variation_box_key]);
375
- }
376
-
377
- $category_box_key = array_search('wpsc_product_category_and_tag_forms', $order);
378
- if(is_numeric($category_box_key) && isset($order[$category_box_key])) {
379
- unset($order[$category_box_key]);
380
- }
381
-
382
- }
383
- foreach((array)$order["side"] as $key => $box_function_name) {
384
- if(function_exists($box_function_name)) {
385
- echo call_user_func($box_function_name,$product_data);
386
- }
387
- }
388
- // echo "<pre>"; print_r($order); echo "</pre>";
389
- ?>
390
- </div>
391
- </div>
392
- <script type="text/javascript">
393
- var makeSlugeditClickable;
394
- makeSlugeditClickable = null;
395
- //<![CDATA[
396
- jQuery(document).ready( function($) {
397
- <?php
398
- $closed_boxes = $order["closedboxes"];
399
- foreach ($closed_boxes as $key=>$val) {
400
- if ( $val == 0 ) {
401
- ?>
402
- $('div#<?php echo $key; ?>').addClass('closed');
403
- <?
404
- }
405
- }
406
- ?>
407
- $('#poststuff .postbox h3, .postbox div.handlediv').click( function() {
408
- $(this).parent().toggleClass('closed');
409
- wpsc_save_postboxes_state('store_page_wpsc-edit-products', '#poststuff');
410
- });
411
-
412
- <?php
413
- $hidden_boxes = $order["hiddenboxes"];
414
- foreach ($hidden_boxes as $key=>$val) {
415
- if ( $val == 0 ) {
416
- ?>
417
- $('div#<?php echo $key; ?>').css('display', 'none');
418
- $('div.metabox-prefs label input[value=<?php echo $key; ?>]').attr('checked', false);
419
- <?
420
- }
421
- elseif ($val == 1) {
422
-
423
- ?>
424
- $('div.metabox-prefs label input[value=<?php echo $key; ?>]').attr('checked', true);
425
-
426
- <?
427
-
428
- }
429
- }
430
- ?>
431
- });
432
- //]]>
433
- </script>
434
- <div id="post-body" class="has-sidebar">
435
- <div id="post-body-content">
436
- <table class='product_editform' >
437
- <tr>
438
- <td colspan='2' class='itemfirstcol'>
439
- <div class='admin_product_name'>
440
- <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'); ?>' />
441
- <a href='#' class='shorttag_toggle'></a>
442
- </div>
443
- <div class='admin_product_shorttags'>
444
- <h4><?php _e('Shortcodes', 'wpsc'); ?></h4>
445
-
446
- <dl>
447
- <dt><?php _e('Display Product Shortcode', 'wpsc'); ?>: </dt><dd>[wpsc_products product_id='<?php echo $product_data['id'];?>']</dd>
448
- <dt><?php _e('Buy Now Shortcode', 'wpsc'); ?>: </dt><dd>[buy_now_button=<?php echo $product_data['id'];?>]</dd>
449
- <dt><?php _e('Add to Cart Shortcode', 'wpsc'); ?>: </dt><dd>[add_to_cart=<?php echo $product_data['id'];?>]</dd>
450
- </dl>
451
-
452
- <h4><?php _e('Template Tags', 'wpsc'); ?></h4>
453
-
454
- <dl>
455
- <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>
456
- <dt><?php _e('Buy Now PHP', 'wpsc'); ?>: </dt><dd>&lt;?php echo wpsc_buy_now_button(<?php echo $product_data['id'];?>); ?&gt;</dd>
457
- <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>
458
- <dt><?php _e('Display Product SKU', 'wpsc'); ?>: </dt><dd>&lt;?php echo wpsc_product_sku(<?php echo $product_data['id'];?>); ?&gt;</dd>
459
- </dl>
460
-
461
- <?php if ( $product_data['id'] > 0 ) { ?>
462
- <p><a href="<?php echo wpsc_product_url( $product_data['id'] ); ?>" target="_blank" class="button">View product</a></p>
463
- <?php } ?>
464
-
465
- </div>
466
- <div style='clear:both; height: 0px; margin-bottom: 15px;'></div>
467
- </td>
468
- </tr>
469
- <tr>
470
- <td colspan='2'>
471
- <div id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>" class="postarea" >
472
- <?php
473
- wpsc_the_editor($product_data['description'], 'content',true, true);
474
- ?>
475
- <table id="post-status-info" cellspacing="0"><tbody><tr>
476
- <td id="wp-word-count"></td>
477
- <td class="autosave-info">
478
- <span id="autosave">&nbsp;</span>
479
- </td>
480
- </tr></tbody></table>
481
- </div>
482
- </td>
483
- </tr>
484
-
485
- <tr>
486
- <td class='itemfirstcol' colspan='2'>
487
-
488
- <strong ><?php echo __('Additional Description', 'wpsc'); ?> :</strong><br />
489
-
490
- <textarea name='additional_description' id='additional_description' cols='40' rows='5' ><?php echo stripslashes($product_data['additional_description']); ?></textarea>
491
- </td>
492
- </tr>
493
- </table>
494
- </div>
495
- <div id="advanced-sortables" class="meta-box-sortables-wpec ui-sortable">
496
- <?php
497
- foreach((array)$order["advanced"] as $key => $box_function_name) {
498
- if(function_exists($box_function_name)) {
499
- echo call_user_func($box_function_name,$product_data);
500
- }
501
- }
502
- ?>
503
- </div>
504
- </div>
505
- <?php
506
- }
507
- function wpsc_product_category_and_tag_forms($product_data=''){
508
- global $closed_postboxes, $wpdb, $variations_processor;
509
-
510
- $output = '';
511
- //echo "<pre>".print_r($product_data['tags'], true)."</pre>";
512
- $tag_array = array();
513
- foreach((array)$product_data['tags'] as $tag) {
514
- $tag_array[] = $tag->name;
515
- }
516
- if ($product_data == 'empty') {
517
- $display = "style='visibility:hidden;'";
518
- }
519
- $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' : '')."' ".((array_search('wpsc_product_category_and_tag_forms', $product_data['hidden_postboxes']) !== false) ? 'style="display: none;"' : '')." ><div class=\"handlediv\" title=\"Click to toggle\"><br></div>";
520
-
521
- if (IS_WP27) {
522
- $output .= "<h3 class='hndle'>";
523
- } else {
524
- $output .= "<h3>
525
- <a class='togbox'>+</a>";
526
- }
527
- $output .= __('Categories and Tags', 'wpsc');
528
-
529
- $output .= "
530
- </h3>
531
- <div class='inside'>
532
- <table>";
533
- $output .= "
534
- <tr>
535
- <td class='itemfirstcol'>
536
- <strong >".__('Product Categories', 'wpsc')." </strong>
537
- <div id='categorydiv' >";
538
- $search_sql = apply_filters('wpsc_product_category_and_tag_forms_group_search_sql', '');
539
- //$categorisation_groups = get_terms('wpsc_product_category', "hide_empty=0&parent=0", ARRAY_A);
540
-
541
- $output .= wpsc_category_list($product_data, 0, $product_data['id'], 'edit_');
542
-
543
-
544
- $output .= "
545
- </div>
546
- </td>
547
- <td class='itemfirstcol product_tags'>
548
- <strong > ".__('Product Tags', 'wpsc')."</strong><br />
549
- <p id='jaxtag'>
550
- <label for='tags-input' class='hidden'>".__('Product Tags', 'wpsc')."</label>
551
- <input type='text' value='".implode(',',$tag_array)."' tabindex='3' size='20' id='tags-input' class='tags-input' name='product_tags'/>
552
- <span class='howto'>".__('Separate tags with commas')."</span>
553
- </p>
554
- <div id='tagchecklist' class='tagchecklist' onload='tag_update_quickclicks();'></div>
555
-
556
- </td>
557
-
558
- </tr>";
559
- $output .= "
560
- </table>
561
- </div>
562
- </div>";
563
- $output = apply_filters('wpsc_product_category_and_tag_forms_output', $output);
564
-
565
- return $output;
566
-
567
- }
568
- function wpsc_product_price_and_stock_forms($product_data=''){
569
- global $closed_postboxes, $wpdb, $variations_processor;
570
- $product_meta = &$product_data['meta']['_wpsc_product_metadata'];
571
- $table_rate_price = $product_data['meta']['_wpsc_table_rate_price'];
572
- $custom_tax = $product_data['meta']['_wpsc_custom_tax'];
573
-
574
- if ($product_data == 'empty') {
575
- $display = "style='visibility:hidden;'";
576
- }
577
- echo "<div id='wpsc_product_price_and_stock_forms' class='wpsc_product_price_and_stock_forms postbox ".((array_search('wpsc_product_price_and_stock_forms', $product_data['closed_postboxes']) !== false) ? 'closed' : '')."' ".((array_search('wpsc_product_price_and_stock_forms', $product_data['hidden_postboxes']) !== false) ? 'style="display: none;"' : '')." ><div class=\"handlediv\" title=\"Click to toggle\"><br></div>";
578
-
579
- echo "<h3 class='hndle'>";
580
-
581
- echo __('Price and Stock Control', 'wpsc');
582
- echo "
583
- </h3>
584
- <div class='inside'>
585
- <table>
586
- ";
587
- // echo "<pre>".print_r($product_data['meta']['_wpsc_product_metadata'],true)."</pre>";
588
- ?><br />
589
- <tr>
590
- <td colspan='3' class='skuandprice'>
591
- <div class='wpsc_floatleft'>
592
- <?php echo __('Stock Keeping Unit', 'wpsc'); ?> :<br />
593
- <input size='17' type='text' class='text' name='meta[_wpsc_sku]' value='<?php echo htmlentities(stripslashes($product_data['meta']['_wpsc_sku']), ENT_QUOTES, 'UTF-8'); ?>' />
594
- </div>
595
-
596
- <div class='wpsc_floatleft'>
597
- <?php echo __('Price', 'wpsc'); ?> :<br />
598
- <input type='text' class='text' size='17' name='meta[_wpsc_price]' value='<?php echo number_format($product_data['meta']['_wpsc_price'], 2); ?>' />
599
- </div>
600
-
601
- <div class='wpsc_floatleft' style='display:<?php if(($product_data['special'] == 1) ? 'block' : 'none'); ?>'>
602
- <label for='add_form_special'><?php echo __('Sale Price :', 'wpsc'); ?></label>
603
- <div id='add_special'>
604
- <input type='text' size='17' value='<?php echo number_format( $product_data['meta']['_wpsc_special_price'], 2); ?>' name='meta[_wpsc_special_price]' />
605
- </div>
606
- </div>
607
-
608
- </td>
609
-
610
-
611
- </tr>
612
-
613
- <tr>
614
- <td ><a href='' class='wpsc_add_new_currency'>+ <?php echo __('New Currency', 'wpsc');?></a></td>
615
- </tr>
616
- <tr class='new_layer'>
617
- <td>
618
- <label for='newCurrency[]'><?php echo __('Currency type', 'wpsc');?>:</label><br />
619
- <select name='newCurrency[]' class='newCurrency'>
620
- <?php
621
- $currency_data = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_CURRENCY_LIST."` ORDER BY `country` ASC",ARRAY_A);
622
- foreach((array)$currency_data as $currency) {
623
- if($isocode == $currency['isocode']) {
624
- $selected = "selected='selected'";
625
- } else {
626
- $selected = "";
627
- } ?>
628
- <option value='<?php echo $currency['id']; ?>' <?php echo $selected; ?> ><?php echo htmlspecialchars($currency['country']); ?> (<?php echo $currency['currency']; ?>)</option>
629
- <?php }
630
- $currency_data = $wpdb->get_row("SELECT `symbol`,`symbol_html`,`code` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `id`='".get_option('currency_type')."' LIMIT 1",ARRAY_A) ;
631
- if($currency_data['symbol'] != '') {
632
- $currency_sign = $currency_data['symbol_html'];
633
- } else {
634
- $currency_sign = $currency_data['code'];
635
- }
636
- ?>
637
- </select>
638
- </td>
639
- <td>
640
- <?php echo __('Price', 'wpsc');?> :<br />
641
- <input type='text' class='text' size='15' name='newCurrPrice[]' value='0.00' />
642
- <a href='' class='deletelayer' rel='<?php echo $isocode; ?>'><?php echo __('Delete Currency', 'wpsc');?></a>
643
- </td>
644
-
645
- </tr>
646
- <?php if(count($product_data['newCurr']) > 0) :
647
- $i = 0;
648
- foreach($product_data['newCurr'] as $newCurr){
649
- $i++;
650
- $isocode = str_replace("currency[", "", $newCurr['meta_key']);
651
- $isocode = str_replace("]", "", $isocode);
652
- // exit('ere<pre>'.print_r($isocode, true).'</pre>');
653
-
654
- ?>
655
- <tr>
656
- <td>
657
- <label for='newCurrency[]'><?php echo __('Currency type', 'wpsc');?>:</label><br />
658
- <select name='newCurrency[]' class='newCurrency'>
659
- <?php
660
- $currency_data = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_CURRENCY_LIST."` ORDER BY `country` ASC",ARRAY_A);
661
- foreach($currency_data as $currency) {
662
- if($isocode == $currency['isocode']) {
663
- $selected = "selected='selected'";
664
- } else {
665
- $selected = "";
666
- }
667
- ?>
668
- <option value='<?php echo $currency['id']; ?>' <?php echo $selected; ?> ><?php echo htmlspecialchars($currency['country']); ?> (<?php echo $currency['currency']; ?>)</option>
669
- <?php
670
- }
671
- $currency_data = $wpdb->get_row("SELECT `symbol`,`symbol_html`,`code` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `id`='".get_option('currency_type')."' LIMIT 1",ARRAY_A) ;
672
- if($currency_data['symbol'] != '') {
673
- $currency_sign = $currency_data['symbol_html'];
674
- } else {
675
- $currency_sign = $currency_data['code'];
676
- }
677
- ?>
678
- </select>
679
- </td>
680
- <td>
681
- Price:<br />
682
- <input type='text' class='text' size='15' name='newCurrPrice[]' value='<?php echo $newCurr['meta_value']; ?>' />
683
- <a href='' class='wpsc_delete_currency_layer' rel='<?php echo $isocode; ?>'><?php echo __('Delete Currency', 'wpsc');?></a>
684
- </td>
685
- </tr>
686
- <?php } ?>
687
- <?php endif;
688
- echo "
689
- <tr>
690
- <td>
691
- <br /><input id='add_form_donation' type='checkbox' name='meta[_wpsc_is_donation]' value='yes' ".(($product_data['meta']['_wpsc_is_donation'] == 1) ? 'checked="checked"' : '')." />&nbsp;<label for='add_form_donation'>".__('This is a donation, checking this box populates the donations widget.', 'wpsc')."</label>
692
- </td>
693
- </tr>";
694
- ?>
695
-
696
- <tr>
697
- <td><br />
698
-
699
- <input type='checkbox' value='1' name='table_rate_price[state]' id='table_rate_price' <?php echo (((bool)$product_meta['table_rate_price']['state'] == true) ? 'checked=\'checked\'' : ''); ?> />
700
-
701
-
702
- <label for='table_rate_price'><?php echo __('Table Rate Price', 'wpsc'); ?></label>
703
- <div id='table_rate'>
704
- <a class='add_level' style='cursor:pointer;'>+ Add level</a><br />
705
- <table>
706
- <tr>
707
- <td><br /><?php echo __('Quantity In Cart', 'wpsc'); ?></td>
708
- <td><?php echo __('Discounted Price', 'wpsc'); ?></td>
709
- </tr>
710
- <?php
711
- if(count($product_meta['table_rate_price']['quantity']) > 0 ) {
712
- foreach((array)$product_meta['table_rate_price']['quantity'] as $key => $quantity) {
713
- if($quantity != '') {
714
- $table_price = number_format($product_meta['table_rate_price']['table_price'][$key], 2, '.', '');
715
- ?>
716
- <tr>
717
- <td>
718
- <input type="text" size="10" value="<?php echo $quantity; ?>" name="table_rate_price[quantity][]"/> and above
719
- </td>
720
- <td>
721
- <input type="text" size="10" value="<?php echo $table_price; ?>" name="table_rate_price[table_price][]" />
722
- </td>
723
- <td><img src="<?php echo WPSC_URL; ?>/images/cross.png" class="remove_line" /></td>
724
- </tr>
725
- <?php
726
- }
727
- }
728
- }
729
- ?>
730
- <tr>
731
- <td><input type='text' size='10' value='' name='table_rate_price[quantity][]'/> and above</td>
732
- <td><input type='text' size='10' value='' name='table_rate_price[table_price][]'/></td>
733
- </tr>
734
- </table>
735
- </div>
736
- </td>
737
- </tr>
738
-
739
- <tr>
740
- <td>
741
- <input type='checkbox' value='1' name='meta[_wpsc_product_metadata][custom_tax][state]' id='custom_tax_checkbox' <?php echo ((is_numeric($product_meta['custom_tax']) > 0) ? 'checked=\'checked\'' : ''); ?> />
742
- <label for='custom_tax_checkbox'><?php echo _e("Custom Tax Rate",'wpsc'); ?></label>
743
- <div style='display:<?php echo ((is_numeric($product_meta['custom_tax'])) ? 'block' : 'none'); ?>;' id='custom_tax'>
744
- <input type='text' size='10' value='<?php echo number_format($product_meta['custom_tax'], 2, '.', ''); ?>' name='meta[_wpsc_product_metadata][custom_tax][value]'/>
745
- </div>
746
- </td>
747
- </tr>
748
-
749
-
750
-
751
- <?php
752
- echo "
753
- <tr>
754
- <td style='width:430px;'>
755
- <input class='limited_stock_checkbox' id='add_form_quantity_limited' type='checkbox' value='yes' ".((is_numeric($product_data['meta']['_wpsc_stock'])) ? 'checked="checked"' : '')." name='meta[_wpsc_limited_stock]'/>";
756
- //onclick='hideelement(\"add_stock\")'
757
- echo "&nbsp;<label for='add_form_quantity_limited' class='small'>".__('I have a limited number of this item in stock. If the stock runs out, this product will not be available on the shop unless you untick this box or add more stock.', 'wpsc')."</label>";
758
- if ($product_data['id'] > 0){
759
- if(is_numeric($product_data['meta']['_wpsc_stock'])) {
760
- echo " <div class='edit_stock' style='display: block;'>\n\r";
761
- } else {
762
- echo " <div class='edit_stock' style='display: none;'>\n\r";
763
- }
764
-
765
- echo __('Stock Qty', 'wpsc') . " <input type='text' class='stock_limit_quantity' name='meta[_wpsc_stock]' size='10' value='".$product_data['meta']['_wpsc_stock']."' />";
766
-
767
-
768
-
769
- echo "<div style='font-size:9px; padding:5px;'><input type='checkbox' " . (($product_meta['unpublish_when_none_left'] == 1) ? 'checked="checked"' : '') . " class='inform_when_oos' name='meta[_wpsc_product_metadata][unpublish_when_none_left]' /> " . __('If this product runs out of stock set status to Unpublished & email site owner', 'wpsc') . "</div>";
770
- echo " </div>\n\r";
771
- } else {
772
- echo "
773
- <div style='display: none;' class='edit_stock'>
774
- " .__('Stock Qty', 'wpsc') . " <input type='text' name='meta[_wpsc_stock]' value='0' size='10' />";
775
- echo "<div style='font-size:9px; padding:5px;'><input type='checkbox' class='inform_when_oos' name='meta[_wpsc_product_metadata][unpublish_when_none_left]' /> " . __('If this product runs out of stock set status to Unpublished & email site owner', 'wpsc') . "</div>";
776
- echo "</div>";
777
- }
778
- echo "
779
-
780
- </td>
781
- </tr>";
782
- echo "
783
- </table>
784
- </div>
785
- </div>";
786
-
787
- //return $output;
788
-
789
- }
790
-
791
- function wpsc_product_variation_forms($product_data=''){
792
- global $closed_postboxes, $variations_processor;
793
- $siteurl = get_option('siteurl');
794
- $output='';
795
- if ($product_data == 'empty') {
796
- $display = "style='display:none;'";
797
- }
798
-
799
- $product_term_data = wp_get_object_terms($product_data['id'], 'wpsc-variation');
800
- $product_terms = array();
801
- foreach($product_term_data as $product_term) {
802
- $product_terms[] = $product_term->term_id;
803
- }
804
-
805
- ?>
806
-
807
- <div id='wpsc_product_variation_forms' class='postbox <?php echo ((array_search('wpsc_product_variation_forms', $product_data['closed_postboxes']) !== false) ? 'closed' : ''); ?>' <?php echo ((array_search('wpsc_product_variation_forms', $product_data['hidden_postboxes']) !== false) ? 'style="display: none;"' : ''); ?>><div class="handlediv" title="Click to toggle"><br></div>
808
- <h3 class='hndle'><?php echo __('Variation Control', 'wpsc'); ?></h3>
809
-
810
- <div class='inside'>
811
- <strong><?php echo __('Add Variation Set', 'wpsc'); ?></strong>
812
- <h4 class='product_action_link'><a target='_blank' href='admin.php?page=wpsc-edit-variations'><?php echo __('+ Add New Variations', 'wpsc'); ?></a></h4>
813
- <br />
814
- <div id="product_variations">
815
- <div class="variation_checkboxes">
816
- <?php
817
- $variation_sets = get_terms('wpsc-variation', array(
818
- 'hide_empty' => 0,
819
- 'parent' => 0
820
- ));
821
- foreach((array)$variation_sets as $variation_set) {
822
- $set_checked_state = '';
823
- if(in_array($variation_set->term_id, $product_terms)) {
824
- $set_checked_state = "checked='checked'";
825
- }
826
- //$product_terms
827
- ?>
828
- <div class="variation_set">
829
- <label class='set_label'>
830
- <input type="checkbox" <?php echo $set_checked_state; ?> name="variations[<?php echo $variation_set->term_id; ?>]" value="1">
831
- <?php echo $variation_set->name; ?>
832
- </label>
833
- <?php
834
- $variations = get_terms('wpsc-variation', array(
835
- 'hide_empty' => 0,
836
- 'parent' => $variation_set->term_id
837
- ));
838
- foreach((array)$variations as $variation) {
839
- $checked_state = '';
840
- if(in_array($variation->term_id, $product_terms)) {
841
- $checked_state = "checked='checked'";
842
- }
843
- ?>
844
- <div class="variation">
845
- <label>
846
- <input type="checkbox" <?php echo $checked_state; ?> name="edit_var_val[<?php echo $variation_set->term_id; ?>][<?php echo $variation->term_id; ?>]" value="1">
847
- <?php echo $variation->name; ?>
848
- </label>
849
- </div>
850
- <?php
851
- }
852
- ?>
853
-
854
- </div>
855
- <?php
856
- }
857
- ?>
858
-
859
-
860
- </div>
861
- </div>
862
-
863
- <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>
864
-
865
- </div>
866
- </div>
867
- <?php
868
- }
869
- /**
870
- * Adding function to change text for media buttons
871
- */
872
-
873
- function change_context() {
874
- return __('Upload Image%s');
875
- }
876
-
877
- function change_link($product_data='') {
878
- //Since we're hacking this all together anyway until the complete integration of custom_post_types, we'll go ahead and add the attachment to the db here as well.
879
- $uploading_iframe_ID = $_GET["product"];
880
- $media_upload_iframe_src = "media-upload.php?post_id=$uploading_iframe_ID";
881
- return $media_upload_iframe_src."&amp;type=image";
882
- }
883
- $uploading_iframe_ID = $_GET["product"];
884
-
885
- //Justin Sainton - 5.19.2010 - Adding filters/actions for the media goodness :) Conditions important to not kill media functionality elsewhere
886
- if ( $_GET["page"] == "wpsc-edit-products" ) {
887
- add_filter('media_buttons_context','change_context');
888
- add_filter('image_upload_iframe_src', "change_link");
889
- }
890
- function wpsc_product_shipping_forms($product_data=''){
891
- global $closed_postboxes;
892
- $product_meta = &$product_data['meta']['_wpsc_product_metadata'];
893
- if ($product_data == 'empty') {
894
- $display = "style='display:none;'";
895
- }
896
- $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>";
897
-
898
- if (IS_WP27) {
899
- $output .= "<h3 class='hndle'>";
900
- } else {
901
- $output .= "<h3>
902
- <a class='togbox'>+</a>";
903
- }
904
- $output .= __('Shipping Details', 'wpsc');
905
- $output .= "
906
- </h3>
907
- <div class='inside'>
908
- <table>
909
-
910
- <!--USPS shipping changes-->
911
- <tr>
912
- <td>
913
- ".__('Weight', 'wpsc')."
914
- </td>
915
- <td>
916
- <input type='text' size='5' name='meta[_wpsc_product_metadata][weight]' value='".$product_data['transformed']['weight']."' />
917
- <select name='meta[_wpsc_product_metadata][weight_unit]'>
918
- <option value='pound' ". (($product_meta['display_weight_as'] == 'pound') ? 'selected="selected"' : '') .">Pounds</option>
919
- <option value='ounce' ". ((preg_match("/o(u)?nce/",$product_meta['display_weight_as'])) ? 'selected="selected"' : '') .">Ounces</option>
920
- <option value='gram' ". (($product_meta['display_weight_as'] == 'gram') ? 'selected="selected"' : '') .">Grams</option>
921
- <option value='kilogram' ". (($product_meta['display_weight_as'] == 'kilogram') ? 'selected="selected"' : '') .">Kilograms</option>
922
- </select>
923
- </td>
924
- </tr>
925
- <!--dimension-->
926
- <tr>
927
- <td>
928
- Height
929
- </td>
930
- <td>
931
- <input type='text' size='5' name='meta[_wpsc_product_metadata][dimensions][height]' value='".$product_meta['dimensions']['height']."'>
932
- <select name='meta[_wpsc_product_metadata][dimensions][height_unit]'>
933
- <option value='in' ". (($product_meta['dimensions']['height_unit'] == 'in') ? 'selected' : '') .">inches</option>
934
- <option value='cm' ". (($product_meta['dimensions']['height_unit'] == 'cm') ? 'selected' : '') .">cm</option>
935
- <option value='meter' ". (($product_meta['dimensions']['height_unit'] == 'meter') ? 'selected' : '') .">meter</option>
936
- </select>
937
- </td>
938
- </tr>
939
- <tr>
940
- <td>
941
- Width
942
- </td>
943
- <td>
944
- <input type='text' size='5' name='meta[_wpsc_product_metadata][dimensions][width]' value='".$product_meta['dimensions']['width']."'>
945
- <select name='meta[_wpsc_product_metadata][dimensions][width_unit]'>
946
- <option value='in' ". (($product_meta['dimensions']['width_unit'] == 'in') ? 'selected' : '') .">inches</option>
947
- <option value='cm' ". (($product_meta['dimensions']['width_unit'] == 'cm') ? 'selected' : '') .">cm</option>
948
- <option value='meter' ". (($product_meta['dimensions']['width_unit'] == 'meter') ? 'selected' : '') .">meter</option>
949
- </select>
950
- </td>
951
- </tr>
952
- <tr>
953
- <td>
954
- Length
955
- </td>
956
- <td>
957
- <input type='text' size='5' name='meta[_wpsc_product_metadata][dimensions][length]' value='".$product_meta['dimensions']['length']."'>
958
- <select name='meta[_wpsc_product_metadata][dimensions][length_unit]'>
959
- <option value='in' ". (($product_meta['dimensions']['length_unit'] == 'in') ? 'selected' : '') .">inches</option>
960
- <option value='cm' ". (($product_meta['dimensions']['length_unit'] == 'cm') ? 'selected' : '') .">cm</option>
961
- <option value='meter' ". (($product_meta['dimensions']['length_unit'] == 'meter') ? 'selected' : '') .">meter</option>
962
- </select>
963
- </td>
964
- </tr>
965
-
966
- <!--//dimension-->
967
-
968
-
969
- <!--USPS shipping changes ends-->
970
-
971
-
972
- <!--USPS shipping changes ends-->
973
-
974
-
975
- <tr>
976
- <td colspan='2'>
977
- <strong>".__('Flat Rate Settings', 'wpsc')."</strong>
978
- </td>
979
- </tr>
980
- <tr>
981
- <td>
982
- ".__('Local Shipping Fee', 'wpsc')."
983
- </td>
984
- <td>
985
- <input type='text' size='10' name='meta[_wpsc_product_metadata][shipping][local]' value='".number_format($product_meta['shipping']['local'], 2, '.', '')."' />
986
- </td>
987
- </tr>
988
-
989
- <tr>
990
- <td>
991
- ".__('International Shipping Fee', 'wpsc')."
992
- </td>
993
- <td>
994
- <input type='text' size='10' name='meta[_wpsc_product_metadata][shipping][international]' value='".number_format($product_meta['shipping']['international'], 2, '.', '')."' />
995
- </td>
996
- </tr>
997
- <tr>
998
- <td>
999
- <br />
1000
- <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>
1001
- </td>
1002
- </tr>
1003
- </table></div></div>";
1004
-
1005
- return $output;
1006
- }
1007
-
1008
- function wpsc_product_advanced_forms($product_data='') {
1009
- global $closed_postboxes,$wpdb;
1010
- $product_meta = &$product_data['meta']['_wpsc_product_metadata'];
1011
-
1012
- $custom_fields = $wpdb->get_results( "
1013
- SELECT `meta_id`, `meta_key`, `meta_value`
1014
- FROM `{$wpdb->postmeta}`
1015
- WHERE `post_id` = {$product_data['id']}
1016
- AND `meta_key` NOT LIKE '\_%'
1017
- ORDER BY LOWER(meta_key)", ARRAY_A);
1018
-
1019
-
1020
- $output ='';
1021
-
1022
- //$custom_fields = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_PRODUCTMETA."` WHERE `product_id` IN('{$product_data['id']}') AND `custom` IN('1') ",ARRAY_A);
1023
-
1024
-
1025
- if ($product_data == 'empty') {
1026
- $display = "style='display:none;'";
1027
- }
1028
- $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>";
1029
-
1030
- $output .= "<h3 class='hndle'>";
1031
- $output .= __('Advanced Options', 'wpsc');
1032
- $output .= "
1033
- </h3>
1034
- <div class='inside'>
1035
- <table>";
1036
- $output .= "
1037
- <tr>
1038
- <td colspan='2' class='itemfirstcol'>
1039
- <strong>".__('Custom Meta', 'wpsc').":</strong><br />
1040
- <a href='#' class='add_more_meta' onclick='return add_more_meta(this)'> + ".__('Add Custom Meta', 'wpsc')."</a><br /><br />
1041
- ";
1042
- foreach((array)$custom_fields as $custom_field) {
1043
- $i = $custom_field['meta_id'];
1044
- // 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
1045
- $output .= "
1046
- <div class='product_custom_meta' id='custom_meta_$i'>
1047
- ".__('Name', 'wpsc')."
1048
- <input type='text' class='text' value='{$custom_field['meta_key']}' name='custom_meta[$i][name]' id='custom_meta_name_$i'>
1049
-
1050
- ".__('Value', 'wpsc')."
1051
- <textarea class='text' name='custom_meta[$i][value]' id='custom_meta_value_$i'>{$custom_field['meta_value']}</textarea>
1052
- <a href='#' class='remove_meta' onclick='return remove_meta(this, $i)'>".__('Delete')."</a>
1053
- <br />
1054
- </div>
1055
- ";
1056
- }
1057
-
1058
- $output .= "<div class='product_custom_meta'>
1059
- ".__('Name', 'wpsc').": <br />
1060
- <input type='text' name='new_custom_meta[name][]' value='' class='text'/><br />
1061
-
1062
- ".__('Description', 'wpsc').": <br />
1063
- <textarea name='new_custom_meta[value][]' cols='40' rows='10' class='text' ></textarea>
1064
- <br /></div></td></tr>";
1065
-
1066
- $output .= "<tr>
1067
- <td class='itemfirstcol' colspan='2'><br /> <strong>". __('Merchant Notes', 'wpsc') .":</strong><br />
1068
-
1069
- <textarea cols='40' rows='3' name='meta[_wpsc_product_metadata][merchant_notes]' id='merchant_notes'>".stripslashes($product_meta['merchant_notes'])."</textarea>
1070
- <small>".__('These notes are only available here.', 'wpsc')."</small>
1071
- </td>
1072
- </tr>";
1073
-
1074
- $output .="
1075
- <tr>
1076
- <td class='itemfirstcol' colspan='2'><br />
1077
- <strong>". __('Personalisation Options', 'wpsc') .":</strong><br />
1078
- <input type='hidden' name='meta[_wpsc_product_metadata][engraved]' value='0' />
1079
- <input type='checkbox' name='meta[_wpsc_product_metadata][engraved]' ".(($product_meta['engraved'] == true) ? 'checked="checked"' : '')." id='add_engrave_text' />
1080
- <label for='add_engrave_text'> ".__('Users can personalize this product by leaving a message on single product page', 'wpsc')."</label>
1081
- <br />
1082
- </td>
1083
- </tr>
1084
- <tr>
1085
- <td class='itemfirstcol' colspan='2'>
1086
-
1087
- <input type='hidden' name='meta[_wpsc_product_metadata][can_have_uploaded_image]' value='0' />
1088
- <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' />
1089
- <label for='can_have_uploaded_image'> ".__('Users can upload images on single product page to purchase logs.', 'wpsc')."</label>
1090
- <br />
1091
- </td>
1092
- </tr>";
1093
-
1094
-
1095
- if(get_option('payment_gateway') == 'google') {
1096
- $output .= "<tr>
1097
- <td class='itemfirstcol' colspan='2'>
1098
-
1099
- <input type='checkbox' ".$product_meta['google_prohibited']." name='meta[_wpsc_product_metadata][google_prohibited]' id='add_google_prohibited' /> <label for='add_google_prohibited'>
1100
- ".__('Prohibited', 'wpsc')."
1101
- <a href='http://checkout.google.com/support/sell/bin/answer.py?answer=75724'>by Google?</a></label><br />
1102
- </td>
1103
- </tr>";
1104
- }
1105
-
1106
- ob_start();
1107
- do_action('wpsc_add_advanced_options', $product_data['id']);
1108
- $output .= ob_get_contents();
1109
- ob_end_clean();
1110
-
1111
- $output .= "
1112
- <tr>
1113
- <td class='itemfirstcol' colspan='2'><br />
1114
- <strong>".__('Off Site Product Link', 'wpsc').":</strong><br />
1115
- <small>".__('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 over rides the buy now and add to cart links and takes you to the site linked here.', 'wpsc')."</small><br /><br />
1116
- <label for='external_link'>".__('External Link', 'wpsc')."</label>:<br />
1117
- <input type='text' class='text' name='meta[_wpsc_product_metadata][external_link]' value='".$product_meta['external_link']."' id='external_link' size='40' />
1118
- </td>
1119
- </tr>";
1120
- //if (get_option('wpsc_enable_comments') == 1) {
1121
- $output .= "
1122
- <tr>
1123
- <td class='itemfirstcol' colspan='2'><br />
1124
- <strong>".__('Enable Comments', 'wpsc').":</strong><br />
1125
- <select name='meta[_wpsc_product_metadata][enable_comments]'>
1126
- <option value='' ". (($product_meta['enable_comments'] == '' ) ? 'selected' : '') .">Use Default</option>
1127
- <option value='1' ". (($product_meta['enable_comments'] == '1') ? 'selected' : '') .">Yes</option>
1128
- <option value='0' ". (($product_meta['enable_comments'] == '0') ? 'selected' : '') .">No</option>
1129
- </select>
1130
- <br/>".__('Allow users to comment on this product.', 'wpsc')."
1131
- </td>
1132
- </tr>";
1133
- //}
1134
- $output .= "
1135
- </table></div></div>";
1136
- return $output;
1137
- }
1138
-
1139
- function wpsc_product_image_forms($product_data='') {
1140
- global $closed_postboxes;
1141
- if ($product_data == 'empty') {
1142
- $display = "style='display:none;'";
1143
- }
1144
-
1145
- //echo "<pre>".print_r($product_data,true)."</pre>";
1146
- /* Removing all this goodness in place of the Upload Image Above - justin - 5.20
1147
- //As in WordPress, If Mac and mod_security, no Flash
1148
- $flash = true;
1149
- if ( (false !== strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'mac')) && apache_mod_loaded('mod_security') ) {
1150
- $flash = false;
1151
- }
1152
-
1153
- $flash_action_url = admin_url('async-upload.php');
1154
- $flash = apply_filters('flash_uploader', $flash);
1155
- */
1156
- ?>
1157
- <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>
1158
- <h3 class='hndle'> <?php echo __('Product Images', 'wpsc'); ?></h3>
1159
- <div class='inside'>
1160
- <p><strong <?php echo $display; ?>><a href="media-upload.php?post_id=<?php echo $product_data['id']; ?>&type=image&tab=gallery&TB_iframe=1&width=640&height=566" class="thickbox" title="Manage your images"><?php echo __('Manage your thumbnails', 'wpsc');?></a></strong></p>
1161
- <?php
1162
- edit_multiple_image_gallery($product_data);
1163
- ?>
1164
-
1165
- </div>
1166
- <div style='clear:both'></div>
1167
- </div>
1168
- <?php
1169
- return $output;
1170
- }
1171
-
1172
- function wpsc_product_download_forms($product_data='') {
1173
- global $wpdb, $closed_postboxes;
1174
- if ($product_data == 'empty') {
1175
- $display = "style='display:none;'";
1176
- }
1177
-
1178
- $output ='';
1179
- $upload_max = wpsc_get_max_upload_size();
1180
- $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>";
1181
-
1182
- $output .= "<h3 class='hndle'>".__('Product Downloads', 'wpsc')."</h3>";
1183
- $output .= "<div class='inside'>";
1184
-
1185
- $output .= wpsc_select_product_file($product_data['id']);
1186
-
1187
- $output .= "<h4>".__('Upload New File', 'wpsc').":</h4>";
1188
- $output .= "<input type='file' name='file' value='' /><br />".__('Max Upload Size', 'wpsc')." : <span>".$upload_max."</span><br /><br />";
1189
- $output .= "<h4>".__('<a href="admin.php?wpsc_admin_action=product_files_existing&product_id='.$product_data['id'].'" class="thickbox" title="Select from all product files for '.$product_data['name'].'">Select from existing files</a>', 'wpsc')."</h4>";
1190
-
1191
- if($product_data['file'] > 0) {
1192
- $output .= __('Preview File', 'wpsc').": ";
1193
-
1194
- $output .= "<a class='admin_download' href='index.php?admin_preview=true&product_id=".$product_data['id']."' ><img align='absmiddle' src='".WPSC_URL."/images/download.gif' alt='' title='' /><span>".__('Click to download', 'wpsc')."</span></a>";
1195
-
1196
- $file_data = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_PRODUCT_FILES."` WHERE `id`='".$product_data['file']."' LIMIT 1",ARRAY_A);
1197
- if(($file_data != null) && (function_exists('listen_button'))) {
1198
- $output .= "".listen_button($file_data['idhash'], $file_data['id'])."<br style='clear: both;' /><br />";
1199
- }
1200
- }
1201
- if(function_exists("make_mp3_preview") || function_exists("wpsc_media_player")) {
1202
-
1203
- $output .= "<br />";
1204
- $output .="<h4>".__("Select an MP3 file to upload as a preview")."</h4>";
1205
-
1206
- $output .= "<input type='file' name='preview_file' value='' /><br />";
1207
- $output .= "<br />";
1208
- }
1209
- $output .="</div></div>";
1210
- return $output;
1211
- }
1212
-
1213
- function wpsc_product_label_forms() {
1214
- global $closed_postboxes;
1215
- ?>
1216
- <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>
1217
- <?php
1218
- if (function_exists('add_object_page')) {
1219
- echo "<h3 class='hndle'>";
1220
- } else {
1221
- echo "<h3>
1222
- <a class='togbox'>+</a>";
1223
- }
1224
- ?>
1225
- <?php echo __('Label Control', 'wpsc'); ?>
1226
- </h3>
1227
- <div class='inside'>
1228
- <table>
1229
- <tr>
1230
- <td colspan='2'>
1231
- <?php echo __('Add Label', 'wpsc'); ?> :
1232
- <a id='add_label'><?php echo __('Add Label', 'wpsc'); ?></a>
1233
- </td>
1234
- </tr>
1235
- <tr>
1236
- <td colspan='2'>
1237
- <div id="labels">
1238
- <table>
1239
- <tr>
1240
- <td><?=__('Label', 'wpsc')?> :</td>
1241
- <td><input type="text" name="productmeta_values[labels][]"></td>
1242
- </tr>
1243
- <tr>
1244
- <td><?=__('Label Description', 'wpsc')?> :</td>
1245
- <td><textarea name="productmeta_values[labels_desc][]"></textarea></td>
1246
- </tr>
1247
- <tr>
1248
- <td><?=__('Life Number', 'wpsc')?> :</td>
1249
- <td><input type="text" name="productmeta_values[life_number][]"></td>
1250
- </tr>
1251
- <tr>
1252
- <td><?=__('Item Number', 'wpsc')?> :</td>
1253
- <td><input type="text" name="productmeta_values[item_number][]"></td>
1254
- </tr>
1255
- <tr>
1256
- <td><?=__('Product Code', 'wpsc')?> :</td>
1257
- <td><input type="text" name="productmeta_values[product_code][]"></td>
1258
- </tr>
1259
- <tr>
1260
- <td><?=__('PDF', 'wpsc')?> :</td>
1261
- <td><input type="file" name="pdf[]"></td>
1262
- </tr>
1263
- </table>
1264
- </div>
1265
- </td>
1266
- </tr>
1267
- </table></div></div>
1268
- <?php
1269
- }
1270
-
1271
-
1272
- function edit_multiple_image_gallery($product_data) {
1273
- global $wpdb;
1274
- $siteurl = get_option('siteurl');
1275
- ?>
1276
- <ul id="gallery_list" class="ui-sortable" style="position: relative;">
1277
- <?php
1278
- if($product_data['id'] > 0) {
1279
- $args = array(
1280
- 'post_type' => 'attachment',
1281
- 'numberposts' => -1,
1282
- 'post_status' => null,
1283
- 'post_parent' => $product_data['id'],
1284
- 'orderby' => 'menu_order',
1285
- 'order' => 'ASC'
1286
- );
1287
-
1288
- $attached_images = (array)get_posts($args);
1289
- if($attached_images != null) {
1290
- foreach($attached_images as $image) {
1291
- $image_meta = get_post_meta($image->ID, '');
1292
- foreach($image_meta as $meta_name => $meta_value) {
1293
- $image_meta[$meta_name] = maybe_unserialize(array_pop($meta_value));
1294
- }
1295
-
1296
- if(function_exists("getimagesize")) {
1297
- $num++;
1298
- $image_url = "index.php?wpsc_action=scale_image&amp;attachment_id={$image->ID}&amp;width=60&amp;height=60";
1299
- ?>
1300
- <li id="product_image_<?php echo $image->ID; ?>" class='gallery_image'>
1301
- <input type='hidden' class='image-id' name='gallery_image_id[]' value='<?php echo $image->ID; ?>' />
1302
- <div class='previewimage' id='gallery_image_<?php echo $image->ID; ?>'>
1303
- <a id='extra_preview_link_<?php echo $image->ID; ?>' onclick='return false;' href='' rel='product_extra_image_<?php echo $image->ID; ?>' >
1304
- <img class='previewimage' src='<?php echo $image_url; ?>' alt='<?php echo __('Preview', 'wpsc'); ?>' title='<?php echo __('Preview', 'wpsc'); ?>' /><br />
1305
- </a>
1306
- <?php // echo wpsc_main_product_image_menu($product_data['id']); ?>
1307
- </div>
1308
- </li>
1309
- <?php
1310
- }
1311
- }
1312
- }
1313
- /*
1314
- $main_image = $wpdb->get_row("SELECT `images`.*
1315
- FROM `".WPSC_TABLE_PRODUCT_IMAGES."` AS `images`
1316
- JOIN `".WPSC_TABLE_PRODUCT_LIST."` AS `product`
1317
- ON `product`.`image` = `images`.`id`
1318
- WHERE `product`.`id` = '{$product_data['id']}'
1319
- LIMIT 1", ARRAY_A);
1320
- */
1321
- }
1322
- ?>
1323
- </ul>
1324
- <?php
1325
- }
1326
-
1327
- /*
1328
- function wpsc_main_product_image_menu($product_id) {
1329
- global $wpdb;
1330
- $thumbnail_state = 0;
1331
- if($product_id > 0) {
1332
- //$main_image = $wpdb->get_row("SELECT `images`.*, `product`.`thumbnail_state` FROM `".WPSC_TABLE_PRODUCT_IMAGES."` AS `images` JOIN `".WPSC_TABLE_PRODUCT_LIST."` AS `product` ON `product`.`image` = `images`.`id` WHERE `product`.`id` = '{$product_id}' LIMIT 1", ARRAY_A);
1333
- $thumbnail_state = $main_image['thumbnail_state'];
1334
- } else {
1335
- $thumbnail_state = 1;
1336
- }
1337
-
1338
- $sendback = wp_get_referer();
1339
- $presentation_link = add_query_arg('page','wpsc-settings', $sendback);
1340
- $presentation_link = add_query_arg('tab','presentation#thumb_settings', $presentation_link);
1341
- $thumbnail_image_height = get_product_meta($product_id, 'thumbnail_height');
1342
- $thumbnail_image_width = get_product_meta($product_id, 'thumbnail_width');
1343
-
1344
-
1345
-
1346
- // echo $thumbnail_image_height;
1347
- // echo "|";
1348
- // echo $thumbnail_image_width;
1349
- ob_start();
1350
- ?>
1351
- <div class='image_settings_box'>
1352
- <div class='upper_settings_box'>
1353
- <div class='upper_image'><img src='<?php echo WPSC_URL; ?>/images/pencil.png' alt='' /></div>
1354
- <div class='upper_txt'><?php _e('Thumbnail Settings'); ?><a class='closeimagesettings'>X</a></div>
1355
- </div>
1356
-
1357
- <div class='lower_settings_box'>
1358
- <input type='hidden' id='current_thumbnail_image' name='current_thumbnail_image' value='S' />
1359
- <ul>
1360
-
1361
- <li>
1362
- <input type='radio' name='gallery_resize' value='1' id='gallery_resize1' class='image_resize' onclick='image_resize_extra_forms(this)' /> <label for='gallery_resize1'><?php echo __('use default size', 'wpsc'); ?>(<a href='<?php echo $presentation_link; ?>' title='<?php echo __('This is set on the Settings Page', 'wpsc'); ?>'><?php echo get_option('product_image_height'); ?>&times;<?php echo get_option('product_image_width'); ?>px</a>)
1363
- </label>
1364
-
1365
- </li>
1366
-
1367
- <li>
1368
- <input type='radio' <?php echo (($thumbnail_state != 2) ? "checked='checked'" : "") ;?> name='gallery_resize' value='0' id='gallery_resize0' class='image_resize' onclick='image_resize_extra_forms(this)' /> <label for='gallery_resize0'> <?php echo __('do not resize thumbnail image', 'wpsc'); ?></label><br />
1369
- </li>
1370
-
1371
- <li>
1372
- <input type='radio' <?php echo (($thumbnail_state == 2) ? "checked='checked'" : "") ;?> name='gallery_resize' value='2' id='gallery_resize2' class='image_resize' onclick='image_resize_extra_forms(this)' /> <label for='gallery_resize2'><?php echo __('use specific size', 'wpsc'); ?> </label>
1373
- <div class='heightWidth image_resize_extra_forms' <?php echo (($thumbnail_state == 2) ? "style='display: block;'" : "") ;?>>
1374
- <input id='gallery_image_width' type='text' size='4' name='gallery_width' value='<?php echo $thumbnail_image_width; ?>' /><label for='gallery_image_width'><?php echo __('px width', 'wpsc'); ?></label>
1375
- <input id='gallery_image_height' type='text' size='4' name='gallery_height' value='<?php echo $thumbnail_image_height; ?>' /><label for='gallery_image_height'><?php echo __('px height', 'wpsc'); ?> </label>
1376
- </div>
1377
- </li>
1378
-
1379
- <li>
1380
- <input type='radio' name='gallery_resize' value='3' id='gallery_resize3' class='image_resize' onclick='image_resize_extra_forms(this)' /> <label for='gallery_resize3'> <?php echo __('use separate thumbnail', 'wpsc'); ?></label><br />
1381
- <div class='browseThumb image_resize_extra_forms'>
1382
- <input type='file' name='gallery_thumbnailImage' size='15' value='' />
1383
- </div>
1384
- </li>
1385
- <li>
1386
- <a href='<?php echo htmlentities("admin.php?wpsc_admin_action=crop_image&imagename=".$main_image['image']."&imgheight=".$image_data[1]."&imgwidth=".$image_data[0]."&width=630&height=500&product_id=".$product_id); ?>' title='Crop Image' class='thickbox'>Crop This Image Using jCrop</a>
1387
-
1388
- </li>
1389
- <li>
1390
- <a href='#' class='delete_primary_image delete_button'>Delete this Image</a>
1391
- </li>
1392
-
1393
- </ul>
1394
- </div>
1395
- </div>
1396
- <a class='editButton'>Edit <img src='<?php echo WPSC_URL; ?>/images/pencil.png' alt='' /></a>
1397
- <?php
1398
- $output = ob_get_contents();
1399
- ob_end_clean();
1400
- return $output;
1401
- } /*
1402
-
1403
- /**
1404
- * Displays the category forms for adding and editing products
1405
- * Recurses to generate the branched view for subcategories
1406
- */
1407
- function wpsc_category_list(&$product_data, $group_id, $unique_id = '', $category_id = null) {
1408
- global $wpdb;
1409
- static $iteration = 0;
1410
- $iteration++;
1411
-
1412
- if(is_numeric($category_id)) {
1413
- $values = get_terms('wpsc_product_category', "hide_empty=0&parent=".$category_id, ARRAY_A);
1414
- } else {
1415
- $values = get_terms('wpsc_product_category', "hide_empty=0&parent=".$group_id, ARRAY_A);
1416
- }
1417
-
1418
- if($category_id < 1) {
1419
- $output .= "<ul class='list:category categorychecklist form-no-clear'>\n\r";
1420
- } elseif((count($values) >0)){
1421
- $output .= "<ul class='children'>\n\r";
1422
- }
1423
-
1424
- //echo "<pre>".print_r($values, true)."</pre>";
1425
-
1426
- foreach((array)$values as $option) {
1427
- $option=(array)$option;
1428
-
1429
- if(count($product_data['category_ids']) > 0) {
1430
- if(in_array($option['term_id'], $product_data['category_ids'])) {
1431
- $selected = "checked='checked'";
1432
- }
1433
- }
1434
-
1435
- $output .= " <li id='category-".$option['term_id']."'>\n\r";
1436
- $output .= " <label class='selectit'>\n\r";
1437
- $output .= " <input id='".$unique_id."category_form_".$option['term_id']."' type='checkbox' {$selected} name='category[]' value='".$option['term_id']."' /></label>\n\r";
1438
-
1439
- $output .= " <label for='".$unique_id."category_form_".$option['term_id']."' class='greytext' >".stripslashes($option['name'])."</label>\n\r";
1440
- $output .= wpsc_category_list($product_data, $group_id, $unique_id, $option['term_id']);
1441
-
1442
- $output .= " </li>\n\r";
1443
-
1444
- $selected = "";
1445
- }
1446
- if((count($values) >0) ){
1447
- $output .= "</ul>\n\r";
1448
- }
1449
- return $output;
1450
- }
1451
-
1452
- /**
1453
- * Slightly modified copy of the Wordpress the_editor function
1454
- *
1455
- * We have to use a modified version because the wordpress one calls javascript that uses document.write
1456
- * When this javascript runs after being loaded through AJAX, it replaces the whole page.
1457
- *
1458
- * The amount of rows the text area will have for the content has to be between
1459
- * 3 and 100 or will default at 12. There is only one option used for all users,
1460
- * named 'default_post_edit_rows'.
1461
- *
1462
- * If the user can not use the rich editor (TinyMCE), then the switch button
1463
- * will not be displayed.
1464
- *
1465
- * @since 3.7
1466
- *
1467
- * @param string $content Textarea content.
1468
- * @param string $id HTML ID attribute value.
1469
- * @param string $prev_id HTML ID name for switching back and forth between visual editors.
1470
- * @param bool $media_buttons Optional, default is true. Whether to display media buttons.
1471
- * @param int $tab_index Optional, default is 2. Tabindex for textarea element.
1472
- */
1473
- function wpsc_the_editor($content, $id = 'content', $prev_id = 'title', $media_buttons = true, $tab_index = 2) {
1474
- $rows = get_option('default_post_edit_rows');
1475
- if (($rows < 3) || ($rows > 100))
1476
- $rows = 12;
1477
-
1478
- if ( !current_user_can( 'upload_files' ) )
1479
- $media_buttons = false;
1480
-
1481
- $richedit = user_can_richedit();
1482
- $class = '';
1483
-
1484
- if ( $richedit || $media_buttons ) {
1485
- ?>
1486
- <div id="editor-toolbar">
1487
- <?php
1488
- if ( $richedit ) {
1489
- $wp_default_editor = wp_default_editor(); ?>
1490
- <div class="zerosize"><input accesskey="e" type="button" onclick="switchEditors.go('<?php echo $id; ?>')" /></div>
1491
- <?php if ( 'html' == $wp_default_editor ) {
1492
- add_filter('the_editor_content', 'wp_htmledit_pre'); ?>
1493
- <a id="edButtonHTML" class="active hide-if-no-js" onclick="switchEditors.go('<?php echo $id; ?>', 'html');"><?php _e('HTML'); ?></a>
1494
- <a id="edButtonPreview" class="hide-if-no-js" onclick="switchEditors.go('<?php echo $id; ?>', 'tinymce');"><?php _e('Visual'); ?></a>
1495
- <?php } else {
1496
- $class = " class='theEditor'";
1497
- add_filter('the_editor_content', 'wp_richedit_pre'); ?>
1498
- <a id="edButtonHTML" class="hide-if-no-js" onclick="switchEditors.go('<?php echo $id; ?>', 'html');"><?php _e('HTML'); ?></a>
1499
- <a id="edButtonPreview" class="active hide-if-no-js" onclick="switchEditors.go('<?php echo $id; ?>', 'tinymce');"><?php _e('Visual'); ?></a>
1500
- <?php }
1501
- }
1502
-
1503
- if ( $media_buttons ) { ?>
1504
- <div id="media-buttons" class="hide-if-no-js">
1505
- <?php do_action( 'media_buttons' ); ?>
1506
- </div>
1507
- <?php
1508
- } ?>
1509
- </div>
1510
- <?php
1511
- }
1512
- ?>
1513
- <div id="quicktags"><?php
1514
- wp_print_scripts( 'quicktags' ); ?>
1515
- <div id="ed_toolbar">
1516
- </div>
1517
- <script type="text/javascript" defer="defer'">wpsc_edToolbar()</script>
1518
-
1519
- </div>
1520
-
1521
- <?php
1522
- $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");
1523
- $the_editor_content = apply_filters('the_editor_content', $content);
1524
-
1525
- printf($the_editor, $the_editor_content);
1526
-
1527
- ?>
1528
- <script type="text/javascript">
1529
- edCanvas = document.getElementById('<?php echo $id; ?>');
1530
- </script>
1531
- <?php
1532
- }
1533
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WPSC Product form generation functions
4
+ *
5
+ * @package wp-e-commerce
6
+ * @since 3.7
7
+ */
8
+ //$closed_postboxes = (array)get_user_meta( $current_user->ID, 'editproduct');
9
+ //$variations_processor = new nzshpcrt_variations;
10
+
11
+ global $wpsc_product_defaults;
12
+ $wpsc_product_defaults =array (
13
+ 'id' => '0',
14
+ 'name' => '',
15
+ 'description' => '',
16
+ 'additional_description' => '',
17
+ 'price' => '0.00',
18
+ 'weight' => '0',
19
+ 'weight_unit' => 'pound',
20
+ 'pnp' => '0.00',
21
+ 'international_pnp' => '0.00',
22
+ 'file' => '0',
23
+ 'image' => '',
24
+ 'category' => '0',
25
+ 'brand' => '0',
26
+ 'quantity_limited' => '0',
27
+ 'quantity' => '0',
28
+ 'special' => '0',
29
+ 'special_price' => 0.00,
30
+ 'display_frontpage' => '0',
31
+ 'notax' => '0',
32
+ 'publish' => '1',
33
+ 'active' => '1',
34
+ 'donation' => '0',
35
+ 'no_shipping' => '0',
36
+ 'thumbnail_image' => '',
37
+ 'thumbnail_state' => '1',
38
+ 'meta' =>
39
+ array (
40
+ 'external_link' => NULL,
41
+ 'merchant_notes' => NULL,
42
+ 'sku' => NULL,
43
+ 'engrave' => '0',
44
+ 'can_have_uploaded_image' => '0',
45
+ 'table_rate_price' =>
46
+ array (
47
+ 'quantity' =>
48
+ array (
49
+ 0 => '',
50
+ ),
51
+ 'table_price' =>
52
+ array (
53
+ 0 => '',
54
+ ),
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
+ {
66
+ foreach ($array1 as $key => $value)
67
+ {
68
+ // create new key in $array, if it is empty or not an array
69
+ if (!isset($array[$key]) || (isset($array[$key]) && !is_array($array[$key])))
70
+ {
71
+ $array[$key] = array();
72
+ }
73
+
74
+ // overwrite the value in the base array
75
+ if (is_array($value))
76
+ {
77
+ $value = recurse($array[$key], $value);
78
+ }
79
+ $array[$key] = $value;
80
+ }
81
+ return $array;
82
+ }
83
+
84
+ // handle the arguments, merge one by one
85
+ $args = func_get_args();
86
+ $array = $args[0];
87
+ if (!is_array($array))
88
+ {
89
+ return $array;
90
+ }
91
+ for ($i = 1; $i < count($args); $i++)
92
+ {
93
+ if (is_array($args[$i]))
94
+ {
95
+ $array = recurse($array, $args[$i]);
96
+ }
97
+ }
98
+ return $array;
99
+ }
100
+ }
101
+
102
+ function wpsc_populate_product_data($product_id, $wpsc_product_defaults) {
103
+ global $wpdb, $product;
104
+ $tt_ids = array();
105
+ $term_ids = array();
106
+ $product = get_post($product_id);
107
+ //print("<pre>" . print_r($product, true) . "</pre>");
108
+
109
+ $product_data['id'] = $product->ID;
110
+ $product_data['name'] = $product->post_title;
111
+ $product_data['post_type'] = $product->post_type;
112
+ $product_data['post_status'] = $product->post_status;
113
+ $product_data['description'] = $product->post_content;
114
+ $product_data['additional_description'] = $product->post_excerpt;
115
+ // get the list of categories this product is associated with
116
+
117
+ $product_data['categories'] = wp_get_product_categories($product->ID);
118
+ $product_data['tags'] = wp_get_product_tags($product->ID);
119
+ $product_data['category_ids'] = array();
120
+
121
+ $product_data['product_object'] = $product;
122
+
123
+ foreach((array)$product_data['categories'] as $category_item) {
124
+ $product_data['category_ids'][] = (int)$category_item->term_id;
125
+ }
126
+
127
+
128
+ // Meta Values come straight from the meta table
129
+ $product_data['meta'] = array();
130
+ $product_data['meta'] = get_post_meta($product->ID, '');
131
+ if ( is_array ( $product_data['meta'] ) ) {
132
+ foreach($product_data['meta'] as $meta_name => $meta_value) {
133
+ $product_data['meta'][$meta_name] = maybe_unserialize(array_pop($meta_value));
134
+ }
135
+ }
136
+ //$sql ="SELECT `meta_key`, `meta_value` FROM ".WPSC_TABLE_PRODUCTMETA." WHERE `meta_key` LIKE 'currency%' AND `product_id`=".$product_id;
137
+ //$product_data['newCurr']= $wpdb->get_results($sql, ARRAY_A);
138
+ $product_data['dimensions'] = get_product_meta($product_id, 'dimensions',true);
139
+
140
+ // Transformed Values have been altered in some way since being extracted from some data source
141
+ $product_data['transformed'] = array();
142
+ $product_data['transformed']['weight'] = wpsc_convert_weight($product_data['meta']['_wpsc_product_metadata']['weight'], "gram", $product_data['meta']['_wpsc_product_metadata']['display_weight_as']);
143
+
144
+ //echo "<pre>".print_r($product_data,true)."</pre>";
145
+ if(function_exists('wp_insert_term')) {
146
+ $term_relationships = $wpdb->get_results("SELECT * FROM `{$wpdb->term_relationships}` WHERE object_id = '{$product_data['id']}'", ARRAY_A);
147
+
148
+ foreach ((array)$term_relationships as $term_relationship) {
149
+ $tt_ids[] = $term_relationship['term_taxonomy_id'];
150
+ }
151
+ foreach ((array)$tt_ids as $tt_id) {
152
+ $term_ids[] = $wpdb->get_var("SELECT `term_id` FROM `{$wpdb->term_taxonomy}` WHERE `term_taxonomy_id` = '{$tt_id}' AND `taxonomy` = 'product_tag' LIMIT 1");
153
+ }
154
+ foreach ((array)$term_ids as $term_id ) {
155
+ if ($term_id != NULL){
156
+ $tags[] = $wpdb->get_var("SELECT `name` FROM `{$wpdb->terms}` WHERE `term_id`='{$term_id}' LIMIT 1");
157
+ }
158
+ }
159
+ if (isset($tags)){
160
+ $imtags = implode(',', $tags);
161
+ }
162
+ }
163
+ return $product_data;
164
+ }
165
+
166
+ function wpsc_display_product_form ($product_id = 0) {
167
+ global $wpdb, $wpsc_product_defaults;
168
+ $product_id = absint($product_id);
169
+
170
+ if($product_id > 0) {
171
+ $product_data = wpsc_populate_product_data($product_id, $wpsc_product_defaults);
172
+ } else {
173
+ if(isset($_SESSION['wpsc_failed_product_post_data']) && (count($_SESSION['wpsc_failed_product_post_data']) > 0 )) {
174
+ $product_data = array_merge($wpsc_product_defaults, $_SESSION['wpsc_failed_product_post_data']);
175
+ $_SESSION['wpsc_failed_product_post_data'] = null;
176
+ } else {
177
+ $product_data = $wpsc_product_defaults;
178
+ }
179
+ }
180
+
181
+ $current_user = wp_get_current_user();
182
+
183
+ // we put the closed postboxes array into the product data to propagate it to each form without having it global.
184
+ $product_data['closed_postboxes'] = (array)get_user_meta( $current_user->ID, 'closedpostboxes_products_page_wpsc-edit-products');
185
+ $product_data['hidden_postboxes'] = (array)get_user_meta( $current_user->ID, 'metaboxhidden_products_page_wpsc-edit-products');
186
+
187
+ if(count($product_data) > 0) {
188
+ wpsc_product_basic_details_form($product_data);
189
+ }
190
+ }
191
+ /*
192
+ Stop-gap function replicating native WP functionality
193
+ */
194
+
195
+ function add_new_product_id() {
196
+ global $wpdb;
197
+ $prod_id = $wpdb->get_var($wpdb->prepare("SELECT MAX( ID ) FROM $wpdb->posts"));
198
+ $prod_id = $prod_id + 1;
199
+
200
+ $wpdb->query( $wpdb->prepare( "INSERT INTO $wpdb->posts ( post_author, post_date, post_date_gmt, post_title, post_status, post_parent, post_type)
201
+ VALUES ( %d, %s, %s, %s, %s, %d, %s )",
202
+ 1, 'CURDATE()', 'CURDATE()', 'stopgap', 'inherit', $prod_id, 'attachment' ) );
203
+
204
+ return $prod_id;
205
+ }
206
+
207
+ function delete_stopgap() {
208
+ global $wpdb;
209
+ $wpdb->query( "DELETE FROM $wpdb->posts WHERE post_parent = $uploading_iframe_ID AND post_title = 'stopgap'" );
210
+ }
211
+ if(isset($product_data['id']) && $product_data['id'] > 0) {
212
+ add_action('transition_post_status', 'delete_stopgap');
213
+ }
214
+ function wpsc_product_basic_details_form(&$product_data) {
215
+ global $wpdb,$nzshpcrt_imagesize_info, $user_ID;
216
+
217
+ if(!isset($product_data['product_object'])) $product_data['product_object'] = new stdClass();
218
+ $product = $product_data['product_object'];
219
+ $post_ID = (int) $product_data["id"];
220
+ /*<h3 class='hndle'><?php echo __('Product Details', 'wpsc'); ?> <?php echo __('(enter in your product details here)', 'wpsc'); ?></h3>*/
221
+ ?>
222
+ <h3 class='form_heading' style="display:none;">
223
+ <?php
224
+ if($product_data['id'] > 0) {
225
+ echo __('Edit Product', 'wpsc');
226
+ } else {
227
+ echo __('Add New', 'wpsc');
228
+ $product_data["id"] = $_GET["product"] = add_new_product_id();
229
+ }
230
+ $form_extra = '';
231
+ if(!isset($product->post_status)) $product->post_status = '';
232
+ if ( 'auto-draft' == $product->post_status ) {
233
+ if ( 'edit' == $action )
234
+ $product->post_title = '';
235
+ $autosave = false;
236
+ $form_extra .= "<input type='hidden' id='auto_draft' name='auto_draft' value='1' />";
237
+ } else {
238
+ $autosave = wp_get_post_autosave( $product_data["id"] );
239
+ }
240
+ if(!isset($product->post_type)) $product->post_type = '';
241
+ $nonce_action = 'update-' . $product->post_type . '_' . $product_data["id"];
242
+ $form_extra .= "<input type='hidden' id='post_ID' name='post_ID' value='" . esc_attr($product_data["id"]) . "' />";
243
+
244
+ $sticky = get_option( 'sticky_posts' );
245
+ if ( in_array ( $product_data["id"], $sticky ) )
246
+ $sticky_checked = 'checked="checked" ';
247
+
248
+ ?>
249
+ </h3>
250
+ <div id="side-info-column" class="inner-sidebar">
251
+ <div id="side-sortables" class='meta-box-sortables-wpec ui-sortable'>
252
+ <?php wp_nonce_field($nonce_action);
253
+ if(!isset($form_action)) $form_action = '';
254
+ if(!isset($product->post_author)) $product->post_author = '';
255
+ if(!isset($product->post_type)) $product->post_type = '';
256
+ if(!isset($product->post_status)) $product->post_status = '';
257
+ ?>
258
+ <input type="hidden" id="user-id" name="user_ID" value="<?php echo (int) $user_ID ?>" />
259
+ <input type="hidden" id="hiddenaction" name="action" value="<?php echo esc_attr($form_action) ?>" />
260
+ <input type="hidden" id="originalaction" name="originalaction" value="<?php echo esc_attr($form_action) ?>" />
261
+ <input type="hidden" id="post_author" name="post_author" value="<?php echo esc_attr( $product->post_author ); ?>" />
262
+ <input type="hidden" id="post_type" name="post_type" value="<?php echo esc_attr($product->post_type) ?>" />
263
+ <input type="hidden" id="original_post_status" name="original_post_status" value="<?php echo esc_attr($product->post_status) ?>" />
264
+ <input type="hidden" id="referredby" name="referredby" value="<?php echo esc_url(stripslashes(wp_get_referer())); ?>" />
265
+ <?php
266
+ if ( 'draft' != $product->post_status )
267
+ wp_original_referer_field(true, 'previous');
268
+
269
+ echo $form_extra;
270
+
271
+ wp_nonce_field( 'autosave', 'autosavenonce', false );
272
+ ?>
273
+ <input type='hidden' name='product_id' id='product_id' value='<?php echo (int) $product_data["id"]; ?>' />
274
+ <input type='hidden' name='wpsc_admin_action' value='edit_product' />
275
+ <?php wp_nonce_field('edit-product', 'wpsc-edit-product'); ?>
276
+
277
+ <?php /*
278
+ <input class='button-primary' style='float:left;' type='submit' name='submit' value='<?php if($product_data['id'] > 0) { _e('Update Product', 'wpsc'); } else { _e('Add New Product', 'wpsc'); } ?>' />&nbsp;
279
+ */ ?>
280
+ <div id="submitdiv" class="postbox">
281
+ <div class="handlediv" title="Click to toggle"><br></div><h3 class="hndle"><span>Publish</span></h3>
282
+ <div class="inside publish">
283
+ <div class="submitbox" id="submitpost"><br />
284
+ <span id="sticky-span" style="display: inline; "><input id="sticky" name="sticky" type="checkbox" <?php if (isset($sticky_checked)) echo $sticky_checked; ?>value="sticky" tabindex="4"> <label for="sticky" class="selectit">Stick this product to the front page</label><br></span>
285
+ <div id="minor-publishing">
286
+ <div id="minor-publishing-actions">
287
+ <div id="save-action">
288
+ <?php
289
+ if(($product->post_status == 'draft') || ($product->post_status == null)) {
290
+ ?>
291
+ <input type='submit' value='<?php _e('Save Draft', 'wpsc'); ?>' class='button button-highlighted' id="save-post" name='save' />
292
+ <?php
293
+ } else {
294
+ ?>
295
+ <input type='submit' value='<?php _e('Unpublish', 'wpsc'); ?>' class='button button-highlighted' id='save-post' name='unpublish' />
296
+ <?php
297
+ }
298
+ ?>
299
+ </div>
300
+ <div id="preview-action">
301
+ <a class="preview button" id="post-preview" href="<?php echo wpsc_product_url( $product_data['id'] ); ?>"><?php _e('View Product') ?></a>
302
+ </div>
303
+ <div class="clear"></div>
304
+ </div>
305
+ </div>
306
+ <div id="major-publishing-actions">
307
+ <div id="delete-action">
308
+ <a class='submitdelete deletion' title='<?php echo esc_attr(__('Delete this product')); ?>' href='<?php echo wp_nonce_url("page.php?wpsc_admin_action=trash&amp;product={$product_data['id']}", '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') ?>
309
+ </a><br />
310
+ </div>
311
+ <div id="publishing-action">
312
+ <?php
313
+ if(($product->post_status == 'draft') || ($product->post_status == null)) {
314
+ ?>
315
+ <input type='submit' value='<?php _e('Publish', 'wpsc'); ?>' id='publish' class='button-primary' name='publish' />
316
+ <?php
317
+ } else {
318
+ ?>
319
+ <input type='submit' value='<?php _e('Update', 'wpsc'); ?>' id='publish' class='button-primary' name='save' />
320
+ <?php
321
+ }
322
+ ?>
323
+ </div>
324
+ <div class="clear"></div>
325
+ </div>
326
+ </div>
327
+ </div>
328
+ </div>
329
+
330
+
331
+ <?php
332
+
333
+ $default_order = array(
334
+ "advanced" => array(
335
+ "wpsc_product_shipping_forms",
336
+ "wpsc_product_variation_forms",
337
+ "wpsc_product_advanced_forms"
338
+ ),
339
+ "side" => array(
340
+ "wpsc_product_category_and_tag_forms",
341
+ "wpsc_product_price_and_stock_forms",
342
+ "wpsc_product_image_forms",
343
+ "wpsc_product_download_forms"
344
+ ),
345
+ "closedboxes" => array(
346
+ "wpsc_product_shipping_forms" => 1,
347
+ "wpsc_product_variation_forms" => 1,
348
+ "wpsc_product_advanced_forms" => 1,
349
+ "wpsc_product_category_and_tag_forms" => 1,
350
+ "wpsc_product_price_and_stock_forms" => 1,
351
+ "wpsc_product_image_forms" => 1,
352
+ "wpsc_product_download_forms" => 1
353
+ ),
354
+ "hiddenboxes" => array(
355
+ "wpsc_product_shipping_forms" => 1,
356
+ "wpsc_product_variation_forms" => 1,
357
+ "wpsc_product_advanced_forms" => 1,
358
+ "wpsc_product_category_and_tag_forms" => 1,
359
+ "wpsc_product_price_and_stock_forms" => 1,
360
+ "wpsc_product_image_forms" => 1,
361
+ "wpsc_product_download_forms" => 1
362
+ )
363
+ );
364
+
365
+ $order = get_option('wpsc_product_page_order');
366
+
367
+ $order = apply_filters( 'wpsc_products_page_forms', $order);
368
+
369
+ if ( ( $order == '' ) || ( count ( $order, COUNT_RECURSIVE ) < 24 ) || ( count ( $order ) == count ( $order, COUNT_RECURSIVE ) ) ) {
370
+ $order = $default_order;
371
+ }
372
+ $check_missing_items = array_diff($default_order, $order);
373
+
374
+ if(count($check_missing_items) > 0) {
375
+ $order = array_merge($check_missing_items, $order);
376
+ }
377
+
378
+ update_option('wpsc_product_page_order', $order);
379
+
380
+ // if this is a child product, we need to filter out the variations box here
381
+ if(isset($product_data['product_object']->post_parent) && $product_data['product_object']->post_parent > 0) {
382
+ $variation_box_key = array_search('wpsc_product_variation_forms', $order);
383
+ if(is_numeric($variation_box_key) && isset($order[$variation_box_key])) {
384
+ unset($order[$variation_box_key]);
385
+ }
386
+
387
+ $category_box_key = array_search('wpsc_product_category_and_tag_forms', $order);
388
+ if(is_numeric($category_box_key) && isset($order[$category_box_key])) {
389
+ unset($order[$category_box_key]);
390
+ }
391
+
392
+ }
393
+
394
+ foreach((array)$order["side"] as $key => $box_function_name) {
395
+ if(function_exists($box_function_name)) {
396
+ echo call_user_func($box_function_name,$product_data);
397
+ }
398
+ }
399
+ // echo "<pre>"; print_r($order); echo "</pre>";
400
+ ?>
401
+ </div>
402
+ </div>
403
+ <script type="text/javascript">
404
+ var makeSlugeditClickable;
405
+ makeSlugeditClickable = null;
406
+ //<![CDATA[
407
+ jQuery(document).ready( function($) {
408
+ <?php
409
+ $closed_boxes = $order["closedboxes"];
410
+ foreach ($closed_boxes as $key=>$val) {
411
+ if ( $val == 0 ) {
412
+ ?>
413
+ $('div#<?php echo $key; ?>').addClass('closed');
414
+ <?php
415
+ }
416
+ }
417
+ ?>
418
+ $('#poststuff .postbox h3, .postbox div.handlediv').click( function() {
419
+ $(this).parent().toggleClass('closed');
420
+ wpsc_save_postboxes_state('store_page_wpsc-edit-products', '#poststuff');
421
+ });
422
+
423
+ <?php
424
+ $hidden_boxes = $order["hiddenboxes"];
425
+ foreach ($hidden_boxes as $key=>$val) {
426
+ if ( $val == 0 ) {
427
+ ?>
428
+ $('div#<?php echo $key; ?>').css('display', 'none');
429
+ $('div.metabox-prefs label input[value=<?php echo $key; ?>]').attr('checked', false);
430
+ <?php
431
+ }
432
+ elseif ($val == 1) {
433
+
434
+ ?>
435
+ $('div.metabox-prefs label input[value=<?php echo $key; ?>]').attr('checked', true);
436
+
437
+ <?php
438
+
439
+ }
440
+ }
441
+ ?>
442
+
443
+ $('div.variation input, div.variation_set input').click(function(){
444
+ $('a.update_variations_action').show();
445
+ });
446
+ });
447
+ //]]>
448
+ </script>
449
+ <?php
450
+ if(isset($_GET["product_parent"]) && ($_GET["product_parent"] != '')) {
451
+ $parent_link = add_query_arg(array('page' => 'wpsc-edit-products', 'action' => 'wpsc_add_edit' ,'product' => $_GET["product_parent"]));
452
+ $parent_link = remove_query_arg('product_parent');
453
+ $parent_link = wp_nonce_url($parent_link, 'edit-product_'.$product->ID);
454
+ }
455
+ ?><?php
456
+ if(isset($_GET["product_parent"]) && ($_GET["product_parent"] != '')) {
457
+ ?>
458
+ <a class="button preview update_variations" href="<?php echo $parent_link?>">Back to Main Product</a>
459
+ <?php } ?>
460
+ <div id="post-body" class="has-sidebar">
461
+ <div id="post-body-content">
462
+ <table class='product_editform' >
463
+ <tr>
464
+ <td colspan='2' class='itemfirstcol'>
465
+
466
+ <div class='admin_product_name'>
467
+ <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'); ?>' />
468
+ <a href='#' class='shorttag_toggle'></a>
469
+ </div>
470
+ <div class='admin_product_shorttags'>
471
+ <h4><?php _e('Shortcodes', 'wpsc'); global $wpsc_product_defaults;?></h4>
472
+
473
+ <dl>
474
+ <dt><?php _e('Display Product Shortcode', 'wpsc'); ?>: </dt><dd>[wpsc_products product_id='<?php echo $product_data['id'];?>']</dd>
475
+ <dt><?php _e('Buy Now Shortcode', 'wpsc'); ?>: </dt><dd>[buy_now_button=<?php echo $product_data['id'];?>]</dd>
476
+ <dt><?php _e('Add to Cart Shortcode', 'wpsc'); ?>: </dt><dd>[add_to_cart=<?php echo $product_data['id'];?>]</dd>
477
+ </dl>
478
+
479
+ <h4><?php _e('Template Tags', 'wpsc'); ?></h4>
480
+
481
+ <dl>
482
+ <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>
483
+ <dt><?php _e('Buy Now PHP', 'wpsc'); ?>: </dt><dd>&lt;?php echo wpsc_buy_now_button(<?php echo $product_data['id'];?>); ?&gt;</dd>
484
+ <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>
485
+ <dt><?php _e('Display Product SKU', 'wpsc'); ?>: </dt><dd>&lt;?php echo wpsc_product_sku(<?php echo $product_data['id'];?>); ?&gt;</dd>
486
+ </dl>
487
+
488
+ <?php if ( $product_data['id'] > 0 ) { ?>
489
+ <p><a href="<?php echo wpsc_product_url( $product_data['id'] ); ?>" target="_blank" class="button">View product</a></p>
490
+ <?php } ?>
491
+
492
+ </div>
493
+ <div style='clear:both; height: 0px; margin-bottom: 15px;'></div>
494
+ </td>
495
+ </tr>
496
+ <tr>
497
+ <td colspan='2'>
498
+ <div id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>" class="postarea" >
499
+ <?php
500
+ wpsc_the_editor($product_data['description'], 'content',true, true);
501
+ ?>
502
+ <table id="post-status-info" cellspacing="0"><tbody><tr>
503
+ <td id="wp-word-count"></td>
504
+ <td class="autosave-info">
505
+ <span id="autosave">&nbsp;</span>
506
+ </td>
507
+ </tr></tbody></table>
508
+ </div>
509
+ </td>
510
+ </tr>
511
+
512
+ <tr>
513
+ <td class='itemfirstcol' colspan='2'>
514
+
515
+ <strong ><?php echo __('Additional Description', 'wpsc'); ?> :</strong><br />
516
+
517
+ <textarea name='additional_description' id='additional_description' cols='40' rows='5' ><?php echo stripslashes($product_data['additional_description']); ?></textarea>
518
+ </td>
519
+ </tr>
520
+ </table>
521
+ </div>
522
+ <div id="advanced-sortables" class="meta-box-sortables-wpec ui-sortable">
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
+ }
534
+ function wpsc_product_category_and_tag_forms($product_data=''){
535
+ global $closed_postboxes, $wpdb, $variations_processor;
536
+
537
+ $output = '';
538
+ //echo "<pre>".print_r($product_data['tags'], true)."</pre>";
539
+ $tag_array = array();
540
+ if (!isset($product_data['tags'])) $product_data['tags'] = array();
541
+ foreach((array)$product_data['tags'] as $tag) {
542
+ $tag_array[] = $tag->name;
543
+ }
544
+ if ($product_data == 'empty') {
545
+ $display = "style='visibility:hidden;'";
546
+ }
547
+ $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>";
548
+
549
+ if (IS_WP27) {
550
+ $output .= "<h3 class='hndle'>";
551
+ } else {
552
+ $output .= "<h3>
553
+ <a class='togbox'>+</a>";
554
+ }
555
+ $output .= __('Categories and Tags', 'wpsc');
556
+
557
+ $output .= "
558
+ </h3>
559
+ <div class='inside'>
560
+ <table>";
561
+ $output .= "
562
+ <tr>
563
+ <td class='itemfirstcol'>
564
+ <strong >".__('Product Categories', 'wpsc')." </strong>
565
+ <div id='categorydiv' >";
566
+ $search_sql = apply_filters('wpsc_product_category_and_tag_forms_group_search_sql', '');
567
+ //$categorisation_groups = get_terms('wpsc_product_category', "hide_empty=0&parent=0", ARRAY_A);
568
+
569
+ $output .= wpsc_category_list($product_data, 0, $product_data['id'], 'edit_');
570
+
571
+
572
+ $output .= "
573
+ </div>
574
+ </td>
575
+ <td class='itemfirstcol product_tags'>
576
+ <strong > ".__('Product Tags', 'wpsc')."</strong><br />
577
+ <p id='jaxtag'>
578
+ <label for='tags-input' class='hidden'>".__('Product Tags', 'wpsc')."</label>
579
+ <input type='text' value='".implode(',',$tag_array)."' tabindex='3' size='20' id='tags-input' class='tags-input' name='product_tags'/>
580
+ <span class='howto'>".__('Separate tags with commas')."</span>
581
+ </p>
582
+ <div id='tagchecklist' class='tagchecklist' onload='tag_update_quickclicks();'></div>
583
+
584
+ </td>
585
+
586
+ </tr>";
587
+ $output .= "
588
+ </table>
589
+ </div>
590
+ </div>";
591
+ $output = apply_filters('wpsc_product_category_and_tag_forms_output', $output);
592
+
593
+ return $output;
594
+
595
+ }
596
+ function wpsc_product_price_and_stock_forms($product_data=''){
597
+ global $closed_postboxes, $wpdb, $variations_processor, $wpsc_product_defaults;
598
+ $product_meta = &$product_data['meta']['_wpsc_product_metadata'];
599
+
600
+ if(!isset($product_data['meta']['_wpsc_table_rate_price'])) $product_data['meta']['_wpsc_table_rate_price'] = $wpsc_product_defaults['meta']['table_rate_price'];
601
+ $table_rate_price = $product_data['meta']['_wpsc_table_rate_price'];
602
+
603
+ if(!isset($product_data['meta']['_wpsc_custom_tax'])) $product_data['meta']['_wpsc_custom_tax'] = '';
604
+ $custom_tax = $product_data['meta']['_wpsc_custom_tax'];
605
+
606
+ if(!isset($product_data['meta']['_wpsc_is_donation'])) $product_data['meta']['_wpsc_is_donation'] = $wpsc_product_defaults['donation'];
607
+ if(!isset($product_meta['table_rate_price']['state'])) $product_meta['table_rate_price']['state'] = null;
608
+
609
+ if(!isset($product_meta['custom_tax'])) $product_meta['custom_tax'] = 0.00;
610
+
611
+ if(!isset($product_meta['table_rate_price']['quantity'])) $product_meta['table_rate_price']['quantity'] = $wpsc_product_defaults['meta']['table_rate_price']['quantity'][0];
612
+
613
+ if(!isset($product_meta['unpublish_when_none_left'])) $product_meta['unpublish_when_none_left'] = '';
614
+
615
+ if ($product_data == 'empty') {
616
+ $display = "style='visibility:hidden;'";
617
+ }
618
+ echo "<div id='wpsc_product_price_and_stock_forms' class='wpsc_product_price_and_stock_forms postbox ".((array_search('wpsc_product_price_and_stock_forms', $product_data['closed_postboxes']) !== false) ? 'closed' : '')."' ".((array_search('wpsc_product_price_and_stock_forms', $product_data['hidden_postboxes']) !== false) ? 'style="display: none;"' : '')." ><div class=\"handlediv\" title=\"Click to toggle\"><br></div>";
619
+
620
+ echo "<h3 class='hndle'>";
621
+
622
+ echo __('Price and Stock Control', 'wpsc');
623
+ echo "
624
+ </h3>
625
+ <div class='inside'>
626
+ ";
627
+ // echo "<pre>".print_r($product_data['meta']['_wpsc_product_metadata'],true)."</pre>";
628
+ ?><br />
629
+
630
+ <div class="postbox" style="min-width:225px; width:96%">
631
+ <h3 class="hndle"><?php _e('Price')?></h3>
632
+ <div class="inside">
633
+ <div class='wpsc_floatleft' style="width:85px;">
634
+ <?php echo __('Price', 'wpsc');
635
+ if(!isset($product_data['meta']['_wpsc_price'])) $product_data['meta']['_wpsc_price'] = $wpsc_product_defaults['price'];
636
+ if(!isset($product_data['special'])) $product_data['special'] = $wpsc_product_defaults['special'];
637
+ if(!isset($product_data['meta']['_wpsc_special_price'])) $product_data['meta']['_wpsc_special_price'] = $wpsc_product_defaults['special_price'];
638
+ ?> :<br />
639
+ <input type='text' class='text' size='13' name='meta[_wpsc_price]' value='<?php echo number_format($product_data['meta']['_wpsc_price'], 2); ?>' />
640
+ </div>
641
+ <div class='wpsc_floatleft' style='display:<?php if(($product_data['special'] == 1) ? 'block' : 'none'); ?>; width:85px;; margin-left:30px;'>
642
+ <label for='add_form_special'><?php echo __('Sale Price :', 'wpsc'); ?></label>
643
+ <div id='add_special'>
644
+ <input type='text' size='13' value='<?php echo number_format( $product_data['meta']['_wpsc_special_price'], 2); ?>' name='meta[_wpsc_special_price]' />
645
+ </div>
646
+ </div>
647
+ <br style="clear:both" />
648
+ <br style="clear:both" />
649
+
650
+ <a href='#' class='wpsc_add_new_currency'>+ <?php echo __('New Currency', 'wpsc');?></a>
651
+ <div class='new_layer'>
652
+
653
+ <br /> <label for='newCurrency[]'><?php echo __('Currency type', 'wpsc');?>:</label><br />
654
+ <select name='newCurrency[]' class='newCurrency' style="width:42%">
655
+ <?php
656
+ $currency_data = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_CURRENCY_LIST."` ORDER BY `country` ASC",ARRAY_A);
657
+
658
+
659
+ $isocode = ''; //needs to
660
+ foreach((array)$currency_data as $currency)
661
+ {
662
+ if($isocode == $currency['isocode']) {
663
+ $selected = "selected='selected'";
664
+ } else {
665
+ $selected = "";
666
+ } ?>
667
+ <option value='<?php echo $currency['id']; ?>' <?php echo $selected; ?> ><?php echo htmlspecialchars($currency['country']); ?> (<?php echo $currency['currency']; ?>)</option>
668
+ <?php }
669
+ $currency_data = $wpdb->get_row("SELECT `symbol`,`symbol_html`,`code` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `id`='".get_option('currency_type')."' LIMIT 1",ARRAY_A) ;
670
+ if($currency_data['symbol'] != '') {
671
+ $currency_sign = $currency_data['symbol_html'];
672
+ } else {
673
+ $currency_sign = $currency_data['code'];
674
+ }
675
+ ?>
676
+ </select>
677
+
678
+
679
+ <?php echo __('Price', 'wpsc');?> : <input type='text' class='text' size='15' name='newCurrPrice[]' value='0.00' style="width:40px; display:inline" /><br />
680
+ <a href='' class='deletelayer' rel='<?php echo $isocode; ?>'><?php echo __('Delete Currency', 'wpsc');?></a>
681
+
682
+ </div>
683
+ <?php
684
+ if(isset($product_data['newCurr']) && count($product_data['newCurr']) > 0) :
685
+ $i = 0;
686
+ foreach($product_data['newCurr'] as $newCurr){
687
+ $i++;
688
+ $isocode = str_replace("currency[", "", $newCurr['meta_key']);
689
+ $isocode = str_replace("]", "", $isocode);
690
+ // exit('ere<pre>'.print_r($isocode, true).'</pre>');
691
+
692
+ ?>
693
+ <br /><label for='newCurrency[]'><?php echo __('Currency type', 'wpsc');?>:</label><br />
694
+ <select name='newCurrency[]' class='newCurrency' style="width:42%">
695
+ <?php
696
+ $currency_data = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_CURRENCY_LIST."` ORDER BY `country` ASC",ARRAY_A);
697
+ foreach($currency_data as $currency) {
698
+ if($isocode == $currency['isocode']) {
699
+ $selected = "selected='selected'";
700
+ } else {
701
+ $selected = "";
702
+ }
703
+ ?>
704
+ <option value='<?php echo $currency['id']; ?>' <?php echo $selected; ?> ><?php echo htmlspecialchars($currency['country']); ?> (<?php echo $currency['currency']; ?>)</option>
705
+ <?php
706
+ }
707
+ $currency_data = $wpdb->get_row("SELECT `symbol`,`symbol_html`,`code` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `id`='".get_option('currency_type')."' LIMIT 1",ARRAY_A) ;
708
+ if($currency_data['symbol'] != '') {
709
+ $currency_sign = $currency_data['symbol_html'];
710
+ } else {
711
+ $currency_sign = $currency_data['code'];
712
+ }
713
+ ?>
714
+ </select>
715
+
716
+ Price: <input type='text' class='text' size='15' name='newCurrPrice[]' value='<?php echo $newCurr['meta_value']; ?>' style="width:40px; display:inline" /><br />
717
+ <a href='' class='wpsc_delete_currency_layer' rel='<?php echo $isocode; ?>'><?php echo __('Delete Currency', 'wpsc');?></a>
718
+
719
+ <?php } ?>
720
+ <?php endif;
721
+ echo "
722
+
723
+ <br style=\"clear:both\" />
724
+ <br/><input id='add_form_donation' type='checkbox' name='meta[_wpsc_is_donation]' value='yes' ".(($product_data['meta']['_wpsc_is_donation'] == 1) ? 'checked="checked"' : '')." />&nbsp;<label for='add_form_donation'>".__('This is a donation, checking this box populates the donations widget.', 'wpsc')."</label>
725
+ ";
726
+
727
+ // echo "<pre>".print_r($product_data['meta']['_wpsc_product_metadata'],true)."</pre>";
728
+ ?>
729
+ <br /><br /> <input type='checkbox' value='1' name='table_rate_price[state]' id='table_rate_price' <?php echo (((bool)$product_meta['table_rate_price']['state'] == true) ? 'checked=\'checked\'' : ''); ?> />
730
+
731
+
732
+ <label for='table_rate_price'><?php echo __('Table Rate Price', 'wpsc'); ?></label>
733
+ <div id='table_rate'>
734
+ <a class='add_level' style='cursor:pointer;'>+ Add level</a><br />
735
+ <table>
736
+ <tr>
737
+ <td><br /><?php echo __('Quantity In Cart', 'wpsc'); ?></td>
738
+ <td><?php echo __('Discounted Price', 'wpsc'); ?></td>
739
+ </tr>
740
+ <?php
741
+ if(count($product_meta['table_rate_price']['quantity']) > 0 ) {
742
+ foreach((array)$product_meta['table_rate_price']['quantity'] as $key => $quantity) {
743
+ if($quantity != '') {
744
+ $table_price = number_format($product_meta['table_rate_price']['table_price'][$key], 2, '.', '');
745
+ ?>
746
+ <tr>
747
+ <td>
748
+ <input type="text" size="10" value="<?php echo $quantity; ?>" name="table_rate_price[quantity][]"/> and above
749
+ </td>
750
+ <td>
751
+ <input type="text" size="10" value="<?php echo $table_price; ?>" name="table_rate_price[table_price][]" />
752
+ </td>
753
+ <td><img src="<?php echo WPSC_URL; ?>/images/cross.png" class="remove_line" /></td>
754
+ </tr>
755
+ <?php
756
+ }
757
+ }
758
+ }
759
+ ?>
760
+ <tr>
761
+ <td><input type='text' size='10' value='' name='table_rate_price[quantity][]'/> and above</td>
762
+ <td><input type='text' size='10' value='' name='table_rate_price[table_price][]'/></td>
763
+ </tr>
764
+ </table>
765
+ </div>
766
+ <br style="clear:both" />
767
+ </div>
768
+ </div>
769
+ <br style="clear:both" />
770
+ <div class="postbox" style="min-width:225px; width:96%">
771
+ <h3 class="hndle"><?php _e('Stock')?></h3>
772
+ <div class="inside">
773
+ <div class='wpsc_floatleft'>
774
+ <?php echo __('Stock Keeping Unit', 'wpsc');
775
+ if(!isset($product_data['meta']['_wpsc_sku'])) $product_data['meta']['_wpsc_sku'] = $wpsc_product_defaults['meta']['sku'];
776
+ ?> :<br />
777
+ <input size='17' type='text' class='text' name='meta[_wpsc_sku]' value='<?php echo htmlentities(stripslashes($product_data['meta']['_wpsc_sku']), ENT_QUOTES, 'UTF-8'); ?>' />
778
+ <br style="clear:both" />
779
+
780
+ <?php
781
+ if(!isset($product_data['meta']['_wpsc_stock'])) $product_data['meta']['_wpsc_stock'] = '';
782
+ echo "
783
+ <input class='limited_stock_checkbox' id='add_form_quantity_limited' type='checkbox' value='yes' ".((is_numeric($product_data['meta']['_wpsc_stock'])) ? 'checked="checked"' : '')." name='meta[_wpsc_limited_stock]'/>";
784
+ //onclick='hideelement(\"add_stock\")'
785
+ echo "&nbsp;<label for='add_form_quantity_limited' class='small'>".__('I have a limited number of this item in stock. If the stock runs out, this product will not be available on the shop unless you untick this box or add more stock.', 'wpsc')."</label>";
786
+ if ($product_data['id'] > 0){
787
+ if(is_numeric($product_data['meta']['_wpsc_stock'])) {
788
+ echo " <div class='edit_stock' style='display: block;'>\n\r";
789
+ } else {
790
+ echo " <div class='edit_stock' style='display: none;'>\n\r";
791
+ }
792
+
793
+ echo __('Stock Qty', 'wpsc') . " <input type='text' class='stock_limit_quantity' name='meta[_wpsc_stock]' size='10' value='".$product_data['meta']['_wpsc_stock']."' />";
794
+
795
+
796
+
797
+ echo "<div style='font-size:9px; padding:5px;'><input type='checkbox' " . (($product_meta['unpublish_when_none_left'] == 1) ? 'checked="checked"' : '') . " class='inform_when_oos' name='meta[_wpsc_product_metadata][unpublish_when_none_left]' /> " . __('If this product runs out of stock set status to Unpublished & email site owner', 'wpsc') . "</div>";
798
+ echo " </div>\n\r";
799
+ } else {
800
+ echo "
801
+ <div style='display: none;' class='edit_stock'>
802
+ " .__('Stock Qty', 'wpsc') . " <input type='text' name='meta[_wpsc_stock]' value='0' size='10' />";
803
+ echo "<div style='font-size:9px; padding:5px;'><input type='checkbox' class='inform_when_oos' name='meta[_wpsc_product_metadata][unpublish_when_none_left]' /> " . __('If this product runs out of stock set status to Unpublished & email site owner', 'wpsc') . "</div>";
804
+ echo "</div>";
805
+ }
806
+
807
+ ?>
808
+ </div>
809
+ <br style="clear:both" />
810
+ </div>
811
+ </div>
812
+ <br style="clear:both" />
813
+
814
+ <div class="postbox" style="min-width:225px; width:96%">
815
+ <h3 class="hndle"><?php _e('Taxes'); ?></h3>
816
+ <div class="inside">
817
+ <p>
818
+ <?php
819
+ //Add New WPEC-Taxes Bands Here
820
+ $wpec_taxes_controller = new wpec_taxes_controller();
821
+
822
+ //display tax bands
823
+ $band_select_settings = array(
824
+ 'id' => 'wpec_taxes_band',
825
+ 'name' => 'meta[_wpsc_product_metadata][wpec_taxes_band]',
826
+ 'label' => __('Custom Tax Band')
827
+ );
828
+
829
+ echo $wpec_taxes_controller->wpec_taxes_display_tax_bands($band_select_settings, $product_meta['wpec_taxes_band']);
830
+
831
+ ?>
832
+ </p>
833
+ <!--<input type='checkbox' value='1' name='meta[_wpsc_product_metadata][custom_tax][state]' id='custom_tax_checkbox' <?php echo ((is_numeric($product_meta['custom_tax']) > 0) ? 'checked=\'checked\'' : ''); ?> />
834
+ <label for='custom_tax_checkbox'><?php echo _e("Custom Tax Rate",'wpsc'); ?></label>
835
+ <div style='display:<?php echo ((is_numeric($product_meta['custom_tax'])) ? 'block' : 'none'); ?>;' id='custom_tax'>
836
+ <input type='text' size='10' value='<?php echo number_format($product_meta['custom_tax'], 2, '.', ''); ?>' name='meta[_wpsc_product_metadata][custom_tax][value]'/>
837
+ </div>-->
838
+ </div>
839
+ </div>
840
+ <br style="clear:both" />
841
+ <?php
842
+ echo "
843
+ </div>
844
+ </div>";
845
+
846
+ //return $output;
847
+
848
+ }
849
+
850
+ function wpsc_product_variation_forms($product_data=''){
851
+ global $closed_postboxes, $variations_processor, $wp_query;
852
+ $siteurl = get_option('siteurl');
853
+ $output='';
854
+ if ($product_data == 'empty') {
855
+ $display = "style='display:none;'";
856
+ }
857
+
858
+ $product_term_data = wp_get_object_terms($product_data['id'], 'wpsc-variation');
859
+
860
+ $product_terms = array();
861
+ foreach($product_term_data as $product_term) {
862
+ $product_terms[] = $product_term->term_id;
863
+ }
864
+
865
+ ?>
866
+
867
+ <div id='wpsc_product_variation_forms' class='postbox <?php echo ((array_search('wpsc_product_variation_forms', $product_data['closed_postboxes']) !== false) ? 'closed' : ''); ?>' <?php echo ((array_search('wpsc_product_variation_forms', $product_data['hidden_postboxes']) !== false) ? 'style="display: none;"' : ''); ?>><div class="handlediv" title="Click to toggle"><br></div>
868
+ <h3 class='hndle'><?php echo __('Variation Control', 'wpsc'); ?></h3>
869
+
870
+ <div class='inside'>
871
+ <div id="product_variations">
872
+ <div class="variation_checkboxes">
873
+ <?php
874
+ $variation_sets = get_terms('wpsc-variation', array(
875
+ 'hide_empty' => 0,
876
+ 'parent' => 0
877
+ ));
878
+ foreach((array)$variation_sets as $variation_set) {
879
+ $set_checked_state = '';
880
+ if(in_array($variation_set->term_id, $product_terms)) {
881
+ $set_checked_state = "checked='checked'";
882
+ }
883
+ //$product_terms
884
+ ?>
885
+ <div class="variation_set">
886
+ <label class='set_label'>
887
+ <input type="checkbox" <?php echo $set_checked_state; ?> name="variations[<?php echo $variation_set->term_id; ?>]" value="1">
888
+ <?php echo $variation_set->name; ?>
889
+ </label>
890
+ <?php
891
+ $variations = get_terms('wpsc-variation', array(
892
+ 'hide_empty' => 0,
893
+ 'parent' => $variation_set->term_id
894
+ ));
895
+ foreach((array)$variations as $variation) {
896
+ $checked_state = '';
897
+ if(in_array($variation->term_id, $product_terms)) {
898
+ $checked_state = "checked='checked'";
899
+ }
900
+ ?>
901
+ <div class="variation">
902
+ <label>
903
+ <input type="checkbox" <?php echo $checked_state; ?> name="edit_var_val[<?php echo $variation_set->term_id; ?>][<?php echo $variation->term_id; ?>]" value="1">
904
+ <?php echo $variation->name; ?>
905
+ </label>
906
+ </div>
907
+ <?php
908
+ }
909
+ ?>
910
+
911
+ </div>
912
+ <?php
913
+ }
914
+ ?>
915
+
916
+
917
+ </div>
918
+ </div>
919
+ <?php
920
+
921
+ $parent_product = $product_data['id'];
922
+
923
+ $query = array(
924
+ 'post_type' => 'wpsc-product',
925
+ 'orderby' => 'menu_order post_title',
926
+ 'post_parent' => $parent_product,
927
+ 'post_status' => 'all',
928
+ 'order' => "ASC"
929
+ );
930
+ $args = array(
931
+ 'post_type' => 'attachment',
932
+ 'numberposts' => 1,
933
+ 'post_status' => null,
934
+ 'post_parent' => $parent_product,
935
+ 'orderby' => 'menu_order',
936
+ 'order' => 'ASC'
937
+ );
938
+
939
+ $image_data = (array)get_posts($args);
940
+ $parent_product_data['image'] = array_shift($image_data);
941
+
942
+ add_filter('posts_request', 'wpsc_edit_variations_request_sql');
943
+ ?>
944
+ <!-- <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> -->
945
+ <a class="preview button update_variations_action" href='#'><?php _e('Update Variations &rarr;', 'wpsc'); ?></a><br style="clear:both" />
946
+ <p><?php _e('Check or uncheck variation boxes and then click Update Variations to add or remove variations.')?></p>
947
+ <table class="widefat page" id='wpsc_product_list' cellspacing="0">
948
+ <thead>
949
+ <tr>
950
+ <?php print_column_headers('display-product-list'); ?>
951
+ </tr>
952
+ </thead>
953
+
954
+ <tfoot>
955
+ <tr>
956
+ <?php print_column_headers('display-product-list', false); ?>
957
+ </tr>
958
+ </tfoot>
959
+
960
+ <tbody>
961
+ <?php
962
+ $wp_query= new WP_Query($query);
963
+
964
+ if(!isset($parent_product_data))
965
+ $parent_product_data = null;
966
+
967
+ wpsc_admin_product_listing($parent_product_data);
968
+ //echo "<pre>".print_r($wp_query, true)."</pre>";
969
+ if(count($wp_query->posts) < 1) {
970
+ ?>
971
+ <tr>
972
+ <td colspan='5'>
973
+ <?php _e("You have no products added."); ?>
974
+ </td>
975
+ </tr>
976
+ <?php
977
+ }
978
+ ?>
979
+ </tbody>
980
+ </table>
981
+ </div>
982
+ </div>
983
+ <?php
984
+ }
985
+ /**
986
+ * Adding function to change text for media buttons
987
+ */
988
+
989
+ function change_context() {
990
+ return __('Upload Image%s');
991
+ }
992
+
993
+ function change_link($product_data='') {
994
+ //Since we're hacking this all together anyway until the complete integration of custom_post_types, we'll go ahead and add the attachment to the db here as well.
995
+ $uploading_iframe_ID = $_GET["product"];
996
+ $media_upload_iframe_src = "media-upload.php?post_id=$uploading_iframe_ID";
997
+ return $media_upload_iframe_src."&amp;type=image";
998
+ }
999
+
1000
+ if(!isset($_GET["product"])) $_GET["product"] = '';
1001
+ $uploading_iframe_ID = $_GET["product"];
1002
+
1003
+ //Justin Sainton - 5.19.2010 - Adding filters/actions for the media goodness :) Conditions important to not kill media functionality elsewhere
1004
+ if (isset($_GET["page"]) && ($_GET["page"] == "wpsc-edit-products" )) {
1005
+ add_filter('media_buttons_context','change_context');
1006
+ add_filter('image_upload_iframe_src', "change_link");
1007
+ }
1008
+ function wpsc_product_shipping_forms($product_data=''){
1009
+ global $closed_postboxes;
1010
+ $output = '';
1011
+ $product_meta = &$product_data['meta']['_wpsc_product_metadata'];
1012
+ if ($product_data == 'empty') {
1013
+ $display = "style='display:none;'";
1014
+ }
1015
+ $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>";
1016
+
1017
+ if (IS_WP27) {
1018
+ $output .= "<h3 class='hndle'>";
1019
+ } else {
1020
+ $output .= "<h3>
1021
+ <a class='togbox'>+</a>";
1022
+ }
1023
+ $output .= __('Shipping Details', 'wpsc');
1024
+ if(!isset($product_data['transformed']['weight'])) $product_data['transformed']['weight'] = '';
1025
+ $output .= "
1026
+ </h3>
1027
+ <div class='inside'>
1028
+ <table>
1029
+
1030
+ <!--USPS shipping changes-->
1031
+ <tr>
1032
+ <td>
1033
+ ".__('Weight', 'wpsc')."
1034
+ </td>
1035
+ <td>
1036
+ <input type='text' size='5' name='meta[_wpsc_product_metadata][weight]' value='".$product_data['transformed']['weight']."' />
1037
+ <select name='meta[_wpsc_product_metadata][weight_unit]'>
1038
+ <option value='pound' ". (($product_meta['display_weight_as'] == 'pound') ? 'selected="selected"' : '') .">Pounds</option>
1039
+ <option value='ounce' ". ((preg_match("/o(u)?nce/",$product_meta['display_weight_as'])) ? 'selected="selected"' : '') .">Ounces</option>
1040
+ <option value='gram' ". (($product_meta['display_weight_as'] == 'gram') ? 'selected="selected"' : '') .">Grams</option>
1041
+ <option value='kilogram' ". (($product_meta['display_weight_as'] == 'kilogram') ? 'selected="selected"' : '') .">Kilograms</option>
1042
+ </select>
1043
+ </td>
1044
+ </tr>
1045
+ <!--dimension-->
1046
+ <tr>
1047
+ <td>
1048
+ Height
1049
+ </td>
1050
+ <td>
1051
+ <input type='text' size='5' name='meta[_wpsc_product_metadata][dimensions][height]' value='".$product_meta['dimensions']['height']."'>
1052
+ <select name='meta[_wpsc_product_metadata][dimensions][height_unit]'>
1053
+ <option value='in' ". (($product_meta['dimensions']['height_unit'] == 'in') ? 'selected' : '') .">inches</option>
1054
+ <option value='cm' ". (($product_meta['dimensions']['height_unit'] == 'cm') ? 'selected' : '') .">cm</option>
1055
+ <option value='meter' ". (($product_meta['dimensions']['height_unit'] == 'meter') ? 'selected' : '') .">meter</option>
1056
+ </select>
1057
+ </td>
1058
+ </tr>
1059
+ <tr>
1060
+ <td>
1061
+ Width
1062
+ </td>
1063
+ <td>
1064
+ <input type='text' size='5' name='meta[_wpsc_product_metadata][dimensions][width]' value='".$product_meta['dimensions']['width']."'>
1065
+ <select name='meta[_wpsc_product_metadata][dimensions][width_unit]'>
1066
+ <option value='in' ". (($product_meta['dimensions']['width_unit'] == 'in') ? 'selected' : '') .">inches</option>
1067
+ <option value='cm' ". (($product_meta['dimensions']['width_unit'] == 'cm') ? 'selected' : '') .">cm</option>
1068
+ <option value='meter' ". (($product_meta['dimensions']['width_unit'] == 'meter') ? 'selected' : '') .">meter</option>
1069
+ </select>
1070
+ </td>
1071
+ </tr>
1072
+ <tr>
1073
+ <td>
1074
+ Length
1075
+ </td>
1076
+ <td>
1077
+ <input type='text' size='5' name='meta[_wpsc_product_metadata][dimensions][length]' value='".$product_meta['dimensions']['length']."'>
1078
+ <select name='meta[_wpsc_product_metadata][dimensions][length_unit]'>
1079
+ <option value='in' ". (($product_meta['dimensions']['length_unit'] == 'in') ? 'selected' : '') .">inches</option>
1080
+ <option value='cm' ". (($product_meta['dimensions']['length_unit'] == 'cm') ? 'selected' : '') .">cm</option>
1081
+ <option value='meter' ". (($product_meta['dimensions']['length_unit'] == 'meter') ? 'selected' : '') .">meter</option>
1082
+ </select>
1083
+ </td>
1084
+ </tr>
1085
+
1086
+ <!--//dimension-->
1087
+
1088
+
1089
+ <!--USPS shipping changes ends-->
1090
+
1091
+
1092
+ <!--USPS shipping changes ends-->
1093
+
1094
+
1095
+ <tr>
1096
+ <td colspan='2'>
1097
+ <strong>".__('Flat Rate Settings', 'wpsc')."</strong>
1098
+ </td>
1099
+ </tr>
1100
+ <tr>
1101
+ <td>
1102
+ ".__('Local Shipping Fee', 'wpsc')."
1103
+ </td>
1104
+ <td>
1105
+ <input type='text' size='10' name='meta[_wpsc_product_metadata][shipping][local]' value='".number_format($product_meta['shipping']['local'], 2, '.', '')."' />
1106
+ </td>
1107
+ </tr>
1108
+
1109
+ <tr>
1110
+ <td>
1111
+ ".__('International Shipping Fee', 'wpsc')."
1112
+ </td>
1113
+ <td>
1114
+ <input type='text' size='10' name='meta[_wpsc_product_metadata][shipping][international]' value='".number_format($product_meta['shipping']['international'], 2, '.', '')."' />
1115
+ </td>
1116
+ </tr>
1117
+ <tr>
1118
+ <td>
1119
+ <br />
1120
+ <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>
1121
+ </td>
1122
+ </tr>
1123
+ </table></div></div>";
1124
+
1125
+ return $output;
1126
+ }
1127
+
1128
+ function wpsc_product_advanced_forms($product_data='') {
1129
+ global $closed_postboxes,$wpdb;
1130
+ $product_meta = &$product_data['meta']['_wpsc_product_metadata'];
1131
+
1132
+ $custom_fields = $wpdb->get_results( "
1133
+ SELECT `meta_id`, `meta_key`, `meta_value`
1134
+ FROM `{$wpdb->postmeta}`
1135
+ WHERE `post_id` = {$product_data['id']}
1136
+ AND `meta_key` NOT LIKE '\_%'
1137
+ ORDER BY LOWER(meta_key)", ARRAY_A);
1138
+
1139
+
1140
+ $output ='';
1141
+
1142
+ //$custom_fields = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_PRODUCTMETA."` WHERE `product_id` IN('{$product_data['id']}') AND `custom` IN('1') ",ARRAY_A);
1143
+
1144
+
1145
+ if ($product_data == 'empty') {
1146
+ $display = "style='display:none;'";
1147
+ }
1148
+ $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>";
1149
+
1150
+ $output .= "<h3 class='hndle'>";
1151
+ $output .= __('Advanced Options', 'wpsc');
1152
+ $output .= "
1153
+ </h3>
1154
+ <div class='inside'>
1155
+ <table>";
1156
+ $output .= "
1157
+ <tr>
1158
+ <td colspan='2' class='itemfirstcol'>
1159
+ <strong>".__('Custom Meta', 'wpsc').":</strong><br />
1160
+ <a href='#' class='add_more_meta' onclick='return add_more_meta(this)'> + ".__('Add Custom Meta', 'wpsc')."</a><br /><br />
1161
+ ";
1162
+ foreach((array)$custom_fields as $custom_field) {
1163
+ $i = $custom_field['meta_id'];
1164
+ // 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
1165
+ $output .= "
1166
+ <div class='product_custom_meta' id='custom_meta_$i'>
1167
+ ".__('Name', 'wpsc')."
1168
+ <input type='text' class='text' value='{$custom_field['meta_key']}' name='custom_meta[$i][name]' id='custom_meta_name_$i'>
1169
+
1170
+ ".__('Value', 'wpsc')."
1171
+ <textarea class='text' name='custom_meta[$i][value]' id='custom_meta_value_$i'>{$custom_field['meta_value']}</textarea>
1172
+ <a href='#' class='remove_meta' onclick='return remove_meta(this, $i)'>".__('Delete')."</a>
1173
+ <br />
1174
+ </div>
1175
+ ";
1176
+ }
1177
+
1178
+ $output .= "<div class='product_custom_meta'>
1179
+ ".__('Name', 'wpsc').": <br />
1180
+ <input type='text' name='new_custom_meta[name][]' value='' class='text'/><br />
1181
+
1182
+ ".__('Description', 'wpsc').": <br />
1183
+ <textarea name='new_custom_meta[value][]' cols='40' rows='10' class='text' ></textarea>
1184
+ <br /></div></td></tr>";
1185
+
1186
+ $output .= "<tr>
1187
+ <td class='itemfirstcol' colspan='2'><br /> <strong>". __('Merchant Notes', 'wpsc') .":</strong><br />
1188
+
1189
+ <textarea cols='40' rows='3' name='meta[_wpsc_product_metadata][merchant_notes]' id='merchant_notes'>";
1190
+ if (isset($product_meta['merchant_notes'])) {
1191
+ $output .= stripslashes($product_meta['merchant_notes']);
1192
+ }
1193
+ $output .= "</textarea>
1194
+ <small>".__('These notes are only available here.', 'wpsc')."</small>
1195
+ </td>
1196
+ </tr>";
1197
+
1198
+ $output .="
1199
+ <tr>
1200
+ <td class='itemfirstcol' colspan='2'><br />
1201
+ <strong>". __('Personalisation Options', 'wpsc') .":</strong><br />
1202
+ <input type='hidden' name='meta[_wpsc_product_metadata][engraved]' value='0' />
1203
+ <input type='checkbox' name='meta[_wpsc_product_metadata][engraved]' ".(($product_meta['engraved'] == true) ? 'checked="checked"' : '')." id='add_engrave_text' />
1204
+ <label for='add_engrave_text'> ".__('Users can personalize this product by leaving a message on single product page', 'wpsc')."</label>
1205
+ <br />
1206
+ </td>
1207
+ </tr>
1208
+ <tr>
1209
+ <td class='itemfirstcol' colspan='2'>
1210
+
1211
+ <input type='hidden' name='meta[_wpsc_product_metadata][can_have_uploaded_image]' value='0' />
1212
+ <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' />
1213
+ <label for='can_have_uploaded_image'> ".__('Users can upload images on single product page to purchase logs.', 'wpsc')."</label>
1214
+ <br />
1215
+ </td>
1216
+ </tr>";
1217
+
1218
+
1219
+ if(get_option('payment_gateway') == 'google') {
1220
+ $output .= "<tr>
1221
+ <td class='itemfirstcol' colspan='2'>
1222
+
1223
+ <input type='checkbox' ".$product_meta['google_prohibited']." name='meta[_wpsc_product_metadata][google_prohibited]' id='add_google_prohibited' /> <label for='add_google_prohibited'>
1224
+ ".__('Prohibited', 'wpsc')."
1225
+ <a href='http://checkout.google.com/support/sell/bin/answer.py?answer=75724'>by Google?</a></label><br />
1226
+ </td>
1227
+ </tr>";
1228
+ }
1229
+
1230
+ ob_start();
1231
+ do_action('wpsc_add_advanced_options', $product_data['id']);
1232
+ $output .= ob_get_contents();
1233
+ ob_end_clean();
1234
+
1235
+ $output .= "
1236
+ <tr>
1237
+ <td class='itemfirstcol' colspan='2'><br />
1238
+ <strong>".__('Off Site Product Link', 'wpsc').":</strong><br />
1239
+ <small>".__('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 over rides the buy now and add to cart links and takes you to the site linked here.', 'wpsc')."</small><br /><br />
1240
+ <label for='external_link'>".__('External Link', 'wpsc')."</label>:<br />
1241
+ <input type='text' class='text' name='meta[_wpsc_product_metadata][external_link]' value='";
1242
+ if(isset($product_meta['external_link'])) {
1243
+ $output .= $product_meta['external_link'];
1244
+ }
1245
+ $output .= "' id='external_link' size='40' />
1246
+ </td>
1247
+ </tr>";
1248
+ //if (get_option('wpsc_enable_comments') == 1) {
1249
+ $output .= "
1250
+ <tr>
1251
+ <td class='itemfirstcol' colspan='2'><br />
1252
+ <strong>".__('Enable Comments', 'wpsc').":</strong><br />
1253
+ <select name='meta[_wpsc_product_metadata][enable_comments]'>
1254
+ <option value='' ". ((isset($product_meta['enable_comments']) && $product_meta['enable_comments'] == '' ) ? 'selected' : '') .">Use Default</option>
1255
+ <option value='1' ". ((isset($product_meta['enable_comments']) && $product_meta['enable_comments'] == '1') ? 'selected' : '') .">Yes</option>
1256
+ <option value='0' ". ((isset($product_meta['enable_comments']) && $product_meta['enable_comments'] == '0') ? 'selected' : '') .">No</option>
1257
+ </select>
1258
+ <br/>".__('Allow users to comment on this product.', 'wpsc')."
1259
+ </td>
1260
+ </tr>";
1261
+ //}
1262
+ $output .= "
1263
+ </table></div></div>";
1264
+ return $output;
1265
+ }
1266
+
1267
+ function wpsc_product_image_forms($product_data='') {
1268
+ global $closed_postboxes;
1269
+ if ($product_data == 'empty') {
1270
+ $display = "style='display:none;'";
1271
+ }
1272
+
1273
+ //echo "<pre>".print_r($product_data,true)."</pre>";
1274
+ /* Removing all this goodness in place of the Upload Image Above - justin - 5.20
1275
+ //As in WordPress, If Mac and mod_security, no Flash
1276
+ $flash = true;
1277
+ if ( (false !== strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'mac')) && apache_mod_loaded('mod_security') ) {
1278
+ $flash = false;
1279
+ }
1280
+
1281
+ $flash_action_url = admin_url('async-upload.php');
1282
+ $flash = apply_filters('flash_uploader', $flash);
1283
+ */
1284
+ ?>
1285
+ <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>
1286
+ <h3 class='hndle'> <?php echo __('Product Images', 'wpsc'); ?></h3>
1287
+ <div class='inside'>
1288
+ <p><strong <?php if(isset($display)) echo $display; ?>><a href="media-upload.php?post_id=<?php echo $product_data['id']; ?>&type=image&tab=gallery&TB_iframe=1&width=640&height=566" class="thickbox" title="Manage your images"><?php echo __('Manage your thumbnails', 'wpsc');?></a></strong></p>
1289
+ <?php
1290
+ edit_multiple_image_gallery($product_data);
1291
+ ?>
1292
+
1293
+ </div>
1294
+ <div style='clear:both'></div>
1295
+ </div>
1296
+ <?php
1297
+ // return $output;
1298
+ }
1299
+
1300
+ function wpsc_product_download_forms($product_data='') {
1301
+ global $wpdb, $closed_postboxes;
1302
+ if ($product_data == 'empty') {
1303
+ $display = "style='display:none;'";
1304
+ }
1305
+
1306
+ $output ='';
1307
+ $upload_max = wpsc_get_max_upload_size();
1308
+ $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>";
1309
+
1310
+ $output .= "<h3 class='hndle'>".__('Product Downloads', 'wpsc')."</h3>";
1311
+ $output .= "<div class='inside'>";
1312
+
1313
+ $output .= wpsc_select_product_file($product_data['id']);
1314
+
1315
+ $output .= "<h4>".__('Upload New File', 'wpsc').":</h4>";
1316
+ $output .= "<input type='file' name='file' value='' /><br />".__('Max Upload Size', 'wpsc')." : <span>".$upload_max."</span><br /><br />";
1317
+ $output .= "<h4>".__('<a href="admin.php?wpsc_admin_action=product_files_existing&product_id='.$product_data['id'].'" class="thickbox" title="Select from all product files for '.$product_data['name'].'">Select from existing files</a>', 'wpsc')."</h4>";
1318
+
1319
+ if(isset($product_data['file']) && $product_data['file'] > 0) {
1320
+ $output .= __('Preview File', 'wpsc').": ";
1321
+
1322
+ $output .= "<a class='admin_download' href='index.php?admin_preview=true&product_id=".$product_data['id']."' ><img align='absmiddle' src='".WPSC_URL."/images/download.gif' alt='' title='' /><span>".__('Click to download', 'wpsc')."</span></a>";
1323
+
1324
+ $file_data = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_PRODUCT_FILES."` WHERE `id`='".$product_data['file']."' LIMIT 1",ARRAY_A);
1325
+ if(($file_data != null) && (function_exists('listen_button'))) {
1326
+ $output .= "".listen_button($file_data['idhash'], $file_data['id'])."<br style='clear: both;' /><br />";
1327
+ }
1328
+ }
1329
+ if(function_exists("make_mp3_preview") || function_exists("wpsc_media_player")) {
1330
+
1331
+ $output .= "<br />";
1332
+ $output .="<h4>".__("Select an MP3 file to upload as a preview")."</h4>";
1333
+
1334
+ $output .= "<input type='file' name='preview_file' value='' /><br />";
1335
+ $output .= "<br />";
1336
+ }
1337
+ $output .="</div></div>";
1338
+ return $output;
1339
+ }
1340
+
1341
+ function wpsc_product_label_forms() {
1342
+ global $closed_postboxes;
1343
+ ?>
1344
+ <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>
1345
+ <?php
1346
+ if (function_exists('add_object_page')) {
1347
+ echo "<h3 class='hndle'>";
1348
+ } else {
1349
+ echo "<h3>
1350
+ <a class='togbox'>+</a>";
1351
+ }
1352
+ ?>
1353
+ <?php echo __('Label Control', 'wpsc'); ?>
1354
+ </h3>
1355
+ <div class='inside'>
1356
+ <table>
1357
+ <tr>
1358
+ <td colspan='2'>
1359
+ <?php echo __('Add Label', 'wpsc'); ?> :
1360
+ <a id='add_label'><?php echo __('Add Label', 'wpsc'); ?></a>
1361
+ </td>
1362
+ </tr>
1363
+ <tr>
1364
+ <td colspan='2'>
1365
+ <div id="labels">
1366
+ <table>
1367
+ <tr>
1368
+ <td><?php _e('Label', 'wpsc')?> :</td>
1369
+ <td><input type="text" name="productmeta_values[labels][]"></td>
1370
+ </tr>
1371
+ <tr>
1372
+ <td><?php _e('Label Description', 'wpsc')?> :</td>
1373
+ <td><textarea name="productmeta_values[labels_desc][]"></textarea></td>
1374
+ </tr>
1375
+ <tr>
1376
+ <td><?php _e('Life Number', 'wpsc')?> :</td>
1377
+ <td><input type="text" name="productmeta_values[life_number][]"></td>
1378
+ </tr>
1379
+ <tr>
1380
+ <td><?php _e('Item Number', 'wpsc')?> :</td>
1381
+ <td><input type="text" name="productmeta_values[item_number][]"></td>
1382
+ </tr>
1383
+ <tr>
1384
+ <td><?php _e('Product Code', 'wpsc')?> :</td>
1385
+ <td><input type="text" name="productmeta_values[product_code][]"></td>
1386
+ </tr>
1387
+ <tr>
1388
+ <td><?php _e('PDF', 'wpsc')?> :</td>
1389
+ <td><input type="file" name="pdf[]"></td>
1390
+ </tr>
1391
+ </table>
1392
+ </div>
1393
+ </td>
1394
+ </tr>
1395
+ </table></div></div>
1396
+ <?php
1397
+ }
1398
+
1399
+
1400
+ function edit_multiple_image_gallery($product_data) {
1401
+ global $wpdb;
1402
+ $siteurl = get_option('siteurl');
1403
+ ?>
1404
+ <ul id="gallery_list" class="ui-sortable" style="position: relative;">
1405
+ <?php
1406
+ if($product_data['id'] > 0) {
1407
+ $args = array(
1408
+ 'post_type' => 'attachment',
1409
+ 'numberposts' => -1,
1410
+ 'post_status' => null,
1411
+ 'post_parent' => $product_data['id'],
1412
+ 'orderby' => 'menu_order',
1413
+ 'order' => 'ASC'
1414
+ );
1415
+
1416
+ $attached_images = (array)get_posts($args);
1417
+ if($attached_images != null) {
1418
+ foreach($attached_images as $image) {
1419
+ $image_meta = get_post_meta($image->ID, '');
1420
+ foreach($image_meta as $meta_name => $meta_value) {
1421
+ $image_meta[$meta_name] = maybe_unserialize(array_pop($meta_value));
1422
+ }
1423
+
1424
+ if(function_exists("getimagesize")) {
1425
+ // $num++;
1426
+ $image_url = "index.php?wpsc_action=scale_image&amp;attachment_id={$image->ID}&amp;width=60&amp;height=60";
1427
+ ?>
1428
+ <li id="product_image_<?php echo $image->ID; ?>" class='gallery_image'>
1429
+ <input type='hidden' class='image-id' name='gallery_image_id[]' value='<?php echo $image->ID; ?>' />
1430
+ <div class='previewimage' id='gallery_image_<?php echo $image->ID; ?>'>
1431
+ <a id='extra_preview_link_<?php echo $image->ID; ?>' onclick='return false;' href='' rel='product_extra_image_<?php echo $image->ID; ?>' >
1432
+ <img class='previewimage' src='<?php echo $image_url; ?>' alt='<?php echo __('Preview', 'wpsc'); ?>' title='<?php echo __('Preview', 'wpsc'); ?>' /><br />
1433
+ </a>
1434
+ <?php //echo wpsc_main_product_image_menu($product_data['id']); ?>
1435
+ </div>
1436
+ </li>
1437
+ <?php
1438
+ }
1439
+ }
1440
+ }
1441
+ /*
1442
+ $main_image = $wpdb->get_row("SELECT `images`.*
1443
+ FROM `".WPSC_TABLE_PRODUCT_IMAGES."` AS `images`
1444
+ JOIN `".WPSC_TABLE_PRODUCT_LIST."` AS `product`
1445
+ ON `product`.`image` = `images`.`id`
1446
+ WHERE `product`.`id` = '{$product_data['id']}'
1447
+ LIMIT 1", ARRAY_A);
1448
+ */
1449
+ }
1450
+ ?>
1451
+ </ul>
1452
+ <?php
1453
+ }
1454
+
1455
+ /*
1456
+ function wpsc_main_product_image_menu($product_id) {
1457
+ global $wpdb;
1458
+ $thumbnail_state = 0;
1459
+ if($product_id > 0)
1460
+ {
1461
+ //$main_image = $wpdb->get_row("SELECT `images`.*, `product`.`thumbnail_state` FROM `".WPSC_TABLE_PRODUCT_IMAGES."` AS `images` JOIN `".WPSC_TABLE_PRODUCT_LIST."` AS `product` ON `product`.`image` = `images`.`id` WHERE `product`.`id` = '{$product_id}' LIMIT 1", ARRAY_A);
1462
+ $thumbnail_state = $main_image['thumbnail_state'];
1463
+ } else {
1464
+ $thumbnail_state = 1;
1465
+ }
1466
+
1467
+ $sendback = wp_get_referer();
1468
+ $presentation_link = add_query_arg('page','wpsc-settings', $sendback);
1469
+ $presentation_link = add_query_arg('tab','presentation#thumb_settings', $presentation_link);
1470
+ $thumbnail_image_height = get_product_meta($product_id, 'thumbnail_height');
1471
+ $thumbnail_image_width = get_product_meta($product_id, 'thumbnail_width');
1472
+
1473
+
1474
+
1475
+ // echo $thumbnail_image_height;
1476
+ // echo "|";
1477
+ // echo $thumbnail_image_width;
1478
+ ob_start();
1479
+ ?>
1480
+ <div class='image_settings_box'>
1481
+ <div class='upper_settings_box'>
1482
+ <div class='upper_image'><img src='<?php echo WPSC_URL; ?>/images/pencil.png' alt='' /></div>
1483
+ <div class='upper_txt'><?php _e('Thumbnail Settings'); ?><a class='closeimagesettings'>X</a></div>
1484
+ </div>
1485
+
1486
+ <div class='lower_settings_box'>
1487
+ <input type='hidden' id='current_thumbnail_image' name='current_thumbnail_image' value='S' />
1488
+ <ul>
1489
+
1490
+ <li>
1491
+ <input type='radio' name='gallery_resize' value='1' id='gallery_resize1' class='image_resize' onclick='image_resize_extra_forms(this)' /> <label for='gallery_resize1'><?php echo __('use default size', 'wpsc'); ?>(<a href='<?php echo $presentation_link; ?>' title='<?php echo __('This is set on the Settings Page', 'wpsc'); ?>'><?php echo get_option('product_image_height'); ?>&times;<?php echo get_option('product_image_width'); ?>px</a>)
1492
+ </label>
1493
+
1494
+ </li>
1495
+
1496
+ <li>
1497
+ <input type='radio' <?php echo (($thumbnail_state != 2) ? "checked='checked'" : "") ;?> name='gallery_resize' value='0' id='gallery_resize0' class='image_resize' onclick='image_resize_extra_forms(this)' /> <label for='gallery_resize0'> <?php echo __('do not resize thumbnail image', 'wpsc'); ?></label><br />
1498
+ </li>
1499
+
1500
+ <li>
1501
+ <input type='radio' <?php echo (($thumbnail_state == 2) ? "checked='checked'" : "") ;?> name='gallery_resize' value='2' id='gallery_resize2' class='image_resize' onclick='image_resize_extra_forms(this)' /> <label for='gallery_resize2'><?php echo __('use specific size', 'wpsc'); ?> </label>
1502
+ <div class='heightWidth image_resize_extra_forms' <?php echo (($thumbnail_state == 2) ? "style='display: block;'" : "") ;?>>
1503
+ <input id='gallery_image_width' type='text' size='4' name='gallery_width' value='<?php echo $thumbnail_image_width; ?>' /><label for='gallery_image_width'><?php echo __('px width', 'wpsc'); ?></label>
1504
+ <input id='gallery_image_height' type='text' size='4' name='gallery_height' value='<?php echo $thumbnail_image_height; ?>' /><label for='gallery_image_height'><?php echo __('px height', 'wpsc'); ?> </label>
1505
+ </div>
1506
+ </li>
1507
+
1508
+ <li>
1509
+ <input type='radio' name='gallery_resize' value='3' id='gallery_resize3' class='image_resize' onclick='image_resize_extra_forms(this)' /> <label for='gallery_resize3'> <?php echo __('use separate thumbnail', 'wpsc'); ?></label><br />
1510
+ <div class='browseThumb image_resize_extra_forms'>
1511
+ <input type='file' name='gallery_thumbnailImage' size='15' value='' />
1512
+ </div>
1513
+ </li>
1514
+ <li>
1515
+ <a href='<?php echo htmlentities("admin.php?wpsc_admin_action=crop_image&imagename=".$main_image['image']."&imgheight=".$image_data[1]."&imgwidth=".$image_data[0]."&width=630&height=500&product_id=".$product_id); ?>' title='Crop Image' class='thickbox'>Crop This Image Using jCrop</a>
1516
+
1517
+ </li>
1518
+ <li>
1519
+ <a href='#' class='delete_primary_image delete_button'>Delete this Image</a>
1520
+ </li>
1521
+
1522
+ </ul>
1523
+ </div>
1524
+ </div>
1525
+ <a class='editButton'>Edit <img src='<?php echo WPSC_URL; ?>/images/pencil.png' alt='' /></a>
1526
+ <?php
1527
+ $output = ob_get_contents();
1528
+ ob_end_clean();
1529
+ return $output;
1530
+ } */
1531
+
1532
+ /**
1533
+ * Displays the category forms for adding and editing products
1534
+ * Recurses to generate the branched view for subcategories
1535
+ */
1536
+ function wpsc_category_list(&$product_data, $group_id, $unique_id = '', $category_id = null) {
1537
+ global $wpdb;
1538
+ static $iteration = 0;
1539
+ $iteration++;
1540
+ $output = '';
1541
+ $selected = '';
1542
+
1543
+ if(is_numeric($category_id)) {
1544
+ $values = get_terms('wpsc_product_category', "hide_empty=0&parent=".$category_id, ARRAY_A);
1545
+ } else {
1546
+ $values = get_terms('wpsc_product_category', "hide_empty=0&parent=".$group_id, ARRAY_A);
1547
+ }
1548
+
1549
+ if($category_id < 1) {
1550
+ $output .= "<ul class='list:category categorychecklist form-no-clear'>\n\r";
1551
+ } elseif((count($values) >0)){
1552
+ $output .= "<ul class='children'>\n\r";
1553
+ }
1554
+
1555
+ //echo "<pre>".print_r($values, true)."</pre>";
1556
+
1557
+ foreach((array)$values as $option) {
1558
+ $option=(array)$option;
1559
+
1560
+ if(isset($product_data['category_ids']) && count($product_data['category_ids']) > 0) {
1561
+ if(in_array($option['term_id'], $product_data['category_ids'])) {
1562
+ $selected = "checked='checked'";
1563
+ }
1564
+ }
1565
+
1566
+ $output .= " <li id='category-".$option['term_id']."'>\n\r";
1567
+ $output .= " <label class='selectit'>\n\r";
1568
+ $output .= " <input id='".$unique_id."category_form_".$option['term_id']."' type='checkbox' {$selected} name='category[]' value='".$option['term_id']."' /></label>\n\r";
1569
+
1570
+ $output .= " <label for='".$unique_id."category_form_".$option['term_id']."' class='greytext' >".stripslashes($option['name'])."</label>\n\r";
1571
+ $output .= wpsc_category_list($product_data, $group_id, $unique_id, $option['term_id']);
1572
+
1573
+ $output .= " </li>\n\r";
1574
+
1575
+ $selected = "";
1576
+ }
1577
+ if((count($values) >0) ){
1578
+ $output .= "</ul>\n\r";
1579
+ }
1580
+ return $output;
1581
+ }
1582
+
1583
+ /**
1584
+ * Slightly modified copy of the Wordpress the_editor function
1585
+ *
1586
+ * We have to use a modified version because the wordpress one calls javascript that uses document.write
1587
+ * When this javascript runs after being loaded through AJAX, it replaces the whole page.
1588
+ *
1589
+ * The amount of rows the text area will have for the content has to be between
1590
+ * 3 and 100 or will default at 12. There is only one option used for all users,
1591
+ * named 'default_post_edit_rows'.
1592
+ *
1593
+ * If the user can not use the rich editor (TinyMCE), then the switch button
1594
+ * will not be displayed.
1595
+ *
1596
+ * @since 3.7
1597
+ *
1598
+ * @param string $content Textarea content.
1599
+ * @param string $id HTML ID attribute value.
1600
+ * @param string $prev_id HTML ID name for switching back and forth between visual editors.
1601
+ * @param bool $media_buttons Optional, default is true. Whether to display media buttons.
1602
+ * @param int $tab_index Optional, default is 2. Tabindex for textarea element.
1603
+ */
1604
+ function wpsc_the_editor($content, $id = 'content', $prev_id = 'title', $media_buttons = true, $tab_index = 2) {
1605
+ $rows = get_option('default_post_edit_rows');
1606
+ if (($rows < 3) || ($rows > 100))
1607
+ $rows = 12;
1608
+
1609
+ if ( !current_user_can( 'upload_files' ) )
1610
+ $media_buttons = false;
1611
+
1612
+ $richedit = user_can_richedit();
1613
+ $class = '';
1614
+
1615
+ if ( $richedit || $media_buttons ) {
1616
+ ?>
1617
+ <div id="editor-toolbar">
1618
+ <?php
1619
+ if ( $richedit ) {
1620
+ $wp_default_editor = wp_default_editor(); ?>
1621
+ <div class="zerosize"><input accesskey="e" type="button" onclick="switchEditors.go('<?php echo $id; ?>')" /></div>
1622
+ <?php if ( 'html' == $wp_default_editor ) {
1623
+ add_filter('the_editor_content', 'wp_htmledit_pre'); ?>
1624
+ <a id="edButtonHTML" class="active hide-if-no-js" onclick="switchEditors.go('<?php echo $id; ?>', 'html');"><?php _e('HTML'); ?></a>
1625
+ <a id="edButtonPreview" class="hide-if-no-js" onclick="switchEditors.go('<?php echo $id; ?>', 'tinymce');"><?php _e('Visual'); ?></a>
1626
+ <?php } else {
1627
+ $class = " class='theEditor'";
1628
+ add_filter('the_editor_content', 'wp_richedit_pre'); ?>
1629
+ <a id="edButtonHTML" class="hide-if-no-js" onclick="switchEditors.go('<?php echo $id; ?>', 'html');"><?php _e('HTML'); ?></a>
1630
+ <a id="edButtonPreview" class="active hide-if-no-js" onclick="switchEditors.go('<?php echo $id; ?>', 'tinymce');"><?php _e('Visual'); ?></a>
1631
+ <?php }
1632
+ }
1633
+
1634
+ if ( $media_buttons ) { ?>
1635
+ <div id="media-buttons" class="hide-if-no-js">
1636
+ <?php do_action( 'media_buttons' ); ?>
1637
+ </div>
1638
+ <?php
1639
+ } ?>
1640
+ </div>
1641
+ <?php
1642
+ }
1643
+ ?>
1644
+ <div id="quicktags"><?php
1645
+ wp_print_scripts( 'quicktags' ); ?>
1646
+ <div id="ed_toolbar">
1647
+ </div>
1648
+ <script type="text/javascript" defer="defer'">wpsc_edToolbar()</script>
1649
+
1650
+ </div>
1651
+
1652
+ <?php
1653
+ $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");
1654
+ $the_editor_content = apply_filters('the_editor_content', $content);
1655
+
1656
+ printf($the_editor, $the_editor_content);
1657
+
1658
+ ?>
1659
+ <script type="text/javascript">
1660
+ edCanvas = document.getElementById('<?php echo $id; ?>');
1661
+ </script>
1662
+ <?php
1663
+ }
1664
+ ?>
wpsc-admin/includes/product-functions.php CHANGED
@@ -1,1088 +1,1229 @@
1
- <?php
2
- /**
3
- * WPSC Product modifying functions
4
- *
5
- * @package wp-e-commerce
6
- * @since 3.7
7
- */
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_admin_submit_product function
18
- *
19
- * @return nothing
20
- */
21
- function wpsc_admin_submit_product() {
22
- check_admin_referer('edit-product', 'wpsc-edit-product');
23
-
24
- $sendback = wp_get_referer();
25
- $post_data = wpsc_sanitise_product_forms();
26
- //$post_data['category'] = 1; /// remove this
27
- if(isset($post_data['title']) && $post_data['title'] != '') {
28
- $product_id = wpsc_insert_product($post_data, true);
29
- if($product_id > 0) {
30
- $sendback = add_query_arg('product', $product_id);
31
- }
32
-
33
- $sendback = add_query_arg('message', 1, $sendback);
34
- //exit('<pre>'.print_r($sendback,true).'</pre>');
35
- wp_redirect($sendback);
36
- } else {
37
- $_SESSION['product_error_messages'] = array();
38
- if($post_data['title'] == ''){
39
- $_SESSION['product_error_messages'][] = __('<strong>ERROR</strong>: Please enter a Product name.<br />');
40
- }
41
- if(!isset($post_data['category'])){
42
- $_SESSION['product_error_messages'][] = __('<strong>ERROR</strong>: Please enter a Product Category.<br />');
43
- }
44
-
45
- $_SESSION['wpsc_failed_product_post_data'] = $post_data;
46
- $sendback = add_query_arg('ErrMessage', 1);
47
- wp_redirect($sendback);
48
- }
49
- exit();
50
- }
51
-
52
-
53
- /**
54
- * wpsc_sanitise_product_forms function
55
- *
56
- * @return array - Sanitised product details
57
- */
58
- function wpsc_sanitise_product_forms($post_data = null) {
59
- if ( empty($post_data) ) {
60
- $post_data = &$_POST;
61
- }
62
-
63
- $product = get_post(absint($post_data['post_ID']));
64
-
65
-
66
- // $post_data['product_id'] = isset($post_data['product_id']) ? $post_data['product_id'] : '';
67
- $post_data['name'] = isset($post_data['post_title']) ? $post_data['post_title'] : '';
68
- $post_data['title'] = $post_data['name'];
69
- $post_data['description'] = isset($post_data['content']) ? $post_data['content'] : '';
70
- $post_data['additional_description'] = isset($post_data['additional_description']) ? $post_data['additional_description'] : '';
71
-
72
- //$post_data['publish'] = (int)(bool)$post_data['publish'];
73
- if($product != null) {
74
- $post_data['post_status'] = $product->post_status;
75
- } else {
76
- $post_data['post_status'] = 'draft';
77
-
78
- }
79
-
80
-
81
-
82
- if(isset($post_data['save'])) {
83
- $post_data['post_status'] = $post_data['post_status'];
84
- } else if(isset($post_data['publish'])) {
85
- $post_data['post_status'] = 'publish';
86
- } else if(isset($post_data['unpublish'])) {
87
- $post_data['post_status'] = 'draft';
88
- }
89
-
90
-
91
-
92
- $post_meta['meta'] = (array)$_POST['meta'];
93
-
94
- $post_data['meta']['_wpsc_price'] = (float)$post_data['meta']['_wpsc_price'];
95
- $post_data['meta']['_wpsc_special_price'] = (float)$post_data['meta']['_wpsc_special_price'];
96
- $post_data['meta']['_wpsc_sku'] = $post_data['meta']['_wpsc_sku'];
97
- $post_data['meta']['_wpsc_is_donation'] = (int)(bool)$post_data['meta']['_wpsc_is_donation'];
98
- $post_data['meta']['_wpsc_stock'] = (int)$post_data['meta']['_wpsc_stock'];
99
-
100
- if((bool)$post_data['meta']['_wpsc_limited_stock'] != true) {
101
- $post_data['meta']['_wpsc_stock'] = false;
102
- }
103
- unset($post_data['meta']['_wpsc_limited_stock']);
104
-
105
-
106
- $post_data['meta']['_wpsc_product_metadata']['unpublish_when_none_left'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['unpublish_when_none_left'];
107
- $post_data['meta']['_wpsc_product_metadata']['quantity_limited'] = (int)(bool)$post_data['quantity_limited'];
108
- $post_data['meta']['_wpsc_product_metadata']['special'] = (int)(bool)$post_data['special'];
109
- /* $post_data['meta']['_wpsc_product_metadata']['notax'] = (int)(bool)$post_data['notax'];; */
110
- $post_data['meta']['_wpsc_product_metadata']['no_shipping'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['no_shipping'];
111
-
112
- // Product Weight
113
- $weight = wpsc_convert_weight($post_data['meta']['_wpsc_product_metadata']['weight'], $post_data['meta']['_wpsc_product_metadata']['weight_unit'], "gram");
114
- $post_data['meta']['_wpsc_product_metadata']['weight'] = (float)$weight;
115
- $post_data['meta']['_wpsc_product_metadata']['display_weight_as'] = $post_data['meta']['_wpsc_product_metadata']['weight_unit'];
116
-
117
- // table rate price
118
- $post_data['meta']['_wpsc_product_metadata']['table_rate_price'] = $post_data['table_rate_price'];
119
- // if table_rate_price is unticked, wipe the table rate prices
120
- if($post_data['table_rate_price']['state'] != 1) {
121
- $post_data['meta']['_wpsc_product_metadata']['table_rate_price']['quantity'] = null;
122
- $post_data['meta']['_wpsc_product_metadata']['table_rate_price']['table_rate_price'] = null;
123
- }
124
-
125
- if($post_data['meta']['_wpsc_product_metadata']['custom_tax']['state'] == 1) {
126
- $custom_tax_value = (float)$post_data['meta']['_wpsc_product_metadata']['custom_tax']['value'];
127
- } else {
128
- $custom_tax_value = null;
129
- }
130
- $post_data['meta']['_wpsc_product_metadata']['custom_tax'] = $custom_tax_value;
131
-
132
- $post_data['meta']['_wpsc_product_metadata']['shipping']['local'] = (float)$post_data['meta']['_wpsc_product_metadata']['shipping']['local'];
133
- $post_data['meta']['_wpsc_product_metadata']['shipping']['international'] = (float)$post_data['meta']['_wpsc_product_metadata']['shipping']['international'];
134
-
135
-
136
- // Advanced Options
137
- $post_data['meta']['_wpsc_product_metadata']['engraved'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['engraved'];
138
- $post_data['meta']['_wpsc_product_metadata']['can_have_uploaded_image'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['can_have_uploaded_image'];
139
- $post_data['meta']['_wpsc_product_metadata']['google_prohibited'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['google_prohibited'];
140
- $post_data['meta']['_wpsc_product_metadata']['external_link'] = (string)$post_data['meta']['_wpsc_product_metadata']['external_link'];
141
-
142
- $post_data['meta']['_wpsc_product_metadata']['enable_comments'] = $post_data['meta']['_wpsc_product_metadata']['enable_comments'];
143
- $post_data['meta']['_wpsc_product_metadata']['merchant_notes'] = $post_data['meta']['_wpsc_product_metadata']['merchant_notes'];
144
-
145
-
146
-
147
-
148
-
149
-
150
- /*
151
- if(is_numeric($post_data['special_price'])) {
152
- $post_data['special_price'] = (float)($post_data['price'] - $post_data['special_price']);
153
- } else {
154
- $post_data['special_price'] = 0;
155
- }
156
- */
157
-
158
- /*
159
- // if special is unticked, wipe the special_price value
160
- if($post_data['special'] !== 1) {
161
- $post_data['special_price'] = 0;
162
- }
163
- */
164
- //
165
-
166
-
167
-
168
-
169
-
170
- $post_data['files'] = $_FILES;
171
- return $post_data;
172
- }
173
-
174
-
175
-
176
- /**
177
- * wpsc_insert_product function
178
- *
179
- * @param unknown
180
- * @return unknown
181
- */
182
- // exit('Image height'.get_option('product_image_height'));
183
- function wpsc_insert_product($post_data, $wpsc_error = false) {
184
- global $wpdb, $user_ID;
185
- $adding = false;
186
- $update = false;
187
- if((int)$post_data['post_ID'] > 0) {
188
- $product_id = absint($post_data['post_ID']);
189
- $update = true;
190
- } else if((int)$post_data['product_id'] > 0) {
191
- $product_id = absint($post_data['product_id']);
192
- $update = true;
193
- }
194
-
195
- //exit('<pre>'.print_r($product_id, true).'</pre>');
196
-
197
- $product_columns = array(
198
- 'name' => '',
199
- 'description' => '',
200
- 'additional_description' => '',
201
- 'price' => null,
202
- 'weight' => null,
203
- 'weight_unit' => '',
204
- 'pnp' => null,
205
- 'international_pnp' => null,
206
- 'file' => null,
207
- 'image' => '0',
208
- 'quantity_limited' => '',
209
- 'quantity' => null,
210
- 'special' => null,
211
- 'special_price' => null,
212
- 'display_frontpage' => null,
213
- 'notax' => null,
214
- 'publish' => null,
215
- 'active' => null,
216
- 'donation' => null,
217
- 'no_shipping' => null,
218
- 'thumbnail_image' => null,
219
- 'thumbnail_state' => null
220
- );
221
-
222
-
223
- foreach($product_columns as $column => $default) {
224
- if(isset($post_data[$column]) || ($post_data[$column] !== null) ) {
225
- $update_values[$column] = stripslashes($post_data[$column]);
226
- } else if(($update != true) && ($default !== null)) {
227
- $update_values[$column] = stripslashes($default);
228
- }
229
- }
230
-
231
-
232
- $product_post_values = array(
233
- 'ID' => $product_id,
234
- 'post_author' => $user_ID,
235
- 'post_content' => $post_data['description'],
236
- 'post_excerpt' => $post_data['additional_description'],
237
- 'post_title' => $post_data['name'],
238
- 'post_status' => $post_data['post_status'],
239
- 'post_type' => "wpsc-product",
240
- 'post_name' => sanitize_title($post_data['name'])
241
- );
242
-
243
- if ($post_data['meta']['_wpsc_product_metadata']['enable_comments'] == 0) {
244
- $product_post_values["comment_status"] = "closed";
245
- }else {
246
- $product_post_values["comment_status"] = "open";
247
- }
248
-
249
- //exit("<pre>".print_r(wp_update_post($product_post_values) , true)."</pre>");
250
- if($sku != '') {
251
- $product_post_array['guid'] = $sku;
252
- }
253
-
254
-
255
-
256
- if($update === true) {
257
- $where = array( 'id' => $product_id );
258
- // exit('<pre>'.print_r($product_post_values).'</pre>');
259
- $product_id = wp_update_post($product_post_values);
260
- if ( isset ( $post_data["sticky"] ) ) {
261
- stick_post($product_id);
262
- }else {
263
- unstick_post($product_id);
264
- }
265
- if ($product_id == 0) {
266
- if ( $wpsc_error ) {
267
- return new WP_Error('db_update_error', __('Could not update product in the database'), $wpdb->last_error);
268
- } else {
269
- return false;
270
- }
271
- }
272
- } else {
273
-
274
- $product_post_values += array(
275
- 'post_date' => $product['date_added']
276
- );
277
- $product_id = wp_insert_post($product_post_values);
278
- if ( isset ( $post_data["sticky"] ) ) {
279
- stick_post($product_id);
280
- }else {
281
- unstick_post($product_id);
282
- }
283
- if ($product_id == 0 ) {
284
- if ( $wp_error ) {
285
- return new WP_Error('db_insert_error', __('Could not insert product into the database'), $wpdb->last_error);
286
- } else {
287
- return 0;
288
- }
289
- }
290
- $adding = true;
291
- //$product_id = (int)$wpdb->insert_id;
292
- //exit($product_id.' <-- IS the corresponding ID YAW');
293
- }
294
-
295
- /* Add tidy url name */
296
- if($post_data['name'] != '') {
297
- $existing_name = get_product_meta($product_id, 'url_name');
298
- // strip slashes, trim whitespace, convert to lowercase
299
- $tidied_name = strtolower(trim(stripslashes($post_data['name'])));
300
- // convert " - " to "-", all other spaces to dashes, and remove all foward slashes.
301
- //$url_name = preg_replace(array("/(\s-\s)+/","/(\s)+/", "/(\/)+/"), array("-","-", ""), $tidied_name);
302
- $url_name = sanitize_title($tidied_name);
303
-
304
- // Select all similar names, using an escaped version of the URL name
305
- $similar_names = (array)$wpdb->get_col("SELECT `meta_value` FROM `".WPSC_TABLE_PRODUCTMETA."` WHERE `product_id` NOT IN('{$product_id}}') AND `meta_key` IN ('url_name') AND `meta_value` REGEXP '^(".$wpdb->escape(preg_quote($url_name))."){1}[[:digit:]]*$' ");
306
-
307
- // Check desired name is not taken
308
- if(array_search($url_name, $similar_names) !== false) {
309
- // If it is, try to add a number to the end, if that is taken, try the next highest number...
310
- $i = 0;
311
- do {
312
- $i++;
313
- } while(array_search(($url_name.$i), $similar_names) !== false);
314
- // Concatenate the first number found that wasn't taken
315
- $url_name .= $i;
316
- }
317
- // If our URL name is the same as the existing name, do othing more.
318
- if($existing_name != $url_name) {
319
- update_product_meta($product_id, 'url_name', $url_name);
320
- }
321
- }
322
-
323
- // if we succeed, we can do further editing
324
-
325
- // update the categories
326
- /* wpsc_update_category_associations($product_id, $post_data['category']); */
327
- //wp_set_post_categories($product_id, $post_data['category']);
328
-
329
- //echo "<pre>".print_r($post_data['category'], true)."</pre>";
330
- wp_set_product_categories($product_id, $post_data['category']);
331
-
332
- //echo "<pre>".print_r($test, true)."</pre>";
333
- //exit();
334
-
335
-
336
- // and the tags
337
- wpsc_update_product_tags($product_id, $post_data['product_tags'], $post_data['wpsc_existing_tags']);
338
-
339
- // and the meta
340
- wpsc_update_product_meta($product_id, $post_data['meta']);
341
-
342
- // the variations too
343
- wpsc_edit_product_variations($product_id, $post_data);
344
-
345
- // and the custom meta
346
- wpsc_update_custom_meta($product_id, $post_data);
347
-
348
- // and the images
349
- wpsc_update_product_images($product_id, $post_data);
350
-
351
- //and the alt currency
352
- foreach((array)$post_data['newCurrency'] as $key =>$value){
353
- wpsc_update_alt_product_currency($product_id, $value, $post_data['newCurrPrice'][$key]);
354
- }
355
-
356
- if($post_data['files']['file']['tmp_name'] != '') {
357
- wpsc_item_process_file($product_id, $post_data['files']['file']);
358
- } else {
359
- wpsc_item_reassign_file($product_id, $post_data['select_product_file']);
360
- }
361
-
362
- //exit('<pre>'.print_r($post_data, true).'</pre>');
363
- if($post_data['files']['preview_file']['tmp_name'] != '') {
364
- wpsc_item_add_preview_file($product_id, $post_data['files']['preview_file']);
365
- }
366
-
367
-
368
- do_action('wpsc_edit_product', $product_id);
369
- wpsc_ping();
370
- return $product_id;
371
- }
372
-
373
-
374
-
375
-
376
-
377
- /**
378
- * wpsc_edit_product_variations function.
379
- * this is the function to make child products using variations
380
- *
381
- * @access public
382
- * @param mixed $product_id
383
- * @param mixed $post_data
384
- * @return void
385
- */
386
- function wpsc_edit_product_variations($product_id, $post_data) {
387
- global $wpdb, $user_ID;
388
-
389
- $variations = (array)$post_data['edit_var_val'];
390
- // bail if the array is empty
391
- if(count($variations) < 1) {
392
- return false;
393
- }
394
-
395
-
396
- // Generate the arrays for variation sets, values and combinations
397
- $wpsc_combinator = new wpsc_variation_combinator($variations);
398
- // Retrieve the array containing the variation set IDs
399
- $variation_sets = $wpsc_combinator->return_variation_sets();
400
-
401
- // Retrieve the array containing the combinations of each variation set to be associated with this product.
402
- $variation_values = $wpsc_combinator->return_variation_values();
403
-
404
- // Retrieve the array containing the combinations of each variation set to be associated with this product.
405
- $combinations = $wpsc_combinator->return_combinations();
406
-
407
-
408
- $product_terms = wp_get_object_terms($product_id, 'wpsc-variation');
409
-
410
- $variation_sets_and_values = array_merge($variation_sets, $variation_values);
411
-
412
- wp_set_object_terms($product_id, $variation_sets_and_values, 'wpsc-variation');
413
-
414
- //die('<pre>'.print_r($variation_sets_and_values, true).'</pre>');
415
-
416
- $child_product_template = array(
417
- 'post_author' => $user_ID,
418
- 'post_content' => $post_data['description'],
419
- 'post_excerpt' => $post_data['additional_description'],
420
- 'post_title' => $post_data['name'],
421
- 'post_status' => 'inherit',
422
- 'post_type' => "wpsc-product",
423
- 'post_name' => sanitize_title($post_data['name']),
424
- 'post_parent' => $product_id
425
- );
426
-
427
- $child_product_meta = get_post_custom($product_id);
428
-
429
- // here we loop through the combinations, get the term data and generate custom product names
430
- foreach($combinations as $combination) {
431
- $term_names = array();
432
- $term_ids = array();
433
- $term_slugs = array();
434
- $product_values = $child_product_template;
435
-
436
- $combination_terms = get_terms('wpsc-variation', array(
437
- 'hide_empty' => 0,
438
- 'include' => implode(",", $combination),
439
- 'orderby' => 'parent',
440
- ));
441
- foreach($combination_terms as $term) {
442
- $term_ids[] = $term->term_id;
443
- $term_slugs[] = $term->slug;
444
- $term_names[] = $term->name;
445
- }
446
- $product_values['post_title'] .= " (".implode(", ", $term_names).")";
447
- $product_values['post_name'] = sanitize_title($product_values['post_title']);
448
- // wp_get_post_terms( $post_id = 0, $taxonomy = 'post_tag', $args = array() ) {
449
-
450
- $selected_post = get_posts(array(
451
- //'numberposts' => 1,
452
- 'name' => $product_values['post_name'],
453
- 'post_parent' => $product_id,
454
- 'post_type' => "wpsc-product",
455
- 'post_status' => 'all',
456
- 'suppress_filters' => true
457
- ));
458
- $selected_post = array_shift($selected_post);
459
-
460
- $child_product_id = wpsc_get_child_object_in_terms($product_id, $term_ids, 'wpsc-variation');
461
-
462
- //echo "<pre>".print_r($child_product_id, true)."</pre>";
463
- if($child_product_id == false) {
464
- if($selected_post != null) {
465
- $child_product_id = $selected_post->ID;
466
- } else {
467
- $child_product_id = wp_update_post($product_values);
468
- }
469
- } else {
470
- // sometimes there have been problems saving the variations, this gets the correct product ID
471
- if(($selected_post != null) && ($selected_post->ID != $child_product_id)) {
472
- $child_product_id = $selected_post->ID;
473
- }
474
- }
475
- if($child_product_id > 0) {
476
- wp_set_object_terms($child_product_id, $term_slugs, 'wpsc-variation');
477
- }
478
- //JS - 7.9 - Adding loop to include meta data in child product.
479
- //die("<pre>".print_r($child_product_meta)."</pre>");
480
- foreach ($child_product_meta as $meta_key => $meta_value ) :
481
- if ($meta_key == "_wpsc_product_metadata") {
482
- update_post_meta($child_product_id, $meta_key, unserialize($meta_value[0]));
483
- } else {
484
- update_post_meta($child_product_id, $meta_key, $meta_value[0]);
485
- }
486
-
487
- endforeach;
488
- }
489
-
490
- }
491
-
492
-
493
-
494
- function wpsc_update_alt_product_currency($product_id, $newCurrency, $newPrice){
495
- global $wpdb;
496
- $sql = "SELECT `isocode` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `id`=".$newCurrency;
497
- $isocode = $wpdb->get_var($sql);
498
- //exit($sql);
499
- $newCurrency = 'currency['.$isocode.']';
500
-
501
- if(($newPrice != '') && ($newPrice > 0)){
502
- update_product_meta($product_id, $newCurrency, $newPrice, $prev_value = '');
503
- } else {
504
- delete_product_meta($product_id, $newCurrency);
505
- }
506
-
507
- //exit('<pre>'.print_r($newCurrency, true).'</pre>'.$newPrice);
508
- }
509
- /**
510
- * wpsc_update_categories function
511
- *
512
- * @param integer product ID
513
- * @param array submitted categories
514
- */
515
- function wpsc_update_category_associations($product_id, $categories = array()) {
516
- global $wpdb;
517
-
518
- $associated_categories = $wpdb->get_col($wpdb->prepare("SELECT `category_id` FROM `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."` WHERE `product_id` IN('%s')", $product_id));
519
-
520
- $categories_to_add = array_diff((array)$categories, (array)$associated_categories);
521
- $categories_to_delete = array_diff((array)$associated_categories, (array)$categories);
522
- $insert_sections = array();
523
- foreach($categories_to_delete as $key => $category_to_delete) {
524
- $categories_to_delete[$key] = absint($category_to_delete);
525
- }
526
-
527
- //exit('<pre>'.print_r($categories_to_delete, true).'</pre>');
528
-
529
- foreach($categories_to_add as $category_id) {
530
- $insert_sections[] = $wpdb->prepare("( %d, %d)", $product_id, $category_id);
531
- }
532
- if(count($insert_sections)) {
533
- $wpdb->query("INSERT INTO `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."` (`product_id`, `category_id`) VALUES ".implode(", ",$insert_sections)."");
534
- }
535
-
536
- foreach($categories_to_add as $category_id) {
537
- $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);
538
- 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")) {
539
- $wpdb->query("UPDATE `".WPSC_TABLE_PRODUCT_ORDER."` SET `order` = '0' WHERE `category_id` IN('$category_id') AND `product_id` IN('$product_id') LIMIT 1;");
540
- } else {
541
- $wpdb->query("INSERT INTO `".WPSC_TABLE_PRODUCT_ORDER."` (`category_id`, `product_id`, `order`) VALUES ('$category_id', '$product_id', 0)");
542
- }
543
- if($check_existing != null) {
544
- $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'");
545
- }
546
- }
547
- if(count($categories_to_delete) > 0) {
548
- $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)."");
549
- }
550
- }
551
-
552
- /**
553
- * wpsc_update_product_tags function
554
- *
555
- * @param integer product ID
556
- * @param string comma separated tags
557
- */
558
- function wpsc_update_product_tags($product_id, $product_tags, $existing_tags) {
559
- if(isset($existing_tags)){
560
- $tags = explode(',',$existing_tags);
561
- if(is_array($tags)){
562
- foreach((array)$tags as $tag){
563
- $tt = wp_insert_term((string)$tag, 'product_tag');
564
- }
565
- }
566
- }
567
- wp_set_object_terms($product_id, $tags, 'product_tag');
568
- if(isset($product_tags) && $product_tags != 'Add new tag') {
569
-
570
- $tags = explode(',',$product_tags);
571
- product_tag_init();
572
- if(is_array($tags)) {
573
- foreach((array)$tags as $tag){
574
- $tt = wp_insert_term((string)$tag, 'product_tag');
575
- }
576
- }
577
- wp_set_object_terms($product_id, $tags, 'product_tag');
578
- }
579
- }
580
-
581
- /**
582
- * wpsc_update_product_meta function
583
- *
584
- * @param integer product ID
585
- * @param string comma separated tags
586
- */
587
- function wpsc_update_product_meta($product_id, $product_meta) {
588
- if($product_meta != null) {
589
- foreach((array)$product_meta as $key => $value) {
590
- if(get_post_meta($product_id, $key) != false) {
591
- update_post_meta($product_id, $key, $value);
592
- } else {
593
- add_post_meta($product_id, $key, $value);
594
- }
595
- }
596
- }
597
- }
598
-
599
- /*
600
- /* Code to support Publish/No Publish (1bigidea)
601
- */
602
- /**
603
- * set status of publish conditions
604
- * @return
605
- * @param string $product_id
606
- * @param bool $status Publish State
607
- */
608
- function wpsc_set_publish_status($product_id, $state) {
609
- global $wpdb;
610
- switch($state) {
611
- case 'draft':
612
- case 0:
613
- $status = 'draft';
614
- break;
615
-
616
- default:
617
- $status = 'publish';
618
- break;
619
- }
620
- $result = $wpdb->query("UPDATE `".$wpdb->posts."` SET `post_status` = '{$status}' WHERE `ID` = '{$product_id}'");
621
- }
622
-
623
- /**
624
- * Toggle publish status and update product record
625
- * @return bool Publish status
626
- * @param string $product_id
627
- */
628
- function wpsc_toggle_publish_status($product_id) {
629
- global $wpdb;
630
-
631
- if(wpsc_publish_status($product_id) == 'publish') {
632
- $status = 'draft';
633
- } else {
634
- $status = 'publish';
635
- }
636
-
637
- wpsc_set_publish_status($product_id, $status);
638
- return $status;
639
- }
640
- /**
641
- * Returns publish status from product database
642
- * @return bool publish status
643
- * @param string $product_id
644
- */
645
- function wpsc_publish_status($product_id) {
646
- global $wpdb;
647
- $status = $wpdb->get_var("SELECT `post_status` FROM `".$wpdb->posts."` WHERE `ID` = '{$product_id}'");
648
- return $status;
649
- }
650
- /**
651
- * Called from javascript within product page to toggle publish status - AJAX
652
- * @return bool publish status
653
- */
654
- function wpsc_ajax_toggle_publish() {
655
- /**
656
- * @todo - Check Admin Referer
657
- * @todo - Check Permissions
658
- */
659
- $status = (wpsc_toggle_publish_status($_REQUEST['productid'])) ? ('true') : ('false');
660
- exit( $status );
661
- }
662
- //add_action('wp_ajax_wpsc_toggle_publish','wpsc_ajax_toggle_publish');
663
- /*
664
- /* END - Publish /No Publish functions
665
- */
666
-
667
- function wpsc_update_custom_meta($product_id, $post_data) {
668
- global $wpdb;
669
- if($post_data['new_custom_meta'] != null) {
670
- foreach((array)$post_data['new_custom_meta']['name'] as $key => $name) {
671
- $value = $post_data['new_custom_meta']['value'][(int)$key];
672
- if(($name != '') && ($value != '')) {
673
- add_post_meta($product_id, $name, $value);
674
- }
675
- }
676
- }
677
-
678
- if($post_data['custom_meta'] != null) {
679
- foreach((array)$post_data['custom_meta'] as $key => $values) {
680
- if(($values['name'] != '') && ($values['value'] != '')) {
681
- update_post_meta($product_id, $name, $value);
682
- }
683
- }
684
- }
685
- }
686
-
687
- /**
688
- * wpsc_update_product_tags function
689
- *
690
- * @param integer product ID
691
- * @param array the post data
692
- */
693
- function wpsc_update_product_images($product_id, $post_data) {
694
- global $wpdb;
695
- $uploaded_images = array();
696
-
697
- /* Handle new image uploads here */
698
- if($post_data['files']['image']['tmp_name'] != '') {
699
- $image = wpsc_item_process_image($product_id, $post_data['files']['image']['tmp_name'], str_replace(" ", "_", $post_data['files']['image']['name']), $post_data['width'], $post_data['height'], $post_data['image_resize']);
700
-
701
- $image_action = absint($post_data['image_resize']);
702
- $image_width = $post_data['width'];
703
- $image_height = $post_data['height'];
704
-
705
- } else {
706
- $image_action = absint($post_data['gallery_resize']);
707
- $image_width = $post_data['gallery_width'];
708
- $image_height = $post_data['gallery_height'];
709
-
710
- }
711
-
712
- // exit( "<pre>".print_r($image_action, true)."</pre>");
713
- wpsc_resize_image_thumbnail($product_id, $image_action, $image_width, $image_height);
714
- //exit( " <pre>".print_r($post_data, true)."</pre>");
715
-
716
-
717
-
718
-
719
- }
720
-
721
- /**
722
- * wpsc_resize_image_thumbnail function
723
- *
724
- * @param integer product ID
725
- * @param integer the action to perform on the image
726
- * @param integer the width of the thumbnail image
727
- * @param integer the height of the thumbnail image
728
- * @param array the custom image array from $_FILES
729
- */
730
- function wpsc_resize_image_thumbnail($product_id, $image_action= 0, $width = 0, $height = 0, $custom_image = null) {
731
- global $wpdb;
732
- $image_id = $wpdb->get_var("SELECT `image` FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE `id` = '{$product_id}' LIMIT 1");
733
- $image = $wpdb->get_var("SELECT `image` FROM `".WPSC_TABLE_PRODUCT_IMAGES."` WHERE `id` = '{$image_id}' LIMIT 1");
734
-
735
- // check if there is an image that is supposed to be there.
736
- if($image != '') {
737
- if(is_numeric($image)){
738
- }
739
- // check that is really there
740
- if(file_exists(WPSC_IMAGE_DIR.$image)) {
741
- // if the width or height is less than 1, set the size to the default
742
- if((($width < 1) || ($height < 1)) && ($image_action == 2)) {
743
- $image_action = 1;
744
- }
745
- switch($image_action) {
746
- case 0:
747
- if(!file_exists(WPSC_THUMBNAIL_DIR.$image)) {
748
- copy(WPSC_IMAGE_DIR.$image, WPSC_THUMBNAIL_DIR.$image);
749
- }
750
- break;
751
-
752
-
753
- case 1:
754
- // if case 1, replace the provided size with the default size
755
- $height = get_option('product_image_height');
756
- $width = get_option('product_image_width');
757
- case 2:
758
- // if case 2, use the provided size
759
- $image_input = WPSC_IMAGE_DIR . $image;
760
- $image_output = WPSC_THUMBNAIL_DIR . $image;
761
-
762
- if($width < 1) {
763
- $width = 96;
764
- }
765
- if($height < 1) {
766
- $height = 96;
767
- }
768
-
769
- image_processing($image_input, $image_output, $width, $height);
770
- update_product_meta($product_id, 'thumbnail_width', $width);
771
- update_product_meta($product_id, 'thumbnail_height', $height);
772
- break;
773
-
774
- case 3:
775
- // replacing the thumbnail with a custom image is done here
776
- $uploaded_image = null;
777
- //exit($uploaded_image);
778
- if(file_exists($_FILES['gallery_thumbnailImage']['tmp_name'])) {
779
- $uploaded_image = $_FILES['gallery_thumbnailImage']['tmp_name'];
780
- } else if(file_exists($_FILES['thumbnailImage']['tmp_name'])) {
781
- $uploaded_image = $_FILES['thumbnailImage']['tmp_name'];
782
- }
783
- if($uploaded_image !== null) {
784
-
785
- move_uploaded_file($uploaded_image, WPSC_THUMBNAIL_DIR.$image);
786
- //exit($uploaded_image);
787
-
788
- }
789
- break;
790
- }
791
-
792
- if(!file_exists(WPSC_IMAGE_DIR.$image)) {
793
- $wpdb->query("INSERT INTO `".WPSC_TABLE_PRODUCT_IMAGES."` SET `thumbnail_state` = '$image_action' WHERE `id`='{$product_id}' LIMIT 1");
794
- $sql = "INSERT INTO `".WPSC_TABLE_PRODUCT_IMAGES."` (`product_id`, `image`, `width`, `height`) VALUES ('{$product_id}', '{$image}', '{$width}', '{$height}' )";
795
- $wpdb->query($sql);
796
- $image_id = (int) $wpdb->insert_id;
797
- }
798
-
799
- $sql="UPDATE `".WPSC_TABLE_PRODUCT_LIST."` SET `thumbnail_state` = '$image_action', `image` ='{$image_id}' WHERE `id`='{$product_id}' LIMIT 1";
800
- //exit($sql);
801
- $wpdb->query($sql);
802
- } else {
803
- //if it is not, we need to unset the associated image
804
- //$wpdb->query("UPDATE `".WPSC_TABLE_PRODUCT_LIST."` SET `image` = '' WHERE `id`='{$product_id}' LIMIT 1");
805
- //$wpdb->query("INSERT INTO `".WPSC_TABLE_PRODUCT_IMAGES."` (`product_id`, `image`, `width`, `height`) VALUES ('{$product_id}', '{$image}', '{$width}', '{$height}' )");
806
- }
807
- }
808
-
809
- }
810
-
811
-
812
-
813
-
814
- /**
815
- * wpsc_upload_image_thumbnail function
816
- *
817
- * @param integer product ID
818
- * @param string comma separated tags
819
- */
820
- function wpsc_upload_image_thumbnail($product_id, $product_meta) {
821
- if(($_POST['image_resize'] == 3) && ($_FILES['thumbnailImage'] != null) && file_exists($_FILES['thumbnailImage']['tmp_name'])) {
822
- $imagefield='thumbnailImage';
823
-
824
- $image=image_processing($_FILES['thumbnailImage']['tmp_name'], WPSC_THUMBNAIL_DIR.$_FILES['thumbnailImage']['name'],null,null,$imagefield);
825
- $thumbnail_image = $image;
826
- $wpdb->query("UPDATE `".WPSC_TABLE_PRODUCT_LIST."` SET `thumbnail_image` = '".$thumbnail_image."' WHERE `id` = '".$image_data['id']."'");
827
- $stat = stat( dirname( (WPSC_THUMBNAIL_DIR.$image_data['image']) ));
828
- $perms = $stat['mode'] & 0000775;
829
- @ chmod( (WPSC_THUMBNAIL_DIR.$image_data['image']), $perms );
830
- }
831
- }
832
-
833
-
834
- /**
835
- * wpsc_item_process_file function
836
- *
837
- * @param integer product ID
838
- * @param array the file array from $_FILES
839
- * @param array the preview file array from $_FILES
840
- */
841
- function wpsc_item_process_file($product_id, $submitted_file, $preview_file = null) {
842
- global $wpdb;
843
- add_filter('upload_dir', 'wpsc_modify_upload_directory');
844
- $overrides = array('test_form'=>false);
845
-
846
- $time = current_time('mysql');
847
- if ( $post = get_post($product_id) ) {
848
- if ( substr( $post->post_date, 0, 4 ) > 0 )
849
- $time = $post->post_date;
850
- }
851
-
852
- //$name = basename($submitted_file['name']);
853
- $file = wp_handle_upload($submitted_file, $overrides, $time);
854
-
855
- if ( isset($file['error']) )
856
- return new WP_Error( 'upload_error', $file['error'] );
857
-
858
- $name_parts = pathinfo($file['file']);
859
- //$name = trim( substr( $name, 0, -(1 + strlen($name_parts['extension'])) ) );
860
- $name = $name_parts['basename'];
861
- //echo "<pre>".print_r($name_parts,true)."</pre>"; exit();
862
-
863
- $url = $file['url'];
864
- $type = $file['type'];
865
- $file = $file['file'];
866
- $title = $name;
867
- $content = '';
868
-
869
- // Construct the attachment array
870
- $attachment = array(
871
- 'post_mime_type' => $type,
872
- 'guid' => $url,
873
- 'post_parent' => $product_id,
874
- 'post_title' => $title,
875
- 'post_content' => $content,
876
- 'post_type' => "wpsc-product-file",
877
- 'post_status' => 'inherit'
878
- );
879
-
880
- // Save the data
881
- $id = wp_insert_post($attachment, $file, $product_id);
882
- remove_filter('upload_dir', 'wpsc_modify_upload_directory');
883
- //return $id;
884
- //exit($id);
885
- }
886
-
887
- function wpsc_modify_upload_directory($input) {
888
- //echo "<pre>".print_r($input,true)."</pre>";
889
- $previous_subdir = $input['subdir'];
890
- $download_subdir = str_replace($input['basedir'], '', WPSC_FILE_DIR);
891
-
892
- $input['path'] = str_replace($previous_subdir, $download_subdir, $input['path']);
893
- $input['url'] = str_replace($previous_subdir, $download_subdir, $input['url']);
894
- $input['subdir'] = str_replace($previous_subdir, $download_subdir, $input['subdir']);
895
-
896
- //echo "<pre>".print_r($input,true)."</pre>";
897
- return $input;
898
- }
899
-
900
-
901
-
902
- /**
903
- * wpsc_item_reassign_file function
904
- *
905
- * @param integer product ID
906
- * @param string the selected file name;
907
- */
908
- function wpsc_item_reassign_file($product_id, $selected_files) {
909
- global $wpdb;
910
- $product_file_list = array();
911
- // initialise $idhash to null to prevent issues with undefined variables and error logs
912
- $idhash = null;
913
-
914
- $args = array(
915
- 'post_type' => 'wpsc-product-file',
916
- 'post_parent' => $product_id,
917
- 'numberposts' => -1,
918
- 'post_status' => 'any'
919
- );
920
-
921
- $attached_files = (array)get_posts($args);
922
-
923
- foreach($attached_files as $key => $attached_file) {
924
- $attached_files_by_file[$attached_file->post_title] = $attached_files[$key];
925
- }
926
-
927
-
928
- //echo "<pre>\n";
929
- //echo print_r($attached_files,true);
930
- //echo wp_insert_post($attachment);
931
- //echo "</pre>\n";
932
-
933
-
934
- /* if we are editing, grab the current file and ID hash */
935
- if(!$selected_files) {
936
- // unlikely that anyone will ever upload a file called .none., so its the value used to signify clearing the product association
937
- //$wpdb->query("UPDATE `".WPSC_TABLE_PRODUCT_LIST."` SET `file` = '0' WHERE `id` = '$product_id' LIMIT 1");
938
- return null;
939
- }
940
-
941
-
942
-
943
- foreach($selected_files as $selected_file) {
944
- // if we already use this file, there is no point doing anything more.
945
- $file_is_attached = false;
946
- $selected_file_path = WPSC_FILE_DIR.basename($selected_file);
947
-
948
- if(isset($attached_files_by_file[$selected_file])) {
949
- $file_is_attached = true;
950
- }
951
-
952
- //if(is_file($selected_file_path)) {
953
- if($file_is_attached == false ) {
954
- $type = wpsc_get_mimetype($selected_file_path);
955
- $attachment = array(
956
- 'post_mime_type' => $type,
957
- 'post_parent' => $product_id,
958
- 'post_title' => $selected_file,
959
- 'post_content' => '',
960
- 'post_type' => "wpsc-product-file",
961
- 'post_status' => 'inherit'
962
- );
963
- wp_insert_post($attachment);
964
- } else {
965
- $product_post_values = array(
966
- 'ID' => $attached_files_by_file[$selected_file]->ID,
967
- 'post_status' => 'inherit'
968
- );
969
- wp_update_post($product_post_values);
970
- }
971
- //}
972
- }
973
-
974
-
975
- foreach($attached_files as $attached_file) {
976
- if(!in_array($attached_file->post_title, $selected_files)) {
977
- $product_post_values = array(
978
- 'ID' => $attached_file->ID,
979
- 'post_status' => 'draft'
980
- );
981
- wp_update_post($product_post_values);
982
- }
983
- }
984
-
985
-
986
- //
987
- //exit('<pre>'.print_r($attached_files, true).'</pre>');
988
- //update_product_meta($product_id, 'product_files', $product_file_list);
989
- return $fileid;
990
- }
991
-
992
-
993
-
994
- /**
995
- * wpsc_item_add_preview_file function
996
- *
997
- * @param integer product ID
998
- * @param array the preview file array from $_FILES
999
- */
1000
- function wpsc_item_add_preview_file($product_id, $preview_file) {
1001
- global $wpdb;
1002
-
1003
- $current_file_id = $wpdb->get_var("SELECT `file` FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE `id` = '$product_id' LIMIT 1");
1004
- $file_data = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_PRODUCT_FILES."` WHERE `id`='{$current_file_id}' LIMIT 1",ARRAY_A);
1005
-
1006
- if(apply_filters( 'wpsc_filter_file', $preview_file['tmp_name'] )) {
1007
- //echo "test?";
1008
- if(function_exists("make_mp3_preview")) {
1009
- if($mimetype == "audio/mpeg" && (!isset($preview_file['tmp_name']))) {
1010
- // if we can generate a preview file, generate it (most can't due to sox being rare on servers and sox with MP3 support being even rarer), thus this needs to be enabled by editing code
1011
- make_mp3_preview((WPSC_FILE_DIR.$idhash), (WPSC_PREVIEW_DIR.$idhash.".mp3"));
1012
- $preview_filepath = (WPSC_PREVIEW_DIR.$idhash.".mp3");
1013
- } else if(file_exists($preview_file['tmp_name'])) {
1014
- $preview_filename = basename($preview_file['name']);
1015
- $preview_mimetype = wpsc_get_mimetype($preview_file['tmp_name']);
1016
- copy($preview_file['tmp_name'], (WPSC_PREVIEW_DIR.$preview_filename));
1017
- $preview_filepath = (WPSC_PREVIEW_DIR.$preview_filename);
1018
- $wpdb->query("UPDATE `".WPSC_TABLE_PRODUCT_FILES."` SET `preview` = '".$wpdb->escape($preview_filename)."', `preview_mimetype` = '".$preview_mimetype."' WHERE `id` = '{$file_data['id']}' LIMIT 1");
1019
- //exit("UPDATE `".WPSC_TABLE_PRODUCT_FILES."` SET `preview` = '".$wpdb->escape($preview_filename)."', `preview_mimetype` = '".$preview_mimetype."' WHERE `id` = '{$file_data['id']}' LIMIT 1");
1020
- }
1021
- $stat = stat( dirname($preview_filepath));
1022
- $perms = $stat['mode'] & 0000666;
1023
- @ chmod( $preview_filepath, $perms );
1024
- }
1025
- //exit("<pre>".print_r($preview_file,true)."</pre>");
1026
- return $fileid;
1027
- } else {
1028
- return $selected_files;
1029
- }
1030
- }
1031
-
1032
-
1033
- /**
1034
- * wpsc_variation_combinator class.
1035
- * Produces all combinations of variations selected for this product
1036
- * this class is based off the example code from here:
1037
- * http://www.php.net/manual/en/ref.array.php#94910
1038
- * Thanks, phektus, you are awesome, whoever you are.
1039
- */
1040
- class wpsc_variation_combinator {
1041
- var $variation_sets = array();
1042
- var $variation_values = array();
1043
- var $reprocessed_array = array();
1044
- var $combinations= array();
1045
-
1046
- function wpsc_variation_combinator($variation_sets) {
1047
- foreach($variation_sets as $variation_set_id => $variation_set) {
1048
- $this->variation_sets[] = absint($variation_set_id);
1049
- $new_variation_set = array();
1050
- foreach($variation_set as $variation => $active) {
1051
- if($active == 1) {
1052
- $new_variation_set[] = array(absint($variation));
1053
- $this->variation_values[] = $variation;
1054
- }
1055
- }
1056
- $this->reprocessed_array[] = $new_variation_set;
1057
- }
1058
- $this->get_combinations(array(), $this->reprocessed_array, 0);
1059
- }
1060
-
1061
-
1062
- function get_combinations($batch, $elements, $i) {
1063
- //echo "<pre>".print_r($batch,true)."</pre>";
1064
- if ($i >= count($elements)) {
1065
- $this->combinations[] = $batch;
1066
- } else {
1067
- foreach ($elements[$i] as $element) {
1068
- $this->get_combinations(array_merge($batch, $element), $elements, $i + 1);
1069
- }
1070
- }
1071
- }
1072
-
1073
- function return_variation_sets() {
1074
- return $this->variation_sets;
1075
- }
1076
-
1077
- function return_variation_values() {
1078
- return $this->variation_values;
1079
- }
1080
-
1081
- function return_combinations() {
1082
- return $this->combinations;
1083
-
1084
- }
1085
- }
1086
-
1087
-
1088
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WPSC Product modifying functions
4
+ *
5
+ * @package wp-e-commerce
6
+ * @since 3.7
7
+ */
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_admin_submit_product function
18
+ *
19
+ * @return nothing
20
+ */
21
+ function wpsc_admin_submit_product() {
22
+ check_admin_referer('edit-product', 'wpsc-edit-product');
23
+
24
+ $sendback = wp_get_referer();
25
+ $post_data = wpsc_sanitise_product_forms();
26
+ //$post_data['category'] = 1; /// remove this
27
+ if(isset($post_data['title']) && $post_data['title'] != '') {
28
+ $product_id = wpsc_insert_product($post_data, true);
29
+ if($product_id > 0) {
30
+ $sendback = add_query_arg('product', $product_id);
31
+ }
32
+
33
+ $sendback = add_query_arg('message', 1, $sendback);
34
+ //exit('<pre>'.print_r($sendback,true).'</pre>');
35
+ wp_redirect($sendback);
36
+ } else {
37
+ $_SESSION['product_error_messages'] = array();
38
+ if($post_data['title'] == ''){
39
+ $_SESSION['product_error_messages'][] = __('<strong>ERROR</strong>: Please enter a Product name.<br />');
40
+ }
41
+ if(!isset($post_data['category'])){
42
+ $_SESSION['product_error_messages'][] = __('<strong>ERROR</strong>: Please enter a Product Category.<br />');
43
+ }
44
+
45
+ $_SESSION['wpsc_failed_product_post_data'] = $post_data;
46
+ $sendback = add_query_arg('ErrMessage', 1);
47
+ wp_redirect($sendback);
48
+ }
49
+ exit();
50
+ }
51
+
52
+
53
+ /**
54
+ * wpsc_sanitise_product_forms function
55
+ *
56
+ * @return array - Sanitised product details
57
+ */
58
+ function wpsc_sanitise_product_forms($post_data = null) {
59
+ if ( empty($post_data) ) {
60
+ $post_data = &$_POST;
61
+ }
62
+
63
+ $product = get_post(absint($post_data['post_ID']));
64
+
65
+
66
+ // $post_data['product_id'] = isset($post_data['product_id']) ? $post_data['product_id'] : '';
67
+ $post_data['name'] = isset($post_data['post_title']) ? $post_data['post_title'] : '';
68
+ $post_data['title'] = $post_data['name'];
69
+ $post_data['description'] = isset($post_data['content']) ? $post_data['content'] : '';
70
+ $post_data['additional_description'] = isset($post_data['additional_description']) ? $post_data['additional_description'] : '';
71
+
72
+ //$post_data['publish'] = (int)(bool)$post_data['publish'];
73
+ if($product != null) {
74
+ $post_data['post_status'] = $product->post_status;
75
+ } else {
76
+ $post_data['post_status'] = 'draft';
77
+
78
+ }
79
+
80
+
81
+
82
+ if(isset($post_data['save'])) {
83
+ $post_data['post_status'] = $post_data['post_status'];
84
+ } else if(isset($post_data['publish'])) {
85
+ $post_data['post_status'] = 'publish';
86
+ } else if(isset($post_data['unpublish'])) {
87
+ $post_data['post_status'] = 'draft';
88
+ }
89
+
90
+
91
+
92
+ $post_meta['meta'] = (array)$_POST['meta'];
93
+
94
+ $post_data['meta']['_wpsc_price'] = (float)$post_data['meta']['_wpsc_price'];
95
+ $post_data['meta']['_wpsc_special_price'] = (float)$post_data['meta']['_wpsc_special_price'];
96
+ $post_data['meta']['_wpsc_sku'] = $post_data['meta']['_wpsc_sku'];
97
+ if (!isset($post_data['meta']['_wpsc_is_donation'])) $post_data['meta']['_wpsc_is_donation'] = '';
98
+ $post_data['meta']['_wpsc_is_donation'] = (int)(bool)$post_data['meta']['_wpsc_is_donation'];
99
+ $post_data['meta']['_wpsc_stock'] = (int)$post_data['meta']['_wpsc_stock'];
100
+
101
+ if (!isset($post_data['meta']['_wpsc_limited_stock'])) $post_data['meta']['_wpsc_limited_stock'] = '';
102
+ if((bool)$post_data['meta']['_wpsc_limited_stock'] != true) {
103
+ $post_data['meta']['_wpsc_stock'] = false;
104
+ }
105
+ unset($post_data['meta']['_wpsc_limited_stock']);
106
+ if(!isset($post_data['meta']['_wpsc_product_metadata']['unpublish_when_none_left'])) $post_data['meta']['_wpsc_product_metadata']['unpublish_when_none_left'] = '';
107
+ if(!isset($post_data['quantity_limited'])) $post_data['quantity_limited'] = '';
108
+ if(!isset($post_data['special'])) $post_data['special'] = '';
109
+ if(!isset($post_data['meta']['_wpsc_product_metadata']['no_shipping'])) $post_data['meta']['_wpsc_product_metadata']['no_shipping'] = '';
110
+
111
+ $post_data['meta']['_wpsc_product_metadata']['unpublish_when_none_left'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['unpublish_when_none_left'];
112
+ $post_data['meta']['_wpsc_product_metadata']['quantity_limited'] = (int)(bool)$post_data['quantity_limited'];
113
+ $post_data['meta']['_wpsc_product_metadata']['special'] = (int)(bool)$post_data['special'];
114
+ /* $post_data['meta']['_wpsc_product_metadata']['notax'] = (int)(bool)$post_data['notax'];; */
115
+ $post_data['meta']['_wpsc_product_metadata']['no_shipping'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['no_shipping'];
116
+
117
+ // Product Weight
118
+ if(!isset($post_data['meta']['_wpsc_product_metadata']['display_weight_as'])) $post_data['meta']['_wpsc_product_metadata']['display_weight_as'] = '';
119
+ if(!isset($post_data['meta']['_wpsc_product_metadata']['display_weight_as'])) $post_data['meta']['_wpsc_product_metadata']['display_weight_as'] = '';
120
+
121
+ $weight = wpsc_convert_weight($post_data['meta']['_wpsc_product_metadata']['weight'], $post_data['meta']['_wpsc_product_metadata']['weight_unit'], "gram");
122
+ $post_data['meta']['_wpsc_product_metadata']['weight'] = (float)$weight;
123
+ $post_data['meta']['_wpsc_product_metadata']['display_weight_as'] = $post_data['meta']['_wpsc_product_metadata']['weight_unit'];
124
+
125
+ // table rate price
126
+ $post_data['meta']['_wpsc_product_metadata']['table_rate_price'] = $post_data['table_rate_price'];
127
+ // if table_rate_price is unticked, wipe the table rate prices
128
+ if(!isset($post_data['table_rate_price']['state'])) $post_data['table_rate_price']['state'] = '';
129
+ if($post_data['table_rate_price']['state'] != 1) {
130
+ $post_data['meta']['_wpsc_product_metadata']['table_rate_price']['quantity'] = null;
131
+ $post_data['meta']['_wpsc_product_metadata']['table_rate_price']['table_rate_price'] = null;
132
+ }
133
+
134
+ /*
135
+ if(!isset($post_data['meta']['_wpsc_product_metadata']['custom_tax']['state'])) $post_data['meta']['_wpsc_product_metadata']['custom_tax']['state'] = '';
136
+ if($post_data['meta']['_wpsc_product_metadata']['custom_tax']['state'] == 1) {
137
+ $custom_tax_value = (float)$post_data['meta']['_wpsc_product_metadata']['custom_tax']['value'];
138
+ } else {
139
+ $custom_tax_value = null;
140
+ }
141
+ $post_data['meta']['_wpsc_product_metadata']['custom_tax'] = $custom_tax_value;
142
+ */
143
+
144
+ $post_data['meta']['_wpsc_product_metadata']['shipping']['local'] = (float)$post_data['meta']['_wpsc_product_metadata']['shipping']['local'];
145
+ $post_data['meta']['_wpsc_product_metadata']['shipping']['international'] = (float)$post_data['meta']['_wpsc_product_metadata']['shipping']['international'];
146
+
147
+
148
+ // Advanced Options
149
+ $post_data['meta']['_wpsc_product_metadata']['engraved'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['engraved'];
150
+ $post_data['meta']['_wpsc_product_metadata']['can_have_uploaded_image'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['can_have_uploaded_image'];
151
+ if(!isset($post_data['meta']['_wpsc_product_metadata']['google_prohibited'])) $post_data['meta']['_wpsc_product_metadata']['google_prohibited'] = '';
152
+ $post_data['meta']['_wpsc_product_metadata']['google_prohibited'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['google_prohibited'];
153
+ $post_data['meta']['_wpsc_product_metadata']['external_link'] = (string)$post_data['meta']['_wpsc_product_metadata']['external_link'];
154
+
155
+ $post_data['meta']['_wpsc_product_metadata']['enable_comments'] = $post_data['meta']['_wpsc_product_metadata']['enable_comments'];
156
+ $post_data['meta']['_wpsc_product_metadata']['merchant_notes'] = $post_data['meta']['_wpsc_product_metadata']['merchant_notes'];
157
+
158
+
159
+
160
+
161
+
162
+
163
+ /*
164
+ if(is_numeric($post_data['special_price'])) {
165
+ $post_data['special_price'] = (float)($post_data['price'] - $post_data['special_price']);
166
+ } else {
167
+ $post_data['special_price'] = 0;
168
+ }
169
+ */
170
+
171
+ /*
172
+ // if special is unticked, wipe the special_price value
173
+ if($post_data['special'] !== 1) {
174
+ $post_data['special_price'] = 0;
175
+ }
176
+ */
177
+ //
178
+
179
+
180
+
181
+
182
+
183
+ $post_data['files'] = $_FILES;
184
+ return $post_data;
185
+ }
186
+
187
+
188
+
189
+ /**
190
+ * wpsc_insert_product function
191
+ *
192
+ * @param unknown
193
+ * @return unknown
194
+ */
195
+ // exit('Image height'.get_option('product_image_height'));
196
+ function wpsc_insert_product($post_data, $wpsc_error = false) {
197
+ global $wpdb, $user_ID;
198
+ $adding = false;
199
+ $update = false;
200
+ if((int)$post_data['post_ID'] > 0) {
201
+ $product_id = absint($post_data['post_ID']);
202
+ $update = true;
203
+ } else if((int)$post_data['product_id'] > 0) {
204
+ $product_id = absint($post_data['product_id']);
205
+ $update = true;
206
+ }
207
+
208
+ //exit('<pre>'.print_r($product_id, true).'</pre>');
209
+
210
+ $product_columns = array(
211
+ 'name' => '',
212
+ 'description' => '',
213
+ 'additional_description' => '',
214
+ 'price' => null,
215
+ 'weight' => null,
216
+ 'weight_unit' => '',
217
+ 'pnp' => null,
218
+ 'international_pnp' => null,
219
+ 'file' => null,
220
+ 'image' => '0',
221
+ 'quantity_limited' => '',
222
+ 'quantity' => null,
223
+ 'special' => null,
224
+ 'special_price' => null,
225
+ 'display_frontpage' => null,
226
+ 'notax' => null,
227
+ 'publish' => null,
228
+ 'active' => null,
229
+ 'donation' => null,
230
+ 'no_shipping' => null,
231
+ 'thumbnail_image' => null,
232
+ 'thumbnail_state' => null
233
+ );
234
+
235
+
236
+ foreach($product_columns as $column => $default)
237
+ {
238
+ if (!isset($post_data[$column])) $post_data[$column] = '';
239
+
240
+ if($post_data[$column] !== null) {
241
+ $update_values[$column] = stripslashes($post_data[$column]);
242
+ } else if(($update != true) && ($default !== null)) {
243
+ $update_values[$column] = stripslashes($default);
244
+ }
245
+ }
246
+
247
+
248
+ $product_post_values = array(
249
+ 'ID' => $product_id,
250
+ 'post_author' => $user_ID,
251
+ 'post_content' => $post_data['description'],
252
+ 'post_excerpt' => $post_data['additional_description'],
253
+ 'post_title' => $post_data['name'],
254
+ 'post_status' => $post_data['post_status'],
255
+ 'post_type' => "wpsc-product",
256
+ 'post_name' => sanitize_title($post_data['name'])
257
+ );
258
+
259
+ if ($post_data['meta']['_wpsc_product_metadata']['enable_comments'] == 0) {
260
+ $product_post_values["comment_status"] = "closed";
261
+ }else {
262
+ $product_post_values["comment_status"] = "open";
263
+ }
264
+
265
+ //exit("<pre>".print_r(wp_update_post($product_post_values) , true)."</pre>");
266
+ if(isset($sku) && ($sku != '')) {
267
+ $product_post_array['guid'] = $sku;
268
+ }
269
+
270
+
271
+
272
+ if($update === true) {
273
+ $where = array( 'id' => $product_id );
274
+ // exit('<pre>'.print_r($product_post_values).'</pre>');
275
+ $product_id = wp_update_post($product_post_values);
276
+ if ( isset ( $post_data["sticky"] ) ) {
277
+ stick_post($product_id);
278
+ }else {
279
+ unstick_post($product_id);
280
+ }
281
+ if ($product_id == 0) {
282
+ if ( $wpsc_error ) {
283
+ return new WP_Error('db_update_error', __('Could not update product in the database'), $wpdb->last_error);
284
+ } else {
285
+ return false;
286
+ }
287
+ }
288
+ } else {
289
+
290
+ $product_post_values += array(
291
+ 'post_date' => $product['date_added']
292
+ );
293
+ $product_id = wp_insert_post($product_post_values);
294
+ if ( isset ( $post_data["sticky"] ) ) {
295
+ stick_post($product_id);
296
+ }else {
297
+ unstick_post($product_id);
298
+ }
299
+ if ($product_id == 0 ) {
300
+ if ( $wp_error ) {
301
+ return new WP_Error('db_insert_error', __('Could not insert product into the database'), $wpdb->last_error);
302
+ } else {
303
+ return 0;
304
+ }
305
+ }
306
+ $adding = true;
307
+ //$product_id = (int)$wpdb->insert_id;
308
+ //exit($product_id.' <-- IS the corresponding ID YAW');
309
+ }
310
+
311
+ /* Add tidy url name */
312
+ if($post_data['name'] != '') {
313
+ $existing_name = get_product_meta($product_id, 'url_name');
314
+ // strip slashes, trim whitespace, convert to lowercase
315
+ $tidied_name = strtolower(trim(stripslashes($post_data['name'])));
316
+ // convert " - " to "-", all other spaces to dashes, and remove all foward slashes.
317
+ //$url_name = preg_replace(array("/(\s-\s)+/","/(\s)+/", "/(\/)+/"), array("-","-", ""), $tidied_name);
318
+ $url_name = sanitize_title($tidied_name);
319
+
320
+ // Select all similar names, using an escaped version of the URL name
321
+ $similar_names = (array)$wpdb->get_col("SELECT `meta_value` FROM `".WPSC_TABLE_PRODUCTMETA."` WHERE `product_id` NOT IN('{$product_id}}') AND `meta_key` IN ('url_name') AND `meta_value` REGEXP '^(".$wpdb->escape(preg_quote($url_name))."){1}[[:digit:]]*$' ");
322
+
323
+ // Check desired name is not taken
324
+ if(array_search($url_name, $similar_names) !== false) {
325
+ // If it is, try to add a number to the end, if that is taken, try the next highest number...
326
+ $i = 0;
327
+ do {
328
+ $i++;
329
+ } while(array_search(($url_name.$i), $similar_names) !== false);
330
+ // Concatenate the first number found that wasn't taken
331
+ $url_name .= $i;
332
+ }
333
+ // If our URL name is the same as the existing name, do othing more.
334
+ if($existing_name != $url_name) {
335
+ update_product_meta($product_id, 'url_name', $url_name);
336
+ }
337
+ }
338
+
339
+ // if we succeed, we can do further editing
340
+
341
+ // update the categories
342
+ /* wpsc_update_category_associations($product_id, $post_data['category']); */
343
+ //wp_set_post_categories($product_id, $post_data['category']);
344
+
345
+ //echo "<pre>".print_r($post_data['category'], true)."</pre>";
346
+ if (!isset($post_data['category'])) $post_data['category'] = array();
347
+ wp_set_product_categories($product_id, $post_data['category']);
348
+
349
+ //echo "<pre>".print_r($test, true)."</pre>";
350
+ //exit();
351
+
352
+
353
+ // and the tags
354
+ if (!isset($post_data['product_tags'])) $post_data['product_tags'] = '';
355
+ if (!isset($post_data['wpsc_existing_tags'])) $post_data['wpsc_existing_tags'] = '';
356
+ wpsc_update_product_tags($product_id, $post_data['product_tags'], $post_data['wpsc_existing_tags']);
357
+
358
+ // and the meta
359
+ wpsc_update_product_meta($product_id, $post_data['meta']);
360
+
361
+ // the variations too
362
+ wpsc_edit_product_variations($product_id, $post_data);
363
+
364
+ // and the custom meta
365
+ wpsc_update_custom_meta($product_id, $post_data);
366
+
367
+ // and the images
368
+ wpsc_update_product_images($product_id, $post_data);
369
+
370
+ //and the alt currency
371
+ foreach((array)$post_data['newCurrency'] as $key =>$value){
372
+ wpsc_update_alt_product_currency($product_id, $value, $post_data['newCurrPrice'][$key]);
373
+ }
374
+
375
+ if($post_data['files']['file']['tmp_name'] != '') {
376
+ wpsc_item_process_file($product_id, $post_data['files']['file']);
377
+ } else {
378
+ if (!isset($post_data['select_product_file'])) $post_data['select_product_file'] = null;
379
+ wpsc_item_reassign_file($product_id, $post_data['select_product_file']);
380
+ }
381
+
382
+ //exit('<pre>'.print_r($post_data, true).'</pre>');
383
+ if(isset($post_data['files']['preview_file']['tmp_name']) && ($post_data['files']['preview_file']['tmp_name'] != '')) {
384
+ wpsc_item_add_preview_file($product_id, $post_data['files']['preview_file']);
385
+ }
386
+
387
+
388
+ do_action('wpsc_edit_product', $product_id);
389
+ wpsc_ping();
390
+ return $product_id;
391
+ }
392
+
393
+
394
+ /**
395
+ * term_id_price function
396
+ * Retreives associated price, if any, with term_id
397
+ * @param integer term ID
398
+ * @param integer parent product price
399
+ * @return integer modified price for child product, based on term ID price and parent price
400
+ */
401
+
402
+ function term_id_price($term_id, $parent_price) {
403
+
404
+ $term_price_arr = get_option( 'term_prices' );
405
+
406
+ if ( isset($term_price_arr[$term_id]) ) {
407
+ $price = $term_price_arr[$term_id]["price"];
408
+ } else {
409
+ $price = 0;
410
+ }
411
+
412
+ //Check for flat, percentile or differential
413
+ $var_price_type = '';
414
+
415
+ if (flat_price($price)) {
416
+ $var_price_type = 'flat';
417
+ $price = floatval($price);
418
+ } elseif ( differential_price($price) ) {
419
+ $var_price_type = 'differential';
420
+ } elseif (percentile_price($price)) {
421
+ $var_price_type = 'percentile';
422
+ }
423
+
424
+ if (strchr($price, '-') ) {
425
+ $negative = true;
426
+ } else {
427
+ $positive = true;
428
+ }
429
+
430
+ if ($positive) {
431
+
432
+ if ( $var_price_type == 'differential' ) {
433
+ $differential = (floatval($price));
434
+ $price = $parent_price + $differential;
435
+ } elseif ( $var_price_type == 'percentile' ) {
436
+ $percentage = (floatval($price) / 100);
437
+ $price = $parent_price + ($parent_price * $percentage);
438
+ }
439
+
440
+ } else {
441
+
442
+ if ( $var_price_type == 'differential' ) {
443
+ $differential = (floatval($price));
444
+ $price = $parent_price - $differential;
445
+ } elseif ( $var_price_type == 'percentile' ) {
446
+ $percentage = (floatval($price) / 100);
447
+ $price = $parent_price - ($parent_price * $percentage);
448
+ }
449
+ }
450
+ return $price;
451
+ }
452
+
453
+
454
+
455
+ /**
456
+ * wpsc_edit_product_variations function.
457
+ * this is the function to make child products using variations
458
+ *
459
+ * @access public
460
+ * @param mixed $product_id
461
+ * @param mixed $post_data
462
+ * @return void
463
+ */
464
+ function wpsc_edit_product_variations($product_id, $post_data) {
465
+ global $wpdb, $user_ID;
466
+ $variations = array();
467
+ if (!isset($post_data['edit_var_val'])) $post_data['edit_var_val'] = '';
468
+
469
+ $variations = (array)$post_data['edit_var_val'];
470
+ // bail if the array is empty
471
+ if(count($variations) < 1) {
472
+ return false;
473
+ }
474
+
475
+
476
+ // Generate the arrays for variation sets, values and combinations
477
+ $wpsc_combinator = new wpsc_variation_combinator($variations);
478
+ // Retrieve the array containing the variation set IDs
479
+ $variation_sets = $wpsc_combinator->return_variation_sets();
480
+
481
+ // Retrieve the array containing the combinations of each variation set to be associated with this product.
482
+ $variation_values = $wpsc_combinator->return_variation_values();
483
+
484
+ // Retrieve the array containing the combinations of each variation set to be associated with this product.
485
+ $combinations = $wpsc_combinator->return_combinations();
486
+
487
+ $product_terms = wp_get_object_terms($product_id, 'wpsc-variation');
488
+
489
+ $variation_sets_and_values = array_merge($variation_sets, $variation_values);
490
+
491
+ wp_set_object_terms($product_id, $variation_sets_and_values, 'wpsc-variation');
492
+
493
+ //die('<pre>'.print_r($variation_sets_and_values, true).'</pre>');
494
+
495
+ $child_product_template = array(
496
+ 'post_author' => $user_ID,
497
+ 'post_content' => $post_data['description'],
498
+ 'post_excerpt' => $post_data['additional_description'],
499
+ 'post_title' => $post_data['name'],
500
+ 'post_status' => 'inherit',
501
+ 'post_type' => "wpsc-product",
502
+ 'post_name' => sanitize_title($post_data['name']),
503
+ 'post_parent' => $product_id
504
+ );
505
+
506
+ $child_product_meta = get_post_custom($product_id);
507
+
508
+ // here we loop through the combinations, get the term data and generate custom product names
509
+ foreach($combinations as $combination) {
510
+ $term_names = array();
511
+ $term_ids = array();
512
+ $term_slugs = array();
513
+ $product_values = $child_product_template;
514
+
515
+ $combination_terms = get_terms('wpsc-variation', array(
516
+ 'hide_empty' => 0,
517
+ 'include' => implode(",", $combination),
518
+ 'orderby' => 'parent',
519
+ ));
520
+ foreach($combination_terms as $term) {
521
+ $term_ids[] = $term->term_id;
522
+ $term_slugs[] = $term->slug;
523
+ $term_names[] = $term->name;
524
+ }
525
+
526
+ $product_values['post_title'] .= " (".implode(", ", $term_names).")";
527
+ $product_values['post_name'] = sanitize_title($product_values['post_title']);
528
+
529
+ // wp_get_post_terms( $post_id = 0, $taxonomy = 'post_tag', $args = array() ) {
530
+
531
+ $selected_post = get_posts(array(
532
+ //'numberposts' => 1,
533
+ 'name' => $product_values['post_name'],
534
+ 'post_parent' => $product_id,
535
+ 'post_type' => "wpsc-product",
536
+ 'post_status' => 'all',
537
+ 'suppress_filters' => true
538
+ ));
539
+ $selected_post = array_shift($selected_post);
540
+
541
+ $child_product_id = wpsc_get_child_object_in_terms($product_id, $term_ids, 'wpsc-variation');
542
+
543
+ // echo "<pre>".print_r($child_product_id, true)."</pre>";
544
+ if($child_product_id == false) {
545
+ if($selected_post != null) {
546
+ $child_product_id = $selected_post->ID;
547
+ } else {
548
+ $child_product_id = wp_update_post($product_values);
549
+ }
550
+ } else {
551
+ // sometimes there have been problems saving the variations, this gets the correct product ID
552
+ if(($selected_post != null) && ($selected_post->ID != $child_product_id)) {
553
+ $child_product_id = $selected_post->ID;
554
+ }
555
+ }
556
+ if($child_product_id > 0) {
557
+ wp_set_object_terms($child_product_id, $term_slugs, 'wpsc-variation');
558
+ }
559
+ //JS - 7.9 - Adding loop to include meta data in child product.
560
+ //die("<pre>".print_r($child_product_meta)."</pre>");
561
+ foreach ($child_product_meta as $meta_key => $meta_value ) :
562
+ if ($meta_key == "_wpsc_product_metadata") {
563
+ update_post_meta($child_product_id, $meta_key, unserialize($meta_value[0]));
564
+ } else {
565
+ update_post_meta($child_product_id, $meta_key, $meta_value[0]);
566
+ }
567
+
568
+ endforeach;
569
+
570
+ //Adding this to check for a price on variations. Applying the highest price, seems to make the most sense.
571
+ if ( is_array ($term_ids) ) {
572
+ $price = array();
573
+ foreach ($term_ids as $term_id_price) {
574
+ $price[] = term_id_price($term_id_price, $child_product_meta["_wpsc_price"][0]);
575
+ //$price[] = $term_id_price;
576
+ }
577
+ rsort($price);
578
+ $price = $price[0];
579
+
580
+ if($price > 0) {
581
+ update_post_meta($child_product_id, "_wpsc_price", $price);
582
+ }
583
+ }
584
+ }
585
+
586
+
587
+ //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.
588
+ //Get posted terms (multi-dimensional array, first level = parent var, second level = child var)
589
+ $posted_term = $variations;
590
+ //Get currently associated terms
591
+ $currently_associated_var = $product_terms;
592
+
593
+ foreach ($currently_associated_var as $current) {
594
+ $currently_associated_vars[] = $current->term_id;
595
+ }
596
+
597
+ foreach ($posted_term as $term=>$val) {
598
+ $posted_terms[] = $term;
599
+ foreach($val as $term2=>$val2) {
600
+ $posted_terms[] = $term2;
601
+ }
602
+ }
603
+
604
+ //if currently associated > posted, get diff (current_associated - posted)
605
+ if(count($currently_associated_vars) > count($posted_terms) && isset($_REQUEST["product"]) ) {
606
+
607
+ $post_ids_to_delete = array();
608
+ $term_ids_to_delete = array();
609
+
610
+ $term_ids_to_delete = array_diff($currently_associated_vars, $posted_terms);
611
+
612
+ // Whatever remains, find child products of current product with that term, in the variation taxonomy, and delete
613
+
614
+ $post_ids_to_delete = wpsc_get_child_object_in_terms_var($_REQUEST["product_id"], $term_ids_to_delete, 'wpsc-variation');
615
+ if(is_array($post_ids_to_delete)) {
616
+ foreach($post_ids_to_delete as $object_ids) {
617
+ foreach($object_ids as $object_id) {
618
+ wp_delete_post($object_id);
619
+ }
620
+ }
621
+ }
622
+ }
623
+
624
+ }
625
+
626
+ function wpsc_update_alt_product_currency($product_id, $newCurrency, $newPrice){
627
+ global $wpdb;
628
+ $sql = "SELECT `isocode` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `id`=".$newCurrency;
629
+ $isocode = $wpdb->get_var($sql);
630
+ //exit($sql);
631
+ $newCurrency = 'currency['.$isocode.']';
632
+
633
+ if(($newPrice != '') && ($newPrice > 0)){
634
+ update_product_meta($product_id, $newCurrency, $newPrice, $prev_value = '');
635
+ } else {
636
+ delete_product_meta($product_id, $newCurrency);
637
+ }
638
+
639
+ //exit('<pre>'.print_r($newCurrency, true).'</pre>'.$newPrice);
640
+ }
641
+ /**
642
+ * wpsc_update_categories function
643
+ *
644
+ * @param integer product ID
645
+ * @param array submitted categories
646
+ */
647
+ function wpsc_update_category_associations($product_id, $categories = array()) {
648
+ global $wpdb;
649
+
650
+ $associated_categories = $wpdb->get_col($wpdb->prepare("SELECT `category_id` FROM `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."` WHERE `product_id` IN('%s')", $product_id));
651
+
652
+ $categories_to_add = array_diff((array)$categories, (array)$associated_categories);
653
+ $categories_to_delete = array_diff((array)$associated_categories, (array)$categories);
654
+ $insert_sections = array();
655
+ foreach($categories_to_delete as $key => $category_to_delete) {
656
+ $categories_to_delete[$key] = absint($category_to_delete);
657
+ }
658
+
659
+ //exit('<pre>'.print_r($categories_to_delete, true).'</pre>');
660
+
661
+ foreach($categories_to_add as $category_id) {
662
+ $insert_sections[] = $wpdb->prepare("( %d, %d)", $product_id, $category_id);
663
+ }
664
+ if(count($insert_sections)) {
665
+ $wpdb->query("INSERT INTO `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."` (`product_id`, `category_id`) VALUES ".implode(", ",$insert_sections)."");
666
+ }
667
+
668
+ foreach($categories_to_add as $category_id) {
669
+ $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);
670
+ 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")) {
671
+ $wpdb->query("UPDATE `".WPSC_TABLE_PRODUCT_ORDER."` SET `order` = '0' WHERE `category_id` IN('$category_id') AND `product_id` IN('$product_id') LIMIT 1;");
672
+ } else {
673
+ $wpdb->query("INSERT INTO `".WPSC_TABLE_PRODUCT_ORDER."` (`category_id`, `product_id`, `order`) VALUES ('$category_id', '$product_id', 0)");
674
+ }
675
+ if($check_existing != null) {
676
+ $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'");
677
+ }
678
+ }
679
+ if(count($categories_to_delete) > 0) {
680
+ $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)."");
681
+ }
682
+ }
683
+
684
+ /**
685
+ * wpsc_update_product_tags function
686
+ *
687
+ * @param integer product ID
688
+ * @param string comma separated tags
689
+ */
690
+ function wpsc_update_product_tags($product_id, $product_tags, $existing_tags) {
691
+ if(isset($existing_tags)){
692
+ $tags = explode(',',$existing_tags);
693
+ if(is_array($tags)){
694
+ foreach((array)$tags as $tag){
695
+ $tt = wp_insert_term((string)$tag, 'product_tag');
696
+ }
697
+ }
698
+ }
699
+ wp_set_object_terms($product_id, $tags, 'product_tag');
700
+ if(isset($product_tags) && $product_tags != 'Add new tag') {
701
+
702
+ $tags = explode(',',$product_tags);
703
+ product_tag_init();
704
+ if(is_array($tags)) {
705
+ foreach((array)$tags as $tag){
706
+ $tt = wp_insert_term((string)$tag, 'product_tag');
707
+ }
708
+ }
709
+ wp_set_object_terms($product_id, $tags, 'product_tag');
710
+ }
711
+ }
712
+
713
+ /**
714
+ * wpsc_update_product_meta function
715
+ *
716
+ * @param integer product ID
717
+ * @param string comma separated tags
718
+ */
719
+ function wpsc_update_product_meta($product_id, $product_meta) {
720
+ if($product_meta != null) {
721
+ foreach((array)$product_meta as $key => $value) {
722
+ if(get_post_meta($product_id, $key) != false) {
723
+ update_post_meta($product_id, $key, $value);
724
+ } else {
725
+ add_post_meta($product_id, $key, $value);
726
+ }
727
+ }
728
+ }
729
+ }
730
+
731
+ /*
732
+ /* Code to support Publish/No Publish (1bigidea)
733
+ */
734
+ /**
735
+ * set status of publish conditions
736
+ * @return
737
+ * @param string $product_id
738
+ * @param bool $status Publish State
739
+ */
740
+ function wpsc_set_publish_status($product_id, $state) {
741
+ global $wpdb;
742
+ switch($state) {
743
+ case 'draft':
744
+ case 0:
745
+ $status = 'draft';
746
+ break;
747
+
748
+ default:
749
+ $status = 'publish';
750
+ break;
751
+ }
752
+ $result = $wpdb->query("UPDATE `".$wpdb->posts."` SET `post_status` = '{$status}' WHERE `ID` = '{$product_id}'");
753
+ }
754
+
755
+ /**
756
+ * Toggle publish status and update product record
757
+ * @return bool Publish status
758
+ * @param string $product_id
759
+ */
760
+ function wpsc_toggle_publish_status($product_id) {
761
+ global $wpdb;
762
+
763
+ if(wpsc_publish_status($product_id) == 'publish') {
764
+ $status = 'draft';
765
+ } else {
766
+ $status = 'publish';
767
+ }
768
+
769
+ wpsc_set_publish_status($product_id, $status);
770
+ return $status;
771
+ }
772
+ /**
773
+ * Returns publish status from product database
774
+ * @return bool publish status
775
+ * @param string $product_id
776
+ */
777
+ function wpsc_publish_status($product_id) {
778
+ global $wpdb;
779
+ $status = $wpdb->get_var("SELECT `post_status` FROM `".$wpdb->posts."` WHERE `ID` = '{$product_id}'");
780
+ return $status;
781
+ }
782
+ /**
783
+ * Called from javascript within product page to toggle publish status - AJAX
784
+ * @return bool publish status
785
+ */
786
+ function wpsc_ajax_toggle_publish() {
787
+ /**
788
+ * @todo - Check Admin Referer
789
+ * @todo - Check Permissions
790
+ */
791
+ $status = (wpsc_toggle_publish_status($_REQUEST['productid'])) ? ('true') : ('false');
792
+ exit( $status );
793
+ }
794
+ //add_action('wp_ajax_wpsc_toggle_publish','wpsc_ajax_toggle_publish');
795
+ /*
796
+ /* END - Publish /No Publish functions
797
+ */
798
+
799
+ function wpsc_update_custom_meta($product_id, $post_data) {
800
+ global $wpdb;
801
+ if($post_data['new_custom_meta'] != null) {
802
+ foreach((array)$post_data['new_custom_meta']['name'] as $key => $name) {
803
+ $value = $post_data['new_custom_meta']['value'][(int)$key];
804
+ if(($name != '') && ($value != '')) {
805
+ add_post_meta($product_id, $name, $value);
806
+ }
807
+ }
808
+ }
809
+
810
+ if (!isset($post_data['custom_meta'])) $post_data['custom_meta'] = '';
811
+ if($post_data['custom_meta'] != null) {
812
+ foreach((array)$post_data['custom_meta'] as $key => $values) {
813
+ if(($values['name'] != '') && ($values['value'] != '')) {
814
+ update_post_meta($product_id, $name, $value);
815
+ }
816
+ }
817
+ }
818
+ }
819
+
820
+ /**
821
+ * wpsc_update_product_tags function
822
+ *
823
+ * @param integer product ID
824
+ * @param array the post data
825
+ */
826
+ function wpsc_update_product_images($product_id, $post_data) {
827
+ global $wpdb;
828
+ $uploaded_images = array();
829
+
830
+ if(!isset($post_data['gallery_resize'])) $post_data['gallery_resize'] = '';
831
+ if(!isset($post_data['gallery_width'])) $post_data['gallery_width'] = '';
832
+ if(!isset($post_data['gallery_height'])) $post_data['gallery_height'] = '';
833
+
834
+ /* Handle new image uploads here */
835
+ if(isset($post_data['files']['image']['tmp_name']) && ($post_data['files']['image']['tmp_name'] != '')) {
836
+ $image = wpsc_item_process_image($product_id, $post_data['files']['image']['tmp_name'], str_replace(" ", "_", $post_data['files']['image']['name']), $post_data['width'], $post_data['height'], $post_data['image_resize']);
837
+
838
+ $image_action = absint($post_data['image_resize']);
839
+ $image_width = $post_data['width'];
840
+ $image_height = $post_data['height'];
841
+
842
+ } else {
843
+ $image_action = absint($post_data['gallery_resize']);
844
+ $image_width = $post_data['gallery_width'];
845
+ $image_height = $post_data['gallery_height'];
846
+
847
+ }
848
+
849
+ // exit( "<pre>".print_r($image_action, true)."</pre>");
850
+ wpsc_resize_image_thumbnail($product_id, $image_action, $image_width, $image_height);
851
+ //exit( " <pre>".print_r($post_data, true)."</pre>");
852
+
853
+
854
+
855
+
856
+ }
857
+
858
+ /**
859
+ * wpsc_resize_image_thumbnail function
860
+ *
861
+ * @param integer product ID
862
+ * @param integer the action to perform on the image
863
+ * @param integer the width of the thumbnail image
864
+ * @param integer the height of the thumbnail image
865
+ * @param array the custom image array from $_FILES
866
+ */
867
+ function wpsc_resize_image_thumbnail($product_id, $image_action= 0, $width = 0, $height = 0, $custom_image = null) {
868
+ global $wpdb;
869
+ $image_id = $wpdb->get_var("SELECT `image` FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE `id` = '{$product_id}' LIMIT 1");
870
+ $image = $wpdb->get_var("SELECT `image` FROM `".WPSC_TABLE_PRODUCT_IMAGES."` WHERE `id` = '{$image_id}' LIMIT 1");
871
+
872
+ // check if there is an image that is supposed to be there.
873
+ if($image != '') {
874
+ if(is_numeric($image)){
875
+ }
876
+ // check that is really there
877
+ if(file_exists(WPSC_IMAGE_DIR.$image)) {
878
+ // if the width or height is less than 1, set the size to the default
879
+ if((($width < 1) || ($height < 1)) && ($image_action == 2)) {
880
+ $image_action = 1;
881
+ }
882
+ switch($image_action) {
883
+ case 0:
884
+ if(!file_exists(WPSC_THUMBNAIL_DIR.$image)) {
885
+ copy(WPSC_IMAGE_DIR.$image, WPSC_THUMBNAIL_DIR.$image);
886
+ }
887
+ break;
888
+
889
+
890
+ case 1:
891
+ // if case 1, replace the provided size with the default size
892
+ $height = get_option('product_image_height');
893
+ $width = get_option('product_image_width');
894
+ case 2:
895
+ // if case 2, use the provided size
896
+ $image_input = WPSC_IMAGE_DIR . $image;
897
+ $image_output = WPSC_THUMBNAIL_DIR . $image;
898
+
899
+ if($width < 1) {
900
+ $width = 96;
901
+ }
902
+ if($height < 1) {
903
+ $height = 96;
904
+ }
905
+
906
+ image_processing($image_input, $image_output, $width, $height);
907
+ update_product_meta($product_id, 'thumbnail_width', $width);
908
+ update_product_meta($product_id, 'thumbnail_height', $height);
909
+ break;
910
+
911
+ case 3:
912
+ // replacing the thumbnail with a custom image is done here
913
+ $uploaded_image = null;
914
+ //exit($uploaded_image);
915
+ if(file_exists($_FILES['gallery_thumbnailImage']['tmp_name'])) {
916
+ $uploaded_image = $_FILES['gallery_thumbnailImage']['tmp_name'];
917
+ } else if(file_exists($_FILES['thumbnailImage']['tmp_name'])) {
918
+ $uploaded_image = $_FILES['thumbnailImage']['tmp_name'];
919
+ }
920
+ if($uploaded_image !== null) {
921
+
922
+ move_uploaded_file($uploaded_image, WPSC_THUMBNAIL_DIR.$image);
923
+ //exit($uploaded_image);
924
+
925
+ }
926
+ break;
927
+ }
928
+
929
+ if(!file_exists(WPSC_IMAGE_DIR.$image)) {
930
+ $wpdb->query("INSERT INTO `".WPSC_TABLE_PRODUCT_IMAGES."` SET `thumbnail_state` = '$image_action' WHERE `id`='{$product_id}' LIMIT 1");
931
+ $sql = "INSERT INTO `".WPSC_TABLE_PRODUCT_IMAGES."` (`product_id`, `image`, `width`, `height`) VALUES ('{$product_id}', '{$image}', '{$width}', '{$height}' )";
932
+ $wpdb->query($sql);
933
+ $image_id = (int) $wpdb->insert_id;
934
+ }
935
+
936
+ $sql="UPDATE `".WPSC_TABLE_PRODUCT_LIST."` SET `thumbnail_state` = '$image_action', `image` ='{$image_id}' WHERE `id`='{$product_id}' LIMIT 1";
937
+ //exit($sql);
938
+ $wpdb->query($sql);
939
+ } else {
940
+ //if it is not, we need to unset the associated image
941
+ //$wpdb->query("UPDATE `".WPSC_TABLE_PRODUCT_LIST."` SET `image` = '' WHERE `id`='{$product_id}' LIMIT 1");
942
+ //$wpdb->query("INSERT INTO `".WPSC_TABLE_PRODUCT_IMAGES."` (`product_id`, `image`, `width`, `height`) VALUES ('{$product_id}', '{$image}', '{$width}', '{$height}' )");
943
+ }
944
+ }
945
+
946
+ }
947
+
948
+
949
+
950
+
951
+ /**
952
+ * wpsc_upload_image_thumbnail function
953
+ *
954
+ * @param integer product ID
955
+ * @param string comma separated tags
956
+ */
957
+ function wpsc_upload_image_thumbnail($product_id, $product_meta) {
958
+ if(($_POST['image_resize'] == 3) && ($_FILES['thumbnailImage'] != null) && file_exists($_FILES['thumbnailImage']['tmp_name'])) {
959
+ $imagefield='thumbnailImage';
960
+
961
+ $image=image_processing($_FILES['thumbnailImage']['tmp_name'], WPSC_THUMBNAIL_DIR.$_FILES['thumbnailImage']['name'],null,null,$imagefield);
962
+ $thumbnail_image = $image;
963
+ $wpdb->query("UPDATE `".WPSC_TABLE_PRODUCT_LIST."` SET `thumbnail_image` = '".$thumbnail_image."' WHERE `id` = '".$image_data['id']."'");
964
+ $stat = stat( dirname( (WPSC_THUMBNAIL_DIR.$image_data['image']) ));
965
+ $perms = $stat['mode'] & 0000775;
966
+ @ chmod( (WPSC_THUMBNAIL_DIR.$image_data['image']), $perms );
967
+ }
968
+ }
969
+
970
+
971
+ /**
972
+ * wpsc_item_process_file function
973
+ *
974
+ * @param integer product ID
975
+ * @param array the file array from $_FILES
976
+ * @param array the preview file array from $_FILES
977
+ */
978
+ function wpsc_item_process_file($product_id, $submitted_file, $preview_file = null) {
979
+ global $wpdb;
980
+ add_filter('upload_dir', 'wpsc_modify_upload_directory');
981
+ $overrides = array('test_form'=>false);
982
+
983
+ $time = current_time('mysql');
984
+ if ( $post = get_post($product_id) ) {
985
+ if ( substr( $post->post_date, 0, 4 ) > 0 )
986
+ $time = $post->post_date;
987
+ }
988
+
989
+ //$name = basename($submitted_file['name']);
990
+ $file = wp_handle_upload($submitted_file, $overrides, $time);
991
+
992
+ if ( isset($file['error']) )
993
+ return new WP_Error( 'upload_error', $file['error'] );
994
+
995
+ $name_parts = pathinfo($file['file']);
996
+ //$name = trim( substr( $name, 0, -(1 + strlen($name_parts['extension'])) ) );
997
+ $name = $name_parts['basename'];
998
+ //echo "<pre>".print_r($name_parts,true)."</pre>"; exit();
999
+
1000
+ $url = $file['url'];
1001
+ $type = $file['type'];
1002
+ $file = $file['file'];
1003
+ $title = $name;
1004
+ $content = '';
1005
+
1006
+ // Construct the attachment array
1007
+ $attachment = array(
1008
+ 'post_mime_type' => $type,
1009
+ 'guid' => $url,
1010
+ 'post_parent' => $product_id,
1011
+ 'post_title' => $title,
1012
+ 'post_content' => $content,
1013
+ 'post_type' => "wpsc-product-file",
1014
+ 'post_status' => 'inherit'
1015
+ );
1016
+
1017
+ // Save the data
1018
+ $id = wp_insert_post($attachment, $file, $product_id);
1019
+ remove_filter('upload_dir', 'wpsc_modify_upload_directory');
1020
+ //return $id;
1021
+ //exit($id);
1022
+ }
1023
+
1024
+ function wpsc_modify_upload_directory($input) {
1025
+ //echo "<pre>".print_r($input,true)."</pre>";
1026
+ $previous_subdir = $input['subdir'];
1027
+ $download_subdir = str_replace($input['basedir'], '', WPSC_FILE_DIR);
1028
+
1029
+ $input['path'] = str_replace($previous_subdir, $download_subdir, $input['path']);
1030
+ $input['url'] = str_replace($previous_subdir, $download_subdir, $input['url']);
1031
+ $input['subdir'] = str_replace($previous_subdir, $download_subdir, $input['subdir']);
1032
+
1033
+ //echo "<pre>".print_r($input,true)."</pre>";
1034
+ return $input;
1035
+ }
1036
+
1037
+
1038
+
1039
+ /**
1040
+ * wpsc_item_reassign_file function
1041
+ *
1042
+ * @param integer product ID
1043
+ * @param string the selected file name;
1044
+ */
1045
+ function wpsc_item_reassign_file($product_id, $selected_files) {
1046
+ global $wpdb;
1047
+ $product_file_list = array();
1048
+ // initialise $idhash to null to prevent issues with undefined variables and error logs
1049
+ $idhash = null;
1050
+
1051
+ $args = array(
1052
+ 'post_type' => 'wpsc-product-file',
1053
+ 'post_parent' => $product_id,
1054
+ 'numberposts' => -1,
1055
+ 'post_status' => 'any'
1056
+ );
1057
+
1058
+ $attached_files = (array)get_posts($args);
1059
+
1060
+ foreach($attached_files as $key => $attached_file) {
1061
+ $attached_files_by_file[$attached_file->post_title] = $attached_files[$key];
1062
+ }
1063
+
1064
+
1065
+ //echo "<pre>\n";
1066
+ //echo print_r($attached_files,true);
1067
+ //echo wp_insert_post($attachment);
1068
+ //echo "</pre>\n";
1069
+
1070
+
1071
+ /* if we are editing, grab the current file and ID hash */
1072
+ if(!$selected_files) {
1073
+ // unlikely that anyone will ever upload a file called .none., so its the value used to signify clearing the product association
1074
+ //$wpdb->query("UPDATE `".WPSC_TABLE_PRODUCT_LIST."` SET `file` = '0' WHERE `id` = '$product_id' LIMIT 1");
1075
+ return null;
1076
+ }
1077
+
1078
+
1079
+
1080
+ foreach($selected_files as $selected_file) {
1081
+ // if we already use this file, there is no point doing anything more.
1082
+ $file_is_attached = false;
1083
+ $selected_file_path = WPSC_FILE_DIR.basename($selected_file);
1084
+
1085
+ if(isset($attached_files_by_file[$selected_file])) {
1086
+ $file_is_attached = true;
1087
+ }
1088
+
1089
+ //if(is_file($selected_file_path)) {
1090
+ if($file_is_attached == false ) {
1091
+ $type = wpsc_get_mimetype($selected_file_path);
1092
+ $attachment = array(
1093
+ 'post_mime_type' => $type,
1094
+ 'post_parent' => $product_id,
1095
+ 'post_title' => $selected_file,
1096
+ 'post_content' => '',
1097
+ 'post_type' => "wpsc-product-file",
1098
+ 'post_status' => 'inherit'
1099
+ );
1100
+ wp_insert_post($attachment);
1101
+ } else {
1102
+ $product_post_values = array(
1103
+ 'ID' => $attached_files_by_file[$selected_file]->ID,
1104
+ 'post_status' => 'inherit'
1105
+ );
1106
+ wp_update_post($product_post_values);
1107
+ }
1108
+ //}
1109
+ }
1110
+
1111
+
1112
+ foreach($attached_files as $attached_file) {
1113
+ if(!in_array($attached_file->post_title, $selected_files)) {
1114
+ $product_post_values = array(
1115
+ 'ID' => $attached_file->ID,
1116
+ 'post_status' => 'draft'
1117
+ );
1118
+ wp_update_post($product_post_values);
1119
+ }
1120
+ }
1121
+
1122
+
1123
+ //
1124
+ //exit('<pre>'.print_r($attached_files, true).'</pre>');
1125
+ //update_product_meta($product_id, 'product_files', $product_file_list);
1126
+ return $fileid;
1127
+ }
1128
+
1129
+
1130
+
1131
+ /**
1132
+ * wpsc_item_add_preview_file function
1133
+ *
1134
+ * @param integer product ID
1135
+ * @param array the preview file array from $_FILES
1136
+ */
1137
+ function wpsc_item_add_preview_file($product_id, $preview_file) {
1138
+ global $wpdb;
1139
+
1140
+ $current_file_id = $wpdb->get_var("SELECT `file` FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE `id` = '$product_id' LIMIT 1");
1141
+ $file_data = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_PRODUCT_FILES."` WHERE `id`='{$current_file_id}' LIMIT 1",ARRAY_A);
1142
+
1143
+ if(apply_filters( 'wpsc_filter_file', $preview_file['tmp_name'] )) {
1144
+ //echo "test?";
1145
+ if(function_exists("make_mp3_preview")) {
1146
+ if($mimetype == "audio/mpeg" && (!isset($preview_file['tmp_name']))) {
1147
+ // if we can generate a preview file, generate it (most can't due to sox being rare on servers and sox with MP3 support being even rarer), thus this needs to be enabled by editing code
1148
+ make_mp3_preview((WPSC_FILE_DIR.$idhash), (WPSC_PREVIEW_DIR.$idhash.".mp3"));
1149
+ $preview_filepath = (WPSC_PREVIEW_DIR.$idhash.".mp3");
1150
+ } else if(file_exists($preview_file['tmp_name'])) {
1151
+ $preview_filename = basename($preview_file['name']);
1152
+ $preview_mimetype = wpsc_get_mimetype($preview_file['tmp_name']);
1153
+ copy($preview_file['tmp_name'], (WPSC_PREVIEW_DIR.$preview_filename));
1154
+ $preview_filepath = (WPSC_PREVIEW_DIR.$preview_filename);
1155
+ $wpdb->query("UPDATE `".WPSC_TABLE_PRODUCT_FILES."` SET `preview` = '".$wpdb->escape($preview_filename)."', `preview_mimetype` = '".$preview_mimetype."' WHERE `id` = '{$file_data['id']}' LIMIT 1");
1156
+ //exit("UPDATE `".WPSC_TABLE_PRODUCT_FILES."` SET `preview` = '".$wpdb->escape($preview_filename)."', `preview_mimetype` = '".$preview_mimetype."' WHERE `id` = '{$file_data['id']}' LIMIT 1");
1157
+ }
1158
+ $stat = stat( dirname($preview_filepath));
1159
+ $perms = $stat['mode'] & 0000666;
1160
+ @ chmod( $preview_filepath, $perms );
1161
+ }
1162
+ //exit("<pre>".print_r($preview_file,true)."</pre>");
1163
+ return $fileid;
1164
+ } else {
1165
+ return $selected_files;
1166
+ }
1167
+ }
1168
+
1169
+
1170
+ /**
1171
+ * wpsc_variation_combinator class.
1172
+ * Produces all combinations of variations selected for this product
1173
+ * this class is based off the example code from here:
1174
+ * http://www.php.net/manual/en/ref.array.php#94910
1175
+ * Thanks, phektus, you are awesome, whoever you are.
1176
+ */
1177
+ class wpsc_variation_combinator {
1178
+ var $variation_sets = array();
1179
+ var $variation_values = array();
1180
+ var $reprocessed_array = array();
1181
+ var $combinations= array();
1182
+
1183
+ function wpsc_variation_combinator($variation_sets) {
1184
+ if( $variation_sets ) {
1185
+ foreach($variation_sets as $variation_set_id => $variation_set) {
1186
+ $this->variation_sets[] = absint($variation_set_id);
1187
+ $new_variation_set = array();
1188
+ if( $variation_set ) {
1189
+ foreach($variation_set as $variation => $active) {
1190
+ if($active == 1) {
1191
+ $new_variation_set[] = array(absint($variation));
1192
+ $this->variation_values[] = $variation;
1193
+ }
1194
+ }
1195
+ }
1196
+ $this->reprocessed_array[] = $new_variation_set;
1197
+ }
1198
+ $this->get_combinations(array(), $this->reprocessed_array, 0);
1199
+ }
1200
+ }
1201
+
1202
+
1203
+ function get_combinations($batch, $elements, $i) {
1204
+ //echo "<pre>".print_r($batch,true)."</pre>";
1205
+ if ($i >= count($elements)) {
1206
+ $this->combinations[] = $batch;
1207
+ } else {
1208
+ foreach ($elements[$i] as $element) {
1209
+ $this->get_combinations(array_merge($batch, $element), $elements, $i + 1);
1210
+ }
1211
+ }
1212
+ }
1213
+
1214
+ function return_variation_sets() {
1215
+ return $this->variation_sets;
1216
+ }
1217
+
1218
+ function return_variation_values() {
1219
+ return $this->variation_values;
1220
+ }
1221
+
1222
+ function return_combinations() {
1223
+ return $this->combinations;
1224
+
1225
+ }
1226
+ }
1227
+
1228
+
1229
+ ?>
wpsc-admin/includes/products.php CHANGED
@@ -58,6 +58,7 @@ function wpsc_product_row(&$product, $parent_product = null) {
58
  $posts_columns = get_column_headers('display-product-list');
59
  $hidden = get_hidden_columns('display-product-list');
60
  //exit('<pre>'.print_r($product,true).'</pre>');
 
61
  foreach ( $posts_columns as $column_name=>$column_display_name ) {
62
  $class = "class=\"$column_name column-$column_name\"";
63
 
@@ -120,7 +121,13 @@ function wpsc_product_row(&$product, $parent_product = null) {
120
 
121
  case 'title': /* !title case */
122
  $attributes = 'class="post-title column-title"' . $style;
123
- $edit_link = add_query_arg(array('page' => 'wpsc-edit-products', 'action' => 'wpsc_add_edit' ,'product' => $product->ID));
 
 
 
 
 
 
124
  $edit_link = wp_nonce_url($edit_link, 'edit-product_'.$product->ID);
125
  ?>
126
  <td <?php echo $attributes ?>>
@@ -157,14 +164,14 @@ function wpsc_product_row(&$product, $parent_product = null) {
157
  if ( current_user_can('edit_product', $product->ID) ) {
158
  $actions['view'] = '<a href="'.get_permalink($product->ID).'" title="'.esc_attr(sprintf(__('Preview &#8220;%s&#8221;'), $title)) . '" rel="permalink">'.__('Preview').'</a>';
159
  }
160
- } else if ( 'trash' != $product->post_status ) {
161
  $actions['view'] = '<a href="'.get_permalink($product->ID).'" title="'.esc_attr(sprintf(__('View &#8220;%s&#8221;'), $title)).'" rel="permalink">'.__('View').'</a>';
162
  }
163
-
164
  $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>";
165
-
166
 
167
- $actions = apply_filters('post_row_actions', $actions, $post);
168
  $action_count = count($actions);
169
  $i = 0;
170
  echo '<div class="row-actions">';
@@ -176,7 +183,7 @@ function wpsc_product_row(&$product, $parent_product = null) {
176
  }
177
 
178
  echo '</div>';
179
- get_inline_data($post);
180
  ?>
181
  </td>
182
  <?php
@@ -250,6 +257,9 @@ function wpsc_product_row(&$product, $parent_product = null) {
250
  $product_data['meta'][$meta_name] = maybe_unserialize(array_pop($meta_value));
251
  }
252
  $product_data['transformed'] = array();
 
 
 
253
  $product_data['transformed']['weight'] = wpsc_convert_weight($product_data['meta']['_wpsc_product_metadata']['weight'], "gram", $product_data['meta']['_wpsc_product_metadata']['weight_unit']);
254
  $weight = $product_data['transformed']['weight'];
255
  if($weight == ''){
58
  $posts_columns = get_column_headers('display-product-list');
59
  $hidden = get_hidden_columns('display-product-list');
60
  //exit('<pre>'.print_r($product,true).'</pre>');
61
+
62
  foreach ( $posts_columns as $column_name=>$column_display_name ) {
63
  $class = "class=\"$column_name column-$column_name\"";
64
 
121
 
122
  case 'title': /* !title case */
123
  $attributes = 'class="post-title column-title"' . $style;
124
+ $_GET["product_parent"] = '';
125
+ if( isset($_GET["product"]) && ($_GET["product_parent"] == '' )){
126
+ $edit_link = add_query_arg(array('page' => 'wpsc-edit-products', 'action' => 'wpsc_add_edit' ,'product' => $product->ID, 'product_parent' => $_GET["product"]));
127
+ } else {
128
+ $edit_link = add_query_arg(array('page' => 'wpsc-edit-products', 'action' => 'wpsc_add_edit' ,'product' => $product->ID));
129
+ $edit_link = remove_query_arg( 'product_parent' );
130
+ }
131
  $edit_link = wp_nonce_url($edit_link, 'edit-product_'.$product->ID);
132
  ?>
133
  <td <?php echo $attributes ?>>
164
  if ( current_user_can('edit_product', $product->ID) ) {
165
  $actions['view'] = '<a href="'.get_permalink($product->ID).'" title="'.esc_attr(sprintf(__('Preview &#8220;%s&#8221;'), $title)) . '" rel="permalink">'.__('Preview').'</a>';
166
  }
167
+ } else if ( 'trash' != $product->post_status && (!isset($_GET["product"]) && $_GET["product"] != "") ) {
168
  $actions['view'] = '<a href="'.get_permalink($product->ID).'" title="'.esc_attr(sprintf(__('View &#8220;%s&#8221;'), $title)).'" rel="permalink">'.__('View').'</a>';
169
  }
170
+ if(!isset($_GET["product"]) || $_GET["product"] == '' ) {
171
  $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>";
172
+ }
173
 
174
+ $actions = apply_filters('post_row_actions', $actions, $product);
175
  $action_count = count($actions);
176
  $i = 0;
177
  echo '<div class="row-actions">';
183
  }
184
 
185
  echo '</div>';
186
+ get_inline_data($product);
187
  ?>
188
  </td>
189
  <?php
257
  $product_data['meta'][$meta_name] = maybe_unserialize(array_pop($meta_value));
258
  }
259
  $product_data['transformed'] = array();
260
+ if(!isset($product_data['meta']['_wpsc_product_metadata']['weight'])) $product_data['meta']['_wpsc_product_metadata']['weight'] = "";
261
+ if(!isset($product_data['meta']['_wpsc_product_metadata']['weight_unit'])) $product_data['meta']['_wpsc_product_metadata']['weight_unit'] = "";
262
+
263
  $product_data['transformed']['weight'] = wpsc_convert_weight($product_data['meta']['_wpsc_product_metadata']['weight'], "gram", $product_data['meta']['_wpsc_product_metadata']['weight_unit']);
264
  $weight = $product_data['transformed']['weight'];
265
  if($weight == ''){
wpsc-admin/includes/purchlogs_upgrade.php CHANGED
@@ -64,13 +64,13 @@ function wpsc_select_options_purchlogs_fix($id){
64
 
65
  <?php if ( $numChanged != 0 && $numQueries != 0 ) {
66
  echo '<div id="message" class="updated fade"><p>';
67
- printf( __ngettext( 'Check Out Form Fields updated.', 'Check Out Form Fields updated.', $numChanged, $numQueries ), $numChanged , $numQueries);
68
  echo '</p></div>';
69
  }
70
 
71
  ?>
72
 
73
- <h2><?php echo wp_specialchars( __('Sales', 'wpsc').' Upgrade Fix' ); ?> </h2>
74
  <p><?php _e('Upgrading to WP e-Commerce 3.7 and later requires you to run this fix once.The following Boxes corresponds to the form fields in your current checkout page. All you have to do is select from the drop-down menu box what each of the following fields represent. Sorry for any inconvenience caused, but we\'re sure you\'ll agree that the new purchase logs are worth this minor hassle. '); ?> </p>
75
 
76
  <div class="metabox-holder" style="width:700px">
64
 
65
  <?php if ( $numChanged != 0 && $numQueries != 0 ) {
66
  echo '<div id="message" class="updated fade"><p>';
67
+ printf(_n( 'Check Out Form Fields updated.', 'Check Out Form Fields updated.', $numChanged, $numQueries ), $numChanged , $numQueries);
68
  echo '</p></div>';
69
  }
70
 
71
  ?>
72
 
73
+ <h2><?php echo esc_html( __('Sales', 'wpsc').' Upgrade Fix' ); ?> </h2>
74
  <p><?php _e('Upgrading to WP e-Commerce 3.7 and later requires you to run this fix once.The following Boxes corresponds to the form fields in your current checkout page. All you have to do is select from the drop-down menu box what each of the following fields represent. Sorry for any inconvenience caused, but we\'re sure you\'ll agree that the new purchase logs are worth this minor hassle. '); ?> </p>
75
 
76
  <div class="metabox-holder" style="width:700px">
wpsc-admin/includes/save-data.functions.php CHANGED
@@ -1,293 +1,365 @@
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
-
38
-
39
-
40
- //print("<pre>".print_r($term,true)."</pre>");
41
- //exit("<pre>".print_r($_POST,true)."</pre>");
42
-
43
- if(($_POST['submit_action'] == "add") || ($_POST['submit_action'] == "edit")) {
44
- check_admin_referer('edit-variation', 'wpsc-edit-variation');
45
-
46
- /* add variation */
47
- if($_POST['submit_action'] == "add") {
48
- $name = $_POST['name'];
49
- $term = get_term_by('name', $name, 'wpsc-variation', ARRAY_A);
50
- if(empty($term)) {
51
- $term = wp_insert_term( $name, 'wpsc-variation',array('parent' => 0));
52
- }
53
-
54
- //print("<pre>".print_r($term,true)."</pre>");
55
- //exit("<pre>".print_r($_POST,true)."</pre>");
56
- if(!empty($term)) {
57
- $variation_id = $term['term_id'];
58
- $variation_values = $_POST['new_variation_values'];
59
- $variation_value_sql_items = array();
60
- foreach($variation_values as $variation_value) {
61
- $term = get_term_by('name', $variation_value, 'wpsc-variation', ARRAY_A);
62
- if(empty($term)) {
63
- $term = wp_insert_term( $variation_value, 'wpsc-variation',array('parent' => $variation_id));
64
- }
65
- }
66
- }
67
- }
68
-
69
- /* edit variation */
70
- if(($_POST['submit_action'] == "edit") && is_numeric($_POST['variation_id'])) {
71
- $variation_id = absint($_POST['variation_id']);
72
-
73
- $variation_set_name = $_POST['name'];
74
- $term = get_term_by('name', $name, 'wpsc-variation', ARRAY_A);
75
- if(empty($term)) {
76
- $term = wp_insert_term( $name, 'wpsc-variation',array('parent' => 0));
77
- } else {
78
- wp_update_term($variation_id, 'wpsc-variation', array(
79
- 'name' => $variation_set_name
80
- ));
81
- }
82
-
83
-
84
-
85
-
86
- //exit("<pre>".print_r($_POST, true)."</pre>");
87
- foreach($_POST['variation_values'] as $variation_value_id => $variation_value_name) {
88
- if(is_numeric($variation_value_id)) {
89
- $variation_value_id = absint($variation_value_id);
90
- wp_update_term($variation_value_id, 'wpsc-variation', array(
91
- 'name' => $variation_value_name
92
- ));
93
- //$variation_value_state = $wpdb->get_results("SELECT `name` FROM `".WPSC_TABLE_VARIATION_VALUES."` WHERE `id` = '$variation_value_id' AND `variation_id` = '$variation_id' LIMIT 1",ARRAY_A);
94
- //$variation_value_state = $variation_value_state[0]['name'];
95
- }
96
-
97
- if($variation_value_state != $variation_value) {
98
- //$wpdb->query("UPDATE `".WPSC_TABLE_VARIATION_VALUES."` SET `name` = '".$wpdb->escape($variation_value)."' WHERE `id` = '$variation_value_id' AND `variation_id` = '".$variation_id."' LIMIT 1;");
99
- }
100
- }
101
-
102
- if($_POST['new_variation_values'] != null) {
103
- foreach($_POST['new_variation_values'] as $variation_value) {
104
- $term = get_term_by('name', $variation_value, 'wpsc-variation', ARRAY_A);
105
- if(empty($term)) {
106
- $term = wp_insert_term( $variation_value, 'wpsc-variation',array('parent' => $variation_id));
107
- }
108
- }
109
- }
110
- }
111
- }
112
- //http://sandbox.boiling-pukeko.geek.nz/wp-admin/admin.php?wpsc_admin_action=wpsc-variation-set&delete_value=true&value_id=20&_wpnonce=c1eab6de52
113
- $sendback = remove_query_arg(array(
114
- 'wpsc_admin_action',
115
- 'delete_value',
116
- '_wpnonce',
117
- 'value_id'
118
- ));
119
-
120
- if($_GET['page'] == null) {
121
- $sendback = add_query_arg('page', 'wpsc-edit-variations', $sendback);
122
- }
123
- $sendback = add_query_arg('message', 1, $sendback);
124
- //exit($sendback);
125
- wp_redirect($sendback);
126
- }
127
-
128
-
129
- /**
130
- * wpsc_save_category_set, Saves the category set data
131
- * @param nothing
132
- * @return nothing
133
- */
134
- function wpsc_save_category_set() {
135
- global $wpdb;
136
-
137
- if(($_POST['submit_action'] == "add") || ($_POST['submit_action'] == "edit")) {
138
- check_admin_referer('edit-category', 'wpsc-edit-category');
139
-
140
- //exit("<pre>".print_r($_POST,true)."</pre>");
141
-
142
- /* Image Processing Code*/
143
- if(($_FILES['image'] != null) && preg_match("/\.(gif|jp(e)*g|png){1}$/i",$_FILES['image']['name'])) {
144
- if(function_exists("getimagesize")) {
145
- if(((int)$_POST['width'] > 10 && (int)$_POST['width'] < 512) && ((int)$_POST['height'] > 10 && (int)$_POST['height'] < 512) ) {
146
- $width = (int)$_POST['width'];
147
- $height = (int)$_POST['height'];
148
- image_processing($_FILES['image']['tmp_name'], (WPSC_CATEGORY_DIR.$_FILES['image']['name']), $width, $height);
149
- } else {
150
- image_processing($_FILES['image']['tmp_name'], (WPSC_CATEGORY_DIR.$_FILES['image']['name']));
151
- }
152
- $image = $wpdb->escape($_FILES['image']['name']);
153
- } else {
154
- $new_image_path = (WPSC_CATEGORY_DIR.basename($_FILES['image']['name']));
155
- move_uploaded_file($_FILES['image']['tmp_name'], $new_image_path);
156
- $stat = stat( dirname( $new_image_path ));
157
- $perms = $stat['mode'] & 0000666;
158
- @ chmod( $new_image_path, $perms );
159
- $image = $wpdb->escape($_FILES['image']['name']);
160
- }
161
- } else {
162
- $image = '';
163
- }
164
-
165
-
166
- /* Set the parent category ID variable*/
167
- if(is_numeric($_POST['category_parent']) && absint($_POST['category_parent']) > 0) {
168
- $parent_category = (int)$_POST['category_parent'];
169
- } else {
170
- $parent_category = 0;
171
- }
172
-
173
-
174
- /* add category code */
175
- if($_POST['submit_action'] == "add") {
176
- $name = $_POST['name'];
177
- $term = get_term_by('name', $name, 'wpsc_product_category', ARRAY_A);
178
- if(empty($term)) {
179
- $term = wp_insert_term( $name, 'wpsc_product_category',array('parent' => 0));
180
- }
181
-
182
- $category_id= $term['term_id'];
183
-
184
- $category = get_term_by('id', $category_id, 'wpsc_product_category');
185
- $url_name=$category->slug;
186
-
187
- //$wp_rewrite->flush_rules();
188
- if($category_id > 0) {
189
- wpsc_update_categorymeta($category_id, 'nice-name', $url_name);
190
- wpsc_update_categorymeta($category_id, 'description', $wpdb->escape(stripslashes($_POST['description'])));
191
- if($image != '') {
192
- wpsc_update_categorymeta($category_id, 'image', $image);
193
- }
194
- //wpsc_update_categorymeta($category_id, 'image', $image);
195
- wpsc_update_categorymeta($category_id, 'fee', '0');
196
- wpsc_update_categorymeta($category_id, 'active', '1');
197
- wpsc_update_categorymeta($category_id, 'order', '0');
198
-
199
- if($_POST['use_additonal_form_set'] != '') {
200
- wpsc_update_categorymeta($category_id, 'use_additonal_form_set', $_POST['use_additonal_form_set']);
201
- } else {
202
- wpsc_delete_categorymeta($category_id, 'use_additonal_form_set');
203
- }
204
-
205
- if((bool)(int)$_POST['uses_billing_address'] == true) {
206
- wpsc_update_categorymeta($category_id, 'uses_billing_address', 1);
207
- $uses_additional_forms = true;
208
- } else {
209
- wpsc_update_categorymeta($category_id, 'uses_billing_address', 0);
210
- $uses_additional_forms = false;
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
-
224
- if($category->name != $name) {
225
- wp_update_term($category_id, 'wpsc_product_category', array(
226
- 'name' => $name
227
- ));
228
- $category = get_term($category_id, 'wpsc_product_category');
229
- //$wp_rewrite->flush_rules();
230
- }
231
-
232
-
233
- $url_name=$category->slug;
234
- wpsc_update_categorymeta($category_id, 'nice-name', $url_name);
235
- wpsc_update_categorymeta($category_id, 'description', $wpdb->escape(stripslashes($_POST['description'])));
236
-
237
-
238
- if($_POST['deleteimage'] == 1) {
239
- wpsc_delete_categorymeta($category_id, 'image');
240
- } else if($image != '') {
241
- wpsc_update_categorymeta($category_id, 'image', $image);
242
- }
243
-
244
- if(is_numeric($_POST['height']) && is_numeric($_POST['width']) && ($image == null)) {
245
- $imagedata = wpsc_get_categorymeta($category_id, 'image');
246
- if($imagedata != null) {
247
- $height = $_POST['height'];
248
- $width = $_POST['width'];
249
- $imagepath = WPSC_CATEGORY_DIR . $imagedata;
250
- $image_output = WPSC_CATEGORY_DIR . $imagedata;
251
- image_processing($imagepath, $image_output, $width, $height);
252
- }
253
- }
254
-
255
-
256
- wpsc_update_categorymeta($category_id, 'fee', '0');
257
- wpsc_update_categorymeta($category_id, 'active', '1');
258
- wpsc_update_categorymeta($category_id, 'order', '0');
259
-
260
-
261
- if($_POST['use_additonal_form_set'] != '') {
262
- wpsc_update_categorymeta($category_id, 'use_additonal_form_set', $_POST['use_additonal_form_set']);
263
- } else {
264
- wpsc_delete_categorymeta($category_id, 'use_additonal_form_set');
265
- }
266
-
267
- if((bool)(int)$_POST['uses_billing_address'] == true) {
268
- wpsc_update_categorymeta($category_id, 'uses_billing_address', 1);
269
- $uses_additional_forms = true;
270
- } else {
271
- wpsc_update_categorymeta($category_id, 'uses_billing_address', 0);
272
- $uses_additional_forms = false;
273
- }
274
- }
275
- }
276
-
277
- $sendback = remove_query_arg(array(
278
- 'wpsc_admin_action',
279
- 'delete_category',
280
- '_wpnonce',
281
- 'category_id'
282
- ));
283
-
284
- if($_GET['page'] == null) {
285
- $sendback = add_query_arg('page', 'wpsc-edit-variations', $sendback);
286
- }
287
-
288
- $sendback = add_query_arg('message', 1, $sendback);
289
- wp_redirect($sendback);
290
- }
291
-
292
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
293
  ?>
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
+
38
+
39
+
40
+ //print("<pre>".print_r($term,true)."</pre>");
41
+ //exit("<pre>".print_r($_POST,true)."</pre>");
42
+
43
+ if(($_POST['submit_action'] == "add") || ($_POST['submit_action'] == "edit")) {
44
+ check_admin_referer('edit-variation', 'wpsc-edit-variation');
45
+
46
+ /* add variation */
47
+ if($_POST['submit_action'] == "add") {
48
+ $name = $_POST['name'];
49
+ $term = get_term_by('name', $name, 'wpsc-variation', ARRAY_A);
50
+ if(empty($term)) {
51
+ $term = wp_insert_term( $name, 'wpsc-variation',array('parent' => 0));
52
+ }
53
+
54
+ //print("<pre>".print_r($term,true)."</pre>");
55
+ //exit("<pre>".print_r($_POST,true)."</pre>");
56
+ if(!empty($term)) {
57
+ $variation_id = $term['term_id'];
58
+ $variation_values = $_POST['new_variation_values'];
59
+ $variation_value_sql_items = array();
60
+ foreach($variation_values as $variation_value) {
61
+ $term = get_term_by('name', $variation_value, 'wpsc-variation', ARRAY_A);
62
+ if(empty($term)) {
63
+ $term = wp_insert_term( $variation_value, 'wpsc-variation',array('parent' => $variation_id));
64
+ }
65
+ }
66
+ }
67
+ }
68
+
69
+ /* edit variation */
70
+ if(($_POST['submit_action'] == "edit") && is_numeric($_POST['variation_id'])) {
71
+ $variation_id = absint($_POST['variation_id']);
72
+
73
+ $variation_set_name = $_POST['name'];
74
+ $term = get_term_by('name', $name, 'wpsc-variation', ARRAY_A);
75
+ if(empty($term)) {
76
+ $term = wp_insert_term( $name, 'wpsc-variation',array('parent' => 0));
77
+ } else {
78
+ wp_update_term($variation_id, 'wpsc-variation', array(
79
+ 'name' => $variation_set_name
80
+ ));
81
+ }
82
+
83
+
84
+
85
+
86
+ //exit("<pre>".print_r($_POST, true)."</pre>");
87
+ foreach($_POST['variation_values'] as $variation_value_id => $variation_value_name) {
88
+ if(is_numeric($variation_value_id)) {
89
+ $variation_value_id = absint($variation_value_id);
90
+ wp_update_term($variation_value_id, 'wpsc-variation', array(
91
+ 'name' => $variation_value_name
92
+ ));
93
+ //$variation_value_state = $wpdb->get_results("SELECT `name` FROM `".WPSC_TABLE_VARIATION_VALUES."` WHERE `id` = '$variation_value_id' AND `variation_id` = '$variation_id' LIMIT 1",ARRAY_A);
94
+ //$variation_value_state = $variation_value_state[0]['name'];
95
+ }
96
+
97
+ if($variation_value_state != $variation_value) {
98
+ //$wpdb->query("UPDATE `".WPSC_TABLE_VARIATION_VALUES."` SET `name` = '".$wpdb->escape($variation_value)."' WHERE `id` = '$variation_value_id' AND `variation_id` = '".$variation_id."' LIMIT 1;");
99
+ }
100
+ }
101
+
102
+ if($_POST['new_variation_values'] != null) {
103
+ foreach($_POST['new_variation_values'] as $variation_value) {
104
+ $term = get_term_by('name', $variation_value, 'wpsc-variation', ARRAY_A);
105
+ if(empty($term)) {
106
+ $term = wp_insert_term( $variation_value, 'wpsc-variation',array('parent' => $variation_id));
107
+ }
108
+ }
109
+ }
110
+ }
111
+ }
112
+ //http://sandbox.boiling-pukeko.geek.nz/wp-admin/admin.php?wpsc_admin_action=wpsc-variation-set&delete_value=true&value_id=20&_wpnonce=c1eab6de52
113
+ $sendback = remove_query_arg(array(
114
+ 'wpsc_admin_action',
115
+ 'delete_value',
116
+ '_wpnonce',
117
+ 'value_id'
118
+ ));
119
+
120
+ if($_GET['page'] == null) {
121
+ $sendback = add_query_arg('page', 'wpsc-edit-variations', $sendback);
122
+ }
123
+ $sendback = add_query_arg('message', 1, $sendback);
124
+ //exit($sendback);
125
+ wp_redirect($sendback);
126
+ }
127
+
128
+
129
+ /**
130
+ * wpsc_save_category_set, Saves the category set data
131
+ * @param nothing
132
+ * @return nothing
133
+ */
134
+ function wpsc_save_category_set() {
135
+ global $wpdb;
136
+
137
+ if(($_POST['submit_action'] == "add") || ($_POST['submit_action'] == "edit")) {
138
+ check_admin_referer('edit-category', 'wpsc-edit-category');
139
+
140
+ //exit("<pre>".print_r($_POST,true)."</pre>");
141
+
142
+ /* Image Processing Code*/
143
+ if(($_FILES['image'] != null) && preg_match("/\.(gif|jp(e)*g|png){1}$/i",$_FILES['image']['name'])) {
144
+ if(function_exists("getimagesize")) {
145
+ if(((int)$_POST['width'] > 10 && (int)$_POST['width'] < 512) && ((int)$_POST['height'] > 10 && (int)$_POST['height'] < 512) ) {
146
+ $width = (int)$_POST['width'];
147
+ $height = (int)$_POST['height'];
148
+ image_processing($_FILES['image']['tmp_name'], (WPSC_CATEGORY_DIR.$_FILES['image']['name']), $width, $height);
149
+ } else {
150
+ image_processing($_FILES['image']['tmp_name'], (WPSC_CATEGORY_DIR.$_FILES['image']['name']));
151
+ }
152
+ $image = $wpdb->escape($_FILES['image']['name']);
153
+ } else {
154
+ $new_image_path = (WPSC_CATEGORY_DIR.basename($_FILES['image']['name']));
155
+ move_uploaded_file($_FILES['image']['tmp_name'], $new_image_path);
156
+ $stat = stat( dirname( $new_image_path ));
157
+ $perms = $stat['mode'] & 0000666;
158
+ @ chmod( $new_image_path, $perms );
159
+ $image = $wpdb->escape($_FILES['image']['name']);
160
+ }
161
+ } else {
162
+ $image = '';
163
+ }
164
+
165
+
166
+ /* Set the parent category ID variable*/
167
+ if(is_numeric($_POST['category_parent']) && absint($_POST['category_parent']) > 0) {
168
+ $parent_category = (int)$_POST['category_parent'];
169
+ } else {
170
+ $parent_category = 0;
171
+ }
172
+
173
+
174
+ /* add category code */
175
+ if($_POST['submit_action'] == "add") {
176
+ $name = $_POST['name'];
177
+ $term = get_term_by('name', $name, 'wpsc_product_category', ARRAY_A);
178
+
179
+ if(empty($term)) {
180
+ $term = wp_insert_term( $name, 'wpsc_product_category',array('parent' => $parent_category));
181
+ }
182
+
183
+ if (is_wp_error($term)) {
184
+ $_GET['message'] = $term->get_error_code();
185
+ return;
186
+ }
187
+
188
+ $category_id= $term['term_id'];
189
+
190
+ $category = get_term_by('id', $category_id, 'wpsc_product_category');
191
+ $url_name=$category->slug;
192
+
193
+ //$wp_rewrite->flush_rules();
194
+ if($category_id > 0) {
195
+ wpsc_update_categorymeta($category_id, 'nice-name', $url_name);
196
+ wpsc_update_categorymeta($category_id, 'description', $wpdb->escape(stripslashes($_POST['description'])));
197
+ if($image != '') {
198
+ wpsc_update_categorymeta($category_id, 'image', $image);
199
+ }
200
+ //wpsc_update_categorymeta($category_id, 'image', $image);
201
+ wpsc_update_categorymeta($category_id, 'fee', '0');
202
+ wpsc_update_categorymeta($category_id, 'active', '1');
203
+ wpsc_update_categorymeta($category_id, 'order', '0');
204
+
205
+ if($_POST['use_additonal_form_set'] != '') {
206
+ wpsc_update_categorymeta($category_id, 'use_additonal_form_set', $_POST['use_additonal_form_set']);
207
+ } else {
208
+ wpsc_delete_categorymeta($category_id, 'use_additonal_form_set');
209
+ }
210
+
211
+ if((bool)(int)$_POST['uses_billing_address'] == true) {
212
+ wpsc_update_categorymeta($category_id, 'uses_billing_address', 1);
213
+ $uses_additional_forms = true;
214
+ } else {
215
+ wpsc_update_categorymeta($category_id, 'uses_billing_address', 0);
216
+ $uses_additional_forms = false;
217
+ }
218
+ }
219
+
220
+ if(($_POST['countrylist2'] != null ) && ($category_id > 0)){
221
+ $AllSelected = false;
222
+
223
+ $countryList = $wpdb->get_col("SELECT `id` FROM `".WPSC_TABLE_CURRENCY_LIST."`");
224
+
225
+ if(in_array('all',$_POST['countrylist2'])) {
226
+ foreach($countryList as $country){
227
+ $wpdb->query("INSERT INTO `".WPSC_TABLE_CATEGORY_TM."`(`visible`, `countryid`, `categoryid`) VALUES ('1','{$country}', '{$category_id}' )");
228
+ //echo "REPLACE INTO `".WPSC_TABLE_CATEGORY_TM."`(`visible`, `countryid`, `categoryid`) VALUES ('1','{$country}', '{$category_id}' )<br />";
229
+ }
230
+ $AllSelected = true;
231
+ }
232
+
233
+
234
+ if(in_array('none', $_POST['countrylist2'])){
235
+ foreach($countryList as $country){
236
+ $wpdb->query("REPLACE INTO `".WPSC_TABLE_CATEGORY_TM."`(`visible`, `countryid`, `categoryid`) VALUES ('0','{$country}', '{$category_id}' )");
237
+ }
238
+ $AllSelected = true;
239
+ }
240
+
241
+
242
+ if($AllSelected != true){
243
+ $unselectedCountries = array_diff($countryList, $_POST['countrylist2']);
244
+ foreach($unselectedCountries as $unselected){
245
+ $wpdb->query("REPLACE INTO `".WPSC_TABLE_CATEGORY_TM."`(`visible`, `countryid`, `categoryid`) VALUES ('0','{$unselected}', '{$category_id}' )");
246
+ //echo "REPLACE INTO `".WPSC_TABLE_CATEGORY_TM."`(`visible`, `countryid`, `categoryid`) VALUES ('0','{$unselected}', '{$category_id}' )<br />";
247
+ }
248
+
249
+ //find the countries that are selected
250
+ $selectedCountries = array_intersect($countryList, $_POST['countrylist2']);
251
+ foreach($selectedCountries as $selected){
252
+ $wpdb->query("REPLACE INTO `".WPSC_TABLE_CATEGORY_TM."`(`visible`, `countryid`, `categoryid`) VALUES ('1','{$selected}', '{$category_id}' )");
253
+ //echo "REPLACE INTO `".WPSC_TABLE_CATEGORY_TM."`(`visible`, `countryid`, `categoryid`) VALUES ('1','{$unselected}', '{$category_id}' )<br />";
254
+ }
255
+ }
256
+ }
257
+
258
+ }
259
+
260
+
261
+
262
+ /* edit category code */
263
+ if(($_POST['submit_action'] == "edit") && is_numeric($_POST['category_id'])) {
264
+ $category_id = absint($_POST['category_id']);
265
+
266
+ $name = $_POST['name'];
267
+
268
+ $category = get_term_by('id', $category_id, 'wpsc_product_category');
269
+ if($category->name != $name) {
270
+ wp_update_term($category_id, 'wpsc_product_category', array(
271
+ 'name' => $name
272
+ ));
273
+ $category = get_term($category_id, 'wpsc_product_category');
274
+ //$wp_rewrite->flush_rules();
275
+ }
276
+
277
+
278
+ $url_name=$category->slug;
279
+ wpsc_update_categorymeta($category_id, 'nice-name', $url_name);
280
+ wpsc_update_categorymeta($category_id, 'description', $wpdb->escape(stripslashes($_POST['description'])));
281
+
282
+
283
+ if(isset($_POST['deleteimage']) && $_POST['deleteimage'] == 1) {
284
+ wpsc_delete_categorymeta($category_id, 'image');
285
+ } else if($image != '') {
286
+ wpsc_update_categorymeta($category_id, 'image', $image);
287
+ }
288
+
289
+ if(is_numeric($_POST['height']) && is_numeric($_POST['width']) && ($image == null)) {
290
+ $imagedata = wpsc_get_categorymeta($category_id, 'image');
291
+ if($imagedata != null) {
292
+ $height = $_POST['height'];
293
+ $width = $_POST['width'];
294
+ $imagepath = WPSC_CATEGORY_DIR . $imagedata;
295
+ $image_output = WPSC_CATEGORY_DIR . $imagedata;
296
+ image_processing($imagepath, $image_output, $width, $height);
297
+ }
298
+ }
299
+
300
+
301
+ wpsc_update_categorymeta($category_id, 'fee', '0');
302
+ wpsc_update_categorymeta($category_id, 'active', '1');
303
+ wpsc_update_categorymeta($category_id, 'order', '0');
304
+
305
+
306
+ if($_POST['use_additonal_form_set'] != '') {
307
+ wpsc_update_categorymeta($category_id, 'use_additonal_form_set', $_POST['use_additonal_form_set']);
308
+ } else {
309
+ wpsc_delete_categorymeta($category_id, 'use_additonal_form_set');
310
+ }
311
+
312
+ if((bool)(int)$_POST['uses_billing_address'] == true) {
313
+ wpsc_update_categorymeta($category_id, 'uses_billing_address', 1);
314
+ $uses_additional_forms = true;
315
+ } else {
316
+ wpsc_update_categorymeta($category_id, 'uses_billing_address', 0);
317
+ $uses_additional_forms = false;
318
+ }
319
+
320
+ if($_POST['countrylist2'] != null){
321
+ $countryList = $wpdb->get_col("SELECT `id` FROM `".WPSC_TABLE_CURRENCY_LIST."`");
322
+ $AllSelected = false;
323
+ if(in_array('all',$_POST['countrylist2'])){
324
+ foreach($countryList as $country){
325
+ $wpdb->query("REPLACE INTO `".WPSC_TABLE_CATEGORY_TM."`(`visible`, `countryid`, `categoryid`) VALUES ('1','{$country}', '{$category_id}' )");
326
+ }
327
+ $AllSelected = true;
328
+ }
329
+ if(in_array('none', $_POST['countrylist2'])){
330
+ $wpdb->query("UPDATE `".WPSC_TABLE_CATEGORY_TM."` SET `visible` = '0' WHERE `categoryid`='{$category_id}'");
331
+ $AllSelected = true;
332
+ }
333
+ if($AllSelected != true){
334
+ $unselectedCountries = array_diff($countryList, $_POST['countrylist2']);
335
+ foreach($unselectedCountries as $unselected){
336
+ $wpdb->query("REPLACE INTO `".WPSC_TABLE_CATEGORY_TM."` (`visible`, `countryid`, `categoryid`) VALUES (0,'{$unselected}', '{$category_id}' )");
337
+ }
338
+
339
+ //find the countries that are selected
340
+ $selectedCountries = array_intersect($countryList, $_POST['countrylist2']);
341
+ foreach($selectedCountries as $selected){
342
+ $wpdb->query("REPLACE INTO `".WPSC_TABLE_CATEGORY_TM."`(`visible`, `countryid`, `categoryid`) VALUES ('1','{$selected}', '{$category_id}' )");
343
+ }
344
+ }
345
+ }
346
+ }
347
+ }
348
+
349
+ $sendback = remove_query_arg(array(
350
+ 'wpsc_admin_action',
351
+ 'delete_category',
352
+ '_wpnonce',
353
+ 'category_id'
354
+ ));
355
+
356
+ if($_GET['page'] == null) {
357
+ $sendback = add_query_arg('page', 'wpsc-edit-variations', $sendback);
358
+ }
359
+
360
+ $sendback = add_query_arg('message', 1, $sendback);
361
+ wp_redirect($sendback);
362
+ }
363
+
364
+
365
  ?>
wpsc-admin/includes/settings-pages/checkout.php CHANGED
@@ -91,9 +91,9 @@ $form_types = get_option('wpsc_checkout_form_fields');
91
  ?>
92
  <td scope="row"><?php echo __('Lock Tax to Billing Country', 'wpsc'); ?>:</td>
93
  <td>
94
- <input type='radio' value='1' name='wpsc_options[lock_tax]' id='lock_tax1' <?php echo $lock_tax1; ?> />
95
  <label for='lock_tax1'><?php echo __('Yes', 'wpsc');?></label> &nbsp;
96
- <input type='radio' value='0' name='wpsc_options[lock_tax]' id='lock_tax2' <?php echo $lock_tax2; ?> />
97
  <label for='lock_tax2'><?php echo __('No', 'wpsc');?></label>
98
  </td>
99
  </tr>
@@ -114,9 +114,9 @@ $form_types = get_option('wpsc_checkout_form_fields');
114
  ?>
115
  <td scope="row"><?php echo __(' Disregard Billing State for Tax Calculations', 'wpsc'); ?>:</td>
116
  <td>
117
- <input type='radio' value='1' name='wpsc_options[lock_tax_to_shipping]' id='lock_tax1' <?php echo $lock_tax_to_shipping1; ?> />
118
  <label for='lock_tax_to_shipping1'><?php echo __('Yes', 'wpsc');?></label> &nbsp;
119
- <input type='radio' value='0' name='wpsc_options[lock_tax_to_shipping]' id='lock_tax2' <?php echo $lock_tax_to_shipping2; ?> />
120
  <label for='lock_tax_to_shipping2'><?php echo __('No', 'wpsc');?></label>
121
  </td>
122
 
@@ -139,9 +139,9 @@ $form_types = get_option('wpsc_checkout_form_fields');
139
  ?>
140
  <td scope="row"><?php echo __('Enable Shipping Same as Billing Option: ', 'wpsc'); ?>:</td>
141
  <td>
142
- <input type='radio' value='1' name='wpsc_options[shippingsameasbilling]' id='shippingsameasbilling1' <?php echo $shippingBilling1; ?> />
143
  <label for='shippingsameasbilling1'><?php echo __('Yes', 'wpsc');?></label> &nbsp;
144
- <input type='radio' value='0' name='wpsc_options[shippingsameasbilling]' id='shippingsameasbilling2' <?php echo $shippingBilling2; ?> />
145
  <label for='shippingsameasbilling2'><?php echo __('No', 'wpsc');?></label>
146
  </td>
147
 
@@ -212,7 +212,9 @@ $form_types = get_option('wpsc_checkout_form_fields');
212
 
213
 
214
  $form_data = $wpdb->get_results($form_sql,ARRAY_A);
215
- $selected_checkout_set = $_GET['checkout-set'];
 
 
216
  echo "<input type='hidden' name='selected_form_set' value='".$selected_checkout_set."' />";
217
  ?>
218
  <table id="wpsc_checkout_list" class="widefat page fixed" cellspacing="0">
91
  ?>
92
  <td scope="row"><?php echo __('Lock Tax to Billing Country', 'wpsc'); ?>:</td>
93
  <td>
94
+ <input type='radio' value='1' name='wpsc_options[lock_tax]' id='lock_tax1' <?php if (isset($lock_tax1)) echo $lock_tax1; ?> />
95
  <label for='lock_tax1'><?php echo __('Yes', 'wpsc');?></label> &nbsp;
96
+ <input type='radio' value='0' name='wpsc_options[lock_tax]' id='lock_tax2' <?php if (isset($lock_tax2)) echo $lock_tax2; ?> />
97
  <label for='lock_tax2'><?php echo __('No', 'wpsc');?></label>
98
  </td>
99
  </tr>
114
  ?>
115
  <td scope="row"><?php echo __(' Disregard Billing State for Tax Calculations', 'wpsc'); ?>:</td>
116
  <td>
117
+ <input type='radio' value='1' name='wpsc_options[lock_tax_to_shipping]' id='lock_tax1' <?php if (isset($lock_tax_to_shipping1)) echo $lock_tax_to_shipping1; ?> />
118
  <label for='lock_tax_to_shipping1'><?php echo __('Yes', 'wpsc');?></label> &nbsp;
119
+ <input type='radio' value='0' name='wpsc_options[lock_tax_to_shipping]' id='lock_tax2' <?php if (isset($lock_tax_to_shipping2)) echo $lock_tax_to_shipping2; ?> />
120
  <label for='lock_tax_to_shipping2'><?php echo __('No', 'wpsc');?></label>
121
  </td>
122
 
139
  ?>
140
  <td scope="row"><?php echo __('Enable Shipping Same as Billing Option: ', 'wpsc'); ?>:</td>
141
  <td>
142
+ <input type='radio' value='1' name='wpsc_options[shippingsameasbilling]' id='shippingsameasbilling1' <?php if (isset($shippingBilling1)) echo $shippingBilling1; ?> />
143
  <label for='shippingsameasbilling1'><?php echo __('Yes', 'wpsc');?></label> &nbsp;
144
+ <input type='radio' value='0' name='wpsc_options[shippingsameasbilling]' id='shippingsameasbilling2' <?php if (isset($shippingBilling2)) echo $shippingBilling2; ?> />
145
  <label for='shippingsameasbilling2'><?php echo __('No', 'wpsc');?></label>
146
  </td>
147
 
212
 
213
 
214
  $form_data = $wpdb->get_results($form_sql,ARRAY_A);
215
+ if (!isset($_GET['checkout-set'])) $_GET['checkout-set'] = '';
216
+
217
+ $selected_checkout_set = $_GET['checkout-set'];
218
  echo "<input type='hidden' name='selected_form_set' value='".$selected_checkout_set."' />";
219
  ?>
220
  <table id="wpsc_checkout_list" class="widefat page fixed" cellspacing="0">
wpsc-admin/includes/settings-pages/gateway.php CHANGED
@@ -25,9 +25,12 @@ if (is_array($GLOBALS['nzshpcrt_gateways'])) {
25
  $disabled = "disabled='disabled'";
26
  }
27
 
 
 
28
  $gatewaylist .="<option $disabled value='".$gateway['internalname']."' ".$selected." >".$gateway['name']."</option>";
29
  }
30
  }
 
31
  $gatewaylist = "<option value='".$nogw."'>".__('Please Select A Payment Gateway', 'wpsc')."</option>" . $gatewaylist;
32
 
33
  ?>
@@ -135,9 +138,11 @@ function selectgateway() {
135
  </td>
136
  <td style='border-top: none;'>
137
  <?php
138
- if($payment_gateway_names[$selected_gateway_data['internalname']] != '') {
 
139
  $display_name = $payment_gateway_names[$selected_gateway_data['internalname']];
140
  } else {
 
141
  switch($selected_gateway_data['payment_type']) {
142
  case "paypal";
143
  $display_name = "PayPal";
@@ -163,7 +168,11 @@ function selectgateway() {
163
  </td>
164
  </tr>
165
 
166
- <?php echo $form; ?>
 
 
 
 
167
 
168
  <tr class='update_gateway' >
169
  <td colspan='2'>
25
  $disabled = "disabled='disabled'";
26
  }
27
 
28
+ if (!isset($gateway['internalname'])) $gateway['internalname'] = '';
29
+ $gatewaylist = '';
30
  $gatewaylist .="<option $disabled value='".$gateway['internalname']."' ".$selected." >".$gateway['name']."</option>";
31
  }
32
  }
33
+ $nogw = '';
34
  $gatewaylist = "<option value='".$nogw."'>".__('Please Select A Payment Gateway', 'wpsc')."</option>" . $gatewaylist;
35
 
36
  ?>
138
  </td>
139
  <td style='border-top: none;'>
140
  <?php
141
+ if (!isset($selected_gateway_data['internalname'])) $selected_gateway_data['internalname'] = '';
142
+ if(isset($payment_gateway_names[$selected_gateway_data['internalname']]) && $payment_gateway_names[$selected_gateway_data['internalname']] != '') {
143
  $display_name = $payment_gateway_names[$selected_gateway_data['internalname']];
144
  } else {
145
+ if (!isset($selected_gateway_data['payment_type'])) $selected_gateway_data['payment_type'] = '';
146
  switch($selected_gateway_data['payment_type']) {
147
  case "paypal";
148
  $display_name = "PayPal";
168
  </td>
169
  </tr>
170
 
171
+ <?php
172
+ if (!isset($form)) $form = '';
173
+
174
+ echo $form;
175
+ ?>
176
 
177
  <tr class='update_gateway' >
178
  <td colspan='2'>
wpsc-admin/includes/settings-pages/general.php CHANGED
@@ -1,190 +1,193 @@
1
  <?php
2
  function wpsc_options_general(){
3
- global $wpdb;
4
  ?>
5
- <form name='cart_options' id='cart_options' method='post' action=''>
6
- <div id="options_general">
7
- <h2><?php _e('General Settings', 'wpsc'); ?></h2>
8
- <?php
9
- /* wpsc_setting_page_update_notification displays the wordpress styled notifications */
10
- wpsc_settings_page_update_notification(); ?>
11
- <table class='wpsc_options form-table'>
12
- <tr>
13
- <th scope="row"><?php echo __('Base Country/Region', 'wpsc'); ?>: </th>
14
- <td>
15
- <select name='wpsc_options[base_country]' onchange='submit_change_country();'>
16
- <?php echo country_list(get_option('base_country')); ?>
17
- </select>
18
- <span id='options_country'>
19
- <?php
20
- $region_list = $wpdb->get_results("SELECT `".WPSC_TABLE_REGION_TAX."`.* FROM `".WPSC_TABLE_REGION_TAX."`, `".WPSC_TABLE_CURRENCY_LIST."` WHERE `".WPSC_TABLE_CURRENCY_LIST."`.`isocode` IN('".get_option('base_country')."') AND `".WPSC_TABLE_CURRENCY_LIST."`.`id` = `".WPSC_TABLE_REGION_TAX."`.`country_id`",ARRAY_A) ;
21
- if($region_list != null) {
22
- ?>
23
- <select name='wpsc_options[base_region]'>
24
- <?php
25
- foreach($region_list as $region) {
26
- if(get_option('base_region') == $region['id']) {
27
- $selected = "selected='selected'";
28
- } else {
29
- $selected = "";
30
- }
31
- ?>
32
- <option value='<?php echo $region['id']; ?>' <?php echo $selected; ?> ><?php echo $region['name']; ?></option> <?php
33
- }
34
- ?>
35
- </select>
36
-
37
- <?php } ?>
38
- </span>
39
- <br /><?php echo __('Select your primary business location.', 'wpsc');?>
40
- </td>
41
- </tr>
42
- <tr>
43
- <th scope="row"><?php echo __('Tax Settings', 'wpsc');?>:</th>
44
- <td>
45
- <span id='options_region'>
46
- <?php
47
- $country_data = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `isocode`='".get_option('base_country')."' LIMIT 1",ARRAY_A);
48
- echo $country_data['country'];
49
- $region_count = $wpdb->get_var("SELECT COUNT(*) AS `count` FROM `".WPSC_TABLE_REGION_TAX."`, `".WPSC_TABLE_CURRENCY_LIST."` WHERE `".WPSC_TABLE_CURRENCY_LIST."`.`isocode` IN('".get_option('base_country')."') AND `".WPSC_TABLE_CURRENCY_LIST."`.`id` = `".WPSC_TABLE_REGION_TAX."`.`country_id`") ;
50
- if($country_data['has_regions'] == 1) {
51
- ?>&nbsp;&nbsp;&nbsp;&nbsp;<a href='<?php echo add_query_arg(array( 'page' => 'wpsc-settings', 'isocode' => get_option('base_country') )); ?>'><?php echo $region_count ?> Regions</a>
52
- <?php } else { ?>
53
- <input type='hidden' name='country_id' value='<?php echo $country_data['id']; ?>' />
54
- &nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='country_tax' class='tax_forms' maxlength='5' size='5' value='<?php echo $country_data['tax']; ?>' />%
55
- <?php } ?>
56
- </span>
57
- </td>
58
- </tr>
59
- <tr>
60
- <th scope="row"><?php _e('Tax Included in prices','wpsc') ?>:</th>
61
- <td>
62
- <?php
63
- $tax_inprice0= '';
64
- $tax_inprice1= '';
65
- if(wpsc_tax_isincluded()){
66
- $tax_inprice1= 'checked="checked"';
67
- }else{
68
- $tax_inprice0= 'checked="checked"';
69
- }
70
- ?>
71
- <input <?php echo $tax_inprice1; ?> type='radio' name='wpsc_options[tax_inprice]' value='1' id='tax_inprice1' />
72
- <label for='tax_inprice1'><?php echo __('Yes', 'wpsc'); ?></label>
73
- <input <?php echo $tax_inprice0; ?> type='radio' name='wpsc_options[tax_inprice]' value='0' id='tax_inprice0' />
74
- <label for='tax_inprice1'><?php echo __('No', 'wpsc'); ?></label>
75
- </td>
76
- </tr>
77
 
78
- <?php /* START OF TARGET MARKET SELECTION */
79
- $countrylist = $wpdb->get_results("SELECT id,country,visible FROM `".WPSC_TABLE_CURRENCY_LIST."` ORDER BY country ASC ",ARRAY_A);
80
- ?>
81
- <tr>
82
- <th scope="row">
83
- <?php echo __('Target Markets', 'wpsc'); ?>:
84
- </th>
85
- <td>
86
- <?php
87
- // check for the suhosin module
88
- if(@extension_loaded('suhosin') && (@ini_get('suhosin.post.max_vars') > 0) && (@ini_get('suhosin.post.max_vars') < 500)) {
89
- echo "<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.
90
- ",'wpsc')."</em>";
91
-
92
- } else {
93
- ?>
94
- <span>Select: <a href='<?php echo add_query_arg(array('selected_all' => 'all'))?>' class='wpsc_select_all'>All</a>&nbsp; <a href='<?php echo add_query_arg(array( 'selected_all'=>'none'))?>' class='wpsc_select_none'>None</a></span><br />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
 
96
- <div id='resizeable' class='ui-widget-content multiple-select'>
97
- <?php
98
- foreach((array)$countrylist as $country){
99
- $country['country'] = htmlspecialchars($country['country']);
100
- if($country['visible'] == 1){ ?>
101
- <input type='checkbox' name='countrylist2[]' value='<?php echo $country['id']; ?>' checked='checked' /><?php echo $country['country']; ?><br />
102
- <?php }else{ ?>
103
- <input type='checkbox' name='countrylist2[]' value='<?php echo $country['id']; ?>' /><?php echo $country['country']; ?><br />
104
- <?php }
105
-
106
- } ?>
107
- </div><br />
108
- Select the markets you are selling products to.
109
- <?php
110
- }
111
- ?>
112
- </td>
113
- </tr>
114
- </table>
115
-
116
- <h3 class="form_group"><?php echo __('Currency Settings', 'wpsc');?>:</h3>
117
- <table class='wpsc_options form-table'>
118
- <tr>
119
- <th scope="row"><?php echo __('Currency type', 'wpsc');?>:</th>
120
- <td>
121
- <select name='wpsc_options[currency_type]' onchange='getcurrency(this.options[this.selectedIndex].value);'>
122
- <?php
123
- $currency_data = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_CURRENCY_LIST."` ORDER BY `country` ASC",ARRAY_A);
124
- foreach($currency_data as $currency) {
125
- if(get_option('currency_type') == $currency['id']) {
126
- $selected = "selected='selected'";
127
- } else {
128
- $selected = "";
129
- } ?>
130
- <option value='<?php echo $currency['id']; ?>' <?php echo $selected; ?> ><?php echo htmlspecialchars($currency['country']); ?> (<?php echo $currency['currency']; ?>)</option>
131
- <?php }
132
- $currency_data = $wpdb->get_row("SELECT `symbol`,`symbol_html`,`code` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `id`='".get_option('currency_type')."' LIMIT 1",ARRAY_A) ;
133
- if($currency_data['symbol'] != '') {
134
- $currency_sign = $currency_data['symbol_html'];
135
- } else {
136
- $currency_sign = $currency_data['code'];
137
- }
138
- ?>
139
- </select>
140
- </td>
141
- </tr>
142
- <tr>
143
- <th scope="row"><?php echo __('Currency sign location', 'wpsc');?>:</th>
144
- <td>
145
- <?php
146
- $currency_sign_location = get_option('currency_sign_location');
147
- $csl1 = "";
148
- $csl2 = "";
149
- $csl3 = "";
150
- $csl4 = "";
151
- switch($currency_sign_location) {
152
- case 1:
153
- $csl1 = "checked ='checked'";
154
- break;
155
-
156
- case 2:
157
- $csl2 = "checked ='checked'";
158
- break;
159
-
160
- case 3:
161
- $csl3 = "checked ='checked'";
162
- break;
163
-
164
- case 4:
165
- $csl4 = "checked ='checked'";
166
- break;
167
- }
168
- ?>
169
- <input type='radio' value='1' name='wpsc_options[currency_sign_location]' id='csl1' <?php echo $csl1; ?> />
170
- <label for='csl1'>100<span id='cslchar1'><?php echo $currency_sign; ?></span></label> &nbsp;
171
- <input type='radio' value='2' name='wpsc_options[currency_sign_location]' id='csl2' <?php echo $csl2; ?> />
172
- <label for='csl2'>100 <span id='cslchar2'><?php echo $currency_sign; ?></span></label> &nbsp;
173
- <input type='radio' value='3' name='wpsc_options[currency_sign_location]' id='csl3' <?php echo $csl3; ?> />
174
- <label for='csl3'><span id='cslchar3'><?php echo $currency_sign; ?></span>100</label> &nbsp;
175
- <input type='radio' value='4' name='wpsc_options[currency_sign_location]' id='csl4' <?php echo $csl4; ?> />
176
- <label for='csl4'><span id='cslchar4'><?php echo $currency_sign; ?></span> 100</label>
177
- </td>
178
- </tr>
179
- </table>
180
- <div class="submit">
181
- <input type='hidden' name='wpsc_admin_action' value='submit_options' />
182
- <?php wp_nonce_field('update-options', 'wpsc-update-options'); ?>
183
- <input type="submit" value="<?php echo __('Update &raquo;', 'wpsc');?>" name="updateoption"/>
184
- </div>
185
- </div>
186
- </form>
187
- <?php
188
- }
189
 
190
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
  function wpsc_options_general(){
3
+ global $wpdb;
4
  ?>
5
+ <form name='cart_options' id='cart_options' method='post' action=''>
6
+ <div id="options_general">
7
+ <h2><?php _e('General Settings', 'wpsc'); ?></h2>
8
+ <?php
9
+ /* wpsc_setting_page_update_notification displays the wordpress styled notifications */
10
+ wpsc_settings_page_update_notification(); ?>
11
+ <table class='wpsc_options form-table'>
12
+ <tr>
13
+ <th scope="row"><?php echo __('Base Country/Region', 'wpsc'); ?>: </th>
14
+ <td>
15
+ <select name='wpsc_options[base_country]' onchange='submit_change_country();'>
16
+ <?php echo country_list(get_option('base_country')); ?>
17
+ </select>
18
+ <span id='options_country'>
19
+ <?php
20
+ $region_list = $wpdb->get_results("SELECT `".WPSC_TABLE_REGION_TAX."`.* FROM `".WPSC_TABLE_REGION_TAX."`, `".WPSC_TABLE_CURRENCY_LIST."` WHERE `".WPSC_TABLE_CURRENCY_LIST."`.`isocode` IN('".get_option('base_country')."') AND `".WPSC_TABLE_CURRENCY_LIST."`.`id` = `".WPSC_TABLE_REGION_TAX."`.`country_id`",ARRAY_A) ;
21
+ if($region_list != null) {
22
+ ?>
23
+ <select name='wpsc_options[base_region]'>
24
+ <?php
25
+ foreach($region_list as $region) {
26
+ if(get_option('base_region') == $region['id']) {
27
+ $selected = "selected='selected'";
28
+ } else {
29
+ $selected = "";
30
+ }
31
+ ?>
32
+ <option value='<?php echo $region['id']; ?>' <?php echo $selected; ?> ><?php echo $region['name']; ?></option> <?php
33
+ }
34
+ ?>
35
+ </select>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
+ <?php } ?>
38
+ </span>
39
+ <br /><?php echo __('Select your primary business location.', 'wpsc');?>
40
+ </td>
41
+ </tr>
42
+ <?php
43
+ /*SEE TAX SETTINGS PAGE
44
+ <tr>
45
+ <th scope="row"><?php echo __('Tax Settings', 'wpsc');?>:</th>
46
+ <td>
47
+ <span id='options_region'>
48
+ <?php
49
+ $country_data = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `isocode`='".get_option('base_country')."' LIMIT 1",ARRAY_A);
50
+ echo $country_data['country'];
51
+ $region_count = $wpdb->get_var("SELECT COUNT(*) AS `count` FROM `".WPSC_TABLE_REGION_TAX."`, `".WPSC_TABLE_CURRENCY_LIST."` WHERE `".WPSC_TABLE_CURRENCY_LIST."`.`isocode` IN('".get_option('base_country')."') AND `".WPSC_TABLE_CURRENCY_LIST."`.`id` = `".WPSC_TABLE_REGION_TAX."`.`country_id`") ;
52
+ if($country_data['has_regions'] == 1) {
53
+ ?>&nbsp;&nbsp;&nbsp;&nbsp;<a href='<?php echo add_query_arg(array( 'page' => 'wpsc-settings', 'isocode' => get_option('base_country') )); ?>'><?php echo $region_count ?> Regions</a>
54
+ <?php } else { ?>
55
+ <input type='hidden' name='country_id' value='<?php echo $country_data['id']; ?>' />
56
+ &nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='country_tax' class='tax_forms' maxlength='5' size='5' value='<?php echo $country_data['tax']; ?>' />%
57
+ <?php } ?>
58
+ </span>
59
+ </td>
60
+ </tr>
61
+ <tr>
62
+ <th scope="row"><?php _e('Tax Included in prices','wpsc') ?>:</th>
63
+ <td>
64
+ <?php
65
+ $tax_inprice0= '';
66
+ $tax_inprice1= '';
67
+ if(wpsc_tax_isincluded()){
68
+ $tax_inprice1= 'checked="checked"';
69
+ }else{
70
+ $tax_inprice0= 'checked="checked"';
71
+ }
72
+ ?>
73
+ <input <?php echo $tax_inprice1; ?> type='radio' name='wpsc_options[tax_inprice]' value='1' id='tax_inprice1' />
74
+ <label for='tax_inprice1'><?php echo __('Yes', 'wpsc'); ?></label>
75
+ <input <?php echo $tax_inprice0; ?> type='radio' name='wpsc_options[tax_inprice]' value='0' id='tax_inprice0' />
76
+ <label for='tax_inprice1'><?php echo __('No', 'wpsc'); ?></label>
77
+ </td>
78
+ </tr>
79
+ END SEE TAX SETTINGS PAGE*/
80
+ ?>
81
+ <?php /* START OF TARGET MARKET SELECTION */
82
+ $countrylist = $wpdb->get_results("SELECT id,country,visible FROM `".WPSC_TABLE_CURRENCY_LIST."` ORDER BY country ASC ",ARRAY_A);
83
+ ?>
84
+ <tr>
85
+ <th scope="row">
86
+ <?php echo __('Target Markets', 'wpsc'); ?>:
87
+ </th>
88
+ <td>
89
+ <?php
90
+ // check for the suhosin module
91
+ if(@extension_loaded('suhosin') && (@ini_get('suhosin.post.max_vars') > 0) && (@ini_get('suhosin.post.max_vars') < 500)) {
92
+ echo "<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.
93
+ ",'wpsc')."</em>";
94
+
95
+ } else {
96
+ ?>
97
+ <span>Select: <a href='<?php echo add_query_arg(array('selected_all' => 'all'))?>' class='wpsc_select_all'>All</a>&nbsp; <a href='<?php echo add_query_arg(array( 'selected_all'=>'none'))?>' class='wpsc_select_none'>None</a></span><br />
98
+
99
+ <div id='resizeable' class='ui-widget-content multiple-select'>
100
+ <?php
101
+ foreach((array)$countrylist as $country){
102
+ $country['country'] = htmlspecialchars($country['country']);
103
+ if($country['visible'] == 1){ ?>
104
+ <input type='checkbox' name='countrylist2[]' value='<?php echo $country['id']; ?>' checked='checked' /><?php echo $country['country']; ?><br />
105
+ <?php }else{ ?>
106
+ <input type='checkbox' name='countrylist2[]' value='<?php echo $country['id']; ?>' /><?php echo $country['country']; ?><br />
107
+ <?php }
108
+
109
+ } ?>
110
+ </div><br />
111
+ Select the markets you are selling products to.
112
+ <?php
113
+ }
114
+ ?>
115
+ </td>
116
+ </tr>
117
+ </table>
118
 
119
+ <h3 class="form_group"><?php echo __('Currency Settings', 'wpsc');?>:</h3>
120
+ <table class='wpsc_options form-table'>
121
+ <tr>
122
+ <th scope="row"><?php echo __('Currency type', 'wpsc');?>:</th>
123
+ <td>
124
+ <select name='wpsc_options[currency_type]' onchange='getcurrency(this.options[this.selectedIndex].value);'>
125
+ <?php
126
+ $currency_data = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_CURRENCY_LIST."` ORDER BY `country` ASC",ARRAY_A);
127
+ foreach($currency_data as $currency) {
128
+ if(get_option('currency_type') == $currency['id']) {
129
+ $selected = "selected='selected'";
130
+ } else {
131
+ $selected = "";
132
+ } ?>
133
+ <option value='<?php echo $currency['id']; ?>' <?php echo $selected; ?> ><?php echo htmlspecialchars($currency['country']); ?> (<?php echo $currency['currency']; ?>)</option>
134
+ <?php }
135
+ $currency_data = $wpdb->get_row("SELECT `symbol`,`symbol_html`,`code` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `id`='".get_option('currency_type')."' LIMIT 1",ARRAY_A) ;
136
+ if($currency_data['symbol'] != '') {
137
+ $currency_sign = $currency_data['symbol_html'];
138
+ } else {
139
+ $currency_sign = $currency_data['code'];
140
+ }
141
+ ?>
142
+ </select>
143
+ </td>
144
+ </tr>
145
+ <tr>
146
+ <th scope="row"><?php echo __('Currency sign location', 'wpsc');?>:</th>
147
+ <td>
148
+ <?php
149
+ $currency_sign_location = get_option('currency_sign_location');
150
+ $csl1 = "";
151
+ $csl2 = "";
152
+ $csl3 = "";
153
+ $csl4 = "";
154
+ switch($currency_sign_location) {
155
+ case 1:
156
+ $csl1 = "checked ='checked'";
157
+ break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
158
 
159
+ case 2:
160
+ $csl2 = "checked ='checked'";
161
+ break;
162
+
163
+ case 3:
164
+ $csl3 = "checked ='checked'";
165
+ break;
166
+
167
+ case 4:
168
+ $csl4 = "checked ='checked'";
169
+ break;
170
+ }
171
+ ?>
172
+ <input type='radio' value='1' name='wpsc_options[currency_sign_location]' id='csl1' <?php echo $csl1; ?> />
173
+ <label for='csl1'>100<span id='cslchar1'><?php echo $currency_sign; ?></span></label> &nbsp;
174
+ <input type='radio' value='2' name='wpsc_options[currency_sign_location]' id='csl2' <?php echo $csl2; ?> />
175
+ <label for='csl2'>100 <span id='cslchar2'><?php echo $currency_sign; ?></span></label> &nbsp;
176
+ <input type='radio' value='3' name='wpsc_options[currency_sign_location]' id='csl3' <?php echo $csl3; ?> />
177
+ <label for='csl3'><span id='cslchar3'><?php echo $currency_sign; ?></span>100</label> &nbsp;
178
+ <input type='radio' value='4' name='wpsc_options[currency_sign_location]' id='csl4' <?php echo $csl4; ?> />
179
+ <label for='csl4'><span id='cslchar4'><?php echo $currency_sign; ?></span> 100</label>
180
+ </td>
181
+ </tr>
182
+ </table>
183
+ <div class="submit">
184
+ <input type='hidden' name='wpsc_admin_action' value='submit_options' />
185
+ <?php wp_nonce_field('update-options', 'wpsc-update-options'); ?>
186
+ <input type="submit" value="<?php echo __('Update &raquo;', 'wpsc');?>" name="updateoption"/>
187
+ </div>
188
+ </div>
189
+ </form>
190
+ <?php
191
+ }
192
+
193
+ ?>
wpsc-admin/includes/settings-pages/import.php CHANGED
@@ -13,7 +13,8 @@ global $wpdb;
13
  <input type='submit' value='Import' class='button-primary'>
14
  <?php
15
  //exit('<pre>'.print_r($_FILES, true).'</pre>');
16
- if ($_FILES['csv_file']['name'] != '') {
 
17
  ini_set("auto_detect_line_endings", 1);
18
  $file = $_FILES['csv_file'];
19
  //exit('<pre>'.print_r($file,true).'</pre>');
@@ -91,7 +92,7 @@ ini_set("auto_detect_line_endings", 1);
91
 
92
  }
93
  }
94
- if($_POST['csv_action'] == 'import'){
95
  global $wpdb;
96
 
97
  $cvs_data = $_SESSION['cvs_data'];
13
  <input type='submit' value='Import' class='button-primary'>
14
  <?php
15
  //exit('<pre>'.print_r($_FILES, true).'</pre>');
16
+
17
+ if (isset($_FILES['csv_file']['name']) && ($_FILES['csv_file']['name'] != '')) {
18
  ini_set("auto_detect_line_endings", 1);
19
  $file = $_FILES['csv_file'];
20
  //exit('<pre>'.print_r($file,true).'</pre>');
92
 
93
  }
94
  }
95
+ if(isset($_POST['csv_action']) && ($_POST['csv_action'] == 'import')) {
96
  global $wpdb;
97
 
98
  $cvs_data = $_SESSION['cvs_data'];
wpsc-admin/includes/settings-pages/presentation.php CHANGED
@@ -1,6 +1,7 @@
1
  <?php
2
  function options_categorylist() {
3
  global $wpdb;
 
4
  $current_default = get_option('wpsc_default_category');
5
  $group_data = get_terms('wpsc_product_category','hide_empty=0&parent=0', ARRAY_A);
6
  $categorylist .= "<select name='wpsc_options[wpsc_default_category]'>";
@@ -228,9 +229,9 @@ global $wpdb;
228
  break;
229
  }
230
  ?>
231
- <input type='radio' value='1' name='wpsc_options[multi_add]' id='multi_adding1' <?php echo $multi_adding1; ?> />
232
  <label for='multi_adding1'><?php echo __('Yes', 'wpsc');?></label> &nbsp;
233
- <input type='radio' value='0' name='wpsc_options[multi_add]' id='multi_adding2' <?php echo $multi_adding2; ?> />
234
  <label for='multi_adding2'><?php echo __('No', 'wpsc');?></label>
235
  </td>
236
  </tr>
@@ -241,7 +242,7 @@ global $wpdb;
241
  <div class='themes_and_appearance'>
242
  <h4><?php _e("Theme Customisation", 'wpsc'); ?></h4>
243
  <?php
244
- if($_SESSION['wpsc_themes_copied'] == true) {
245
  ?>
246
  <div class="updated fade below-h2" id="message" style="background-color: rgb(255, 251, 204);">
247
  <p><?php _e("Thanks, the themes have been copied."); ?></p>
@@ -376,7 +377,7 @@ global $wpdb;
376
  <input type='checkbox' value='1' name='wpsc_options[list_view_quantity]' id='list_view_quantity' <?php echo $list_view_quantity_value;?> />
377
  <label for='list_view_options'><?php echo __('Show quantity form in list view', 'wpsc');?></label>
378
  </div>
379
- <div id='grid_view_options' <?php echo $list_view_quantity_style;?> <?php if(is_null($product_view3)) { echo "style='display:none;'";} ?>>
380
 
381
  <input type='text' name='wpsc_options[grid_number_per_row]' id='grid_number_per_row' size='1' value='<?php echo get_option('grid_number_per_row');?>' />
382
  <label for='grid_number_per_row'><?php echo __('Products Per Row', 'wpsc');?></label><br />
@@ -454,10 +455,10 @@ global $wpdb;
454
  </th>
455
  <td>
456
  <select name='wpsc_options[wpsc_sort_by]'>
457
- <option <?php echo $wpsc_sort_by1; ?> value='name'><?php echo __('Name', 'wpsc');?></option>
458
- <option <?php echo $wpsc_sort_by2; ?> value='price'><?php echo __('Price', 'wpsc');?></option>
459
- <option <?php echo $wpsc_sort_by4; ?> value='dragndrop'><?php echo __('Drag &amp; Drop', 'wpsc');?></option>
460
- <option <?php echo $wpsc_sort_by3; ?> value='id'><?php echo __('Time Uploaded', 'wpsc');?></option>
461
  </select>
462
  </td>
463
  </tr>
@@ -619,7 +620,7 @@ global $wpdb;
619
  $cart5 = "checked ='checked'";
620
  break;
621
  }
622
- if(function_exists('register_sidebar_widget')) {
623
  ?>
624
  <input type='radio' value='1' onclick='hideelement1("dropshop_option", this.value)' disabled='disabled' name='wpsc_options[cart_location]' id='cart1' <?php echo $cart1; ?> /> <label style='color: #666666;' for='cart1'><?php echo __('Sidebar', 'wpsc');?></label> &nbsp;
625
  <?php
@@ -631,7 +632,7 @@ global $wpdb;
631
  ?>
632
  <input type='radio' onclick='hideelement1("dropshop_option", this.value)' value='2' name='wpsc_options[cart_location]' id='cart2' <?php echo $cart2; ?> /> <label for='cart2'><?php echo __('Page', 'wpsc');?></label> &nbsp;
633
  <?php
634
- if(function_exists('register_sidebar_widget')) {
635
  ?>
636
  <input type='radio' value='4' onclick='hideelement1("dropshop_option", this.value)' name='wpsc_options[cart_location]' id='cart4' <?php echo $cart4; ?> /> <label for='cart4'><?php echo __('Widget', 'wpsc');?></label> &nbsp;
637
  <?php
@@ -647,11 +648,11 @@ global $wpdb;
647
  <?php
648
  } else {
649
  ?>
650
- <input type='radio' disabled='disabled' value='5' name='wpsc_options[cart_location]' id='cart5' alt='<?php echo __('You need to enable the widgets plugin to use this', 'wpsc');?>' title='<?php echo __('You need to install the Gold and DropShop extentions to use this', 'wpsc');?>' <?php echo $cart5; ?> /> <label style='color: #666666;' for='cart5' title='<?php echo __('You need to install the Gold and DropShop extentions to use this', 'wpsc');?>'><?php echo __('DropShop', 'wpsc');?></label> &nbsp;
651
  <?php
652
  }
653
  ?>
654
- <input type='radio' onclick='hideelement1("dropshop_option", this.value)' value='3' name='wpsc_options[cart_location]' id='cart3' <?php echo $cart3; ?> /> <label for='cart3'><?php echo __('Manual', 'wpsc');?> <span style='font-size: 7pt;'>(PHP code: &lt;?php echo nzshpcrt_shopping_basket(); ?&gt; )</span></label>
655
  <div style='display: <?php if (isset($cart5)) { echo "block"; } else { echo "none"; } ?>;' id='dropshop_option'>
656
  <p>
657
  <input type="radio" id="drop1" value="all" <?php if (get_option('dropshop_display') == 'all') { echo "checked='checked'"; } ?> name="wpsc_options[dropshop_display]" /><label for="drop1"><?php echo __('Show Dropshop on every page', 'wpsc');?></label>
1
  <?php
2
  function options_categorylist() {
3
  global $wpdb;
4
+ $categorylist = "";
5
  $current_default = get_option('wpsc_default_category');
6
  $group_data = get_terms('wpsc_product_category','hide_empty=0&parent=0', ARRAY_A);
7
  $categorylist .= "<select name='wpsc_options[wpsc_default_category]'>";
229
  break;
230
  }
231
  ?>
232
+ <input type='radio' value='1' name='wpsc_options[multi_add]' id='multi_adding1' <?php if(isset($multi_adding1)) echo $multi_adding1; ?> />
233
  <label for='multi_adding1'><?php echo __('Yes', 'wpsc');?></label> &nbsp;
234
+ <input type='radio' value='0' name='wpsc_options[multi_add]' id='multi_adding2' <?php if(isset($multi_adding2)) echo $multi_adding2; ?> />
235
  <label for='multi_adding2'><?php echo __('No', 'wpsc');?></label>
236
  </td>
237
  </tr>
242
  <div class='themes_and_appearance'>
243
  <h4><?php _e("Theme Customisation", 'wpsc'); ?></h4>
244
  <?php
245
+ if(isset($_SESSION['wpsc_themes_copied']) && ($_SESSION['wpsc_themes_copied'] == true)) {
246
  ?>
247
  <div class="updated fade below-h2" id="message" style="background-color: rgb(255, 251, 204);">
248
  <p><?php _e("Thanks, the themes have been copied."); ?></p>
377
  <input type='checkbox' value='1' name='wpsc_options[list_view_quantity]' id='list_view_quantity' <?php echo $list_view_quantity_value;?> />
378
  <label for='list_view_options'><?php echo __('Show quantity form in list view', 'wpsc');?></label>
379
  </div>
380
+ <div id='grid_view_options' <?php if(isset($list_view_quantity_style)) echo $list_view_quantity_style;?> <?php if(is_null($product_view3)) { echo "style='display:none;'";} ?>>
381
 
382
  <input type='text' name='wpsc_options[grid_number_per_row]' id='grid_number_per_row' size='1' value='<?php echo get_option('grid_number_per_row');?>' />
383
  <label for='grid_number_per_row'><?php echo __('Products Per Row', 'wpsc');?></label><br />
455
  </th>
456
  <td>
457
  <select name='wpsc_options[wpsc_sort_by]'>
458
+ <option <?php if(isset($wpsc_sort_by1)) echo $wpsc_sort_by1; ?> value='name'><?php echo __('Name', 'wpsc');?></option>
459
+ <option <?php if(isset($wpsc_sort_by2)) echo $wpsc_sort_by2; ?> value='price'><?php echo __('Price', 'wpsc');?></option>
460
+ <option <?php if(isset($wpsc_sort_by4)) echo $wpsc_sort_by4; ?> value='dragndrop'><?php echo __('Drag &amp; Drop', 'wpsc');?></option>
461
+ <option <?php if(isset($wpsc_sort_by3)) echo $wpsc_sort_by3; ?> value='id'><?php echo __('Time Uploaded', 'wpsc');?></option>
462
  </select>
463
  </td>
464
  </tr>
620
  $cart5 = "checked ='checked'";
621
  break;
622
  }
623
+ if(function_exists('wp_register_sidebar_widget')) {
624
  ?>
625
  <input type='radio' value='1' onclick='hideelement1("dropshop_option", this.value)' disabled='disabled' name='wpsc_options[cart_location]' id='cart1' <?php echo $cart1; ?> /> <label style='color: #666666;' for='cart1'><?php echo __('Sidebar', 'wpsc');?></label> &nbsp;
626
  <?php
632
  ?>
633
  <input type='radio' onclick='hideelement1("dropshop_option", this.value)' value='2' name='wpsc_options[cart_location]' id='cart2' <?php echo $cart2; ?> /> <label for='cart2'><?php echo __('Page', 'wpsc');?></label> &nbsp;
634
  <?php
635
+ if(function_exists('wp_register_sidebar_widget')) {
636
  ?>
637
  <input type='radio' value='4' onclick='hideelement1("dropshop_option", this.value)' name='wpsc_options[cart_location]' id='cart4' <?php echo $cart4; ?> /> <label for='cart4'><?php echo __('Widget', 'wpsc');?></label> &nbsp;
638
  <?php
648
  <?php
649
  } else {
650
  ?>
651
+ <input type='radio' disabled='disabled' value='5' name='wpsc_options[cart_location]' id='cart5' alt='<?php echo __('You need to enable the widgets plugin to use this', 'wpsc');?>' title='<?php echo __('You need to install the Gold and DropShop extentions to use this', 'wpsc');?>' <?php if(isset($cart5)) echo $cart5; ?> /> <label style='color: #666666;' for='cart5' title='<?php echo __('You need to install the Gold and DropShop extentions to use this', 'wpsc');?>'><?php echo __('DropShop', 'wpsc');?></label> &nbsp;
652
  <?php
653
  }
654
  ?>
655
+ <input type='radio' onclick='hideelement1("dropshop_option", this.value)' value='3' name='wpsc_options[cart_location]' id='cart3' <?php if(isset($cart3)) echo $cart3; ?> /> <label for='cart3'><?php echo __('Manual', 'wpsc');?> <span style='font-size: 7pt;'>(PHP code: &lt;?php echo nzshpcrt_shopping_basket(); ?&gt; )</span></label>
656
  <div style='display: <?php if (isset($cart5)) { echo "block"; } else { echo "none"; } ?>;' id='dropshop_option'>
657
  <p>
658
  <input type="radio" id="drop1" value="all" <?php if (get_option('dropshop_display') == 'all') { echo "checked='checked'"; } ?> name="wpsc_options[dropshop_display]" /><label for="drop1"><?php echo __('Show Dropshop on every page', 'wpsc');?></label>
wpsc-admin/includes/settings-pages/shipping.php CHANGED
@@ -3,8 +3,9 @@ function wpsc_options_shipping(){
3
  global $wpdb,$external_shipping_modules,$internal_shipping_modules;
4
 
5
  // sort into external and internal arrays.
6
- foreach($GLOBALS['wpsc_shipping_modules'] as $key => $module) {
7
- if($module->is_external == true) {
 
8
  $external_shipping_modules[$key] = $module;
9
  } else {
10
  $internal_shipping_modules[$key] = $module;
@@ -207,7 +208,9 @@ function selectgateway() {
207
  <?php
208
  foreach($internal_shipping_modules as $shipping) {
209
  // exit("<pre>".print_r($shipping,1)."</pre>");
210
- if (in_array($shipping->getInternalName(), (array)$selected_shippings)) { ?>
 
 
211
 
212
  <div class='wpsc_shipping_options'>
213
  <div class='wpsc-shipping-actions'>
@@ -224,10 +227,10 @@ function selectgateway() {
224
  <div class='wpsc_shipping_options'>
225
  <div class='wpsc-shipping-actions'>
226
  | <span class="edit">
227
- <a class='edit-shippping-module' onclick="event.preventDefault();" rel="<?php echo $shipping->internal_name; ?>" title="Edit this Shipping Module" href='<?php echo htmlspecialchars(add_query_arg('shipping_module', $shipping->internal_name)); ?>' style="cursor:pointer;">Edit</a>
228
  </span> |
229
  </div>
230
- <p><input name='custom_shipping_options[]' type='checkbox' value='<?php echo $shipping->internal_name; ?>' id='<?php echo $shipping->internal_name; ?>_id' /><label for='<?php echo $shipping->internal_name; ?>_id'><?php echo $shipping->name; ?></label></p>
231
  </div>
232
  <?php
233
  }
@@ -289,6 +292,10 @@ function selectgateway() {
289
  <td class='gateway_settings' rowspan='2'>
290
  <div class='postbox'>
291
  <?php
 
 
 
 
292
  $shipping_data = wpsc_get_shipping_form($_SESSION['previous_shipping_name']);
293
  ?>
294
  <h3 class='hndle'><?php echo $shipping_data['name']; ?></h3>
3
  global $wpdb,$external_shipping_modules,$internal_shipping_modules;
4
 
5
  // sort into external and internal arrays.
6
+ foreach($GLOBALS['wpsc_shipping_modules'] as $key => $module)
7
+ {
8
+ if(isset($module->is_external) && ($module->is_external == true)) {
9
  $external_shipping_modules[$key] = $module;
10
  } else {
11
  $internal_shipping_modules[$key] = $module;
208
  <?php
209
  foreach($internal_shipping_modules as $shipping) {
210
  // exit("<pre>".print_r($shipping,1)."</pre>");
211
+
212
+
213
+ if (is_object($shipping) && in_array($shipping->getInternalName(), (array)$selected_shippings)) { ?>
214
 
215
  <div class='wpsc_shipping_options'>
216
  <div class='wpsc-shipping-actions'>
227
  <div class='wpsc_shipping_options'>
228
  <div class='wpsc-shipping-actions'>
229
  | <span class="edit">
230
+ <a class='edit-shippping-module' onclick="event.preventDefault();" rel="<?php if(isset($shipping->internal_name)) echo $shipping->internal_name; ?>" title="Edit this Shipping Module" href='<?php if(isset($shipping->internal_name)) echo htmlspecialchars(add_query_arg('shipping_module', $shipping->internal_name)); ?>' style="cursor:pointer;">Edit</a>
231
  </span> |
232
  </div>
233
+ <p><input name='custom_shipping_options[]' type='checkbox' value='<?php if(isset($shipping->internal_name)) echo $shipping->internal_name; ?>' id='<?php if(isset($shipping->internal_name)) echo $shipping->internal_name; ?>_id' /><label for='<?php if(isset($shipping->internal_name)) echo $shipping->internal_name; ?>_id'><?php if(isset($shipping->internal_name)) echo $shipping->name; ?></label></p>
234
  </div>
235
  <?php
236
  }
292
  <td class='gateway_settings' rowspan='2'>
293
  <div class='postbox'>
294
  <?php
295
+
296
+ if(!isset($_SESSION['previous_shipping_name']))
297
+ $_SESSION['previous_shipping_name'] = "";
298
+
299
  $shipping_data = wpsc_get_shipping_form($_SESSION['previous_shipping_name']);
300
  ?>
301
  <h3 class='hndle'><?php echo $shipping_data['name']; ?></h3>
wpsc-admin/includes/updating-functions.php CHANGED
@@ -171,7 +171,7 @@ GROUP BY wp_wpsc_product_list.id", ARRAY_A);
171
  'post_author' => $user_ID,
172
  'post_date' => $product['date_added'],
173
  'post_content' => $product['description'],
174
- 'post_excerpt' => $post_data['additional_description'],
175
  'post_title' => $product['name'],
176
  'post_status' => $post_status,
177
  'post_type' => "wpsc-product",
@@ -202,7 +202,11 @@ GROUP BY wp_wpsc_product_list.id", ARRAY_A);
202
  $pm['meta_value'] = 1;
203
  break;
204
  default:
205
- $pm['meta_value'] = unserialize($pm['meta_value']);
 
 
 
 
206
  break;
207
  }
208
 
@@ -235,8 +239,9 @@ GROUP BY wp_wpsc_product_list.id", ARRAY_A);
235
 
236
  $post_data['_wpsc_product_metadata']['quantity_limited'] = (int)(bool)$product['quantity_limited'];
237
  $post_data['_wpsc_product_metadata']['special'] = (int)(bool)$product['special'];
238
-
239
- $post_data['_wpsc_product_metadata']['unpublish_when_none_left'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['unpublish_when_none_left'];
 
240
  /* $post_data['meta']['_wpsc_product_metadata']['notax'] = (int)(bool)$post_data['notax'];; */
241
  $post_data['_wpsc_product_metadata']['no_shipping'] = (int)(bool)$product['no_shipping'];
242
 
@@ -325,7 +330,7 @@ function wpec_update_gateway(&$value,$key) {
325
  }
326
  }
327
  function wpsc_convert_variation_combinations() {
328
- global $wpdb, $user_ID;
329
 
330
  // get the posts
331
  // I use a direct SQL query here because the get_posts function sometimes does not function for a reason that is not clear.
171
  'post_author' => $user_ID,
172
  'post_date' => $product['date_added'],
173
  'post_content' => $product['description'],
174
+ 'post_excerpt' => $product['additional_description'],
175
  'post_title' => $product['name'],
176
  'post_status' => $post_status,
177
  'post_type' => "wpsc-product",
202
  $pm['meta_value'] = 1;
203
  break;
204
  default:
205
+ if(is_serialized($pm['meta_value'])) {
206
+ $pm['meta_value'] = unserialize($pm['meta_value']);
207
+ } else {
208
+ $pm['meta_value'] = $pm['meta_value'];
209
+ }
210
  break;
211
  }
212
 
239
 
240
  $post_data['_wpsc_product_metadata']['quantity_limited'] = (int)(bool)$product['quantity_limited'];
241
  $post_data['_wpsc_product_metadata']['special'] = (int)(bool)$product['special'];
242
+ if(isset($post_data['meta'])) {
243
+ $post_data['_wpsc_product_metadata']['unpublish_when_none_left'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['unpublish_when_none_left'];
244
+ }
245
  /* $post_data['meta']['_wpsc_product_metadata']['notax'] = (int)(bool)$post_data['notax'];; */
246
  $post_data['_wpsc_product_metadata']['no_shipping'] = (int)(bool)$product['no_shipping'];
247
 
330
  }
331
  }
332
  function wpsc_convert_variation_combinations() {
333
+ global $wpdb, $user_ID, $current_version_number;
334
 
335
  // get the posts
336
  // I use a direct SQL query here because the get_posts function sometimes does not function for a reason that is not clear.
wpsc-admin/js/admin.js CHANGED
@@ -2,6 +2,23 @@
2
  var postboxes = function postboxes() {};
3
  jQuery(document).ready( function () {
4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  //JS - 5.12.2010 - Instead of modding functions, using JQuery to remove pricedisplay class from span.
6
  jQuery('td.sale_price span.pricedisplay').removeClass('pricedisplay').addClass('salespricedisplay');
7
 
@@ -176,7 +193,7 @@ jQuery(document).ready( function () {
176
  });
177
  });
178
  //new currency JS in admin product page
179
- jQuery('tr.new_layer').livequery(function(){
180
  jQuery(this).hide();
181
 
182
  });
@@ -184,11 +201,11 @@ jQuery(document).ready( function () {
184
  jQuery('a.wpsc_add_new_currency').livequery(function(){
185
  jQuery(this).click(function(event){
186
  if(firstclick == true){
187
- jQuery('tr.new_layer').show();
188
- html = jQuery('tr.new_layer').html();
189
  firstclick = false;
190
  }else{
191
- jQuery('tr.new_layer').after('<tr>'+html+'</tr>');
192
  }
193
  event.preventDefault();
194
  });
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
+ post_values = edit_var_val+'&description='+description+'&additional_description='+additional_description+'&name='+name+'&product_id='+product_id;
13
+
14
+ jQuery.post('index.php?wpsc_admin_action=wpsc_update_variations',post_values, function(returned_data){
15
+ var url = location.href;
16
+ jQuery('table#wpsc_product_list').fadeOut(500).load(url +' table#wpsc_product_list').fadeIn(500);
17
+ jQuery('img.loading').hide();
18
+ });
19
+ return false;
20
+
21
+ });
22
  //JS - 5.12.2010 - Instead of modding functions, using JQuery to remove pricedisplay class from span.
23
  jQuery('td.sale_price span.pricedisplay').removeClass('pricedisplay').addClass('salespricedisplay');
24
 
193
  });
194
  });
195
  //new currency JS in admin product page
196
+ jQuery('div.new_layer').livequery(function(){
197
  jQuery(this).hide();
198
 
199
  });
201
  jQuery('a.wpsc_add_new_currency').livequery(function(){
202
  jQuery(this).click(function(event){
203
  if(firstclick == true){
204
+ jQuery('div.new_layer').show();
205
+ html = jQuery('div.new_layer').html();
206
  firstclick = false;
207
  }else{
208
+ jQuery('div.new_layer').after('<div>'+html+'</div>');
209
  }
210
  event.preventDefault();
211
  });
wpsc-admin/js/variations.js CHANGED
@@ -32,6 +32,7 @@ jQuery('.variation_checkboxes').livequery(function(){
32
  break;
33
 
34
  case false:
 
35
  jQuery('div.variation', variation_set).hide();
36
  break;
37
 
32
  break;
33
 
34
  case false:
35
+ jQuery('div.variation input:checkbox', variation_set).attr('checked', false);
36
  jQuery('div.variation', variation_set).hide();
37
  break;
38
 
wpsc-includes/ajax.functions.php CHANGED
@@ -8,492 +8,493 @@
8
  * @since 3.7
9
  */
10
  function wpsc_special_widget(){
11
- global $wpdb;
12
- wpsc_add_to_cart();
13
- //exit();
14
  }
15
-
16
- if($_REQUEST['wpsc_ajax_action'] == 'special_widget' || $_REQUEST['wpsc_ajax_action'] == 'donations_widget') {
17
- add_action('init', 'wpsc_special_widget');
18
  }
19
 
20
 
21
  // function wpsc_api_key_finder(){
22
- // global $wpdb;
23
- // $transactid = $wpdb->escape($_POST['wpsc_transaction_id']);
24
- // $sql = 'SELECT `id` FROM `'.WPSC_TABLE_PURCHASE_LOGS.'` WHERE `transactid`='.$transactid;
25
- // $id = $wpdb->get_var($sql);
26
- // $sql = 'SELECT `name`, `key`, `first_name` FROM `'.$wpdb->prefix.'api_keys` WHERE `purchase_id`='.$id;
27
- // $api_info = $wpdb->get_results($sql);
28
- // $_SESSION['api_info'] = $api_info;
29
- // //exit('ID<pre>'.print_r($id, true).'</pre>');
30
- // exit();
31
  // }
32
- //
33
  // if($_REQUEST['wpsc_ajax_action'] == 'api_key_finder') {
34
- // add_action('init', 'wpsc_api_key_finder');
35
  // }
36
 
37
  /**
38
- * add_to_cart function, used through ajax and in normal page loading.
39
- * No parameters, returns nothing
40
  */
41
  function wpsc_add_to_cart() {
42
- global $wpdb, $wpsc_cart, $wpsc_theme_path;
43
- /// default values
44
- $default_parameters['variation_values'] = null;
45
- $default_parameters['quantity'] = 1;
46
- $default_parameters['provided_price'] = null;
47
- $default_parameters['comment'] =null;
48
- $default_parameters['time_requested']= null;
49
- $default_parameters['custom_message'] = null;
50
- $default_parameters['file_data'] = null;
51
- $default_parameters['is_customisable'] = false;
52
- $default_parameters['meta'] = null;
53
-
54
-
55
- /// sanitise submitted values
56
- $product_id = (int)$_POST['product_id'];
57
- foreach((array)$_POST['variation'] as $key => $variation) {
58
- $provided_parameters['variation_values'][(int)$key] = (int)$variation;
59
- }
60
- if(count($provided_parameters['variation_values']) > 0) {
61
- $variation_product_id = wpsc_get_child_object_in_terms($product_id, $provided_parameters['variation_values'],'wpsc-variation');
62
- if($variation_product_id > 0) {
63
- $product_id = $variation_product_id;
64
- }
65
- }
66
-
67
-
68
-
69
- if($_POST['quantity'] > 0 && (!isset($_POST['wpsc_quantity_update']))) {
70
- $provided_parameters['quantity'] = (int)$_POST['quantity'];
71
- } else if (isset($_POST['wpsc_quantity_update'])) {
72
- $wpsc_cart->remove_item($_POST['key']);
73
- $provided_parameters['quantity'] = (int)$_POST['wpsc_quantity_update'];
74
- }
75
- // exit('<pre>'.print_r($_POST, true).'</pre>');
76
- if($_POST['is_customisable'] == 'true') {
77
- $provided_parameters['is_customisable'] = true;
78
-
79
- if(isset($_POST['custom_text'])) {
80
- $provided_parameters['custom_message'] = $_POST['custom_text'];
81
- }
82
- if(isset($_FILES['custom_file'])) {
83
- $provided_parameters['file_data'] = $_FILES['custom_file'];
84
- }
85
- }
86
- if(((float)$_POST['donation_price'] > 0)) {
87
- $provided_parameters['provided_price'] = (float)$_POST['donation_price'];
88
- }
89
- //exit();
90
- $parameters = array_merge($default_parameters, (array)$provided_parameters);
91
- //echo "/*\n\r".print_r($parameters,true)."*/\n\r";
92
- $state = $wpsc_cart->set_item($product_id,$parameters);
93
-
94
- $product = get_post($product_id);
95
-
96
- if($state == true) {
97
- $cart_messages[] = str_replace("[product_name]", stripslashes($product->post_title), __('You just added "[product_name]" to your cart.', 'wpsc'));
98
- } else {
99
- if($parameters['quantity'] <= 0) {
100
- $cart_messages[] = __('Sorry, but you cannot add zero items to your cart', 'wpsc');
101
- } else if($wpsc_cart->get_remaining_quantity($product_id,$parameters['variation_values'], $parameters['quantity']) > 0) {
102
- $cart_messages[] = str_replace("[number]", $wpsc_cart->get_remaining_quantity($product_id,$parameters['variation_values'], $parameters['quantity']), __('Sorry, but there are only [number] of this item in stock.', 'wpsc'));
103
- } else {
104
- $cart_messages[] = str_replace("[product_name]", $product['name'], __('Sorry, but the item "[product_name]" is out of stock.', 'wpsc'));
105
- }
106
- }
107
-
108
- if($_GET['ajax'] == 'true') {
109
- if(($product_id != null) &&(get_option('fancy_notifications') == 1)) {
110
- echo "if(jQuery('#fancy_notification_content')) {\n\r";
111
- echo " jQuery('#fancy_notification_content').html(\"".str_replace(array("\n","\r") , array('\n','\r'), addslashes(fancy_notification_content($cart_messages))). "\");\n\r";
112
- echo " jQuery('#loading_animation').css('display', 'none');\n\r";
113
- echo " jQuery('#fancy_notification_content').css('display', 'block');\n\r";
114
- echo "}\n\r";
115
- $error_messages = array();
116
- }
117
-
118
- ob_start();
119
- $cur_wpsc_theme_folder = apply_filters('wpsc_theme_folder',$wpsc_theme_path.WPSC_THEME_DIR);
120
- include_once($cur_wpsc_theme_folder."/cart_widget.php");
121
- $output = ob_get_contents();
122
- ob_end_clean();
123
- $output = str_replace(Array("\n","\r") , Array("\\n","\\r"),addslashes($output));
124
- echo "jQuery('div.shopping-cart-wrapper').html('$output');\n";
125
-
126
-
127
- if(get_option('show_sliding_cart') == 1) {
128
- if((wpsc_cart_item_count() > 0) || (count($cart_messages) > 0)) {
129
- $_SESSION['slider_state'] = 1;
130
- echo "
131
- jQuery('#sliding_cart').slideDown('fast',function(){
132
- jQuery('#fancy_collapser').attr('src', (WPSC_URL+'/images/minus.png'));
133
- });
134
- ";
135
-
136
- } else {
137
- $_SESSION['slider_state'] = 0;
138
- echo "
139
- jQuery('#sliding_cart').slideUp('fast',function(){
140
- jQuery('#fancy_collapser').attr('src', (WPSC_URL+'/images/plus.png'));
141
- });
142
- ";
143
- }
144
- }
145
-
146
- do_action('wpsc_alternate_cart_html', $cart_messages);
147
- exit();
148
- }
149
  }
150
  // execute on POST and GET
151
- if($_REQUEST['wpsc_ajax_action'] == 'add_to_cart') {
152
- add_action('init', 'wpsc_add_to_cart');
153
  }
154
 
155
 
156
  function wpsc_get_cart() {
157
- global $wpdb, $wpsc_cart, $wpsc_theme_path;
158
- ob_start();
159
- $cur_wpsc_theme_folder = apply_filters('wpsc_theme_folder',$wpsc_theme_path.WPSC_THEME_DIR);
160
- include_once($cur_wpsc_theme_folder."/cart_widget.php");
161
- $output = ob_get_contents();
162
- ob_end_clean();
163
- $output = str_replace(Array("\n","\r") , Array("\\n","\\r"),addslashes($output));
164
- echo "jQuery('div.shopping-cart-wrapper').html('$output');\n";
165
-
166
-
167
- if(get_option('show_sliding_cart') == 1) {
168
- if((wpsc_cart_item_count() > 0) || (count($cart_messages) > 0)) {
169
- $_SESSION['slider_state'] = 1;
170
- echo "
171
- jQuery('#sliding_cart').slideDown('fast',function(){
172
- jQuery('#fancy_collapser').attr('src', (WPSC_URL+'/images/minus.png'));
173
- });
174
- ";
175
-
176
- } else {
177
- $_SESSION['slider_state'] = 0;
178
- echo "
179
- jQuery('#sliding_cart').slideUp('fast',function(){
180
- jQuery('#fancy_collapser').attr('src', (WPSC_URL+'/images/plus.png'));
181
- });
182
- ";
183
- }
184
- }
185
-
186
-
187
- do_action('wpsc_alternate_cart_html', '');
188
- exit();
189
  }
190
 
191
- if($_REQUEST['wpsc_ajax_action'] == 'get_cart') {
192
- add_action('init', 'wpsc_get_cart');
193
  }
194
 
195
 
196
  /**
197
- * empty cart function, used through ajax and in normal page loading.
198
- * No parameters, returns nothing
199
  */
200
  function wpsc_empty_cart() {
201
- global $wpdb, $wpsc_cart, $wpsc_theme_path;
202
- $wpsc_cart->empty_cart(false);
203
-
204
- if($_REQUEST['ajax'] == 'true') {
205
- ob_start();
206
- $cur_wpsc_theme_folder = apply_filters('wpsc_theme_folder',$wpsc_theme_path.WPSC_THEME_DIR);
207
- include_once($cur_wpsc_theme_folder."/cart_widget.php");
208
-
209
- $output = ob_get_contents();
210
- ob_end_clean();
211
- $output = str_replace(Array("\n","\r") , Array("\\n","\\r"),addslashes($output));
212
- echo "jQuery('div.shopping-cart-wrapper').html('$output');";
213
- do_action('wpsc_alternate_cart_html');
214
-
215
- if(get_option('show_sliding_cart') == 1) {
216
- $_SESSION['slider_state'] = 0;
217
- echo "
218
- jQuery('#sliding_cart').slideUp('fast',function(){
219
- jQuery('#fancy_collapser').attr('src', (WPSC_URL+'/images/plus.png'));
220
- });
221
- ";
222
- }
223
- exit();
224
- }
225
-
226
- // this if statement is needed, as this function also runs on returning from the gateway
227
- if($_REQUEST['wpsc_ajax_action'] == 'empty_cart') {
228
- wp_redirect(remove_query_arg(array('wpsc_ajax_action','ajax')));
229
- exit();
230
- }
231
  }
232
 
233
 
234
  // execute on POST and GET
235
- if(($_REQUEST['wpsc_ajax_action'] == 'empty_cart') || ($_GET['sessionid'] > 0)) {
236
- add_action('init', 'wpsc_empty_cart');
237
  }
238
 
239
 
240
  /**
241
- * coupons price, used through ajax and in normal page loading.
242
- * No parameters, returns nothing
243
  */
244
  function wpsc_coupon_price($currCoupon = '') {
245
- global $wpdb, $wpsc_cart, $wpsc_coupons;
246
- if(isset($_POST['coupon_num']) && $_POST['coupon_num'] != ''){
247
- $coupon = $wpdb->escape($_POST['coupon_num']);
248
- $_SESSION['coupon_numbers'] = $coupon;
249
- $wpsc_coupons = new wpsc_coupons($coupon);
250
-
251
- if ($wpsc_coupons->validate_coupon()){
252
- $discountAmount = $wpsc_coupons->calculate_discount();
253
- $wpsc_cart->apply_coupons($discountAmount, $coupon);
254
- $wpsc_coupons->errormsg = false;
255
- } else {
256
- $wpsc_coupons->errormsg = true;
257
- $wpsc_cart->coupons_amount = 0;
258
- $wpsc_cart->coupons_name = '';
259
- }
260
-
261
- } else if ($_POST['coupon_num'] == '' && $currCoupon == ''){
262
- $wpsc_cart->coupons_amount = 0;
263
- $wpsc_cart->coupons_name = '';
264
- } else if ($currCoupon != '') {
265
- $coupon = $wpdb->escape($currCoupon);
266
- $_SESSION['coupon_numbers'] = $coupon;
267
- $wpsc_coupons = new wpsc_coupons($coupon);
268
-
269
- if($wpsc_coupons->validate_coupon()){
270
-
271
- $discountAmount = $wpsc_coupons->calculate_discount();
272
- $wpsc_cart->apply_coupons($discountAmount, $coupon);
273
- $wpsc_coupons->errormsg = false;
274
- }
275
- }
276
-
277
-
278
  }
279
  // execute on POST and GET
280
  if(isset($_POST['coupon_num'])) {
281
- add_action('init', 'wpsc_coupon_price');
282
  }
283
 
284
 
285
  /**
286
- * update quantity function, used through ajax and in normal page loading.
287
- * No parameters, returns nothing
288
  */
289
  function wpsc_update_item_quantity() {
290
- global $wpdb, $wpsc_cart, $wpsc_theme_path;
291
-
292
- if(is_numeric($_POST['key'])) {
293
- $key = (int)$_POST['key'];
294
- if($_POST['quantity'] > 0) {
295
- // if the quantity is greater than 0, update the item;
296
- $parameters['quantity'] = (int)$_POST['quantity'];
297
- $wpsc_cart->edit_item($key, $parameters);
298
- } else {
299
- // if the quantity is 0, remove the item.
300
- $wpsc_cart->remove_item($key);
301
- }
302
- wpsc_coupon_price($_SESSION['coupon_numbers']);
303
- }
304
-
305
  if($_REQUEST['ajax'] == 'true') {
306
- ob_start();
307
- $cur_wpsc_theme_folder = apply_filters('wpsc_theme_folder',$wpsc_theme_path.WPSC_THEME_DIR);
308
- include_once($cur_wpsc_theme_folder."/cart_widget.php");
309
- $output = ob_get_contents();
310
- ob_end_clean();
311
- $output = str_replace(Array("\n","\r") , Array("\\n","\\r"),addslashes($output));
312
-
313
- echo "jQuery('div.shopping-cart-wrapper').html('$output');\n";
314
- do_action('wpsc_alternate_cart_html');
315
-
316
-
317
- exit();
318
  }
319
-
320
  }
321
-
322
  // execute on POST and GET
323
- if($_REQUEST['wpsc_update_quantity'] == 'true') {
324
- add_action('init', 'wpsc_update_item_quantity');
325
  }
326
 
327
 
328
 
329
  function wpsc_update_product_rating() {
330
- global $wpdb;
331
- //exit("<pre>".print_r($_POST, true)."</pre>");
332
- $nowtime = time();
333
- $product_id = absint($_POST['product_id']);
334
- $ip_number = $wpdb->escape($_SERVER['REMOTE_ADDR']);
335
- $rating = absint($_POST['product_rating']);
336
-
337
- $cookie_data = explode(",",$_COOKIE['voting_cookie'][$product_id]);
338
-
339
- if(is_numeric($cookie_data[0]) && ($cookie_data[0] > 0)) {
340
- $vote_id = absint($cookie_data[0]);
341
- $wpdb->query("UPDATE `".WPSC_TABLE_PRODUCT_RATING."` SET `rated` = '".$rating."' WHERE `id` ='".$vote_id."' LIMIT 1 ;");
342
- } else {
343
- $wpdb->query("INSERT INTO `".WPSC_TABLE_PRODUCT_RATING."` ( `ipnum` , `productid` , `rated`, `time`) VALUES ( '".$ip_number."', '".$product_id."', '".$rating."', '".$nowtime."');");
344
-
345
- $data = $wpdb->get_results("SELECT `id`,`rated` FROM `".WPSC_TABLE_PRODUCT_RATING."` WHERE `ipnum`='".$ip_number."' AND `productid` = '".$product_id."' AND `rated` = '".$rating."' AND `time` = '".$nowtime."' ORDER BY `id` DESC LIMIT 1",ARRAY_A) ;
346
-
347
- $vote_id = $data[0]['id'];
348
- setcookie("voting_cookie[$prodid]", ($vote_id.",".$rating),time()+(60*60*24*360));
349
- }
350
- if($_POST['ajax'] == 'true') {
351
-
352
- exit();
353
- }
354
  }
355
-
356
  // execute on POST and GET
357
- if($_REQUEST['wpsc_ajax_action'] == 'rate_product') {
358
- add_action('init', 'wpsc_update_product_rating');
359
  }
360
 
361
 
362
  /**
363
- * update_shipping_price function, used through ajax and in normal page loading.
364
- * No parameters, returns nothing
365
  */
366
  function wpsc_update_shipping_price() {
367
- global $wpdb, $wpsc_cart;
368
- $quote_shipping_method = $_POST['key1'];
369
- $quote_shipping_option = $_POST['key'];
370
- $wpsc_cart->update_shipping($quote_shipping_method, $quote_shipping_option);
371
- echo "jQuery('.pricedisplay.checkout-shipping').html('".wpsc_cart_shipping()."');\n\r";
372
- echo "jQuery('.pricedisplay.checkout-total').html('".wpsc_cart_total()."');\n\r";
373
- exit();
374
  }
375
  // execute on POST and GET
376
- if($_REQUEST['wpsc_ajax_action'] == 'update_shipping_price') {
377
- add_action('init', 'wpsc_update_shipping_price');
378
  }
379
 
380
 
381
  /**
382
- * update_shipping_price function, used through ajax and in normal page loading.
383
- * No parameters, returns nothing
384
  */
385
  function wpsc_get_rating_count() {
386
- global $wpdb, $wpsc_cart;
387
- $prodid = $_POST['product_id'];
388
- $data = $wpdb->get_results("SELECT COUNT(*) AS `count` FROM `".WPSC_TABLE_PRODUCT_RATING."` WHERE `productid` = '".$prodid."'",ARRAY_A) ;
389
- echo $data[0]['count'].",".$prodid;
390
- exit();
391
  }
392
  // execute on POST and GET
393
- if(($_REQUEST['get_rating_count'] == 'true') && is_numeric($_POST['product_id'])) {
394
- add_action('init', 'wpsc_get_rating_count');
395
  }
396
 
397
 
398
  /**
399
- * update_product_page_price function, used through ajax with variations
400
- * No parameters, returns nothing
401
  */
402
  function wpsc_update_product_price() {
403
- global $wpdb, $wpsc_cart;
404
- foreach((array)$_POST['variation'] as $variation) {
405
- if(is_numeric($variation)) {
406
- $variations[] = (int)$variation;
407
- }
408
- }
409
- $pm=$_POST['pm'];
410
- echo "product_id=".(int)$_POST['product_id'].";\n";
411
-
412
-
413
- echo "old_price=\"".nzshpcrt_currency_display(wpsc_calculate_price( (int) $_POST['product_id'], $variations), $notax, true)."\";\n";
414
- echo "numeric_old_price=\"".number_format(wpsc_calculate_price( (int) $_POST['product_id'], $variations), 2)."\";\n";
415
-
416
- echo "price=\"".nzshpcrt_currency_display(wpsc_calculate_price( (int) $_POST['product_id'], $variations, true), $notax, true)."\";\n";
417
- echo "numeric_price=\"".number_format(wpsc_calculate_price( (int) $_POST['product_id'], $variations, true), 2)."\";\n";
418
- exit();
419
  }
420
  // execute on POST and GET
421
- if(($_REQUEST['update_product_price'] == 'true') && is_numeric($_POST['product_id'])) {
422
- add_action('init', 'wpsc_update_product_price');
423
  }
424
 
425
 
426
 
427
  /**
428
- * update location function, used through ajax and in normal page loading.
429
- * No parameters, returns nothing
430
  */
431
  function wpsc_update_location() {
432
- global $wpdb, $wpsc_cart;
433
- if($_POST['country'] != null) {
434
- $_SESSION['wpsc_delivery_country'] = $_POST['country'];
435
- if($_SESSION['wpsc_selected_country'] == null) {
436
- $_SESSION['wpsc_selected_country'] = $_POST['country'];
437
- }
438
- if($_POST['region'] != null) {
439
- $_SESSION['wpsc_delivery_region'] = $_POST['region'];
440
- if($_SESSION['wpsc_selected_region'] == null) {
441
- $_SESSION['wpsc_selected_region'] = $_POST['region'];
442
- }
443
- } else if($_SESSION['wpsc_selected_region'] == '') {
444
- $_SESSION['wpsc_delivery_region'] = get_option('base_region');
445
- $_SESSION['wpsc_selected_region'] = get_option('base_region');
446
- }
447
-
448
- if($_SESSION['wpsc_delivery_region'] == '') {
449
- $_SESSION['wpsc_delivery_region'] = $_SESSION['wpsc_selected_region'];
450
- }
451
- }
452
-
453
- if($_POST['zipcode'] != '') {
454
- $_SESSION['wpsc_zipcode'] = $_POST['zipcode'];
455
- }
456
-
457
- $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($_SESSION['wpsc_delivery_country'])."')");
458
- if($delivery_region_count < 1) {
459
- $_SESSION['wpsc_delivery_region'] = null;
460
- }
461
-
462
- $selected_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($_SESSION['wpsc_selected_country'])."')");
463
- if($selected_region_count < 1) {
464
- $_SESSION['wpsc_selected_region'] = null;
465
- }
466
-
467
- $wpsc_cart->update_location();
468
- $wpsc_cart->get_shipping_method();
469
- $wpsc_cart->get_shipping_option();
470
- //echo $wpsc_cart->shipping_method;
471
- if($wpsc_cart->selected_shipping_method != '') {
472
- $wpsc_cart->update_shipping($wpsc_cart->selected_shipping_method, $wpsc_cart->selected_shipping_option);
473
- }
474
- //echo "<pre>".print_r($wpsc_cart, true)."</pre>";
475
- //exit();
476
- if($_GET['ajax'] == 'true') {
477
- exit();
478
- }
 
479
  }
480
-
481
  // execute on POST and GET
482
- if($_REQUEST['wpsc_ajax_actions'] == 'update_location') {
483
- add_action('init', 'wpsc_update_location');
484
  }
485
 
486
 
487
 
488
 
489
  function wpsc_cart_html_page() {
490
- require_once(WPSC_FILE_PATH."/wpsc-includes/shopping_cart_container.php");
491
- exit();
492
  }
493
 
494
  // execute on POST and GET
495
- if($_REQUEST['wpsc_action'] == 'cart_html_page') {
496
- add_action('init', 'wpsc_cart_html_page', 110);
497
  }
498
 
499
 
@@ -502,387 +503,398 @@ if($_REQUEST['wpsc_action'] == 'cart_html_page') {
502
 
503
 
504
  /**
505
- * submit checkout function, used through ajax and in normal page loading.
506
- * No parameters, returns nothing
507
  */
508
  function wpsc_submit_checkout() {
509
- global $wpdb, $wpsc_cart, $user_ID,$nzshpcrt_gateways, $wpsc_shipping_modules, $wpsc_gateways;
510
- //echo "break redirect";
511
- $_SESSION['wpsc_checkout_misc_error_messages'] = array();
512
- $wpsc_checkout = new wpsc_checkout();
513
- //exit('coupons:'.$wpsc_cart->coupons_name);
514
- $selected_gateways = get_option('custom_gateway_options');
515
- $submitted_gateway = $_POST['custom_gateway'];
516
-
517
- $options = get_option('custom_shipping_options');
518
- $form_validity = $wpsc_checkout->validate_forms();
519
-
520
- // exit('2<pre>'.print_r($_SESSION['wpsc_zipcode'], true).'</pre>');
521
- extract($form_validity); // extracts $is_valid and $error_messages
522
- // exit('<pre>'.print_r($results, true).'</pre>');
523
- //print('<pre>'.print_r(array((int)$is_valid), true).'</pre>');
524
- if (get_option('do_not_use_shipping') == 0 && ($wpsc_cart->selected_shipping_method == null || $wpsc_cart->selected_shipping_option == null)) {
525
- $_SESSION['wpsc_checkout_misc_error_messages'][] = __('You must select a shipping method, otherwise we cannot process your order.', 'wpsc');
526
- $is_valid = false;
527
- }
528
-
529
- if($_POST['agree'] != 'yes') {
530
- $_SESSION['wpsc_checkout_misc_error_messages'][] = __('Please agree to the terms and conditions, otherwise we cannot process your order.', 'wpsc');
531
- $is_valid = false;
532
- }
533
-
534
-
535
- //exit('<pre>'.print_r($_POST, true).'</pre>');
536
-
537
- $selectedCountry = $wpdb->get_results("SELECT id, country FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE isocode='".$wpdb->escape($_SESSION['wpsc_delivery_country'])."'", ARRAY_A);
538
-
539
- // exit('valid >'.$is_valid.'\r\n'.$_SESSION['wpsc_delivery_country']);
540
-
541
- foreach($wpsc_cart->cart_items as $cartitem){
542
- // exit('<pre>'.print_r($cartitem, true).'</pre>');
543
- $categoriesIDs = $wpdb->get_col("SELECT category_id FROM `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."` WHERE product_id=".$cartitem->product_id);
544
-
545
- foreach((array)$categoriesIDs as $catid){
546
- if(is_array($catid)){
547
- $sql ="SELECT `countryid` FROM `".WPSC_TABLE_CATEGORY_TM."` WHERE `visible`=0 AND `categoryid`=".$catid[0];
548
- }else{
549
- $sql ="SELECT `countryid` FROM `".WPSC_TABLE_CATEGORY_TM."` WHERE `visible`=0 AND `categoryid`=".$catid;
550
- }
551
- $countries = $wpdb->get_col($sql);
552
- if(in_array($selectedCountry[0]['id'], (array)$countries)){
553
- $errormessage =sprintf(__('Oops the product : %s cannot be shipped to %s. To continue with your transaction please remove this product from the list above.', 'wpsc'), $cartitem->product_name, $selectedCountry[0]['country']);
554
- $_SESSION['categoryAndShippingCountryConflict']= $errormessage;
555
- $is_valid = false;
556
- }
557
- }
558
- //count number of items, and number of items using shipping
559
- $num_items ++;
560
- if($cartitem->uses_shipping != 1){
561
- $disregard_shipping ++;
562
- }else{
563
- $use_shipping ++;
564
- }
565
- }
566
-
567
- // exit('valid >'.$is_valid);
568
- //print('<pre>'.print_r($_SESSION['wpsc_gateway_error_messages'], true).'</pre>');
569
- //print('<pre>'.print_r($_SESSION['wpsc_checkout_error_messages'], true).'</pre>');
570
- //print('<pre>'.print_r(array((int)$is_valid), true).'</pre>');
571
- if(array_search($submitted_gateway,$selected_gateways) !== false) {
572
- $_SESSION['wpsc_previous_selected_gateway'] = $submitted_gateway;
573
- } else {
574
- $is_valid = false;
575
- }
576
-
577
-
578
- if((get_option('do_not_use_shipping') != 1) && (in_array('ups', (array)$options)) && $_SESSION['wpsc_zipcode'] == '') {
579
- //exit('Not being called');
580
- if($num_items != $disregard_shipping){ //<-- new line of code
581
- $_SESSION['categoryAndShippingCountryConflict'] = __('Please enter a Zipcode and click calculate to proceed');
582
- $is_valid = false;
583
- }
584
- }
585
-
586
-
587
- // print('<pre>'.print_r(array((int)$is_valid), true).'</pre>');
588
- if($is_valid == true || $_GET['gateway'] == 'noca') {
589
- $_SESSION['categoryAndShippingCountryConflict']= '';
590
- // check that the submitted gateway is in the list of selected ones
591
- $sessionid = (mt_rand(100,999).time());
592
- $_SESSION['wpsc_sessionid'] = $sessionid;
593
- $subtotal = $wpsc_cart->calculate_subtotal();
594
- if($wpsc_cart->has_total_shipping_discount() == false ) {
595
- $base_shipping= $wpsc_cart->calculate_base_shipping();
596
-
597
- } else {
598
- $base_shipping = 0;
599
-
600
- }
601
- if(wpsc_uses_shipping()){
602
- $shipping_method = $wpsc_cart->selected_shipping_method;
603
- $shipping_option = $wpsc_cart->selected_shipping_option;
604
- $delivery_country = $wpsc_cart->delivery_country;
605
- $delivery_region = $wpsc_cart->delivery_region;
606
- }else{
607
- $shipping_method = '';
608
- $shipping_option = '';
609
- $delivery_country = '';
610
- $delivery_region = '';
611
-
612
- }
613
- if(isset($_POST['how_find_us'])){
614
- $find_us = $_POST['how_find_us'];
615
- }else{
616
- $find_us = '';
617
- }
618
-
619
- $tax = $wpsc_cart->calculate_total_tax();
620
- $total = $wpsc_cart->calculate_total_price();
621
- $sql = "INSERT INTO `".WPSC_TABLE_PURCHASE_LOGS."` (`totalprice`,`statusno`, `sessionid`, `user_ID`, `date`, `gateway`, `billing_country`,`shipping_country`, `billing_region`, `shipping_region`, `base_shipping`,`shipping_method`, `shipping_option`, `plugin_version`, `discount_value`, `discount_data`,`find_us`) VALUES ('$total' ,'0', '{$sessionid}', '".(int)$user_ID."', UNIX_TIMESTAMP(), '{$submitted_gateway}', '{$wpsc_cart->selected_country}', '{$delivery_country}','{$wpsc_cart->selected_region}', '{$delivery_region}', '{$base_shipping}', '{$shipping_method}', '{$shipping_option}', '".WPSC_VERSION."', '{$wpsc_cart->coupons_amount}','{$wpsc_cart->coupons_name}', '{$find_us}')";
622
-
623
-
624
- $wpdb->query($sql);
625
-
626
- $purchase_log_id = $wpdb->get_var("SELECT `id` FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `sessionid` IN('{$sessionid}') LIMIT 1") ;
627
- //exit('PurchLog id'.$purchase_log_id);
628
- $wpsc_checkout->save_forms_to_db($purchase_log_id);
629
- $wpsc_cart->save_to_db($purchase_log_id);
630
- $wpsc_cart->submit_stock_claims($purchase_log_id);
631
-
632
- if(get_option('wpsc_also_bought') == 1) {
633
- wpsc_populate_also_bought_list();
634
- }
635
-
636
- do_action('wpsc_submit_checkout', array("purchase_log_id" => $purchase_log_id, "our_user_id" => $our_user_id));
637
-
638
- if(get_option('permalink_structure') != '') {
639
- $seperator = "?";
640
- } else {
641
- $seperator = "&";
642
- }
643
-
644
-
645
-
646
- /// submit to gateway
647
- print_r($current_gateway_data);
648
- $current_gateway_data = &$wpsc_gateways[$submitted_gateway];
649
- if($current_gateway_data['api_version'] >= 2.0) {
650
- $merchant_instance = new $current_gateway_data['class_name']($purchase_log_id);
651
- $merchant_instance->construct_value_array();
652
- $merchant_instance->submit();
653
- // print_r($merchant_instance);
654
-
655
- } else {
656
- if(($current_gateway_data['internalname'] == $submitted_gateway) && ($current_gateway_data['internalname'] != 'google')) {
657
- $gateway_used = $current_gateway_data['internalname'];
658
- $wpdb->query("UPDATE `".WPSC_TABLE_PURCHASE_LOGS."` SET `gateway` = '".$gateway_used."' WHERE `id` = '".$log_id."' LIMIT 1 ;");
659
- $current_gateway_data['function']($seperator, $sessionid);
660
- //break;
661
- } else if (($current_gateway_data['internalname'] == 'google') && ($current_gateway_data['internalname'] == $submitted_gateway)){
662
- $gateway_used = $current_gateway_data['internalname'];
663
- $wpdb->query("UPDATE `".WPSC_TABLE_PURCHASE_LOGS."` SET `gateway` = '".$gateway_used."' WHERE `id` = '".$log_id."' LIMIT 1 ;");
664
- $_SESSION['gateway'] = 'google';
665
- header('Location: '.get_option('shopping_cart_url'));
666
- //break;
667
- }
668
- }
669
-
670
- if(isset($_GET['gateway']) && $_GET['gateway'] == 'noca'){
671
- echo transaction_results($sessionid, true);
672
- }else{
673
- }
 
 
 
 
 
 
 
 
 
 
 
674
  } else {
675
-
676
- }
677
  }
678
 
679
  // execute on POST and GET
680
- if($_REQUEST['wpsc_action'] == 'submit_checkout') {
681
- add_action('init', 'wpsc_submit_checkout');
682
  }
683
 
684
- if($_REQUEST['wpsc_action'] == 'gateway_notification') {
685
- add_action('init', 'wpsc_gateway_notification');
686
  }
687
 
688
 
689
  function wpsc_product_rss() {
690
- global $wpsc_query, $wpdb;
691
- header("Content-Type: application/xml; charset=UTF-8");
692
- header('Content-Disposition: inline; filename="E-Commerce_Product_List.rss"');
693
- //echo "<pre>".print_r($wpsc_query,true)."</pre>";
694
- require_once(WPSC_FILE_PATH.'/wpsc-includes/rss_template.php');
695
- exit();
696
  }
697
 
698
 
699
- if($_REQUEST['wpsc_action'] == "rss") {
700
- add_action('template_redirect', 'wpsc_product_rss', 80);
701
  }
702
 
703
 
704
 
705
  function wpsc_gateway_notification() {
706
- global $wpdb, $wpsc_gateways;
707
- $gateway_name = $_GET['gateway'];
708
- // work out what gateway we are getting the request from, run the appropriate code.
709
- if(($gateway_name != null) && isset($wpsc_gateways[$gateway_name]['class_name'])) {
710
- $merchant_class = $wpsc_gateways[$gateway_name]['class_name'];
711
- $merchant_instance = new $merchant_class(null, true);
712
- $merchant_instance->process_gateway_notification();
713
- }
714
- exit();
715
  }
716
 
717
  // execute on POST and GET
718
- if($_REQUEST['wpsc_action'] == 'gateway_notification') {
719
- add_action('init', 'wpsc_gateway_notification');
720
  }
721
 
722
- if($_GET['termsandconds'] === 'true'){
723
- echo wpautop(stripslashes(get_option('terms_and_conditions')));
724
- exit();
725
  }
726
 
727
 
728
 
729
  /**
730
- * wpsc_change_tax function, used through ajax and in normal page loading.
731
- * No parameters, returns nothing
732
  */
733
  function wpsc_change_tax() {
734
- global $wpdb, $wpsc_cart, $wpsc_theme_path;
735
- $form_id = absint($_POST['form_id']);
736
-
737
- $wpsc_selected_country = $wpsc_cart->selected_country;
738
- $wpsc_selected_region = $wpsc_cart->selected_region;
739
-
740
- $wpsc_delivery_country = $wpsc_cart->delivery_country;
741
- $wpsc_delivery_region = $wpsc_cart->delivery_region;
742
-
743
-
744
- $previous_country = $_SESSION['wpsc_selected_country'];
745
- if(isset($_POST['billing_country'])){
746
- $wpsc_selected_country = $wpdb->escape($_POST['billing_country']);
747
- $_SESSION['wpsc_selected_country'] = $wpsc_selected_country;
748
- }
749
-
750
- if(isset($_POST['billing_region'])){
751
- $wpsc_selected_region = absint($_POST['billing_region']);
752
- $_SESSION['wpsc_selected_region'] = $wpsc_selected_region;
753
- }
754
-
755
- $check_country_code = $wpdb->get_var(" SELECT `country`.`isocode` FROM `".WPSC_TABLE_REGION_TAX."` AS `region` INNER JOIN `".WPSC_TABLE_CURRENCY_LIST."` AS `country` ON `region`.`country_id` = `country`.`id` WHERE `region`.`id` = '".$_SESSION['wpsc_selected_region']."' LIMIT 1");
756
-
757
- if($_SESSION['wpsc_selected_country'] != $check_country_code) {
758
- $wpsc_selected_region = null;
759
- }
760
-
761
- if(isset($_POST['shipping_country'])){
762
- $wpsc_delivery_country = $wpdb->escape($_POST['shipping_country']);
763
- $_SESSION['wpsc_delivery_country'] = $wpsc_delivery_country;
764
- }
765
- if(isset($_POST['shipping_region'])){
766
- $wpsc_delivery_region = absint($_POST['shipping_region']);
767
- $_SESSION['wpsc_delivery_region'] = $wpsc_delivery_region;
768
- }
769
-
770
- $check_country_code = $wpdb->get_var(" SELECT `country`.`isocode` FROM `".WPSC_TABLE_REGION_TAX."` AS `region` INNER JOIN `".WPSC_TABLE_CURRENCY_LIST."` AS `country` ON `region`.`country_id` = `country`.`id` WHERE `region`.`id` = '".$wpsc_delivery_region."' LIMIT 1");
771
-
772
- if($wpsc_delivery_country != $check_country_code) {
773
- $wpsc_delivery_region = null;
774
- }
775
-
776
-
777
- $wpsc_cart->update_location();
778
- $wpsc_cart->get_shipping_method();
779
- $wpsc_cart->get_shipping_option();
780
- if($wpsc_cart->selected_shipping_method != '') {
781
- $wpsc_cart->update_shipping($wpsc_cart->selected_shipping_method, $wpsc_cart->selected_shipping_option);
782
- }
783
-
784
-
785
-
786
-
787
-
788
- $tax = $wpsc_cart->calculate_total_tax();
789
- $total = wpsc_cart_total();
790
- ob_start();
791
- $cur_wpsc_theme_folder = apply_filters('wpsc_theme_folder',$wpsc_theme_path.WPSC_THEME_DIR);
792
- include_once($cur_wpsc_theme_folder."/cart_widget.php");
793
- $output = ob_get_contents();
794
- ob_end_clean();
795
- //exit("/*<pre>".print_r($wpsc_cart,true)."</pre>*/");
796
- $output = str_replace(Array("\n","\r") , Array("\\n","\\r"),addslashes($output));
797
- if(get_option('lock_tax') == 1){
798
- //echo "jQuery('#region').val(".$_SESSION['wpsc_delivery_region']."); \n";
799
- echo "jQuery('#current_country').val('".$_SESSION['wpsc_delivery_country']."'); \n";
800
- if($_SESSION['wpsc_delivery_country']== 'US' && get_option('lock_tax') == 1){
801
- //exit('<pre>'.print_r($_SESSION, true).'</pre>');
802
- $output = wpsc_shipping_region_list($_SESSION['wpsc_delivery_country'], $_SESSION['wpsc_delivery_region']);
803
- // echo 'jQuery("#change_country").append(\''.$output.'\');\n\r';
804
- $output = str_replace(Array("\n","\r") , Array("\\n","\\r"),addslashes($output));
805
- echo "jQuery('#region').remove();\n\r";
806
- echo "jQuery('#change_country').append(\"".$output."\");\n\r";
807
- }
808
- }
809
-
810
-
811
- foreach($wpsc_cart->cart_items as $key => $cart_item) {
812
- echo "jQuery('#shipping_$key').html(\"".$wpsc_cart->process_as_currency($cart_item->shipping)."\");\n\r";
813
-
814
- }
815
-
816
- echo "jQuery('#checkout_shipping').html(\"".wpsc_cart_shipping()."\");\n\r";
817
-
818
- echo "jQuery('div.shopping-cart-wrapper').html('$output');\n";
819
- if(get_option('lock_tax') == 1){
820
- echo "jQuery('.shipping_country').val('".$_SESSION['wpsc_delivery_country']."') \n";
821
- $sql ="SELECT `country` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `isocode`='".$_SESSION['wpsc_selected_country']."'";
822
- $country_name = $wpdb->get_var($sql);
823
- echo "jQuery('.shipping_country_name').html('".$country_name."') \n";
824
- }
825
-
826
-
827
- $form_selected_country = null;
828
- $form_selected_region = null;
829
- $onchange_function = null;
830
-
831
- if(($_POST['billing_country'] != 'undefined') && !isset($_POST['shipping_country'])) {
832
- $form_selected_country = $wpsc_selected_country;
833
- $form_selected_region = $wpsc_selected_region;
834
- $onchange_function = 'set_billing_country';
835
- } else if(($_POST['shipping_country'] != 'undefined') && !isset($_POST['billing_country'])) {
836
- $form_selected_country = $wpsc_delivery_country;
837
- $form_selected_region = $wpsc_delivery_region;
838
- $onchange_function = 'set_shipping_country';
839
- }
840
-
841
- if(($form_selected_country != null) && ($onchange_function != null)) {
842
- $region_list = $wpdb->get_results("SELECT `".WPSC_TABLE_REGION_TAX."`.* FROM `".WPSC_TABLE_REGION_TAX."`, `".WPSC_TABLE_CURRENCY_LIST."` WHERE `".WPSC_TABLE_CURRENCY_LIST."`.`isocode` IN('".$form_selected_country."') AND `".WPSC_TABLE_CURRENCY_LIST."`.`id` = `".WPSC_TABLE_REGION_TAX."`.`country_id`",ARRAY_A) ;
843
- if($region_list != null) {
844
-
845
- $output = "<select name='collected_data[".$form_id."][1]' class='current_region' onchange='$onchange_function(\"region_country_form_$form_id\", \"$form_id\");'>\n\r";
846
-
847
- foreach($region_list as $region) {
848
- if($$form_selected_region == $region['id']) {
849
- $selected = "selected='selected'";
850
- } else {
851
- $selected = "";
852
- }
853
- $output .= " <option value='".$region['id']."' $selected>".htmlspecialchars($region['name'])."</option>\n\r";
854
- }
855
- $output .= "</select>\n\r";
856
-
857
- $output = str_replace(Array("\n","\r") , Array("\\n","\\r"),addslashes($output));
858
- echo "jQuery('#region_select_$form_id').html(\"".$output."\");\n\r";
859
-
860
- } else {
861
- if(get_option('lock_tax') == 1){
862
- echo "jQuery('#region').hide();";
863
- }
864
- echo "jQuery('#region_select_$form_id').html('');\n\r";
865
- }
866
- }
867
-
868
-
869
-
870
-
871
-
872
- if($tax > 0) {
873
- echo "jQuery(\"tr.total_tax\").show();\n\r";
874
- } else {
875
- echo "jQuery(\"tr.total_tax\").hide();\n\r";
876
- }
877
- echo "jQuery('#checkout_tax').html(\"<span class='pricedisplay'>".wpsc_cart_tax()."</span>\");\n\r";
878
- echo "jQuery('#checkout_total').html(\"<span class='pricedisplay'>{$total}</span><input id='shopping_cart_total_price' type='hidden' value='{$total}' />\");\n\r";
879
- //echo "\n\r/*\n\r{$wpsc_cart->tax_percentage}\n\r*/\n\r";
880
- exit();
881
  }
882
 
883
  // execute on POST and GET
884
- if($_REQUEST['wpsc_ajax_action'] == 'change_tax') {
885
- add_action('init', 'wpsc_change_tax');
886
  }
887
 
888
 
@@ -891,215 +903,220 @@ if($_REQUEST['wpsc_ajax_action'] == 'change_tax') {
891
  */
892
 
893
  function wpsc_scale_image() {
894
- global $wpdb;
895
- require_once(ABSPATH . 'wp-admin/includes/image.php');
896
- $attachment_id = absint($_REQUEST['attachment_id']);
897
- $width = absint($_REQUEST['width']);
898
- $height = absint($_REQUEST['height']);
899
-
900
- if((($width >= 10) && ($height >= 10)) && (($width <= 1024) && ($height <= 1024))) {
901
- $intermediate_size = "wpsc-{$width}x{$height}";
902
- $generate_thumbnail = true;
903
- } else {
904
- $intermediate_size = $wpdb->escape($_REQUEST['intermediate_size']);
905
- $generate_thumbnail = false;
906
- }
907
-
908
-
909
- // If the attachment ID is greater than 0, and the width and height is greater than or equal to 10, and less than or equal to 1024
910
- if(($attachment_id > 0) && ($intermediate_size != '')) {
911
- // Get all the required information about the attachment
912
- $uploads = wp_upload_dir();
913
-
914
- $image_meta = get_post_meta($attachment_id, '');
915
- $file_path = get_attached_file($attachment_id);
916
- foreach($image_meta as $meta_name => $meta_value) { // clean up the meta array
917
- $image_meta[$meta_name] = maybe_unserialize(array_pop($meta_value));
918
- }
919
- $attachment_metadata = $image_meta['_wp_attachment_metadata'];
920
-
921
- // determine if we already have an image of this size
922
- if((count($attachment_metadata['sizes']) > 0) && ($attachment_metadata['sizes'][$intermediate_size])) {
923
- $intermediate_image_data = image_get_intermediate_size($attachment_id, $intermediate_size);
924
- if(file_exists($file_path)) {
925
- $original_modification_time = filemtime($file_path);
926
- $cache_modification_time = filemtime($uploads['basedir']."/".$intermediate_image_data['path']);
927
- if($original_modification_time < $cache_modification_time) {
928
- $generate_thumbnail = false;
929
- }
930
- }
931
- //header("Location: ".$cache_url.$cache_filename.$extension);
932
- }
933
-
934
- if($generate_thumbnail == true) {
935
- //JS - 7.1.2010 - Added true parameter to function to not crop - causing issues on WPShop
936
- $intermediate_size_data = image_make_intermediate_size($file_path, $width, $height, true);
937
- $attachment_metadata['sizes'][$intermediate_size] = $intermediate_size_data;
938
- wp_update_attachment_metadata($attachment_id, $attachment_metadata);
939
- $intermediate_image_data =image_get_intermediate_size($attachment_id, $intermediate_size);
940
- }
941
-
942
- //
943
- //echo "<pre>".print_r((int)$generate_thumbnail,true)."</pre>";
944
- //echo "<pre>".print_r($intermediate_image_data,true)."</pre>";
945
-
946
- /// if we are serving the page using SSL, we have to use for the image too.
947
- if(is_ssl()) {
948
- $output_url = str_replace("http://", "https://", $intermediate_image_data['url']);
949
- } else {
950
- $output_url = $intermediate_image_data['url'];
951
- }
952
- wp_redirect($output_url);
953
- } else {
954
- _e("Invalid Image parameters", 'wpsc');
955
- }
956
- exit();
 
 
 
 
 
957
  }
958
 
959
 
960
- if(($_REQUEST['wpsc_action'] == 'scale_image') && is_numeric($_REQUEST['attachment_id'])) {
961
- add_action('init', 'wpsc_scale_image');
962
  }
963
 
964
-
965
 
966
 
967
  function wpsc_download_file() {
968
- global $wpdb,$user_level,$wp_rewrite;
969
- get_currentuserinfo();
970
-
971
- if(isset($_GET['downloadid'])) {
972
- // strip out anything that isnt 'a' to 'z' or '0' to '9'
973
- //ini_set('max_execution_time',10800);
974
- $downloadid = preg_replace("/[^a-z0-9]+/i",'',strtolower($_GET['downloadid']));
975
- $download_data = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_DOWNLOAD_STATUS."` WHERE `uniqueid` = '".$downloadid."' AND `downloads` > '0' AND `active`='1' LIMIT 1",ARRAY_A);
976
-
977
- if(($download_data == null) && is_numeric($downloadid)) {
978
- $download_data = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_DOWNLOAD_STATUS."` WHERE `id` = '".$downloadid."' AND `downloads` > '0' AND `active`='1' AND `uniqueid` IS NULL LIMIT 1",ARRAY_A);
979
- }
980
-
981
- if((get_option('wpsc_ip_lock_downloads') == 1) && ($_SERVER['REMOTE_ADDR'] != null)) {
982
- $ip_number = $_SERVER['REMOTE_ADDR'];
983
- if($download_data['ip_number'] == '') {
984
- // if the IP number is not set, set it
985
- $wpdb->query("UPDATE `".WPSC_TABLE_DOWNLOAD_STATUS."` SET `ip_number` = '{$ip_number}' WHERE `id` = '{$download_data['id']}' LIMIT 1");
986
- } else if($ip_number != $download_data['ip_number']) {
987
- // if the IP number is set but does not match, fail here.
988
- exit(WPSC_DOWNLOAD_INVALID);
989
- }
990
- }
991
-
992
- if(wpsc_get_meta($download_data['id'], '_is_legacy', 'wpsc_downloads') == 'true') {
993
- $file_id = wpsc_get_meta($download_data['fileid'], '_new_file_id', 'wpsc_files');
994
- } else {
995
- $file_id = $download_data['fileid'];
996
-
997
- }
998
-
999
- //exit($file_id. "-".$download_data['fileid']);
1000
-
1001
- $file_data = get_post($file_id);
1002
-
1003
- if($file_data == null) {
1004
- exit(WPSC_DOWNLOAD_INVALID);
1005
- }
1006
-
1007
- if($download_data != null) {
1008
- if((int)$download_data['downloads'] >= 1) {
1009
- $download_count = (int)$download_data['downloads'] - 1;
1010
- } else {
1011
- $download_count = 0;
1012
- }
1013
-
1014
-
1015
- $wpdb->query("UPDATE `".WPSC_TABLE_DOWNLOAD_STATUS."` SET `downloads` = '{$download_count}' WHERE `id` = '{$download_data['id']}' LIMIT 1");
1016
- $cart_contents = $wpdb->get_results('SELECT `'.WPSC_TABLE_CART_CONTENTS.'`.*,`'.WPSC_TABLE_PRODUCT_LIST.'`.`file` FROM `'.WPSC_TABLE_CART_CONTENTS.'` LEFT JOIN `'.WPSC_TABLE_PRODUCT_LIST.'` ON `'.WPSC_TABLE_CART_CONTENTS.'`.`prodid`= `'.WPSC_TABLE_PRODUCT_LIST.'`.`id` WHERE `purchaseid` ='.$download_data['purchid'], ARRAY_A);
1017
- $dl = 0;
1018
-
1019
-
1020
-
1021
- foreach($cart_contents as $cart_content) {
1022
- if($cart_content['file'] == 1) {
1023
- $dl++;
1024
- }
1025
- }
1026
- if(count($cart_contents) == $dl) {
1027
- $wpdb->query("UPDATE `".WPSC_TABLE_PURCHASE_LOGS."` SET `processed` = '4' WHERE `id` = '".$download_data['purchid']."' LIMIT 1");
1028
- }
1029
-
1030
-
1031
-
1032
- do_action('wpsc_alter_download_action', $file_id);
1033
-
1034
- //exit('<pre>'.print_r($cart_contents,true).'</pre>');
1035
- $file_path = WPSC_FILE_DIR.basename($file_data->post_name);
1036
- $file_name = basename($file_data->post_title);
1037
-
1038
-
1039
-
1040
- if(is_file($file_path)) {
1041
- header('Content-Type: '.$file_data->post_mime_type);
1042
- header('Content-Length: '.filesize($file_path));
1043
- header('Content-Transfer-Encoding: binary');
1044
- header('Content-Disposition: attachment; filename="'.stripslashes($file_name).'"');
1045
- if(isset($_SERVER["HTTPS"]) && ($_SERVER["HTTPS"] != '')) {
1046
- /*
1047
- There is a bug in how IE handles downloads from servers using HTTPS, this is part of the fix, you may also need:
1048
- session_cache_limiter('public');
1049
- session_cache_expire(30);
1050
- At the start of your index.php file or before the session is started
1051
- */
1052
- header("Pragma: public");
1053
- header("Expires: 0");
1054
- header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
1055
- header("Cache-Control: public");
1056
- } else {
1057
- header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
1058
- }
1059
- // destroy the session to allow the file to be downloaded on some buggy browsers and webservers
1060
- session_destroy();
1061
- wpsc_readfile_chunked($file_path);
1062
- exit();
1063
- }
1064
- } else {
1065
- exit(WPSC_DOWNLOAD_INVALID);
1066
- }
1067
- } else {
1068
- if(($_GET['admin_preview'] == "true") && is_numeric($_GET['product_id']) && current_user_can('edit_plugins')) {
1069
- $product_id = $_GET['product_id'];
1070
- $product_data = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE `id` = '$product_id' LIMIT 1",ARRAY_A);
1071
- if(is_numeric($product_data[0]['file']) && ($product_data[0]['file'] > 0)) {
1072
- $file_data = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_PRODUCT_FILES."` WHERE `id`='".$product_data[0]['file']."' LIMIT 1",ARRAY_A) ;
1073
- $file_data = $file_data[0];
1074
-
1075
- do_action('wpsc_alter_download_action',$file_id);
1076
-
1077
- if(is_file(WPSC_FILE_DIR.$file_data['idhash'])) {
1078
- header('Content-Type: '.$file_data['mimetype']);
1079
- header('Content-Length: '.filesize(WPSC_FILE_DIR.$file_data['idhash']));
1080
- header('Content-Transfer-Encoding: binary');
1081
- if($_GET['preview_track'] != 'true') {
1082
- header('Content-Disposition: attachment; filename="'.$file_data['filename'].'"');
1083
- } else {
1084
- header('Content-Disposition: inline; filename="'.$file_data['filename'].'"');
1085
- }
1086
- if(isset($_SERVER["HTTPS"]) && ($_SERVER["HTTPS"] != '')) {
1087
- header("Pragma: public");
1088
- header("Expires: 0");
1089
- header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
1090
- header("Cache-Control: public");
1091
- } else {
1092
- header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
1093
- }
1094
- $filename = WPSC_FILE_DIR.$file_data['idhash'];
1095
- session_destroy();
1096
- wpsc_readfile_chunked($filename);
1097
- exit();
1098
- }
1099
- }
1100
- }
1101
- }
1102
  }
1103
 
1104
  add_action('init', 'wpsc_download_file');
1105
- ?>
8
  * @since 3.7
9
  */
10
  function wpsc_special_widget(){
11
+ global $wpdb;
12
+ wpsc_add_to_cart();
13
+ //exit();
14
  }
15
+
16
+ if (isset($_REQUEST['wpsc_ajax_action']) && ($_REQUEST['wpsc_ajax_action'] == 'special_widget' || $_REQUEST['wpsc_ajax_action'] == 'donations_widget')) {
17
+ add_action('init', 'wpsc_special_widget');
18
  }
19
 
20
 
21
  // function wpsc_api_key_finder(){
22
+ // global $wpdb;
23
+ // $transactid = $wpdb->escape($_POST['wpsc_transaction_id']);
24
+ // $sql = 'SELECT `id` FROM `'.WPSC_TABLE_PURCHASE_LOGS.'` WHERE `transactid`='.$transactid;
25
+ // $id = $wpdb->get_var($sql);
26
+ // $sql = 'SELECT `name`, `key`, `first_name` FROM `'.$wpdb->prefix.'api_keys` WHERE `purchase_id`='.$id;
27
+ // $api_info = $wpdb->get_results($sql);
28
+ // $_SESSION['api_info'] = $api_info;
29
+ // //exit('ID<pre>'.print_r($id, true).'</pre>');
30
+ // exit();
31
  // }
32
+ //
33
  // if($_REQUEST['wpsc_ajax_action'] == 'api_key_finder') {
34
+ // add_action('init', 'wpsc_api_key_finder');
35
  // }
36
 
37
  /**
38
+ * add_to_cart function, used through ajax and in normal page loading.
39
+ * No parameters, returns nothing
40
  */
41
  function wpsc_add_to_cart() {
42
+ global $wpdb, $wpsc_cart, $wpsc_theme_path;
43
+ /// default values
44
+ $default_parameters['variation_values'] = null;
45
+ $default_parameters['quantity'] = 1;
46
+ $default_parameters['provided_price'] = null;
47
+ $default_parameters['comment'] =null;
48
+ $default_parameters['time_requested']= null;
49
+ $default_parameters['custom_message'] = null;
50
+ $default_parameters['file_data'] = null;
51
+ $default_parameters['is_customisable'] = false;
52
+ $default_parameters['meta'] = null;
53
+
54
+
55
+ /// sanitise submitted values
56
+ $product_id = (int)$_POST['product_id'];
57
+ foreach((array)$_POST['variation'] as $key => $variation) {
58
+ $provided_parameters['variation_values'][(int)$key] = (int)$variation;
59
+ }
60
+ if(count($provided_parameters['variation_values']) > 0) {
61
+ $variation_product_id = wpsc_get_child_object_in_terms($product_id, $provided_parameters['variation_values'],'wpsc-variation');
62
+ if($variation_product_id > 0) {
63
+ $product_id = $variation_product_id;
64
+ }
65
+ }
66
+
67
+
68
+
69
+ if($_POST['quantity'] > 0 && (!isset($_POST['wpsc_quantity_update']))) {
70
+ $provided_parameters['quantity'] = (int)$_POST['quantity'];
71
+ } else if (isset($_POST['wpsc_quantity_update'])) {
72
+ $wpsc_cart->remove_item($_POST['key']);
73
+ $provided_parameters['quantity'] = (int)$_POST['wpsc_quantity_update'];
74
+ }
75
+ // exit('<pre>'.print_r($_POST, true).'</pre>');
76
+ if($_POST['is_customisable'] == 'true') {
77
+ $provided_parameters['is_customisable'] = true;
78
+
79
+ if(isset($_POST['custom_text'])) {
80
+ $provided_parameters['custom_message'] = $_POST['custom_text'];
81
+ }
82
+ if(isset($_FILES['custom_file'])) {
83
+ $provided_parameters['file_data'] = $_FILES['custom_file'];
84
+ }
85
+ }
86
+ if(((float)$_POST['donation_price'] > 0)) {
87
+ $provided_parameters['provided_price'] = (float)$_POST['donation_price'];
88
+ }
89
+ //exit();
90
+ $parameters = array_merge($default_parameters, (array)$provided_parameters);
91
+ //echo "/*\n\r".print_r($parameters,true)."*/\n\r";
92
+ $state = $wpsc_cart->set_item($product_id,$parameters);
93
+
94
+ $product = get_post($product_id);
95
+
96
+ if($state == true) {
97
+ $cart_messages[] = str_replace("[product_name]", stripslashes($product->post_title), __('You just added "[product_name]" to your cart.', 'wpsc'));
98
+ } else {
99
+ if($parameters['quantity'] <= 0) {
100
+ $cart_messages[] = __('Sorry, but you cannot add zero items to your cart', 'wpsc');
101
+ } else if($wpsc_cart->get_remaining_quantity($product_id,$parameters['variation_values'], $parameters['quantity']) > 0) {
102
+ $cart_messages[] = str_replace("[number]", $wpsc_cart->get_remaining_quantity($product_id,$parameters['variation_values'], $parameters['quantity']), __('Sorry, but there are only [number] of this item in stock.', 'wpsc'));
103
+ } else {
104
+ $cart_messages[] = str_replace("[product_name]", $product['name'], __('Sorry, but the item "[product_name]" is out of stock.', 'wpsc'));
105
+ }
106
+ }
107
+
108
+ if($_GET['ajax'] == 'true') {
109
+ if(($product_id != null) &&(get_option('fancy_notifications') == 1)) {
110
+ echo "if(jQuery('#fancy_notification_content')) {\n\r";
111
+ echo " jQuery('#fancy_notification_content').html(\"".str_replace(array("\n","\r") , array('\n','\r'), addslashes(fancy_notification_content($cart_messages))). "\");\n\r";
112
+ echo " jQuery('#loading_animation').css('display', 'none');\n\r";
113
+ echo " jQuery('#fancy_notification_content').css('display', 'block');\n\r";
114
+ echo "}\n\r";
115
+ $error_messages = array();
116
+ }
117
+
118
+ ob_start();
119
+ $cur_wpsc_theme_folder = apply_filters('wpsc_theme_folder',$wpsc_theme_path.WPSC_THEME_DIR);
120
+ include_once($cur_wpsc_theme_folder."/cart_widget.php");
121
+ $output = ob_get_contents();
122
+ ob_end_clean();
123
+ $output = str_replace(Array("\n","\r") , Array("\\n","\\r"),addslashes($output));
124
+ echo "jQuery('div.shopping-cart-wrapper').html('$output');\n";
125
+
126
+
127
+ if(get_option('show_sliding_cart') == 1) {
128
+ if((wpsc_cart_item_count() > 0) || (count($cart_messages) > 0)) {
129
+ $_SESSION['slider_state'] = 1;
130
+ echo "
131
+ jQuery('#sliding_cart').slideDown('fast',function(){
132
+ jQuery('#fancy_collapser').attr('src', (WPSC_URL+'/images/minus.png'));
133
+ });
134
+ ";
135
+
136
+ } else {
137
+ $_SESSION['slider_state'] = 0;
138
+ echo "
139
+ jQuery('#sliding_cart').slideUp('fast',function(){
140
+ jQuery('#fancy_collapser').attr('src', (WPSC_URL+'/images/plus.png'));
141
+ });
142
+ ";
143
+ }
144
+ }
145
+
146
+ do_action('wpsc_alternate_cart_html', $cart_messages);
147
+ exit();
148
+ }
149
  }
150
  // execute on POST and GET
151
+ if(isset($_REQUEST['wpsc_ajax_action']) && ($_REQUEST['wpsc_ajax_action'] == 'add_to_cart')) {
152
+ add_action('init', 'wpsc_add_to_cart');
153
  }
154
 
155
 
156
  function wpsc_get_cart() {
157
+ global $wpdb, $wpsc_cart, $wpsc_theme_path;
158
+ ob_start();
159
+ $cur_wpsc_theme_folder = apply_filters('wpsc_theme_folder',$wpsc_theme_path.WPSC_THEME_DIR);
160
+ include_once($cur_wpsc_theme_folder."/cart_widget.php");
161
+ $output = ob_get_contents();
162
+ ob_end_clean();
163
+ $output = str_replace(Array("\n","\r") , Array("\\n","\\r"),addslashes($output));
164
+ echo "jQuery('div.shopping-cart-wrapper').html('$output');\n";
165
+
166
+
167
+ if(get_option('show_sliding_cart') == 1) {
168
+ if((wpsc_cart_item_count() > 0) || (count($cart_messages) > 0)) {
169
+ $_SESSION['slider_state'] = 1;
170
+ echo "
171
+ jQuery('#sliding_cart').slideDown('fast',function(){
172
+ jQuery('#fancy_collapser').attr('src', (WPSC_URL+'/images/minus.png'));
173
+ });
174
+ ";
175
+
176
+ } else {
177
+ $_SESSION['slider_state'] = 0;
178
+ echo "
179
+ jQuery('#sliding_cart').slideUp('fast',function(){
180
+ jQuery('#fancy_collapser').attr('src', (WPSC_URL+'/images/plus.png'));
181
+ });
182
+ ";
183
+ }
184
+ }
185
+
186
+
187
+ do_action('wpsc_alternate_cart_html', '');
188
+ exit();
189
  }
190
 
191
+ if(isset($_REQUEST['wpsc_ajax_action']) && ($_REQUEST['wpsc_ajax_action'] == 'get_cart')) {
192
+ add_action('init', 'wpsc_get_cart');
193
  }
194
 
195
 
196
  /**
197
+ * empty cart function, used through ajax and in normal page loading.
198
+ * No parameters, returns nothing
199
  */
200
  function wpsc_empty_cart() {
201
+ global $wpdb, $wpsc_cart, $wpsc_theme_path;
202
+ $wpsc_cart->empty_cart(false);
203
+
204
+ if($_REQUEST['ajax'] == 'true') {
205
+ ob_start();
206
+ $cur_wpsc_theme_folder = apply_filters('wpsc_theme_folder',$wpsc_theme_path.WPSC_THEME_DIR);
207
+ include_once($cur_wpsc_theme_folder."/cart_widget.php");
208
+
209
+ $output = ob_get_contents();
210
+ ob_end_clean();
211
+ $output = str_replace(Array("\n","\r") , Array("\\n","\\r"),addslashes($output));
212
+ echo "jQuery('div.shopping-cart-wrapper').html('$output');";
213
+ do_action('wpsc_alternate_cart_html');
214
+
215
+ if(get_option('show_sliding_cart') == 1) {
216
+ $_SESSION['slider_state'] = 0;
217
+ echo "
218
+ jQuery('#sliding_cart').slideUp('fast',function(){
219
+ jQuery('#fancy_collapser').attr('src', (WPSC_URL+'/images/plus.png'));
220
+ });
221
+ ";
222
+ }
223
+ exit();
224
+ }
225
+
226
+ // this if statement is needed, as this function also runs on returning from the gateway
227
+ if($_REQUEST['wpsc_ajax_action'] == 'empty_cart') {
228
+ wp_redirect(remove_query_arg(array('wpsc_ajax_action','ajax')));
229
+ exit();
230
+ }
231
  }
232
 
233
 
234
  // execute on POST and GET
235
+ if(isset($_REQUEST['wpsc_ajax_action']) && (($_REQUEST['wpsc_ajax_action'] == 'empty_cart') || ($_GET['sessionid'] > 0))) {
236
+ add_action('init', 'wpsc_empty_cart');
237
  }
238
 
239
 
240
  /**
241
+ * coupons price, used through ajax and in normal page loading.
242
+ * No parameters, returns nothing
243
  */
244
  function wpsc_coupon_price($currCoupon = '') {
245
+ global $wpdb, $wpsc_cart, $wpsc_coupons;
246
+ if(isset($_POST['coupon_num']) && $_POST['coupon_num'] != ''){
247
+ $coupon = $wpdb->escape($_POST['coupon_num']);
248
+ $_SESSION['coupon_numbers'] = $coupon;
249
+ $wpsc_coupons = new wpsc_coupons($coupon);
250
+
251
+ if ($wpsc_coupons->validate_coupon()){
252
+ $discountAmount = $wpsc_coupons->calculate_discount();
253
+ $wpsc_cart->apply_coupons($discountAmount, $coupon);
254
+ $wpsc_coupons->errormsg = false;
255
+ } else {
256
+ $wpsc_coupons->errormsg = true;
257
+ $wpsc_cart->coupons_amount = 0;
258
+ $wpsc_cart->coupons_name = '';
259
+ }
260
+
261
+ } else if ($_POST['coupon_num'] == '' && $currCoupon == ''){
262
+ $wpsc_cart->coupons_amount = 0;
263
+ $wpsc_cart->coupons_name = '';
264
+ } else if ($currCoupon != '') {
265
+ $coupon = $wpdb->escape($currCoupon);
266
+ $_SESSION['coupon_numbers'] = $coupon;
267
+ $wpsc_coupons = new wpsc_coupons($coupon);
268
+
269
+ if($wpsc_coupons->validate_coupon()){
270
+
271
+ $discountAmount = $wpsc_coupons->calculate_discount();
272
+ $wpsc_cart->apply_coupons($discountAmount, $coupon);
273
+ $wpsc_coupons->errormsg = false;
274
+ }
275
+ }
276
+
277
+
278
  }
279
  // execute on POST and GET
280
  if(isset($_POST['coupon_num'])) {
281
+ add_action('init', 'wpsc_coupon_price');
282
  }
283
 
284
 
285
  /**
286
+ * update quantity function, used through ajax and in normal page loading.
287
+ * No parameters, returns nothing
288
  */
289
  function wpsc_update_item_quantity() {
290
+ global $wpdb, $wpsc_cart, $wpsc_theme_path;
291
+
292
+ if(is_numeric($_POST['key'])) {
293
+ $key = (int)$_POST['key'];
294
+ if($_POST['quantity'] > 0) {
295
+ // if the quantity is greater than 0, update the item;
296
+ $parameters['quantity'] = (int)$_POST['quantity'];
297
+ $wpsc_cart->edit_item($key, $parameters);
298
+ } else {
299
+ // if the quantity is 0, remove the item.
300
+ $wpsc_cart->remove_item($key);
301
+ }
302
+ wpsc_coupon_price($_SESSION['coupon_numbers']);
303
+ }
304
+
305
  if($_REQUEST['ajax'] == 'true') {
306
+ ob_start();
307
+ $cur_wpsc_theme_folder = apply_filters('wpsc_theme_folder',$wpsc_theme_path.WPSC_THEME_DIR);
308
+ include_once($cur_wpsc_theme_folder."/cart_widget.php");
309
+ $output = ob_get_contents();
310
+ ob_end_clean();
311
+ $output = str_replace(Array("\n","\r") , Array("\\n","\\r"),addslashes($output));
312
+
313
+ echo "jQuery('div.shopping-cart-wrapper').html('$output');\n";
314
+ do_action('wpsc_alternate_cart_html');
315
+
316
+
317
+ exit();
318
  }
319
+
320
  }
321
+
322
  // execute on POST and GET
323
+ if (isset($_REQUEST['wpsc_update_quantity']) && ($_REQUEST['wpsc_update_quantity'] == 'true')) {
324
+ add_action('init', 'wpsc_update_item_quantity');
325
  }
326
 
327
 
328
 
329
  function wpsc_update_product_rating() {
330
+ global $wpdb;
331
+ //exit("<pre>".print_r($_POST, true)."</pre>");
332
+ $nowtime = time();
333
+ $product_id = absint($_POST['product_id']);
334
+ $ip_number = $wpdb->escape($_SERVER['REMOTE_ADDR']);
335
+ $rating = absint($_POST['product_rating']);
336
+
337
+ $cookie_data = explode(",",$_COOKIE['voting_cookie'][$product_id]);
338
+
339
+ if(is_numeric($cookie_data[0]) && ($cookie_data[0] > 0)) {
340
+ $vote_id = absint($cookie_data[0]);
341
+ $wpdb->query("UPDATE `".WPSC_TABLE_PRODUCT_RATING."` SET `rated` = '".$rating."' WHERE `id` ='".$vote_id."' LIMIT 1 ;");
342
+ } else {
343
+ $wpdb->query("INSERT INTO `".WPSC_TABLE_PRODUCT_RATING."` ( `ipnum` , `productid` , `rated`, `time`) VALUES ( '".$ip_number."', '".$product_id."', '".$rating."', '".$nowtime."');");
344
+
345
+ $data = $wpdb->get_results("SELECT `id`,`rated` FROM `".WPSC_TABLE_PRODUCT_RATING."` WHERE `ipnum`='".$ip_number."' AND `productid` = '".$product_id."' AND `rated` = '".$rating."' AND `time` = '".$nowtime."' ORDER BY `id` DESC LIMIT 1",ARRAY_A) ;
346
+
347
+ $vote_id = $data[0]['id'];
348
+ setcookie("voting_cookie[$prodid]", ($vote_id.",".$rating),time()+(60*60*24*360));
349
+ }
350
+ if($_POST['ajax'] == 'true') {
351
+
352
+ exit();
353
+ }
354
  }
355
+
356
  // execute on POST and GET
357
+ if(isset($_REQUEST['wpsc_ajax_action']) && ($_REQUEST['wpsc_ajax_action'] == 'rate_product')) {
358
+ add_action('init', 'wpsc_update_product_rating');
359
  }
360
 
361
 
362
  /**
363
+ * update_shipping_price function, used through ajax and in normal page loading.
364
+ * No parameters, returns nothing
365
  */
366
  function wpsc_update_shipping_price() {
367
+ global $wpdb, $wpsc_cart;
368
+ $quote_shipping_method = $_POST['key1'];
369
+ $quote_shipping_option = $_POST['key'];
370
+ $wpsc_cart->update_shipping($quote_shipping_method, $quote_shipping_option);
371
+ echo "jQuery('.pricedisplay.checkout-shipping').html('".wpsc_cart_shipping()."');\n\r";
372
+ echo "jQuery('.pricedisplay.checkout-total').html('".wpsc_cart_total()."');\n\r";
373
+ exit();
374
  }
375
  // execute on POST and GET
376
+ if (isset($_REQUEST['wpsc_ajax_action']) && ($_REQUEST['wpsc_ajax_action'] == 'update_shipping_price')) {
377
+ add_action('init', 'wpsc_update_shipping_price');
378
  }
379
 
380
 
381
  /**
382
+ * update_shipping_price function, used through ajax and in normal page loading.
383
+ * No parameters, returns nothing
384
  */
385
  function wpsc_get_rating_count() {
386
+ global $wpdb, $wpsc_cart;
387
+ $prodid = $_POST['product_id'];
388
+ $data = $wpdb->get_results("SELECT COUNT(*) AS `count` FROM `".WPSC_TABLE_PRODUCT_RATING."` WHERE `productid` = '".$prodid."'",ARRAY_A) ;
389
+ echo $data[0]['count'].",".$prodid;
390
+ exit();
391
  }
392
  // execute on POST and GET
393
+ if(isset($_REQUEST['get_rating_count']) && ($_REQUEST['get_rating_count'] == 'true') && is_numeric($_POST['product_id'])) {
394
+ add_action('init', 'wpsc_get_rating_count');
395
  }
396
 
397
 
398
  /**
399
+ * update_product_page_price function, used through ajax with variations
400
+ * No parameters, returns nothing
401
  */
402
  function wpsc_update_product_price() {
403
+ global $wpdb, $wpsc_cart;
404
+ foreach((array)$_POST['variation'] as $variation) {
405
+ if(is_numeric($variation)) {
406
+ $variations[] = (int)$variation;
407
+ }
408
+ }
409
+ $pm=$_POST['pm'];
410
+ echo "product_id=".(int)$_POST['product_id'].";\n";
411
+
412
+
413
+ echo "old_price=\"".nzshpcrt_currency_display(wpsc_calculate_price( (int) $_POST['product_id'], $variations), $notax, true)."\";\n";
414
+ echo "numeric_old_price=\"".number_format(wpsc_calculate_price( (int) $_POST['product_id'], $variations), 2)."\";\n";
415
+
416
+ echo "price=\"".nzshpcrt_currency_display(wpsc_calculate_price( (int) $_POST['product_id'], $variations, true), $notax, true)."\";\n";
417
+ echo "numeric_price=\"".number_format(wpsc_calculate_price( (int) $_POST['product_id'], $variations, true), 2)."\";\n";
418
+ exit();
419
  }
420
  // execute on POST and GET
421
+ if(isset($_REQUEST['update_product_price']) && ($_REQUEST['update_product_price'] == 'true') && is_numeric($_POST['product_id'])) {
422
+ add_action('init', 'wpsc_update_product_price');
423
  }
424
 
425
 
426
 
427
  /**
428
+ * update location function, used through ajax and in normal page loading.
429
+ * No parameters, returns nothing
430
  */
431
  function wpsc_update_location() {
432
+ global $wpdb, $wpsc_cart;
433
+ if($_POST['country'] != null) {
434
+ $_SESSION['wpsc_delivery_country'] = $_POST['country'];
435
+ if($_SESSION['wpsc_selected_country'] == null) {
436
+ $_SESSION['wpsc_selected_country'] = $_POST['country'];
437
+ }
438
+ if($_POST['region'] != null) {
439
+ $_SESSION['wpsc_delivery_region'] = $_POST['region'];
440
+ if($_SESSION['wpsc_selected_region'] == null) {
441
+ $_SESSION['wpsc_selected_region'] = $_POST['region'];
442
+ }
443
+ } else if($_SESSION['wpsc_selected_region'] == '') {
444
+ $_SESSION['wpsc_delivery_region'] = get_option('base_region');
445
+ $_SESSION['wpsc_selected_region'] = get_option('base_region');
446
+ }
447
+
448
+ if($_SESSION['wpsc_delivery_region'] == '') {
449
+ $_SESSION['wpsc_delivery_region'] = $_SESSION['wpsc_selected_region'];
450
+ }
451
+ }
452
+
453
+ if($_POST['zipcode'] != '') {
454
+ $_SESSION['wpsc_zipcode'] = $_POST['zipcode'];
455
+ }
456
+
457
+ $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($_SESSION['wpsc_delivery_country'])."')");
458
+ if($delivery_region_count < 1) {
459
+ $_SESSION['wpsc_delivery_region'] = null;
460
+ }
461
+
462
+ $selected_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($_SESSION['wpsc_selected_country'])."')");
463
+ if($selected_region_count < 1) {
464
+ $_SESSION['wpsc_selected_region'] = null;
465
+ }
466
+
467
+ $wpsc_cart->update_location();
468
+ $wpsc_cart->get_shipping_method();
469
+ $wpsc_cart->get_shipping_option();
470
+ //echo $wpsc_cart->shipping_method;
471
+ if($wpsc_cart->selected_shipping_method != '') {
472
+ $wpsc_cart->update_shipping($wpsc_cart->selected_shipping_method, $wpsc_cart->selected_shipping_option);
473
+ }
474
+ //echo "<pre>".print_r($wpsc_cart, true)."</pre>";
475
+ //exit();
476
+
477
+ if($_GET['ajax'] == 'true') {
478
+ exit();
479
+ }
480
  }
481
+
482
  // execute on POST and GET
483
+ if(isset($_REQUEST['wpsc_ajax_actions']) && ($_REQUEST['wpsc_ajax_actions'] == 'update_location')) {
484
+ add_action('init', 'wpsc_update_location');
485
  }
486
 
487
 
488
 
489
 
490
  function wpsc_cart_html_page() {
491
+ require_once(WPSC_FILE_PATH."/wpsc-includes/shopping_cart_container.php");
492
+ exit();
493
  }
494
 
495
  // execute on POST and GET
496
+ if(isset($_REQUEST['wpsc_action']) && ($_REQUEST['wpsc_action'] == 'cart_html_page')) {
497
+ add_action('init', 'wpsc_cart_html_page', 110);
498
  }
499
 
500
 
503
 
504
 
505
  /**
506
+ * submit checkout function, used through ajax and in normal page loading.
507
+ * No parameters, returns nothing
508
  */
509
  function wpsc_submit_checkout() {
510
+ global $wpdb, $wpsc_cart, $user_ID,$nzshpcrt_gateways, $wpsc_shipping_modules, $wpsc_gateways;
511
+ //echo "break redirect";
512
+ $_SESSION['wpsc_checkout_misc_error_messages'] = array();
513
+ $wpsc_checkout = new wpsc_checkout();
514
+ //exit('coupons:'.$wpsc_cart->coupons_name);
515
+ $selected_gateways = get_option('custom_gateway_options');
516
+ $submitted_gateway = $_POST['custom_gateway'];
517
+
518
+ $options = get_option('custom_shipping_options');
519
+ $form_validity = $wpsc_checkout->validate_forms();
520
+
521
+ // exit('2<pre>'.print_r($_SESSION['wpsc_zipcode'], true).'</pre>');
522
+ extract($form_validity); // extracts $is_valid and $error_messages
523
+ // exit('<pre>'.print_r($results, true).'</pre>');
524
+ //print('<pre>'.print_r(array((int)$is_valid), true).'</pre>');
525
+ if (get_option('do_not_use_shipping') == 0 && ($wpsc_cart->selected_shipping_method == null || $wpsc_cart->selected_shipping_option == null)) {
526
+ $_SESSION['wpsc_checkout_misc_error_messages'][] = __('You must select a shipping method, otherwise we cannot process your order.', 'wpsc');
527
+ $is_valid = false;
528
+ }
529
+
530
+ if($_POST['agree'] != 'yes') {
531
+ $_SESSION['wpsc_checkout_misc_error_messages'][] = __('Please agree to the terms and conditions, otherwise we cannot process your order.', 'wpsc');
532
+ $is_valid = false;
533
+ }
534
+
535
+
536
+ //exit('<pre>'.print_r($_POST, true).'</pre>');
537
+
538
+ $selectedCountry = $wpdb->get_results("SELECT id, country FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE isocode='".$wpdb->escape($_SESSION['wpsc_delivery_country'])."'", ARRAY_A);
539
+
540
+ // exit('valid >'.$is_valid.'\r\n'.$_SESSION['wpsc_delivery_country']);
541
+
542
+ foreach($wpsc_cart->cart_items as $cartitem){
543
+ // exit('<pre>'.print_r($cartitem, true).'</pre>');
544
+ $categoriesIDs = $wpdb->get_col("SELECT category_id FROM `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."` WHERE product_id=".$cartitem->product_id);
545
+
546
+ foreach((array)$categoriesIDs as $catid){
547
+ if(is_array($catid)){
548
+ $sql ="SELECT `countryid` FROM `".WPSC_TABLE_CATEGORY_TM."` WHERE `visible`=0 AND `categoryid`=".$catid[0];
549
+ }else{
550
+ $sql ="SELECT `countryid` FROM `".WPSC_TABLE_CATEGORY_TM."` WHERE `visible`=0 AND `categoryid`=".$catid;
551
+ }
552
+ $countries = $wpdb->get_col($sql);
553
+ if(in_array($selectedCountry[0]['id'], (array)$countries)){
554
+ $errormessage =sprintf(__('Oops the product : %s cannot be shipped to %s. To continue with your transaction please remove this product from the list above.', 'wpsc'), $cartitem->product_name, $selectedCountry[0]['country']);
555
+ $_SESSION['categoryAndShippingCountryConflict']= $errormessage;
556
+ $is_valid = false;
557
+ }
558
+ }
559
+ //count number of items, and number of items using shipping
560
+ $num_items ++;
561
+ if($cartitem->uses_shipping != 1){
562
+ $disregard_shipping ++;
563
+ }else{
564
+ $use_shipping ++;
565
+ }
566
+ }
567
+
568
+ // exit('valid >'.$is_valid);
569
+ //print('<pre>'.print_r($_SESSION['wpsc_gateway_error_messages'], true).'</pre>');
570
+ //print('<pre>'.print_r($_SESSION['wpsc_checkout_error_messages'], true).'</pre>');
571
+ //print('<pre>'.print_r(array((int)$is_valid), true).'</pre>');
572
+ if(array_search($submitted_gateway,$selected_gateways) !== false) {
573
+ $_SESSION['wpsc_previous_selected_gateway'] = $submitted_gateway;
574
+ } else {
575
+ $is_valid = false;
576
+ }
577
+
578
+
579
+ if((get_option('do_not_use_shipping') != 1) && (in_array('ups', (array)$options)) && $_SESSION['wpsc_zipcode'] == '') {
580
+ //exit('Not being called');
581
+ if($num_items != $disregard_shipping){ //<-- new line of code
582
+ $_SESSION['categoryAndShippingCountryConflict'] = __('Please enter a Zipcode and click calculate to proceed');
583
+ $is_valid = false;
584
+ }
585
+ }
586
+
587
+
588
+ // print('<pre>'.print_r(array((int)$is_valid), true).'</pre>');
589
+ if($is_valid == true || $_GET['gateway'] == 'noca') {
590
+ $_SESSION['categoryAndShippingCountryConflict']= '';
591
+ // check that the submitted gateway is in the list of selected ones
592
+ $sessionid = (mt_rand(100,999).time());
593
+ $_SESSION['wpsc_sessionid'] = $sessionid;
594
+ $subtotal = $wpsc_cart->calculate_subtotal();
595
+ if($wpsc_cart->has_total_shipping_discount() == false) {
596
+ $base_shipping= $wpsc_cart->calculate_base_shipping();
597
+ } else {
598
+ $base_shipping = 0;
599
+
600
+ }
601
+ if(wpsc_uses_shipping()){
602
+ $shipping_method = $wpsc_cart->selected_shipping_method;
603
+ $shipping_option = $wpsc_cart->selected_shipping_option;
604
+ $delivery_country = $wpsc_cart->delivery_country;
605
+ $delivery_region = $wpsc_cart->delivery_region;
606
+ }else{
607
+ $shipping_method = '';
608
+ $shipping_option = '';
609
+ $delivery_country = '';
610
+ $delivery_region = '';
611
+
612
+ }
613
+ if(isset($_POST['how_find_us'])){
614
+ $find_us = $_POST['how_find_us'];
615
+ }else{
616
+ $find_us = '';
617
+ }
618
+
619
+ //keep track of tax if taxes are exclusive
620
+ $wpec_taxes_controller = new wpec_taxes_controller();
621
+ if(!$wpec_taxes_controller->wpec_taxes_isincluded())
622
+ {
623
+ $tax = $wpsc_cart->calculate_total_tax();
624
+ $tax_percentage = $wpsc_cart->tax_percentage;
625
+ }
626
+ else
627
+ {
628
+ $tax = 0.00;
629
+ $tax_percentage = 0.00;
630
+ }
631
+
632
+ $total = $wpsc_cart->calculate_total_price();
633
+ $sql = "INSERT INTO `".WPSC_TABLE_PURCHASE_LOGS."` (`totalprice`,`statusno`, `sessionid`, `user_ID`, `date`, `gateway`, `billing_country`,`shipping_country`, `billing_region`, `shipping_region`, `base_shipping`,`shipping_method`, `shipping_option`, `plugin_version`, `discount_value`, `discount_data`,`find_us`,`wpec_taxes_total`,`wpec_taxes_rate`) VALUES ('$total' ,'0', '{$sessionid}', '".(int)$user_ID."', UNIX_TIMESTAMP(), '{$submitted_gateway}', '{$wpsc_cart->selected_country}', '{$delivery_country}','{$wpsc_cart->selected_region}', '{$delivery_region}', '{$base_shipping}', '{$shipping_method}', '{$shipping_option}', '".WPSC_VERSION."', '{$wpsc_cart->coupons_amount}','{$wpsc_cart->coupons_name}', '{$find_us}', '{$tax}', '{$tax_percentage}')";
634
+
635
+
636
+ $wpdb->query($sql);
637
+
638
+ $purchase_log_id = $wpdb->get_var("SELECT `id` FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `sessionid` IN('{$sessionid}') LIMIT 1") ;
639
+ //exit('PurchLog id'.$purchase_log_id);
640
+ $wpsc_checkout->save_forms_to_db($purchase_log_id);
641
+ $wpsc_cart->save_to_db($purchase_log_id);
642
+ $wpsc_cart->submit_stock_claims($purchase_log_id);
643
+
644
+ if(get_option('wpsc_also_bought') == 1) {
645
+ wpsc_populate_also_bought_list();
646
+ }
647
+
648
+ do_action('wpsc_submit_checkout', array("purchase_log_id" => $purchase_log_id, "our_user_id" => $our_user_id));
649
+
650
+ if(get_option('permalink_structure') != '') {
651
+ $seperator = "?";
652
+ } else {
653
+ $seperator = "&";
654
+ }
655
+
656
+
657
+
658
+ /// submit to gateway
659
+ print_r($current_gateway_data);
660
+ $current_gateway_data = &$wpsc_gateways[$submitted_gateway];
661
+ if($current_gateway_data['api_version'] >= 2.0) {
662
+ $merchant_instance = new $current_gateway_data['class_name']($purchase_log_id);
663
+ $merchant_instance->construct_value_array();
664
+ $merchant_instance->submit();
665
+ // print_r($merchant_instance);
666
+
667
+ } else {
668
+ if(($current_gateway_data['internalname'] == $submitted_gateway) && ($current_gateway_data['internalname'] != 'google')) {
669
+ $gateway_used = $current_gateway_data['internalname'];
670
+ $wpdb->query("UPDATE `".WPSC_TABLE_PURCHASE_LOGS."` SET `gateway` = '".$gateway_used."' WHERE `id` = '".$log_id."' LIMIT 1 ;");
671
+ $current_gateway_data['function']($seperator, $sessionid);
672
+ //break;
673
+ } else if (($current_gateway_data['internalname'] == 'google') && ($current_gateway_data['internalname'] == $submitted_gateway)){
674
+ $gateway_used = $current_gateway_data['internalname'];
675
+ $wpdb->query("UPDATE `".WPSC_TABLE_PURCHASE_LOGS."` SET `gateway` = '".$gateway_used."' WHERE `id` = '".$log_id."' LIMIT 1 ;");
676
+ $_SESSION['gateway'] = 'google';
677
+ header('Location: '.get_option('shopping_cart_url'));
678
+ //break;
679
+ }
680
+ }
681
+
682
+ if(isset($_GET['gateway']) && $_GET['gateway'] == 'noca'){
683
+ echo transaction_results($sessionid, true);
684
+ }else{
685
+ }
686
  } else {
687
+
688
+ }
689
  }
690
 
691
  // execute on POST and GET
692
+ if(isset($_REQUEST['wpsc_action']) && ($_REQUEST['wpsc_action'] == 'submit_checkout')) {
693
+ add_action('init', 'wpsc_submit_checkout');
694
  }
695
 
696
+ if(isset($_REQUEST['wpsc_action']) && ($_REQUEST['wpsc_action'] == 'gateway_notification')) {
697
+ add_action('init', 'wpsc_gateway_notification');
698
  }
699
 
700
 
701
  function wpsc_product_rss() {
702
+ global $wpsc_query, $wpdb;
703
+ header("Content-Type: application/xml; charset=UTF-8");
704
+ header('Content-Disposition: inline; filename="E-Commerce_Product_List.rss"');
705
+ //echo "<pre>".print_r($wpsc_query,true)."</pre>";
706
+ require_once(WPSC_FILE_PATH.'/wpsc-includes/rss_template.php');
707
+ exit();
708
  }
709
 
710
 
711
+ if(isset($_REQUEST['wpsc_action']) && ($_REQUEST['wpsc_action'] == "rss")) {
712
+ add_action('template_redirect', 'wpsc_product_rss', 80);
713
  }
714
 
715
 
716
 
717
  function wpsc_gateway_notification() {
718
+ global $wpdb, $wpsc_gateways;
719
+ $gateway_name = $_GET['gateway'];
720
+ // work out what gateway we are getting the request from, run the appropriate code.
721
+ if(($gateway_name != null) && isset($wpsc_gateways[$gateway_name]['class_name'])) {
722
+ $merchant_class = $wpsc_gateways[$gateway_name]['class_name'];
723
+ $merchant_instance = new $merchant_class(null, true);
724
+ $merchant_instance->process_gateway_notification();
725
+ }
726
+ exit();
727
  }
728
 
729
  // execute on POST and GET
730
+ if(isset($_REQUEST['wpsc_action']) && ($_REQUEST['wpsc_action'] == 'gateway_notification')) {
731
+ add_action('init', 'wpsc_gateway_notification');
732
  }
733
 
734
+ if(isset($_GET['termsandconds']) && ($_GET['termsandconds'] === 'true')){
735
+ echo wpautop(stripslashes(get_option('terms_and_conditions')));
736
+ exit();
737
  }
738
 
739
 
740
 
741
  /**
742
+ * wpsc_change_tax function, used through ajax and in normal page loading.
743
+ * No parameters, returns nothing
744
  */
745
  function wpsc_change_tax() {
746
+ global $wpdb, $wpsc_cart, $wpsc_theme_path;
747
+ $form_id = absint($_POST['form_id']);
748
+
749
+ $wpsc_selected_country = $wpsc_cart->selected_country;
750
+ $wpsc_selected_region = $wpsc_cart->selected_region;
751
+
752
+ $wpsc_delivery_country = $wpsc_cart->delivery_country;
753
+ $wpsc_delivery_region = $wpsc_cart->delivery_region;
754
+
755
+
756
+ $previous_country = $_SESSION['wpsc_selected_country'];
757
+ if(isset($_POST['billing_country'])){
758
+ $wpsc_selected_country = $wpdb->escape($_POST['billing_country']);
759
+ $_SESSION['wpsc_selected_country'] = $wpsc_selected_country;
760
+ }
761
+
762
+ if(isset($_POST['billing_region'])){
763
+ $wpsc_selected_region = absint($_POST['billing_region']);
764
+ $_SESSION['wpsc_selected_region'] = $wpsc_selected_region;
765
+ }
766
+
767
+ $check_country_code = $wpdb->get_var(" SELECT `country`.`isocode` FROM `".WPSC_TABLE_REGION_TAX."` AS `region` INNER JOIN `".WPSC_TABLE_CURRENCY_LIST."` AS `country` ON `region`.`country_id` = `country`.`id` WHERE `region`.`id` = '".$_SESSION['wpsc_selected_region']."' LIMIT 1");
768
+
769
+ if($_SESSION['wpsc_selected_country'] != $check_country_code) {
770
+ $wpsc_selected_region = null;
771
+ }
772
+
773
+ if(isset($_POST['shipping_country'])){
774
+ $wpsc_delivery_country = $wpdb->escape($_POST['shipping_country']);
775
+ $_SESSION['wpsc_delivery_country'] = $wpsc_delivery_country;
776
+ }
777
+ if(isset($_POST['shipping_region'])){
778
+ $wpsc_delivery_region = absint($_POST['shipping_region']);
779
+ $_SESSION['wpsc_delivery_region'] = $wpsc_delivery_region;
780
+ }
781
+
782
+ $check_country_code = $wpdb->get_var(" SELECT `country`.`isocode` FROM `".WPSC_TABLE_REGION_TAX."` AS `region` INNER JOIN `".WPSC_TABLE_CURRENCY_LIST."` AS `country` ON `region`.`country_id` = `country`.`id` WHERE `region`.`id` = '".$wpsc_delivery_region."' LIMIT 1");
783
+
784
+ if($wpsc_delivery_country != $check_country_code) {
785
+ $wpsc_delivery_region = null;
786
+ }
787
+
788
+
789
+ $wpsc_cart->update_location();
790
+ $wpsc_cart->get_shipping_method();
791
+ $wpsc_cart->get_shipping_option();
792
+ if($wpsc_cart->selected_shipping_method != '') {
793
+ $wpsc_cart->update_shipping($wpsc_cart->selected_shipping_method, $wpsc_cart->selected_shipping_option);
794
+ }
795
+
796
+
797
+
798
+
799
+
800
+ $tax = $wpsc_cart->calculate_total_tax();
801
+ $total = wpsc_cart_total();
802
+ ob_start();
803
+ $cur_wpsc_theme_folder = apply_filters('wpsc_theme_folder',$wpsc_theme_path.WPSC_THEME_DIR);
804
+ include_once($cur_wpsc_theme_folder."/cart_widget.php");
805
+ $output = ob_get_contents();
806
+ ob_end_clean();
807
+ //exit("/*<pre>".print_r($wpsc_cart,true)."</pre>*/");
808
+ $output = str_replace(Array("\n","\r") , Array("\\n","\\r"),addslashes($output));
809
+ if(get_option('lock_tax') == 1){
810
+ //echo "jQuery('#region').val(".$_SESSION['wpsc_delivery_region']."); \n";
811
+ echo "jQuery('#current_country').val('".$_SESSION['wpsc_delivery_country']."'); \n";
812
+ if($_SESSION['wpsc_delivery_country']== 'US' && get_option('lock_tax') == 1){
813
+ //exit('<pre>'.print_r($_SESSION, true).'</pre>');
814
+ $output = wpsc_shipping_region_list($_SESSION['wpsc_delivery_country'], $_SESSION['wpsc_delivery_region']);
815
+ // echo 'jQuery("#change_country").append(\''.$output.'\');\n\r';
816
+ $output = str_replace(Array("\n","\r") , Array("\\n","\\r"),addslashes($output));
817
+ echo "jQuery('#region').remove();\n\r";
818
+ echo "jQuery('#change_country').append(\"".$output."\");\n\r";
819
+ }
820
+ }
821
+
822
+
823
+ foreach($wpsc_cart->cart_items as $key => $cart_item) {
824
+ echo "jQuery('#shipping_$key').html(\"".$wpsc_cart->process_as_currency($cart_item->shipping)."\");\n\r";
825
+
826
+ }
827
+
828
+ echo "jQuery('#checkout_shipping').html(\"".wpsc_cart_shipping()."\");\n\r";
829
+
830
+ echo "jQuery('div.shopping-cart-wrapper').html('$output');\n";
831
+ if(get_option('lock_tax') == 1){
832
+ echo "jQuery('.shipping_country').val('".$_SESSION['wpsc_delivery_country']."') \n";
833
+ $sql ="SELECT `country` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `isocode`='".$_SESSION['wpsc_selected_country']."'";
834
+ $country_name = $wpdb->get_var($sql);
835
+ echo "jQuery('.shipping_country_name').html('".$country_name."') \n";
836
+ }
837
+
838
+
839
+ $form_selected_country = null;
840
+ $form_selected_region = null;
841
+ $onchange_function = null;
842
+
843
+ if(($_POST['billing_country'] != 'undefined') && !isset($_POST['shipping_country'])) {
844
+ $form_selected_country = $wpsc_selected_country;
845
+ $form_selected_region = $wpsc_selected_region;
846
+ $onchange_function = 'set_billing_country';
847
+ } else if(($_POST['shipping_country'] != 'undefined') && !isset($_POST['billing_country'])) {
848
+ $form_selected_country = $wpsc_delivery_country;
849
+ $form_selected_region = $wpsc_delivery_region;
850
+ $onchange_function = 'set_shipping_country';
851
+ }
852
+
853
+ if(($form_selected_country != null) && ($onchange_function != null)) {
854
+ $region_list = $wpdb->get_results("SELECT `".WPSC_TABLE_REGION_TAX."`.* FROM `".WPSC_TABLE_REGION_TAX."`, `".WPSC_TABLE_CURRENCY_LIST."` WHERE `".WPSC_TABLE_CURRENCY_LIST."`.`isocode` IN('".$form_selected_country."') AND `".WPSC_TABLE_CURRENCY_LIST."`.`id` = `".WPSC_TABLE_REGION_TAX."`.`country_id`",ARRAY_A) ;
855
+ if($region_list != null) {
856
+
857
+ $output = "<select name='collected_data[".$form_id."][1]' class='current_region' onchange='$onchange_function(\"region_country_form_$form_id\", \"$form_id\");'>\n\r";
858
+
859
+ foreach($region_list as $region) {
860
+ if($form_selected_region == $region['id']) {
861
+ $selected = "selected='selected'";
862
+ } else {
863
+ $selected = "";
864
+ }
865
+ $output .= " <option value='".$region['id']."' $selected>".htmlspecialchars($region['name'])."</option>\n\r";
866
+ }
867
+ $output .= "</select>\n\r";
868
+
869
+ $output = str_replace(Array("\n","\r") , Array("\\n","\\r"),addslashes($output));
870
+ echo "jQuery('#region_select_$form_id').html(\"".$output."\");\n\r";
871
+
872
+ } else {
873
+ if(get_option('lock_tax') == 1){
874
+ echo "jQuery('#region').hide();";
875
+ }
876
+ echo "jQuery('#region_select_$form_id').html('');\n\r";
877
+ }
878
+ }
879
+
880
+
881
+
882
+
883
+
884
+ if($tax > 0) {
885
+ echo "jQuery(\"tr.total_tax\").show();\n\r";
886
+ } else {
887
+ echo "jQuery(\"tr.total_tax\").hide();\n\r";
888
+ }
889
+ echo "jQuery('#checkout_tax').html(\"<span class='pricedisplay'>".wpsc_cart_tax()."</span>\");\n\r";
890
+ echo "jQuery('#checkout_total').html(\"<span class='pricedisplay'>{$total}</span><input id='shopping_cart_total_price' type='hidden' value='{$total}' />\");\n\r";
891
+ //echo "\n\r/*\n\r{$wpsc_cart->tax_percentage}\n\r*/\n\r";
892
+ exit();
893
  }
894
 
895
  // execute on POST and GET
896
+ if(isset($_REQUEST['wpsc_ajax_action']) && ($_REQUEST['wpsc_ajax_action'] == 'change_tax')) {
897
+ add_action('init', 'wpsc_change_tax');
898
  }
899
 
900
 
903
  */
904
 
905
  function wpsc_scale_image() {
906
+ global $wpdb;
907
+ require_once(ABSPATH . 'wp-admin/includes/image.php');
908
+ $attachment_id = absint($_REQUEST['attachment_id']);
909
+ $width = absint($_REQUEST['width']);
910
+ $height = absint($_REQUEST['height']);
911
+ $intermediate_size = '';
912
+
913
+ if((($width >= 10) && ($height >= 10)) && (($width <= 1024) && ($height <= 1024))) {
914
+ $intermediate_size = "wpsc-{$width}x{$height}";
915
+ $generate_thumbnail = true;
916
+ } else {
917
+ if (isset($_REQUEST['intermediate_size']))
918
+ $intermediate_size = $wpdb->escape($_REQUEST['intermediate_size']);
919
+ $generate_thumbnail = false;
920
+ }
921
+
922
+ // If the attachment ID is greater than 0, and the width and height is greater than or equal to 10, and less than or equal to 1024
923
+ if(($attachment_id > 0) && ($intermediate_size != '')) {
924
+ // Get all the required information about the attachment
925
+ $uploads = wp_upload_dir();
926
+
927
+ $image_meta = get_post_meta($attachment_id, '');
928
+ $file_path = get_attached_file($attachment_id);
929
+ foreach($image_meta as $meta_name => $meta_value) { // clean up the meta array
930
+ $image_meta[$meta_name] = maybe_unserialize(array_pop($meta_value));
931
+ }
932
+ if (!isset($image_meta['_wp_attachment_metadata'])) $image_meta['_wp_attachment_metadata'] = '';
933
+ $attachment_metadata = $image_meta['_wp_attachment_metadata'];
934
+
935
+ if (!isset($attachment_metadata['sizes'])) $attachment_metadata['sizes'] = '';
936
+ if (!isset($attachment_metadata['sizes'][$intermediate_size])) $attachment_metadata['sizes'][$intermediate_size] = '';
937
+
938
+ // determine if we already have an image of this size
939
+ if((count($attachment_metadata['sizes']) > 0) && ($attachment_metadata['sizes'][$intermediate_size])) {
940
+ $intermediate_image_data = image_get_intermediate_size($attachment_id, $intermediate_size);
941
+ if(file_exists($file_path)) {
942
+ $original_modification_time = filemtime($file_path);
943
+ $cache_modification_time = filemtime($uploads['basedir']."/".$intermediate_image_data['path']);
944
+ if($original_modification_time < $cache_modification_time) {
945
+ $generate_thumbnail = false;
946
+ }
947
+ }
948
+ //header("Location: ".$cache_url.$cache_filename.$extension);
949
+ }
950
+
951
+ if($generate_thumbnail == true) {
952
+ //JS - 7.1.2010 - Added true parameter to function to not crop - causing issues on WPShop
953
+ $intermediate_size_data = image_make_intermediate_size($file_path, $width, $height, true);
954
+ $attachment_metadata['sizes'][$intermediate_size] = $intermediate_size_data;
955
+ wp_update_attachment_metadata($attachment_id, $attachment_metadata);
956
+ $intermediate_image_data =image_get_intermediate_size($attachment_id, $intermediate_size);
957
+ }
958
+
959
+ //
960
+ //echo "<pre>".print_r((int)$generate_thumbnail,true)."</pre>";
961
+ //echo "<pre>".print_r($intermediate_image_data,true)."</pre>";
962
+
963
+ /// if we are serving the page using SSL, we have to use for the image too.
964
+ if(is_ssl()) {
965
+ $output_url = str_replace("http://", "https://", $intermediate_image_data['url']);
966
+ } else {
967
+ $output_url = $intermediate_image_data['url'];
968
+ }
969
+ wp_redirect($output_url);
970
+ } else {
971
+ _e("Invalid Image parameters", 'wpsc');
972
+ }
973
+ exit();
974
  }
975
 
976
 
977
+ if(isset($_REQUEST['wpsc_action']) && isset($_REQUEST['attachment_id']) && ($_REQUEST['wpsc_action'] == 'scale_image') && is_numeric($_REQUEST['attachment_id'])) {
978
+ add_action('init', 'wpsc_scale_image');
979
  }
980
 
981
+
982
 
983
 
984
  function wpsc_download_file() {
985
+ global $wpdb,$user_level,$wp_rewrite;
986
+ get_currentuserinfo();
987
+
988
+ if(isset($_GET['downloadid'])) {
989
+ // strip out anything that isnt 'a' to 'z' or '0' to '9'
990
+ //ini_set('max_execution_time',10800);
991
+ $downloadid = preg_replace("/[^a-z0-9]+/i",'',strtolower($_GET['downloadid']));
992
+ $download_data = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_DOWNLOAD_STATUS."` WHERE `uniqueid` = '".$downloadid."' AND `downloads` > '0' AND `active`='1' LIMIT 1",ARRAY_A);
993
+
994
+ if(($download_data == null) && is_numeric($downloadid)) {
995
+ $download_data = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_DOWNLOAD_STATUS."` WHERE `id` = '".$downloadid."' AND `downloads` > '0' AND `active`='1' AND `uniqueid` IS NULL LIMIT 1",ARRAY_A);
996
+ }
997
+
998
+ if((get_option('wpsc_ip_lock_downloads') == 1) && ($_SERVER['REMOTE_ADDR'] != null)) {
999
+ $ip_number = $_SERVER['REMOTE_ADDR'];
1000
+ if($download_data['ip_number'] == '') {
1001
+ // if the IP number is not set, set it
1002
+ $wpdb->query("UPDATE `".WPSC_TABLE_DOWNLOAD_STATUS."` SET `ip_number` = '{$ip_number}' WHERE `id` = '{$download_data['id']}' LIMIT 1");
1003
+ } else if($ip_number != $download_data['ip_number']) {
1004
+ // if the IP number is set but does not match, fail here.
1005
+ exit(WPSC_DOWNLOAD_INVALID);
1006
+ }
1007
+ }
1008
+
1009
+ if(wpsc_get_meta($download_data['id'], '_is_legacy', 'wpsc_downloads') == 'true') {
1010
+ $file_id = wpsc_get_meta($download_data['fileid'], '_new_file_id', 'wpsc_files');
1011
+ } else {
1012
+ $file_id = $download_data['fileid'];
1013
+
1014
+ }
1015
+
1016
+ //exit($file_id. "-".$download_data['fileid']);
1017
+
1018
+ $file_data = get_post($file_id);
1019
+
1020
+ if($file_data == null) {
1021
+ exit(WPSC_DOWNLOAD_INVALID);
1022
+ }
1023
+
1024
+ if($download_data != null) {
1025
+ if((int)$download_data['downloads'] >= 1) {
1026
+ $download_count = (int)$download_data['downloads'] - 1;
1027
+ } else {
1028
+ $download_count = 0;
1029
+ }
1030
+
1031
+
1032
+ $wpdb->query("UPDATE `".WPSC_TABLE_DOWNLOAD_STATUS."` SET `downloads` = '{$download_count}' WHERE `id` = '{$download_data['id']}' LIMIT 1");
1033
+ $cart_contents = $wpdb->get_results('SELECT `'.WPSC_TABLE_CART_CONTENTS.'`.*,`'.WPSC_TABLE_PRODUCT_LIST.'`.`file` FROM `'.WPSC_TABLE_CART_CONTENTS.'` LEFT JOIN `'.WPSC_TABLE_PRODUCT_LIST.'` ON `'.WPSC_TABLE_CART_CONTENTS.'`.`prodid`= `'.WPSC_TABLE_PRODUCT_LIST.'`.`id` WHERE `purchaseid` ='.$download_data['purchid'], ARRAY_A);
1034
+ $dl = 0;
1035
+
1036
+
1037
+
1038
+ foreach($cart_contents as $cart_content) {
1039
+ if($cart_content['file'] == 1) {
1040
+ $dl++;
1041
+ }
1042
+ }
1043
+ if(count($cart_contents) == $dl) {
1044
+ $wpdb->query("UPDATE `".WPSC_TABLE_PURCHASE_LOGS."` SET `processed` = '4' WHERE `id` = '".$download_data['purchid']."' LIMIT 1");
1045
+ }
1046
+
1047
+
1048
+
1049
+ do_action('wpsc_alter_download_action', $file_id);
1050
+
1051
+ //exit('<pre>'.print_r($cart_contents,true).'</pre>');
1052
+ $file_path = WPSC_FILE_DIR.basename($file_data->post_name);
1053
+ $file_name = basename($file_data->post_title);
1054
+
1055
+
1056
+
1057
+ if(is_file($file_path)) {
1058
+ header('Content-Type: '.$file_data->post_mime_type);
1059
+ header('Content-Length: '.filesize($file_path));
1060
+ header('Content-Transfer-Encoding: binary');
1061
+ header('Content-Disposition: attachment; filename="'.stripslashes($file_name).'"');
1062
+ if(isset($_SERVER["HTTPS"]) && ($_SERVER["HTTPS"] != '')) {
1063
+ /*
1064
+ There is a bug in how IE handles downloads from servers using HTTPS, this is part of the fix, you may also need:
1065
+ session_cache_limiter('public');
1066
+ session_cache_expire(30);
1067
+ At the start of your index.php file or before the session is started
1068
+ */
1069
+ header("Pragma: public");
1070
+ header("Expires: 0");
1071
+ header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
1072
+ header("Cache-Control: public");
1073
+ } else {
1074
+ header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
1075
+ }
1076
+ // destroy the session to allow the file to be downloaded on some buggy browsers and webservers
1077
+ session_destroy();
1078
+ wpsc_readfile_chunked($file_path);
1079
+ exit();
1080
+ }
1081
+ } else {
1082
+ exit(WPSC_DOWNLOAD_INVALID);
1083
+ }
1084
+ } else {
1085
+ if(isset($_GET['admin_preview']) && ($_GET['admin_preview'] == "true") && is_numeric($_GET['product_id']) && current_user_can('edit_plugins')) {
1086
+ $product_id = $_GET['product_id'];
1087
+ $product_data = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE `id` = '$product_id' LIMIT 1",ARRAY_A);
1088
+ if(is_numeric($product_data[0]['file']) && ($product_data[0]['file'] > 0)) {
1089
+ $file_data = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_PRODUCT_FILES."` WHERE `id`='".$product_data[0]['file']."' LIMIT 1",ARRAY_A) ;
1090
+ $file_data = $file_data[0];
1091
+
1092
+ do_action('wpsc_alter_download_action',$file_id);
1093
+
1094
+ if(is_file(WPSC_FILE_DIR.$file_data['idhash'])) {
1095
+ header('Content-Type: '.$file_data['mimetype']);
1096
+ header('Content-Length: '.filesize(WPSC_FILE_DIR.$file_data['idhash']));
1097
+ header('Content-Transfer-Encoding: binary');
1098
+ if($_GET['preview_track'] != 'true') {
1099
+ header('Content-Disposition: attachment; filename="'.$file_data['filename'].'"');
1100
+ } else {
1101
+ header('Content-Disposition: inline; filename="'.$file_data['filename'].'"');
1102
+ }
1103
+ if(isset($_SERVER["HTTPS"]) && ($_SERVER["HTTPS"] != '')) {
1104
+ header("Pragma: public");
1105
+ header("Expires: 0");
1106
+ header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
1107
+ header("Cache-Control: public");
1108
+ } else {
1109
+ header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
1110
+ }
1111
+ $filename = WPSC_FILE_DIR.$file_data['idhash'];
1112
+ session_destroy();
1113
+ wpsc_readfile_chunked($filename);
1114
+ exit();
1115
+ }
1116
+ }
1117
+ }
1118
+ }
1119
  }
1120
 
1121
  add_action('init', 'wpsc_download_file');
1122
+ ?>
wpsc-includes/breadcrumbs.class.php CHANGED
@@ -78,12 +78,12 @@ class wpsc_breadcrumbs {
78
  global $wp_query;
79
  $this->breadcrumbs = array();
80
 
81
-
82
- $query_data = array(
83
- 'category' => $wp_query->query_vars['products'],
84
- 'product' => $wp_query->query_vars['name']
85
- );
86
-
87
 
88
  if(!empty($query_data['product']) && !empty($wp_query->post)) {
89
  $this->breadcrumbs[] = array(
@@ -93,8 +93,11 @@ class wpsc_breadcrumbs {
93
 
94
  }
95
 
96
-
97
- $term_data = get_term_by('slug', $query_data['category'], 'wpsc_product_category');
 
 
 
98
  if( $term_data != false) {
99
  $this->breadcrumbs[] = array(
100
  'name' => htmlentities( $term_data->name, ENT_QUOTES, 'UTF-8'),
78
  global $wp_query;
79
  $this->breadcrumbs = array();
80
 
81
+ if ( isset($wp_query->query_vars['products']) && isset($wp_query->query_vars['name']) ) {
82
+ $query_data = array(
83
+ 'category' => $wp_query->query_vars['products'],
84
+ 'product' => $wp_query->query_vars['name']
85
+ );
86
+ }
87
 
88
  if(!empty($query_data['product']) && !empty($wp_query->post)) {
89
  $this->breadcrumbs[] = array(
93
 
94
  }
95
 
96
+ if(isset($query_data['category'])) {
97
+ $term_data = get_term_by('slug', $query_data['category'], 'wpsc_product_category');
98
+ } else {
99
+ $term_data = get_term_by('slug', 'uncategorized', 'wpsc_product_category');
100
+ }
101
  if( $term_data != false) {
102
  $this->breadcrumbs[] = array(
103
  'name' => htmlentities( $term_data->name, ENT_QUOTES, 'UTF-8'),
wpsc-includes/cart.class.php CHANGED
@@ -9,7 +9,7 @@
9
  *
10
  * @package wp-e-commerce
11
  * @since 3.7
12
- * @subpackage wpsc-cart-classes
13
  */
14
  /**
15
  * The WPSC Cart API for templates
@@ -24,20 +24,23 @@
24
  * * @return boolean true or false depending on settings>general page
25
  */
26
  function wpsc_tax_isincluded() {
27
- if(get_option('tax_inprice') == false || get_option('tax_inprice') == '0'){
28
- return false;
29
- }elseif(get_option('tax_inprice')=='1'){
30
- return true;
31
- }
 
 
 
32
  }
33
 
34
  function wpsc_cart_item_count() {
35
- global $wpsc_cart;
36
- $count = 0;
37
- foreach((array)$wpsc_cart->cart_items as $cart_item) {
38
- $count += $cart_item->quantity;
39
- }
40
- return $count;
41
  }
42
 
43
 
@@ -46,13 +49,13 @@ function wpsc_cart_item_count() {
46
  * * @return integer the item count
47
  */
48
  function wpsc_coupon_amount($forDisplay=true) {
49
- global $wpsc_cart;
50
- if($forDisplay == true) {
51
- $output = $wpsc_cart->process_as_currency($wpsc_cart->coupons_amount);
52
- } else {
53
- $output = $wpsc_cart->coupons_amount;
54
- }
55
- return $output;
56
  }
57
 
58
  /**
@@ -60,20 +63,20 @@ function wpsc_coupon_amount($forDisplay=true) {
60
  * @return string the total price of the cart, with a currency sign
61
  */
62
  function wpsc_cart_total($forDisplay=true) {
63
- global $wpsc_cart;
64
- $total = $wpsc_cart->calculate_subtotal();
65
- $total += $wpsc_cart->calculate_total_shipping();
66
- if(wpsc_tax_isincluded() == false){
67
- $total += $wpsc_cart->calculate_total_tax();
68
- }
69
-
70
- $total -= $wpsc_cart->coupons_amount;
71
- if($forDisplay){
72
- // exit('abksd'.get_option('add_plustax'));
73
- return $wpsc_cart->process_as_currency($total);
74
- }else{
75
- return $total;
76
- }
77
  }
78
 
79
  /**
@@ -86,27 +89,27 @@ function wpsc_cart_total($forDisplay=true) {
86
  * @return string The subtotal price of the cart, with a currency sign.
87
  */
88
  function wpsc_cart_total_widget( $shipping = true, $tax = true, $coupons = true ) {
89
-
90
- global $wpsc_cart;
91
-
92
- $total = $wpsc_cart->calculate_subtotal();
93
-
94
- if ( $shipping ) {
95
- $total += $wpsc_cart->calculate_total_shipping();
96
- }
97
- if ( $tax && wpsc_tax_isincluded() == false ) {
98
- $total += $wpsc_cart->calculate_total_tax();
99
- }
100
- if ( $coupons ) {
101
- $total -= $wpsc_cart->coupons_amount;
102
- }
103
-
104
- if ( get_option( 'add_plustax' ) == 1 ) {
105
- return $wpsc_cart->process_as_currency( $wpsc_cart->calculate_subtotal() );
106
- } else {
107
- return $wpsc_cart->process_as_currency( $total );
108
- }
109
-
110
  }
111
 
112
  /**
@@ -114,13 +117,13 @@ function wpsc_cart_total_widget( $shipping = true, $tax = true, $coupons = true
114
  * @return string the total price of the cart, with a currency sign
115
  */
116
  function nzshpcrt_overall_total_price() {
117
- global $wpsc_cart;
118
- $total = $wpsc_cart->calculate_subtotal();
119
- $total += $wpsc_cart->calculate_total_shipping();
120
- if(wpsc_tax_isincluded() == false){
121
- $total += $wpsc_cart->calculate_total_tax();
122
- }
123
- $total -= $wpsc_cart->coupons_amount;
124
  return $total;
125
  }
126
 
@@ -129,12 +132,12 @@ function nzshpcrt_overall_total_price() {
129
  * @return float the total weight of the cart
130
  */
131
  function wpsc_cart_weight_total() {
132
- global $wpsc_cart;
133
- if(is_object($wpsc_cart)) {
134
- return $wpsc_cart->calculate_total_weight();
135
- } else {
136
- return 0;
137
- }
138
  }
139
 
140
  /**
@@ -142,17 +145,17 @@ function wpsc_cart_weight_total() {
142
  * @return float the total weight of the cart
143
  */
144
  function wpsc_cart_tax($forDisplay = true) {
145
- global $wpsc_cart;
146
- if($forDisplay){
147
- if(wpsc_tax_isincluded() == false){
148
- return $wpsc_cart->process_as_currency($wpsc_cart->calculate_total_tax());
149
- }else{
150
- return '('.$wpsc_cart->process_as_currency($wpsc_cart->calculate_total_tax()).')';
151
- }
152
-
153
- }else{
154
- return $wpsc_cart->calculate_total_tax();
155
- }
156
  }
157
 
158
 
@@ -162,15 +165,15 @@ function wpsc_cart_tax($forDisplay = true) {
162
  * @return boolean true or false, for use with an if statement
163
  */
164
  function wpsc_cart_show_plus_postage() {
165
- global $wpsc_cart;
166
- // exit($_SESSION['wpsc_has_been_to_checkout'] ."get_option('add_plustax')".get_option('add_plustax'));
167
- if(($_SESSION['wpsc_has_been_to_checkout'] == null ) && (get_option('add_plustax') == 1)) {
168
 
169
- return true;
170
 
171
- } else {
172
- return false;
173
- }
174
  }
175
 
176
  /**
@@ -178,28 +181,28 @@ function wpsc_cart_show_plus_postage() {
178
  * @return boolean if true, all items in the cart do use shipping
179
  */
180
  function wpsc_uses_shipping() {
181
- global $wpsc_cart;
182
- $shippingoptions = get_option('custom_shipping_options');
183
- if( (!((get_option('shipping_discount')== 1) && (get_option('shipping_discount_value') <= $wpsc_cart->calculate_subtotal()))) && count($shippingoptions) >= 1 && $shippingoptions[0] != '' && get_option('do_not_use_shipping') == 0) {
184
- $status = $wpsc_cart->uses_shipping();
185
- } else {
186
- $status = false;
187
- }
188
- return $status;
189
  }
190
-
191
  /**
192
  * cart has shipping function, no parameters
193
  * @return boolean true for yes, false for no
194
  */
195
  function wpsc_cart_has_shipping() {
196
- global $wpsc_cart;
197
- if($wpsc_cart->calculate_total_shipping() > 0) {
198
- $output = true;
199
- } else {
200
- $output = false;
201
- }
202
- return $output;
203
  }
204
 
205
  /**
@@ -207,8 +210,8 @@ function wpsc_cart_has_shipping() {
207
  * @return string the total shipping of the cart, with a currency sign
208
  */
209
  function wpsc_cart_shipping() {
210
- global $wpsc_cart;
211
- return $wpsc_cart->process_as_currency($wpsc_cart->calculate_total_shipping());
212
  }
213
 
214
 
@@ -217,16 +220,16 @@ function wpsc_cart_shipping() {
217
  * @return array array of the categories
218
  */
219
  function wpsc_cart_item_categories($get_ids = false) {
220
- global $wpsc_cart;
221
- if(is_object($wpsc_cart)) {
222
- if($get_ids == true) {
223
- return $wpsc_cart->get_item_category_ids();
224
- } else {
225
- return $wpsc_cart->get_item_categories();
226
- }
227
- } else {
228
- return array();
229
- }
230
  }
231
 
232
  /**
@@ -234,67 +237,67 @@ function wpsc_cart_item_categories($get_ids = false) {
234
  * @return boolean true if there are cart items left
235
  */
236
  function wpsc_have_cart_items() {
237
- global $wpsc_cart;
238
- return $wpsc_cart->have_cart_items();
239
  }
240
 
241
  function wpsc_the_cart_item() {
242
- global $wpsc_cart;
243
- return $wpsc_cart->the_cart_item();
244
  }
245
-
246
-
247
-
248
  /**
249
  * cart item key function, no parameters
250
  * @return integer - the cart item key from the array in the cart object
251
  */
252
  function wpsc_the_cart_item_key() {
253
- global $wpsc_cart;
254
- return $wpsc_cart->current_cart_item;
255
  }
256
-
257
  /**
258
  * cart item name function, no parameters
259
  * @return string the cart item name
260
  */
261
  function wpsc_cart_item_name() {
262
- global $wpsc_cart;
263
- return htmlentities(stripslashes($wpsc_cart->cart_item->product_name), ENT_QUOTES, "UTF-8");
264
  }
265
  /**
266
  * cart item quantity function, no parameters
267
  * @return string the selected quantity of items
268
  */
269
  function wpsc_cart_item_product_id() {
270
- global $wpsc_cart;
271
- return $wpsc_cart->cart_item->product_id;
272
- }
273
  /**
274
  * cart item quantity function, no parameters
275
  * @return string the selected quantity of items
276
  */
277
  function wpsc_cart_item_quantity() {
278
- global $wpsc_cart;
279
- return $wpsc_cart->cart_item->quantity;
280
  }
281
 
282
  function wpsc_cart_item_quantity_single_prod($id) {
283
- global $wpsc_cart;
284
- //exit('<pre>'.print_r($wpsc_cart, true).'</pre>');
285
- return $wpsc_cart;
286
  }
287
  /**
288
  * cart item price function, no parameters
289
  * @return string the cart item price multiplied by the quantity, with a currency sign
290
  */
291
  function wpsc_cart_item_price($forDisplay = true) {
292
- global $wpsc_cart;
293
- if($forDisplay){
294
- return $wpsc_cart->process_as_currency($wpsc_cart->cart_item->total_price);
295
- }else{
296
- return $wpsc_cart->cart_item->total_price;
297
- }
298
  }
299
 
300
  /**
@@ -302,12 +305,12 @@ function wpsc_cart_item_price($forDisplay = true) {
302
  * @return string the cart item price multiplied by the quantity, with a currency sign
303
  */
304
  function wpsc_cart_item_shipping($forDisplay = true) {
305
- global $wpsc_cart;
306
- if($forDisplay){
307
- return $wpsc_cart->process_as_currency($wpsc_cart->cart_item->shipping);
308
- }else{
309
- return $wpsc_cart->cart_item->shipping;
310
- }
311
  }
312
 
313
 
@@ -317,8 +320,8 @@ function wpsc_cart_item_shipping($forDisplay = true) {
317
  * @return string the cart item url
318
  */
319
  function wpsc_cart_item_url() {
320
- global $wpsc_cart;
321
- return $wpsc_cart->cart_item->product_url;
322
  }
323
 
324
  /**
@@ -329,19 +332,19 @@ function wpsc_cart_item_url() {
329
  * @return string url to the to the cart item thumbnail image
330
  */
331
  function wpsc_cart_item_image($width = null, $height = null) {
332
- global $wpsc_cart;
333
- $image_data = $wpsc_cart->cart_item->thumbnail_image;
334
- //echo "<pre>".print_r($wpsc_cart->cart_item,true)."</pre>";
335
-
336
- if(($width > 0) && ($height > 0)) {
337
- $image_path = "index.php?wpsc_action=scale_image&amp;attachment_id={$image_data->ID}&amp;width=".$width."&amp;height=".$height."";
338
- } else {
339
- $image_path = WPSC_THUMBNAIL_URL.$wpsc_cart->cart_item->thumbnail_image;
340
- if(is_ssl()) {
341
- $image_path = str_replace("http://", "https://", $image_path);
342
- }
343
- }
344
- return $image_path;
345
  }
346
 
347
  /**
@@ -352,59 +355,59 @@ function wpsc_cart_item_image($width = null, $height = null) {
352
  * @return array of shipping options
353
  */
354
  function wpsc_selfURL() {
355
- $s = empty($_SERVER["HTTPS"]) ? "" : ($_SERVER["HTTPS"] == "on") ? "s" : "";
356
- $protocol = wpsc_strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/").$s;
357
- $port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]);
358
- return $protocol."://".$_SERVER['SERVER_NAME'].$port.$_SERVER['REQUEST_URI'];
359
  }
360
 
361
  function wpsc_strleft($s1, $s2) {
362
- $values = substr($s1, 0, strpos($s1, $s2));
363
- return $values;
364
  }
365
  function wpsc_google_checkout(){
366
- $currpage = wpsc_selfURL();
367
- //exit('<pre>'.print_r(get_option('custom_gateway_options'), true).'</pre>');
368
- if (array_search("google",(array)get_option('custom_gateway_options')) !== false && $currpage != get_option('shopping_cart_url')) {
369
- global $nzshpcrt_gateways;
370
- foreach($nzshpcrt_gateways as $gateway) {
371
- if($gateway['internalname'] == 'google' ) {
372
- $gateway_used = $gateway['internalname'];
373
- $gateway['function'](true);
374
- }
375
- }
376
- }
377
  }
378
  function wpsc_empty_google_logs(){
379
- global $wpdb;
380
- $sql="DELETE FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `sessionid`=".$_SESSION['wpsc_sessionid'];
381
- $wpdb->query($sql);
382
- unset($_SESSION['wpsc_sessionid']);
383
-
384
  }
385
  /**
386
  * have shipping methods function, no parameters
387
  * @return boolean
388
  */
389
  function wpsc_have_shipping_methods() {
390
- global $wpsc_cart;
391
- return $wpsc_cart->have_shipping_methods();
392
  }
393
  /**
394
  * the shipping method function, no parameters
395
  * @return boolean
396
  */
397
  function wpsc_the_shipping_method() {
398
- global $wpsc_cart;
399
- return $wpsc_cart->the_shipping_method();
400
  }
401
  /**
402
  * the shipping method name function, no parameters
403
  * @return string shipping method name
404
  */
405
  function wpsc_shipping_method_name() {
406
- global $wpsc_cart, $wpsc_shipping_modules;
407
- return $wpsc_shipping_modules[$wpsc_cart->shipping_method]->name;
408
  }
409
 
410
 
@@ -413,8 +416,8 @@ function wpsc_shipping_method_name() {
413
  * @return string shipping method internal name
414
  */
415
  function wpsc_shipping_method_internal_name() {
416
- global $wpsc_cart, $wpsc_shipping_modules;
417
- return $wpsc_cart->shipping_method;
418
  }
419
 
420
 
@@ -423,8 +426,8 @@ function wpsc_shipping_method_internal_name() {
423
  * @return string the cart item url
424
  */
425
  function wpsc_have_shipping_quotes() {
426
- global $wpsc_cart;
427
- return $wpsc_cart->have_shipping_quotes();
428
  }
429
 
430
  /**
@@ -432,8 +435,8 @@ function wpsc_have_shipping_quotes() {
432
  * @return string the cart item url
433
  */
434
  function wpsc_the_shipping_quote() {
435
- global $wpsc_cart;
436
- return $wpsc_cart->the_shipping_quote();
437
  }
438
 
439
  /**
@@ -441,8 +444,8 @@ function wpsc_the_shipping_quote() {
441
  * @return string shipping quote name
442
  */
443
  function wpsc_shipping_quote_name() {
444
- global $wpsc_cart;
445
- return $wpsc_cart->shipping_quote['name'];
446
  }
447
 
448
  /**
@@ -450,13 +453,13 @@ function wpsc_shipping_quote_name() {
450
  * @return string shipping quote value
451
  */
452
  function wpsc_shipping_quote_value($numeric = false) {
453
- global $wpsc_cart;
454
- //echo 'Shipping value'.$wpsc_cart->shipping_quote['value'];
455
- if($numeric == true) {
456
- return $wpsc_cart->shipping_quote['value'];
457
- } else {
458
- return $wpsc_cart->process_as_currency($wpsc_cart->shipping_quote['value']);
459
- }
460
  }
461
 
462
  /**
@@ -464,8 +467,8 @@ function wpsc_shipping_quote_value($numeric = false) {
464
  * @return string shipping quote html ID
465
  */
466
  function wpsc_shipping_quote_html_id() {
467
- global $wpsc_cart;
468
- return $wpsc_cart->shipping_method."_".$wpsc_cart->current_shipping_quote;
469
  }
470
 
471
  /**
@@ -473,16 +476,16 @@ function wpsc_shipping_quote_html_id() {
473
  * @return string true or false
474
  */
475
  function wpsc_shipping_quote_selected_state() {
476
- global $wpsc_cart;
477
-
478
- if(($wpsc_cart->selected_shipping_method == $wpsc_cart->shipping_method) && ($wpsc_cart->selected_shipping_option == $wpsc_cart->shipping_quote['name']) ) {
479
- return "checked='checked'";
480
- } else {
481
- return "";
482
- }
483
  }
484
  function wpsc_have_morethanone_shipping_quote(){
485
- global $wpsc_cart;
486
 
487
  // if it's fixed rate shipping, and all the prices are the same, then there aren't really options.
488
  if (count($wpsc_cart->shipping_methods) == 1 && $wpsc_cart->shipping_methods[0] == 'flatrate') {
@@ -501,14 +504,14 @@ function wpsc_have_morethanone_shipping_quote(){
501
  }
502
 
503
  function wpsc_have_morethanone_shipping_methods_and_quotes(){
504
- global $wpsc_cart;
505
-
506
- if(count($wpsc_cart->shipping_quotes) > 1 || count($wpsc_cart->shipping_methods) > 1 || count($wpsc_cart->shipping_quotes) == $wpsc_cart->shipping_quote_count){
507
- //$wpsc_cart->update_shipping($wpsc_cart->shipping_method, $wpsc_cart->selected_shipping_option);
508
- return true;
509
- }else{
510
- return false;
511
- }
512
  }
513
  /**
514
  * Whether or not there is a valid shipping quote/option available to the customer when checking out
@@ -516,25 +519,25 @@ function wpsc_have_morethanone_shipping_methods_and_quotes(){
516
  * @return bool
517
  */
518
  function wpsc_have_shipping_quote(){
519
- global $wpsc_cart;
520
- if ($wpsc_cart->shipping_quote_count > 0 || count($wpsc_cart->shipping_quotes) > 0) {
521
- return true;
522
- }
523
- return false;
524
  }
525
  function wpsc_update_shipping_single_method(){
526
- global $wpsc_cart;
527
- //exit('<pre>'.print_r($wpsc_cart->shipping_method, true).'</pre>');
528
- if(!empty($wpsc_cart->shipping_method)) {
529
- $wpsc_cart->update_shipping($wpsc_cart->shipping_method, $wpsc_cart->selected_shipping_option);
530
- }
531
  }
532
  function wpsc_update_shipping_multiple_methods(){
533
- global $wpsc_cart;
534
  //exit('<pre>'.print_r($wpsc_cart->shipping_method, true).'</pre>'.$wpsc_cart->shipping_methods[0]);
535
- if(!empty($wpsc_cart->selected_shipping_method)) {
536
- $wpsc_cart->update_shipping($wpsc_cart->selected_shipping_method, $wpsc_cart->selected_shipping_option);
537
- }
9
  *
10
  * @package wp-e-commerce
11
  * @since 3.7
12
+ * @subpackage wpsc-cart-classes
13
  */
14
  /**
15
  * The WPSC Cart API for templates
24
  * * @return boolean true or false depending on settings>general page
25
  */
26
  function wpsc_tax_isincluded() {
27
+ /*if(get_option('tax_inprice') == false || get_option('tax_inprice') == '0'){
28
+ return false;
29
+ }elseif(get_option('tax_inprice')=='1'){
30
+ return true;
31
+ }*/
32
+ //uses new wpec_taxes functionality now
33
+ $wpec_taxes_controller = new wpec_taxes_controller();
34
+ return $wpec_taxes_controller->wpec_taxes_isincluded();
35
  }
36
 
37
  function wpsc_cart_item_count() {
38
+ global $wpsc_cart;
39
+ $count = 0;
40
+ foreach((array)$wpsc_cart->cart_items as $cart_item) {
41
+ $count += $cart_item->quantity;
42
+ }
43
+ return $count;
44
  }
45
 
46
 
49
  * * @return integer the item count
50
  */
51
  function wpsc_coupon_amount($forDisplay=true) {
52
+ global $wpsc_cart;
53
+ if($forDisplay == true) {
54
+ $output = $wpsc_cart->process_as_currency($wpsc_cart->coupons_amount);
55
+ } else {
56
+ $output = $wpsc_cart->coupons_amount;
57
+ }
58
+ return $output;
59
  }
60
 
61
  /**
63
  * @return string the total price of the cart, with a currency sign
64
  */
65
  function wpsc_cart_total($forDisplay=true) {
66
+ global $wpsc_cart;
67
+ $total = $wpsc_cart->calculate_subtotal();
68
+ $total += $wpsc_cart->calculate_total_shipping();
69
+ if(wpsc_tax_isincluded() == false){
70
+ $total += $wpsc_cart->calculate_total_tax();
71
+ }
72
+
73
+ $total -= $wpsc_cart->coupons_amount;
74
+ if($forDisplay){
75
+ // exit('abksd'.get_option('add_plustax'));
76
+ return $wpsc_cart->process_as_currency($total);
77
+ }else{
78
+ return $total;
79
+ }
80
  }
81
 
82
  /**
89
  * @return string The subtotal price of the cart, with a currency sign.
90
  */
91
  function wpsc_cart_total_widget( $shipping = true, $tax = true, $coupons = true ) {
92
+
93
+ global $wpsc_cart;
94
+
95
+ $total = $wpsc_cart->calculate_subtotal();
96
+
97
+ if ( $shipping ) {
98
+ $total += $wpsc_cart->calculate_total_shipping();
99
+ }
100
+ if ( $tax && wpsc_tax_isincluded() == false ) {
101
+ $total += $wpsc_cart->calculate_total_tax();
102
+ }
103
+ if ( $coupons ) {
104
+ $total -= $wpsc_cart->coupons_amount;
105
+ }
106
+
107
+ if ( get_option( 'add_plustax' ) == 1 ) {
108
+ return $wpsc_cart->process_as_currency( $wpsc_cart->calculate_subtotal() );
109
+ } else {
110
+ return $wpsc_cart->process_as_currency( $total );
111
+ }
112
+
113
  }
114
 
115
  /**
117
  * @return string the total price of the cart, with a currency sign
118
  */
119
  function nzshpcrt_overall_total_price() {
120
+ global $wpsc_cart;
121
+ $total = $wpsc_cart->calculate_subtotal();
122
+ $total += $wpsc_cart->calculate_total_shipping();
123
+ if(wpsc_tax_isincluded() == false){
124
+ $total += $wpsc_cart->calculate_total_tax();
125
+ }
126
+ $total -= $wpsc_cart->coupons_amount;
127
  return $total;
128
  }
129
 
132
  * @return float the total weight of the cart
133
  */
134
  function wpsc_cart_weight_total() {
135
+ global $wpsc_cart;
136
+ if(is_object($wpsc_cart)) {
137
+ return $wpsc_cart->calculate_total_weight();
138
+ } else {
139
+ return 0;
140
+ }
141
  }
142
 
143
  /**
145
  * @return float the total weight of the cart
146
  */
147
  function wpsc_cart_tax($forDisplay = true) {
148
+ global $wpsc_cart;
149
+ if($forDisplay){
150
+ if(wpsc_tax_isincluded() == false){
151
+ return $wpsc_cart->process_as_currency($wpsc_cart->calculate_total_tax());
152
+ }else{
153
+ return '('.$wpsc_cart->process_as_currency($wpsc_cart->calculate_total_tax()).')';
154
+ }
155
+
156
+ }else{
157
+ return $wpsc_cart->calculate_total_tax();
158
+ }
159
  }
160
 
161
 
165
  * @return boolean true or false, for use with an if statement
166
  */
167
  function wpsc_cart_show_plus_postage() {
168
+ global $wpsc_cart;
169
+ // exit($_SESSION['wpsc_has_been_to_checkout'] ."get_option('add_plustax')".get_option('add_plustax'));
170
+ if(($_SESSION['wpsc_has_been_to_checkout'] == null ) && (get_option('add_plustax') == 1)) {
171
 
172
+ return true;
173
 
174
+ } else {
175
+ return false;
176
+ }
177
  }
178
 
179
  /**
181
  * @return boolean if true, all items in the cart do use shipping
182
  */
183
  function wpsc_uses_shipping() {
184
+ global $wpsc_cart;
185
+ $shippingoptions = get_option('custom_shipping_options');
186
+ if( (!((get_option('shipping_discount')== 1) && (get_option('shipping_discount_value') <= $wpsc_cart->calculate_subtotal()))) && count($shippingoptions) >= 1 && $shippingoptions[0] != '' && get_option('do_not_use_shipping') == 0) {
187
+ $status = $wpsc_cart->uses_shipping();
188
+ } else {
189
+ $status = false;
190
+ }
191
+ return $status;
192
  }
193
+
194
  /**
195
  * cart has shipping function, no parameters
196
  * @return boolean true for yes, false for no
197
  */
198
  function wpsc_cart_has_shipping() {
199
+ global $wpsc_cart;
200
+ if($wpsc_cart->calculate_total_shipping() > 0) {
201
+ $output = true;
202
+ } else {
203
+ $output = false;
204
+ }
205
+ return $output;
206
  }
207
 
208
  /**
210
  * @return string the total shipping of the cart, with a currency sign
211
  */
212
  function wpsc_cart_shipping() {
213
+ global $wpsc_cart;
214
+ return $wpsc_cart->process_as_currency($wpsc_cart->calculate_total_shipping());
215
  }
216
 
217
 
220
  * @return array array of the categories
221
  */
222
  function wpsc_cart_item_categories($get_ids = false) {
223
+ global $wpsc_cart;
224
+ if(is_object($wpsc_cart)) {
225
+ if($get_ids == true) {
226
+ return $wpsc_cart->get_item_category_ids();
227
+ } else {
228
+ return $wpsc_cart->get_item_categories();
229
+ }
230
+ } else {
231
+ return array();
232
+ }
233
  }
234
 
235
  /**
237
  * @return boolean true if there are cart items left
238
  */
239
  function wpsc_have_cart_items() {
240
+ global $wpsc_cart;
241
+ return $wpsc_cart->have_cart_items();
242
  }
243
 
244
  function wpsc_the_cart_item() {
245
+ global $wpsc_cart;
246
+ return $wpsc_cart->the_cart_item();
247
  }
248
+
249
+
250
+
251
  /**
252
  * cart item key function, no parameters
253
  * @return integer - the cart item key from the array in the cart object
254
  */
255
  function wpsc_the_cart_item_key() {
256
+ global $wpsc_cart;
257
+ return $wpsc_cart->current_cart_item;
258
  }
259
+
260
  /**
261
  * cart item name function, no parameters
262
  * @return string the cart item name
263
  */
264
  function wpsc_cart_item_name() {
265
+ global $wpsc_cart;
266
+ return htmlentities(stripslashes($wpsc_cart->cart_item->product_name), ENT_QUOTES, "UTF-8");
267
  }
268
  /**
269
  * cart item quantity function, no parameters
270
  * @return string the selected quantity of items
271
  */
272
  function wpsc_cart_item_product_id() {
273
+ global $wpsc_cart;
274
+ return $wpsc_cart->cart_item->product_id;
275
+ }
276
  /**
277
  * cart item quantity function, no parameters
278
  * @return string the selected quantity of items
279
  */
280
  function wpsc_cart_item_quantity() {
281
+ global $wpsc_cart;
282
+ return $wpsc_cart->cart_item->quantity;
283
  }
284
 
285
  function wpsc_cart_item_quantity_single_prod($id) {
286
+ global $wpsc_cart;
287
+ //exit('<pre>'.print_r($wpsc_cart, true).'</pre>');
288
+ return $wpsc_cart;
289
  }
290
  /**
291
  * cart item price function, no parameters
292
  * @return string the cart item price multiplied by the quantity, with a currency sign
293
  */
294
  function wpsc_cart_item_price($forDisplay = true) {
295
+ global $wpsc_cart;
296
+ if($forDisplay){
297
+ return $wpsc_cart->process_as_currency($wpsc_cart->cart_item->total_price);
298
+ }else{
299
+ return $wpsc_cart->cart_item->total_price;
300
+ }
301
  }
302
 
303
  /**
305
  * @return string the cart item price multiplied by the quantity, with a currency sign
306
  */
307
  function wpsc_cart_item_shipping($forDisplay = true) {
308
+ global $wpsc_cart;
309
+ if($forDisplay){
310
+ return $wpsc_cart->process_as_currency($wpsc_cart->cart_item->shipping);
311
+ }else{
312
+ return $wpsc_cart->cart_item->shipping;
313
+ }
314
  }
315
 
316
 
320
  * @return string the cart item url
321
  */
322
  function wpsc_cart_item_url() {
323
+ global $wpsc_cart;
324
+ return $wpsc_cart->cart_item->product_url;
325
  }
326
 
327
  /**
332
  * @return string url to the to the cart item thumbnail image
333
  */
334
  function wpsc_cart_item_image($width = null, $height = null) {
335
+ global $wpsc_cart;
336
+ $image_data = $wpsc_cart->cart_item->thumbnail_image;
337
+ // echo "<pre>".print_r($wpsc_cart->cart_item)."</pre>";
338
+
339
+ if(($width > 0) && ($height > 0)) {
340
+ $image_path = "index.php?wpsc_action=scale_image&amp;attachment_id={$image_data->ID}&amp;width=".$width."&amp;height=".$height."";
341
+ } else {
342
+ $image_path = WPSC_THUMBNAIL_URL.$wpsc_cart->cart_item->thumbnail_image;
343
+ if(is_ssl()) {
344
+ $image_path = str_replace("http://", "https://", $image_path);
345
+ }
346
+ }
347
+ return $image_path;
348
  }
349
 
350
  /**
355
  * @return array of shipping options
356
  */
357
  function wpsc_selfURL() {
358
+ $s = empty($_SERVER["HTTPS"]) ? "" : ($_SERVER["HTTPS"] == "on") ? "s" : "";
359
+ $protocol = wpsc_strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/").$s;
360
+ $port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]);
361
+ return $protocol."://".$_SERVER['SERVER_NAME'].$port.$_SERVER['REQUEST_URI'];
362
  }
363
 
364
  function wpsc_strleft($s1, $s2) {
365
+ $values = substr($s1, 0, strpos($s1, $s2));
366
+ return $values;
367
  }
368
  function wpsc_google_checkout(){
369
+ $currpage = wpsc_selfURL();
370
+ //exit('<pre>'.print_r(get_option('custom_gateway_options'), true).'</pre>');
371
+ if (array_search("google",(array)get_option('custom_gateway_options')) !== false && $currpage != get_option('shopping_cart_url')) {
372
+ global $nzshpcrt_gateways;
373
+ foreach($nzshpcrt_gateways as $gateway) {
374
+ if($gateway['internalname'] == 'google' ) {
375
+ $gateway_used = $gateway['internalname'];
376
+ $gateway['function'](true);
377
+ }
378
+ }
379
+ }
380
  }
381
  function wpsc_empty_google_logs(){
382
+ global $wpdb;
383
+ $sql="DELETE FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `sessionid`=".$_SESSION['wpsc_sessionid'];
384
+ $wpdb->query($sql);
385
+ unset($_SESSION['wpsc_sessionid']);
386
+
387
  }
388
  /**
389
  * have shipping methods function, no parameters
390
  * @return boolean
391
  */
392
  function wpsc_have_shipping_methods() {
393
+ global $wpsc_cart;
394
+ return $wpsc_cart->have_shipping_methods();
395
  }
396
  /**
397
  * the shipping method function, no parameters
398
  * @return boolean
399
  */
400
  function wpsc_the_shipping_method() {
401
+ global $wpsc_cart;
402
+ return $wpsc_cart->the_shipping_method();
403
  }
404
  /**
405
  * the shipping method name function, no parameters
406
  * @return string shipping method name
407
  */
408
  function wpsc_shipping_method_name() {
409
+ global $wpsc_cart, $wpsc_shipping_modules;
410
+ return $wpsc_shipping_modules[$wpsc_cart->shipping_method]->name;
411
  }
412
 
413
 
416
  * @return string shipping method internal name
417
  */
418
  function wpsc_shipping_method_internal_name() {
419
+ global $wpsc_cart, $wpsc_shipping_modules;
420
+ return $wpsc_cart->shipping_method;
421
  }
422
 
423
 
426
  * @return string the cart item url
427
  */
428
  function wpsc_have_shipping_quotes() {
429
+ global $wpsc_cart;
430
+ return $wpsc_cart->have_shipping_quotes();
431
  }
432
 
433
  /**
435
  * @return string the cart item url
436
  */
437
  function wpsc_the_shipping_quote() {
438
+ global $wpsc_cart;
439
+ return $wpsc_cart->the_shipping_quote();
440
  }
441
 
442
  /**
444
  * @return string shipping quote name
445
  */
446
  function wpsc_shipping_quote_name() {
447
+ global $wpsc_cart;
448
+ return $wpsc_cart->shipping_quote['name'];
449
  }
450
 
451
  /**
453
  * @return string shipping quote value
454
  */
455
  function wpsc_shipping_quote_value($numeric = false) {
456
+ global $wpsc_cart;
457
+ //echo 'Shipping value'.$wpsc_cart->shipping_quote['value'];
458
+ if($numeric == true) {
459
+ return $wpsc_cart->shipping_quote['value'];
460
+ } else {
461
+ return $wpsc_cart->process_as_currency($wpsc_cart->shipping_quote['value']);
462
+ }
463
  }
464
 
465
  /**
467
  * @return string shipping quote html ID
468
  */
469
  function wpsc_shipping_quote_html_id() {
470
+ global $wpsc_cart;
471
+ return $wpsc_cart->shipping_method."_".$wpsc_cart->current_shipping_quote;
472
  }
473
 
474
  /**
476
  * @return string true or false
477
  */
478
  function wpsc_shipping_quote_selected_state() {
479
+ global $wpsc_cart;
480
+
481
+ if(($wpsc_cart->selected_shipping_method == $wpsc_cart->shipping_method) && ($wpsc_cart->selected_shipping_option == $wpsc_cart->shipping_quote['name']) ) {
482
+ return "checked='checked'";
483
+ } else {
484
+ return "";
485
+ }
486
  }
487
  function wpsc_have_morethanone_shipping_quote(){
488
+ global $wpsc_cart;
489
 
490
  // if it's fixed rate shipping, and all the prices are the same, then there aren't really options.
491
  if (count($wpsc_cart->shipping_methods) == 1 && $wpsc_cart->shipping_methods[0] == 'flatrate') {
504
  }
505
 
506
  function wpsc_have_morethanone_shipping_methods_and_quotes(){
507
+ global $wpsc_cart;
508
+
509
+ if(count($wpsc_cart->shipping_quotes) > 1 || count($wpsc_cart->shipping_methods) > 1 || count($wpsc_cart->shipping_quotes) == $wpsc_cart->shipping_quote_count){
510
+ //$wpsc_cart->update_shipping($wpsc_cart->shipping_method, $wpsc_cart->selected_shipping_option);
511
+ return true;
512
+ }else{
513
+ return false;
514
+ }
515
  }
516
  /**
517
  * Whether or not there is a valid shipping quote/option available to the customer when checking out
519
  * @return bool
520
  */
521
  function wpsc_have_shipping_quote(){
522
+ global $wpsc_cart;
523
+ if ($wpsc_cart->shipping_quote_count > 0 || count($wpsc_cart->shipping_quotes) > 0) {
524
+ return true;
525
+ }
526
+ return false;
527
  }
528
  function wpsc_update_shipping_single_method(){
529
+ global $wpsc_cart;
530
+ //exit('<pre>'.print_r($wpsc_cart->shipping_method, true).'</pre>');
531
+ if(!empty($wpsc_cart->shipping_method)) {
532
+ $wpsc_cart->update_shipping($wpsc_cart->shipping_method, $wpsc_cart->selected_shipping_option);
533
+ }
534
  }
535
  function wpsc_update_shipping_multiple_methods(){
536
+ global $wpsc_cart;
537
  //exit('<pre>'.print_r($wpsc_cart->shipping_method, true).'</pre>'.$wpsc_cart->shipping_methods[0]);
538
+ if(!empty($wpsc_cart->selected_shipping_method)) {
539
+ $wpsc_cart->upda